#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
Sub Process_Globals
Public SPHost As String
Private GET_CLASS = "get_class", GET_STUDENTS = "get_students" As String
Type ItemValue (SelChkBox As CheckBox)
End Sub
Sub Globals
Private spnClass As Spinner
Dim ClasCode As Map
Dim CID As Double
Private CLVstd As CustomListView
Dim XUI As XUI
Private lblStdInfo As Label
Private chkAtn As CheckBox
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("LayAttendance")
ClasCode.Initialize
Show_Clases
End Sub
Sub Show_Clases
ExecuteRemoteQuery("Select engname, classid from classid order by classid", GET_CLASS)
End Sub
Sub Show_Students
ExecuteRemoteQuery("SELECT infocustomer.engname, infostudent.TheRollNo, infostudent.CustIDNO FROM infostudent, infocustomer WHERE (infocustomer.CustIDNO = infostudent.CustIDNO) AND (infostudent.TheSection = 'A') AND (infostudent.ClassId = " & CID & ") ORDER BY infostudent.TheRollNo", GET_STUDENTS)
End Sub
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Try
'ProgressDialogShow("Connecting to server...")
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString(SPHost, Query)
Catch
Log(LastException)
End Try
End Sub
Sub JobDone(Job As HttpJob)
'ProgressDialogHide
If Job.Success Then
Dim res As String
res = Job.GetString
Log("Response from server: " & res)
Dim Parser As JSONParser
Parser.Initialize(res)
Select Job.JobName
Case GET_CLASS
Dim l As List
l = Parser.NextArray
If l.Size > 0 Then
For i = 0 To l.Size - 1
Dim m As Map
m = l.Get(i)
spnClass.Add(m.Get("engname"))
ClasCode.Put(m.Get("engname"), m.Get("classid"))
Next
End If
Case GET_STUDENTS
Dim l As List
l = Parser.NextArray
If l.Size > 0 Then
CLVstd.Clear
For i = 0 To l.Size - 1
Dim m As Map
Dim TheCID As Double
m = l.Get(i)
Dim p As B4XView = XUI.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, CLVstd.AsView.Width, 50dip)
chkAtn.Initialize("chkAtn")
chkAtn.Checked = True
TheCID = m.Get("CustIDNO")
CLVstd.Add(CreateListItem(m.Get("TheRollNo") & " : " & m.Get("engname") , CLVstd.AsView.Width, 60dip), TheCID)
Next
End If
End Select
Else
Log(Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub spnClass_ItemClick (Position As Int, Value As Object)
CID = ClasCode.Get(Value)
Log(CID)
Show_Students
End Sub
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
Dim p As B4XView = XUI.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("LayControl")
lblStdInfo.Text = Text
Return p
End Sub
Sub CLVstd_ItemClick (Index As Int, Value As Object)
End Sub
Sub Make_Post
For i = 0 To CLVstd.Size - 1
If chkAtn.Checked = False Then
Log(chkAtn.tag)
End If
Next
End Sub
Sub btnPost_Click
Make_Post
End Sub