#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim reqManager AsDBRequestManager
EndSub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private pnl AsPanel
Private scrChecklist As ScrollView
Private lngYPos As Long
Private tglQuestion As ToggleButton
Private lbl AsLabel
Private txt AsEditText
EndSub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Checklist")
scrChecklist.Initialize(0)
pnl = scrChecklist.Panel
Activity.AddView(scrChecklist, 0, 0, 100%x, 100%y)
scrChecklist.Color = Colors.white
Activity.Title="Vehicle Checklist"
'Read all the values from the table for this checklist, order by the ID as they will have all been set.
'Key
'
' 1=
' 2=
' 3= Comment
' 4= Toggle Button
' 5= Comment
' 6= Overall comment
'Gather all the different values
'Vehicle Type
'Vehicle Trailer
'Number of Sections
'Number of questions in each section
Dim WhereFields As Map
Dim lngCountChecklist As Long
Dim lngCheckListID As Long
Dim lngType As Long
Dim cursor As Cursor
Dim lngSpace1 As Long
Dim lngSpace2 As Long
Dim lngSpace3 As Long
Dim lngSpace4 As Long
Dim lngSpaceBeforeSection As Long
Dim lngSpaceBeforeVehicleHeader As Long
Dim bolFirstSectionHeader As Boolean=True
Dim bolFirstVehicleType As Boolean=True
Dim lngToggleLeft As Long
Dim lngToggleVertical As Long
Dim sf AsStringFunctions
Dim strID As String
sf.Initialize
lngCheckListID = Starter.SQL1.ExecQuerySingleResult("Select cur_Checklist from tbl_current_position where cur_ID=1")
lngCountChecklist=Starter.SQL1.ExecQuerySingleResult("Select count(chk_id) from tbl_vcl_checklist where chk_checklist_ID=" & lngCheckListID)
If lngCountChecklist>0 Then
'reqManager.Initialize(Me, Starter.SQLStat.ExecQuerySingleResult("Select par_jServer_IP from Parameters where par_id=1"))
cursor = Starter.SQL1.ExecQuery("Select * from tbl_vcl_checklist where chk_checklist_ID=" & lngCheckListID & " order by chk_ID")
lngYPos = 20dip
lngSpace1 = 30dip
lngSpace2 = 35dip
lngSpace3 = 35dip
lngSpace4 = 35dip
lngSpaceBeforeSection = 10dip
lngSpaceBeforeVehicleHeader = 20dip
lngToggleLeft = 50
For i = 0 To cursor.RowCount-1
cursor.Position=i
lngType = cursor.Getint("chk_type_ID")
strID = sf.pad(cursor.Getint("chk_ID"),"0",7,False)
Select Case lngType
Case 1 'Vehicle Type Header
If bolFirstSectionHeader = True Then
bolFirstSectionHeader=False
Else
lngYPos=lngYPos+lngSpaceBeforeVehicleHeader
End If
lbl.Initialize("label")
lbl.Tag = "typ" & strID
pnl.AddView(lbl, 1%x, lngYPos, 98%x, 30dip)
lbl.Text=" " & cursor.Getstring("chk_text")
lbl.TextColor=Colors.White
lbl.color=Colors.ARGB(255, 0, 0, 128)
lbl.TextSize = 24 * Starter.dblScaleFactor
lbl.Gravity =Gravity.CENTER_VERTICAL
lngYPos = lngYPos + lngSpace1
Case 2 'Section Header
If bolFirstSectionHeader = True Then
bolFirstSectionHeader=False
Else
lngYPos=lngYPos+lngSpaceBeforeSection
End If
lbl.Initialize("label")
lbl.Tag = "sec" & strID
pnl.AddView(lbl, 1%x, lngYPos, 98%x, 30dip)
lbl.Text= " " & cursor.Getstring("chk_text")
lbl.TextColor=Colors.black
lbl.Typeface = Typeface.DEFAULT_BOLD
lbl.TextSize = 22 * Starter.dblScaleFactor
lbl.Gravity =Gravity.CENTER_VERTICAL
lngYPos = lngYPos + lngSpace2
Case 3 ' Directive at Question Level
lbl.Initialize("label")
lbl.Tag = "dir" & strID
pnl.AddView(lbl, 1%x, lngYPos, 98%x, 30dip)
lbl.Text=" " & cursor.Getstring("chk_text")
lbl.TextColor=Colors.DarkGray
'lbl.color=Colors.ARGB(255, 0, 0, 128)
lbl.TextSize = 20 * Starter.dblScaleFactor
lbl.Gravity =Gravity.CENTER_VERTICAL
lbl.Typeface = Typeface.DEFAULT_BOLD
lngYPos = lngYPos + lngSpace3
Case 4 'Question
'Question Text
lbl.Initialize("label")
lbl.Tag = "que" & strID
pnl.AddView(lbl, 1%x, lngYPos, 98%x, 30dip)
lbl.Text=" " & cursor.Getstring("chk_text")
lbl.TextColor=Colors.DarkGray
lbl.TextSize = 20 * Starter.dblScaleFactor
lbl.Gravity =Gravity.CENTER_VERTICAL
'Toggle Button
If cursor.Getint("chk_button_type_ID") = 0 Then
'No Button
Else
tglQuestion.Initialize("toggle")
If cursor.Getint("chk_button_type_ID") = 1 Then
tglQuestion.Tag = "tg2" & strID & "DG"
If cursor.Getint("chk_critical") = 0 Then
'Not critial
tglQuestion.Tag = "tg2" & strID & "DG"
tglQuestion.Color=Colors.DarkGray
Else
tglQuestion.Tag = "tg3" & strID & "RD"
tglQuestion.Color=Colors.Red
End If
Else
'Tri Stat
If cursor.Getint("chk_critical") = 0 Then
'Not critial
tglQuestion.Tag = "tg4" & strID & "DG"
tglQuestion.Color=Colors.DarkGray
Else
tglQuestion.Tag = "tg5" & strID & "RD"
tglQuestion.Color=Colors.Red
End If
End If
pnl.AddView(tglQuestion, lngToggleLeft * 1%x, lngYPos, 60dip, 30dip*Starter.dblButtonHeight)
tglQuestion.Checked=False
tglQuestion.TextOn="Yes"
tglQuestion.TextOff="No"
tglQuestion.TextSize=20*Starter.dblScaleFactor
End If
'Comment Box
If cursor.Getint("chk_comment_type_ID") = 0 Then
'No Comment Box
Else
txt.Initialize("comment")
txt.Tag = "qtx" & cursor.Getint("chk_ID")
pnl.AddView(txt, 75%x, lngYPos, 22%x, 40dip)
txt.TextColor=Colors.DarkGray
txt.TextSize = 20 * Starter.dblScaleFactor
txt.Gravity =Gravity.CENTER_VERTICAL
End If
lngYPos = lngYPos + lngSpace4
EndSelect
Next
EndIf
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(0, 0, 0dip, 3dip))
EndIf
Next
pnl.Height = 60dip +lngYPos
EndSub
Sub toggle_Click
Dim b AsToggleButton = Sender
Dim sf AsStringFunctions
sf.Initialize
Select Case sf.Left(b.Tag,3)
Case"tg2" 'Two way, not critical
Case"tg3" 'Two way, critical
If b.Checked = False Then
b.Color=Colors.Red
b.Tag=sf.left(b.Tag,11) & "RD"
Else
b.Color = Colors.DarkGray
b.Tag=sf.left(b.Tag,11) & "DG"
EndIf
Case"tg4" 'Three way, not critical
If b.TextOff = "N/A" Then
b.TextOff="No"
Else
b.TextOff="N/A"
EndIf
Case"tg5" 'Three way, critical
If b.TextOff = "N/A" Or b.TextOn = "N/A" Then
b.Color = Colors.DarkGray
b.Tag=sf.left(b.Tag,11) & "DG"
Else
If b.Checked = False Then
b.Color=Colors.Red
b.Tag=sf.left(b.Tag,11) & "RD"
Else
b.Color = Colors.DarkGray
b.Tag=sf.left(b.Tag,11) & "DG"
EndIf
End If
EndSelect
EndSub
Sub Activity_Resume
EndSub
Sub Activity_Pause (UserClosed As Boolean)
EndSub