Sub Process_Globals
Public mType As String=""
End Sub
Sub Globals
Dim lstCustomer As ListView
Private cmdBack As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Activity.LoadLayout("frmDailyCustomer")
End If
End Sub
Sub Activity_Resume
LoadCustomer
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub LoadCustomer()
Dim strSQL As String
Dim Cursor1 As Cursor
Dim mTypeName As String=""
Dim bmp As Bitmap
bmp = LoadBitmap(File.DirAssets, "Positioned.png")
ProgressDialogShow("Loading Customers...")
'If lstCustomer.IsInitialized=False Then lstCustomer.Initialize("lstCustomer")
lstCustomer.Clear
mainModule.FormatListView(lstCustomer,14,13)
Select mType
Case "COMPLETE"
strSQL="Select ifnull(Dist,999) as Dist, LAT,LON,CustomerId,CustomerName,FullAddress,Ifnull(LastCheckIn,0) as LastCheckIn from Customers Where(Ifnull(LastCheckIn,0)>0) And (Ifnull(Cancelled,0)=0) And (DailyRoute='Y') And (ifnull(CallUploaded,0)=1) Order by CustomerName"
mTypeName="Khách hàng đã upload"
Case "ACTIVE"
strSQL="Select ifnull(Dist,999) as Dist,LAT,LON,CustomerId,CustomerName,FullAddress,Ifnull(LastCheckIn,0) as LastCheckIn from Customers Where(Ifnull(LastCheckIn,0)>0) And (Ifnull(Cancelled,0)=0) And (DailyRoute='Y') And (ifnull(CallUploaded,0)=0) Order by CustomerName"
mTypeName="Khách hàng chưa upload"
Case "CANCELLED"
strSQL="Select ifnull(Dist,999) as Dist,LAT,LON,CustomerId,CustomerName,FullAddress,Ifnull(LastCheckIn,0) as LastCheckIn from Customers Where(Ifnull(Cancelled,0)=1) And (DailyRoute='Y') Order by CustomerName"
mTypeName="Khách hàng hủy viếng thăm"
Case "PENDING"
strSQL="Select ifnull(Dist,999) as Dist,LAT,LON,CustomerId,CustomerName,FullAddress,Ifnull(LastCheckIn,0) as LastCheckIn from Customers Where(Ifnull(Cancelled,0)=0) And (DailyRoute='Y') And (Ifnull(CallUploaded,0)=0) And (Ifnull(LastCheckIn,0)=0) Order by Idx"
mTypeName="Khách chưa viếng thăm"
End Select
Cursor1 = Main.SQL1.ExecQuery(strSQL)
If Cursor1.RowCount>0 Then
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
Dim O As Customer
O.CustomerName=Cursor1.GetString("CustomerName")
O.CustomerId=Cursor1.GetLong("CustomerId")
O.LAT=Cursor1.GetDouble("LAT")
O.LON=Cursor1.GetDouble("LON")
If (Cursor1.GetDouble("LAT")>0) OR (Cursor1.GetDouble("LON")>0) Then
lstCustomer.AddTwoLinesAndBitmap2(O.CustomerName,Cursor1.GetString("FullAddress"),bmp,O)
Else
lstCustomer.AddTwoLines2(O.CustomerName,Cursor1.GetString("FullAddress"),O)
End If
Next
Else
Cursor1.Close
ProgressDialogHide
Activity.Finish
End If
Cursor1.Close
ProgressDialogHide
Activity.Title=mTypeName & " (" & Cursor1.RowCount & ")"
End Sub
Sub lstCustomer_ItemClick (Position As Int, Value As Object)
Dim C As Customer=Value
If mType="CANCELLED" Then
If mainModule.NzNum(Main.SQL1.ExecQuerySingleResult("Select Ifnull(RouteClosed,0) from Sys"))<>1 Then
actUnCancel.mCustomerId=C.CustomerId
actUnCancel.mCustomerName=C.CustomerName
StartActivity(actUnCancel)
End If
Else
actProcess.mCustomerId=C.CustomerId
actProcess.mCustomerName=C.CustomerName
StartActivity(actProcess)
End If
End Sub
Sub cmdBack_Click
Activity.Finish
End Sub