Sub TabStrip1_PageSelected (Position As Int)
Log($"Current page: ${Position}"$)
If Position = 0 Then
If Starter.col>-1 Then
EditaValores
End If
else If Position=1 Then
ShowTableInWebView
End If
End Sub
Sub WebView1_OverrideUrl (Url As String) As Boolean
'parse the row and column numbers from the URL
Dim values() As String
values = Regex.Split("[.]", Url.SubString(7))
'Dim col, row As Int
Starter.col = values(0)
Starter.row = values(1)
ToastMessageShow("User pressed on column: " & Starter.col & " and row: " & Starter.row, False)
'==================================================================================
Dim Lista As List
Lista.Initialize
Dim stringa_SQL As String ="SELECT idtt, tici, ticf, tempodispi, tempodispf, actname FROM tectryp ORDER BY tici ASC"
'
'Dim linha() As String ' this is for storing the row selected
Lista = DBUtils.ExecuteMemoryTable(SQL1, "" & stringa_SQL, Null, 0) 'Lista é o DataTable
' ' lista now have the table value with in the first column the index
Starter.linha=Lista.Get(Starter.row) '[0=3, 1=Trabalho , 2=24/06 16:04, 3=24/06 16:04]
TabStrip1.ScrollTo(0, False)
Return True 'Don't try to navigate to this URL
End Sub
Sub EditaValores
Dim DummyIdtt As Int
DummyIdtt = Starter.Linha(0) ' this is the index of the row selected in db, = idtt
' '======================================================================================
'
' 'linha= [0=3, 1=1499115600000, 2=1499126400000, 3=03/07 18:00, 4=03/07 21:00, 5=Viagem R ]
'
'
If Starter.col=0 Then 'Apagar a linha
Private Answ As Int
'ask the user for confirmation
Answ = Msgbox2("Apaga:" & Starter.Linha(5) & " " & Starter.Linha(3) & "... ?", "Apagar registro.", "Sim", "", "Não", Null)
If Answ = DialogResponse.POSITIVE Then 'if yes, delete the entry
SQL1.ExecNonQuery("DELETE FROM tectryp WHERE idtt = " & DummyIdtt) 'delete the entry
End If
Else 'Editar a hora
'========== Definição da Data ==================================================
Dim RData As Map
Dim H As Long
H=DT.Voltatics2(Starter.DiaHora) ' DiaHora=Ano&Mes&Dia&Hora&Minuto
RData=DT.HoraEdit(H, "Editando a hora: " & Starter.linha(Starter.col+2) , 1, 0) '
'=====================================================================================
' ' DummyIdtt=idtt col=1 datai, col=2 dataf
Dim WhereFields As Map
WhereFields.Initialize
WhereFields.Put("idtt", DummyIdtt) 'BuscaMap é o map no início
If Starter.col=1 Then 'Data INICIO
DBUtils.UpdateRecord(SQL1, "tectryp", "tici", RData.Get(7) , WhereFields) 'DataHora do Fechamento da viagem
DBUtils.UpdateRecord(SQL1, "tectryp", "temposisi", RData.Get(1), WhereFields)
DBUtils.UpdateRecord(SQL1, "tectryp", "tempodispi", RData.Get(3), WhereFields)
else if Starter.col=2 Then 'Data FIM
DBUtils.UpdateRecord(SQL1, "tectryp", "ticf", RData.Get(7) , WhereFields) 'DataHora do Fechamento da viagem
DBUtils.UpdateRecord(SQL1, "tectryp", "temposisf", RData.Get(1), WhereFields)
DBUtils.UpdateRecord(SQL1, "tectryp", "tempodispf", RData.Get(3), WhereFields)
End If
End If
Starter.col=-1
TabStrip1.ScrollTo(1, False)
'
'
'
MontaTela
Return