Sub FillList
SQLCursor = SQL1.ExecQuery2("SELECT * FROM Orders WHERE LOADNO = ? AND WSSTOP = ? ORDER BY SCANNED, MRGTKT, ORDNO, ITMNO, ITMSEQ", Array As String(CurrentLoad, CurrentStopNo))
For i = 0 To SQLCursor.RowCount-1
SQLCursor.Position = i
If SQLCursor.GetLong("MRGTKT") > 0 Then
TicketNumber = SQLCursor.GetLong("MRGTKT")
Else
TicketNumber = SQLCursor.GetLong("TKTNO")
End If
' Only include the merge ticket once. All others will have a different ticket each time and will get included.
If TicketNumber <> PrvTicketNo Then
CounterText = (i+1) & " of " & SQLCursor.RowCount
Text1 = "Order #: " & CounterText & CRLF & SQLCursor.GetLong("ORDNO") & "-" & SQLCursor.GetInt("ITMNO") & "-" & SQLCursor.GetInt("ITMSEQ") & CRLF & "Ticket #: " & TicketNumber & " - " & SQLCursor.GetString("TKTTYPE")
Text2 = SQLCursor.GetString("PRODDESC").Trim
If SQLCursor.GetString("SCANNED").Trim = "N" And SQLCursor.GetString("ISSUE").Trim = "" Then
EnableSignature = False
End If
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, clvOrders.AsView.Width, 100dip)
clvOrders.Add(p, CreateMap("Text1": Text1, "Text2": Text2, "SCANNED": SQLCursor.GetString("SCANNED").Trim, "TicketNumber": TicketNumber))
End If
PrvTicketNo = TicketNumber
Next
End Sub
Sub clvOrders_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
Dim ExtraSize As Int = 20
For i = 0 To clvOrders.Size - 1
Dim P As B4XView = clvOrders.GetPanel(i)
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
If p.NumberOfViews = 0 Then
Dim m As Map = clvOrders.GetValue(i)
p.AddView(CreateListItemOrders(m.Get("Text1"), m.Get("Text2"), p.Width, p.Height, m.Get("SCANNED")),0,0,p.Width,p.Height)
End If
Else
If p.NumberOfViews > 0 Then p.RemoveAllViews
End If
Next
End Sub