Sub ConvertUPCToPart (strUPC As String) as resumablesub
' verify the user credentials against the database. Query for username and password
Dim sSQL As String
Dim sSQL2 As String
Dim job As HttpJob
' Job 1 Lookup Secondary Barcode
sSQL = ""
sSQL = sSQL & " Select subkey1 As [Part], [Autopart].[dbo].[product].[desc] As [Desc],A12 As [UPC],[Autopart].[dbo].[product].[range] As [Range], Qty As [BoxQty] "
sSQL = sSQL & " FROM [Autopart].[dbo].[Mvpr], [Autopart].[dbo].[product] where SubKey1 = [Autopart].[dbo].[product].[keycode] "
sSQL = sSQL & " And Prefix = 'L' and A12 = '~UPC~' "
If strUPC <> "" Then
sSQL2 = sSQL.Replace ("~UPC~",strUPC)
Else
' Do nothing
Return
End If
' Job 2 Lookup Primary Barcode
'sSQL = ""
'sSQL = sSQL & "SELECT KeyCode as [Part],[Desc],Asno,[Range],'1' as [DefaultQty] "
'sSQL = sSQL & "FROM [Autopart].[dbo].[Product] where Asno = '~UPC~' "
' Send Job 1, Secondary barcode lookup
job.Initialize("Job1", Me)
job.PostString(ServerUrl, sSQL2)
Wait For (job) JobDone(job As HttpJob)
If job.Success Then
Dim parser As JSONParser
Dim response As String = job.GetString
parser.Initialize(response)
Dim rows As List
rows = parser.NextArray
'work with result
'rows is a List. Each item is a Map with the columns names as keys and the db values as the values.
For i = 0 To rows.Size - 1
Log("Rows #" & i)
Dim m As Map
m = rows.Get(i)
Log("item1=" & m.Get("Part")) 'log the values of col1 and col2
Log("item2=" & m.Get("Desc"))
Log("item2=" & m.Get("BoxQty")
return m.Get("Part")
Next
End If
End Sub