'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim ST As SQL
Dim Cursor As Cursor
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim DisplyWeek As Table
Dim etxtDate As EditText
Dim Dates() As String
Dim btnMain As Button
Dim pnlMainMenu As Panel
Dim btnAddTime As Button
Dim pnlAddTime As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
'If FirstTime Then
'File.Copy(File.DirAssets,"TimeClock.sql",File.DirDefaultExternal,"TimeClock.sql")
'End If
'If ST.IsInitialized = False Then
' ST.Initialize(File.DirDefaultExternal, "jobschedule.sql", False)
' If
Activity.LoadLayout("MainMenu")
End Sub
Sub LoadAddTime
'ST.ExecQuery("Select * FROM tblCurrentWeek")
Activity.LoadLayout("AddTime")
'Activity.Panel.LoadLayout("pnlAddTime")
DisplyWeek.Initialize(pnlAddTime, "DisplyWeek", 0)
DisplyWeek.AddToActivity(pnlAddTime, 0, etxtDate.Top + etxtDate.Height + 4dip, 100%x, 20%y)
DisplyWeek.LoadTableFromCSV(File.DirAssets, "tblCurrentWeekJobs.csv", True)
DisplyWeek.SetColumnsWidths(Array As Int(130dip, 130dip, 130dip, 130dip, 130dip, 130dip, 130dip, 130dip))
ChangeHeaders
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub DisplyWeek_CellClick (Col As Int, Row As Int)
Log("(DisplyWeek) CellClick: " & Col & " , " & Row)
Activity.Title = DisplyWeek.GetValue(Col, Row)
End Sub
Sub btnExit_Click
ExitApplication
End Sub
Sub ChangeHeaders
Dim h() As String
Dim Dates(DisplyWeek.NumberOfColumns) As String
Dim i As Int
h = DisplyWeek.GetHeaderValues ' gets the haeder values
df = DateTime.DateFormat ' gets the current date format
For i = 0 To DisplyWeek.NumberOfColumns - 1
Dim txt() As String
txt = Regex.Split(" ", h(i)) ' splits the the date and time
Dim DateTicks As Long
Dim df As String
DateTime.DateFormat = "MM/dd/yyyy" ' sets the date format according to your csv file
DateTicks = DateTime.DateParse(txt(0)) ' transforms the date to ticks
DateTime.DateFormat = "MM-dd-yyyy" ' sets the date format according to your csv file
Dates(i) = DateTime.Date(DateTicks) ' sets the header dates in MM-dd-yyyy format
DateTime.DateFormat = "MMM-yy EEE-dd" ' sets the date format according to your request
h(i) = DateTime.Date(DateTicks) ' sets the header text with the new format
h(i) = h(i).Replace(".", "") ' removes unnecessary dots
Next
DateTime.DateFormat = df ' sets the date format back to the current one
DisplyWeek.SetHeaderValues(h)
End Sub
Sub DisplyWeek_HeaderClick(col As Int)
etxtDate.Text = Dates(col)
End Sub
Sub btnMain_Click
Activity.LoadLayout("MainMenu")
End Sub
Sub pnlMainMenu_Click
End Sub
Sub btnAddTime_Click
Activity.LoadLayout("AddTime")
End Sub
Sub pnlAddTime_Click
End Sub