PrivateSub ValidateItemField()
Dim Identifier, OldItem AsString
Dim comma, boxQty AsInteger
Dim repackLabel AsBoolean = False
Identifier = " "
Item = ""
OldItem = TextBoxpartnum.Text
If LocationComboBox.Text = ""Then
MessageBox.Show("Location cannot be blank.")
' need to have something like this MessageBox.Show("The calculations are complete", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk)
ExitSub
EndIf
If PlantLocDispLabel.Text = ""Then
MessageBox.Show("PlantLocation cannot be blank.")
'Need to insert a check here for if the locationcombobox is WHMX-2, then plantlocdisplabel cannot be blank.
EndIf
Try
'Consider moving this to the module.
Identifier = myReaderdata.Text.Substring(0, 1)
If myReaderdata.Text.IndexOf("-") = 2 Then'Repacking labels do not have an R but always have - at 3rd position
Identifier = "R"
repackLabel = True
EndIf
If Identifier = "6"And myReaderdata.Length > 35 Or myReaderdata.Text.Substring(0, 2) = "A1"Then
Identifier = "GSE"
EndIf
Catch ex As Exception
ws.email("ValidateItemError", "First Try clause error, Scanner: " + ScannerName + ", " + ex.ToString, "S")
MessageBox.Show(ex.ToString)
EndTry
Try
If NeedFGNumber Then
If Identifier > "F"Then
MessageBox.Show("A FG # is required to complete tag.")
ExitSub
Else
boxQty = ws.ItemDetails(CurrentWIPNumber + "," + myReaderdata.Text, "WHQ")
Item = CurrentWIPNumber
SerialNum = CurrentWIPSerial
CurrentWIPNumber = ""
CurrentWIPSerial = ""
NeedFGNumber = False
EndIf
Else
Call RawMaterialValidation(myReaderdata.Text)
If IsValid Then
Identifier = "K"
Item = VRP_Item
SerialNum = SerialMod
Else
SelectCase Identifier
Case"K", "P", "G"
If myReaderdata.Text.IndexOf(",") < 1 And Identifier > "I"And MasterLocation = "MEX"Then
MessageBox.Show("Label starts with K,P,G but has no ,. Try Again.")
ws.email("Cycle count label problem", "Label starts with K,P,G but has no ,. Scanner: " + ScannerName + ", " + myReaderdata.Text, "S")
Else
comma = myReaderdata.Text.IndexOf(",")
If comma < 0 Then
SelectCase Identifier
Case"P"
Item = myReaderdata.Text.Substring(1)
CaseElse
Item = " "
EndSelect
Else
Call ParseScanInfo(myReaderdata.Text)
Item = VRP_Item
boxQty = QtyMod
SerialNum = Item.Substring(Item.Length - 4) + "-" + SerialMod
EndIf
EndIf
Case"D"
Call ParseScanInfo(myReaderdata.Text)
Item = VRP_Item
boxQty = QtyMod
SerialNum = SerialMod
Case"I"
Call ParseScanInfo(myReaderdata.Text)
Item = VRP_Item
boxQty = QtyMod
SerialNum = ""
PartialCheckBox.Checked = True
Case" "
Item = myReaderdata.Text.Substring(30, 20).Trim(" ")
boxQty = myReaderdata.Text.Substring(70, 7)
SerialNum = myReaderdata.Text.Substring(93, 9)
Case"1"
Item = myReaderdata.Text.Substring(2, 20).Trim(" ")
boxQty = myReaderdata.Text.Substring(42, 7)
Case"R"
'This statement handles both FIFO labels and Repack labels by sending the values to the WS to decipher.
Try
Dim stringToSend AsString = ""
If repackLabel Then
stringToSend = myReaderdata.Text
Else
stringToSend = myReaderdata.Text.Substring(1)
EndIf
Dim valueReturned AsString = ws.MexicoItemQtyByMasLoc(stringToSend, MasterLocation, repackLabel, InventoryCycle, 0, "C")
If valueReturned.StartsWith("Error") Then
MessageBox.Show(valueReturned)
ExitSub
EndIf
' Web Service returns value like:
' Item:6189-0482,Qty:200
Dim values AsString() = valueReturned.Split(",")
ForEach v AsStringIn values
Dim values2 AsString() = v.Split(":")
If values2.Length > 2 Then
MessageBox.Show("Error getting Item and Quantity")
ExitSub
EndIf
SelectCase values2(0)
Case"Item"
Item = values2(1)
Case"Qty"
boxQty = values2(1)
EndSelect
Next
SerialNum = myReaderdata.Text
Catch ex As Exception
ws.email("ValidateItemError", "FIFO tag error, Scanner: " + ScannerName + ", Item,qty,serial: " + Item + "," + boxQty.ToString + "," + myReaderdata.Text + ": " + ex.ToString, "S")
EndTry
Case"W"
If myReaderdata.Text.Substring(0, 2) = "W-"Then
Call ParseScanInfo(myReaderdata.Text)
If NeedFGNumber Then
FGWarningLabel.Visible = True
FGWarningTimer.Enabled = True
CurrentWIPNumber = VRP_Item
CurrentWIPSerial = SerialMod
ExitSub
EndIf
Item = VRP_Item
boxQty = QtyMod
SerialNum = SerialMod
Else
If myReaderdata.Text.IndexOf(",") > 0 Then
Item = myReaderdata.Text.Substring(1, myReaderdata.Text.IndexOf(",") - 1)
boxQty = myReaderdata.Text.Substring(myReaderdata.Text.IndexOf(",") + 2)
Else
PlantLocDispLabel.Text = myReaderdata.Text.Substring(1)
ExitSub
EndIf
EndIf
Case"GSE"
Call ParseScanInfo(myReaderdata.Text)
Item = VRP_Item
boxQty = QtyMod
SerialNum = SerialMod
Case"M"
Call ParseScanInfo(myReaderdata.Text)
Item = VRP_Item
boxQty = QtyMod
SerialNum = SerialMod
CaseElse
' If we get here, we don't know what this is.
MessageBox.Show("You must scan Kanban, Shipping Label, FIFO Tag, Rack or Box Label")
ExitSub
EndSelect
EndIf
EndIf
Catch ex As Exception
ws.email("ValidateItemError", "Second Try clause problem, Scanner: " + ScannerName + ", " + ex.ToString, "S")
MessageBox.Show(ex.ToString)
EndTry
Try
If BoxRadioButton.Checked Then
Call ChangedPart(OldItem)
If ExitSub Then
ExitSub
EndIf
EndIf
Call Validate(Item, boxQty, Identifier)
If PartialCheckBox.Checked Or TotalRadioButton.Checked Then
Call HideShowDetails(True, False)
Else
Call HideShowDetails(False, True)
BoxTextBox.Text = "1"
EndIf
IfNot PartialCheckBox.Checked And BoxRadioButton.Checked And IsValid Then
Call UpdateData()
EndIf
Catch ex As Exception
ws.email("Cycle Count App - ValidateItemField Sub", "Scanner: " + ScannerName + ", Barcode: " + myReaderdata.Text + " Error message: " + ex.ToString, "S")
MessageBox.Show(ex.ToString)
EndTry
EndSub