|
please edit your message and use PRE tags for code snippets; it is too hard to read as is.
Justiin1265 wrote: how do I get it to calculate each time a user scans in a unit
what do you mean by scan? is there a bar code reader involved? if so what data is it providing? should that be added to the database too? the situation isn't clear to me at all.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Yes, a barcode reader is involved, but does not need to be in the db. It is just a tool for users to process units faster. A user would scan in a unit(cable box) and if a part is damaged then it would be refurbed(replaced) and if not a user would enter None(no parts replaced). My formula calculates the toal units refurbed / total units that had a value of none* 100 to get a percentage. My problem is idk how to make the formula constantly change values as the total refurb and total units changes constantly.
|
|
|
|
|
OK. It is a bit clearer now. Still not sure what it is that gets scanned (a serial number? a repair cost label?)
Here is a simple scheme that is bound to work:
- have a class member "int countAccepted", initially zero.
- have a class member "int countRejected", initially zero.
- have an "Accept" button, when clicked it increments countAccepted and calls method Calc().
- have a "Reject" button, when clicked it increments countRejected and calls method Calc().
public void btnAccepted_Clicked(object sender, EventArgs e) {
countAccepted++;
Calc();
}
public void btnRejected_Clicked(object sender, EventArgs e) {
countRejected++;
Calc();
}
public void Calc() {
int totalCount=countAccepted+countRejected;
if (totalCount!=0) {
int rejectedRate=100*countRejected/totalCount;
textBoxAccepted.Text=countAccepted.ToString();
textBoxRejected.Text=countRejected.ToString();
textBoxRejectedRate.Text=rejectedRate.ToString()+" %";
}
}
So the trick here is I'm using two buttons.
If there were a TextBox that accepts the barcode reader's input, then the TextBox.TextChanged event handler would have to update the counters appropriately, then call Calc().
public void BarcodeReaderTextBox_TextChanged(object sender, EventArgs e) {
...
Calc();
}
HTH
Suggestion: if you manage to clearly state your problem in plain English, it will also be easier for yourself to turn it into working code.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Justin, there are multiple things that mnake no sense to me about this, for example you seem to be doing the same query again and again in a loop and also performing what should be a final calculation within that loop without setting the variables, which I would think (quite apart from being illogical) immediately throws a divide by zero error.
I'm sure we could provide a solution quickly if we could understand what you are trying to do more clearly. Which, in pseudocode, might be something like...
foreach repair_part record where repair_ord = value scanned in by user
increment totalRefurb and totalUnits (based on some fields in repair_part record)
endforeach
Refurb_Rate = totalRefurb / totalUnits
Is that on the right track?
|
|
|
|
|
I'm confused about how to make total units and total refurb values change constantly. That seems to be on the right track I was thinking about putting the formula in a for loop to see if that would work.
|
|
|
|
|
More clarity about how the "change" happens in the figures would be helpful.
For example:
1. Are you tring to update the figures whenever a new item is scanned?, If so you need to catch the scanning event (typically this would be an OnKeyDown or OnTextChanged event in a TextBox somewhere?
2. Are there lots of different places where the figures may change (e.g. the are lots of different people scanning in refurbs in different places) and you want to constantly check the database. If so a solution where you check the database at regular intervals might be better (e.g. use a Timer control and put the code in there).
Without knowing exactly what you are trying to achieve and the thought process behind it, it's difficult to work out the best solution.
|
|
|
|
|
nd am having a problem in my application that ive been able to replicate using the code below.
I want the function TestTimeout to run only at certain times so im using Thread.Sleep(Timeout.Infinite); to stop it.
I'm interrupting the thread using the button below it works once however has no effect afterwards ? What should happen is it should display the message then sleep again until interpreted
private static Thread TimeoutThread;
private void Form1Load(object sender, EventArgs e)
{
var Job = new ThreadStart(TestTimeout);
TimeoutThread = new Thread(Job) { IsBackground = true };
TimeoutThread.Start();
}
private static void TestTimeout()
{
MessageBox.Show("Run");
try
{
Thread.Sleep(Timeout.Infinite);
}
catch (ThreadInterruptedException)
{
TestTimeout();
}
}
private void button1_Click(object sender, EventArgs e)
{
TimeoutThread.Interrupt();
}
Can anyone tell me how to resolve this issue
|
|
|
|
|
I think that recursive call to TestTimeout is causing some problems. Does something like this do what you want (I have added a spinwait to simulate some work being done).
private static Thread TimeoutThread;
private void Form1_Load(object sender, EventArgs e)
{
ThreadStart Job = new ThreadStart(TestTimeout);
TimeoutThread = new Thread(Job) { IsBackground = true };
TimeoutThread.Start();
}
private static void TestTimeout()
{
while (true)
{
MessageBox.Show("Starting Work");
try
{
Thread.SpinWait(100000000);
MessageBox.Show("Finished Work");
Thread.Sleep(Timeout.Infinite);
}
catch (ThreadInterruptedException)
{
}
}
}
private void button1_Click(object sender, EventArgs e)
{
TimeoutThread.Interrupt();
}
<pre>
|
|
|
|
|
check out once that may be your form_load event called many times..
|
|
|
|
|
Hi guys nice to see u again ^^
i would like to implement a SysMsgProc Hook to get information about Scroll bar, menu, dialog box, ...
i found some information in msdn http://msdn.microsoft.com/en-us/library/ms632589(VS.85).aspx[^]
i don't know how to do that and if i can use it with SetWindowsHookEx (in user32.dll ) or there is another dll xD may be v_v
thanks for help ^^
|
|
|
|
|
For test purposes, let us take a user with following properties:
samaccountname=testuser1,OU=ou1,OU=test unit,...
Please note that there are two entries for the attribute OU.
Now I try to find out if OU=ou1 is set for user testuser1.
In C# (.NET 3.5), I do:
DirectoryEntry ent = new DirectoryEntry("LDAP://our.domain");
DirectorySearcher searcher = new DirectorySearcher(ent);
searcher.Filter = "(&(samaccountname=testuser1)(OU=ou1))";
searcher.SearchScope = SearchScope.Subtree;
SearchResult result = searcher.FindOne();
... and result is null.
searcher.Filter = "(samaccountname=testuser1)";
or
searcher.Filter = "(OU=ou1)";
get a result.
How does the correct Filter look like for the scenario described above?
|
|
|
|
|
How about:
(&(samaccountname=testuser1)(| (OU=ou1)(OU=test)))
/ravi
|
|
|
|
|
I have come across problem for which I'm looking for permanent solution.
Some software I'm working needs to have a version checking mechanism for update checking and disabling the installed version if necessary. It was decided to that a server be provided from which a small encrypted xml file is downloaded and checked.
I thought, "not too complex with Webclient", simply download the file decrypt and check it and then delete it. If an Exception then status is Unverified. Works file on XP machines when the file is removed from the server the exception happens like expected.
On the Windows 7 machine however it continues to succeed and even when the network is disconnected. NO exception is raised. I even took out the try/catch to confirm that - NO crash.
If set
client.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
just incase, because I wanted to ensure the file was downloaded every time.
It is still coming from somewhere. I'm confused!!!!!
If anyone has an idea about this I would be interested in knowing about it.
Happy programming!!
|
|
|
|
|
Where should the exception be thrown - in some places and under certain circumstances exceptions get swallowed! E.g. in a Form Load or Shown event when the application is executed from Visual Studio; or possibly also on Win7 64 bit machines with those events.
|
|
|
|
|
From what I have tracked down, the exception doesn't occur because the 'old' file is actually being served up. It seems that the BranchCache service is being over kind to us and even ignoring the noCacheNoStore request. I shall confirm or otherwise on Tuesday when I'm back at work.
Happy programming!!
|
|
|
|
|
I think your only recourse is to run it under the debugger and investigate every variable and condition (in the appropriate block of code) until you find the problem.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Did you mean to specify BypassCache instead of NoCacheNoStore ? That's what I use to achieve a similar result and it works fine.
/ravi
|
|
|
|
|
Can you help me about problem delete multiline on listview
Thank you!
modified on Friday, April 8, 2011 6:36 AM
|
|
|
|
|
Possibly. It depends what the problem is.
|
|
|
|
|
Oh dear God! Do questions like this still exist!
|
|
|
|
|
They do indeed. How are you doing mate?
|
|
|
|
|
|
I'm not bad. I'm doing a fair bit of travelling up to Glasgow now, so may be able to make a DDD talk or two in Scotland.
|
|
|
|
|
I'm not allowed to discuss VB.Net in this forum.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Loop through the selected items and remove them.
Never underestimate the power of human stupidity
RAH
|
|
|
|