Hi all,
I have a program that is supposed to log data to a sql table based on a serial port receiving data. When I get a start of text and return I call this routine below. I set some other parameters up previously by a button click, as shown even lower. The problem I am having is that when I call my ParseBarcode routine ContainerNumLabel.Text changes from its set value to whatever I have it set at in the designer, so instead of being "12345" it is "Label1". Why is this, and what can I do to fix it?
Thanks,
Bill
I have a program that is supposed to log data to a sql table based on a serial port receiving data. When I get a start of text and return I call this routine below. I set some other parameters up previously by a button click, as shown even lower. The problem I am having is that when I call my ParseBarcode routine ContainerNumLabel.Text changes from its set value to whatever I have it set at in the designer, so instead of being "12345" it is "Label1". Why is this, and what can I do to fix it?
Thanks,
Bill
Code:
Private Sub ParseBarcode(ByVal InputString As String, ByVal scanner As Integer)
Dim CartonID, DCID, ZIPID, ContainerNum, SealNumber, CustomerName, CustomerID, Retailer, RetailerID, RecieveDate, RecieveTime As String
Dim LastFound, ScannerNum, DoorNum As Integer
Dim SentToAS400 As Boolean
ContainerNum = ContainerNumLabel.Text
SealNumber = SealNumLabel.Text
DoorNum = Convert.ToInt32(DoorNumLabel.Text)
CustomerName = CustomerLabel.Text
CustomerID = CustomerIDLabel.Text
Retailer = RetailerLabel.Text
RetailerID = RetailerIDLabel.Text
ScannerNum = 1
LastFound = InStr(InputString, ",")
CartonID = Mid(InputString, 1, LastFound - 1) ' Get cartonID from inputstring
InputString = Mid(InputString, (LastFound + 1))
LastFound = InStr(InputString, ",")
DCID = Mid(InputString, 1, LastFound - 1) ' Get DCID from inputstring
InputString = Mid(InputString, (LastFound + 1))
ZIPID = Mid(InputString, 1, InputString.Length - 1)
RecieveDate = DateTime.Now.ToString("d")
RecieveTime = DateTime.Now.ToString("T")
SentToAS400 = SendRecieveDataToAS400(ContainerNum, CartonID, DCID, ZIPID, ScannerNum, DoorNum, SealNumber, CustomerName, CustomerID, Retailer, RetailerID, RecieveDate, RecieveTime)
LogRecieveDataToSQL(ContainerNum, CartonID, DCID, ZIPID, ScannerNum, DoorNum, SealNumber, CustomerName, CustomerID, Retailer, RetailerID, RecieveDate, RecieveTime, SentToAS400)
Form2.SerialData1.Text = ""
End Sub
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim y, OpenDoorNum, ContainerCount As Integer
Dim Status As Char
'Check admin level to make sure we can open truck
If Convert.ToInt32(adminleveltext.Text) < 3 Then
MessageBox.Show("Please login as administrator to open truck", "Permission Denied")
Exit Sub
End If
'Check open doors to make sure no two door are open at the same time
For y = 0 To 4
OpenDoorNum = ComboBox1.SelectedIndex
If DoorState(y) = True And y = OpenDoorNum Then
'Trying to open door already in use
MessageBox.Show("Door " & OpenDoorNum & " already in use.", "Warning")
Exit Sub
End If
Next
'Check to ensure all parameters are filled
If ComboBox1.Text.Length < 1 Or ComboBox2.Text.Length < 1 Or ComboBox3.Text.Length < 1 Or ComboBox4.Text.Length < 1 Or TextBox1.Text.Length < 1 Or TextBox3.Text.Length < 1 Then
'Paramater is missing
MessageBox.Show("Please insert missing parameters", "Warning")
Exit Sub
End If
If ComboBox2.SelectedIndex = 0 Then ' User is adding a new truck
'Check to see if truck number is already in table
'if not add truck data to SQL
cmd3.Parameters(0).Value = TextBox4.Text
cmd3.ExecuteNonQuery()
ContainerCount = Convert.ToInt32(cmd3.Parameters(1).Value)
If ContainerCount = 1 Then
'Container Exists
MessageBox.Show("Container already exists. Cannot add existing container")
Exit Sub
End If
cmd4.Parameters(0).Value = TextBox4.Text
cmd4.Parameters(1).Value = TextBox1.Text
cmd4.Parameters(2).Value = ComboBox3.Text
cmd4.Parameters(3).Value = TextBox3.Text
cmd4.Parameters(4).Value = "O"
cmd4.Parameters(5).Value = "Y"
cmd4.Parameters(6).Value = DateTime.Now.ToString("T")
cmd4.ExecuteNonQuery()
Call BuildContainerBox(ConnString)
TextBox4.Text = "" ' New Truck box being cleared, not sure this is being used
ComboBox2.SelectedIndex = ComboBox2.Items.Count - 1
Else
'Update existing container
' Check Status of container(Truck Number) to ensure it is Pending or Closed
cmd2.Parameters(0).Value = ComboBox2.Text
cmd2.ExecuteNonQuery()
Status = cmd2.Parameters(1).Value
If Status = "O" Then
'Container is open
MessageBox.Show("Container is already open", "Warning")
Exit Sub
ElseIf Status = "F" Then
'Truck is finished
MessageBox.Show("Container is already finished", "Warning")
Exit Sub
End If
End If
DoorState(OpenDoorNum) = True
ScannerState(0) = True
'Set Scanner 1 parameters here
ContainerNumLabel.Text = ComboBox2.Text
DoorNumLabel.Text = ComboBox1.SelectedIndex + 1
SealNumLabel.Text = TextBox1.Text
CustomerLabel.Text = ComboBox3.Text
CustomerIDLabel.Text = ComboBox4.Text
RetailerLabel.Text = ""
RetailerIDLabel.Text = ""
'End of Scanner 1 paramaeters here
Button1.Enabled = False ' Open Truck button can not be clicked
Button2.Enabled = True ' Close truck button can be clicked
Button3.Enabled = True
ComboBox1.Enabled = False
ComboBox2.Enabled = False