#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#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 sql As SQL
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.
'Private codigo As EditText
Dim cursor As Cursor
Dim ruta,miniruta As String
Private volver As ImageView
Private cod As EditText
Private enviar_cod As Button
Private mapa1 As Button
Private historial As Button
Private opciones As Panel
Private servicio As Button
Private actualizar As Button
Dim papeleros111 As HttpJob
Dim latitud,longitud As String
Dim p As PhoneIntents
Private Panel1 As Panel
' Private Panel2 As Panel
' Private listado_servicios As ListView
' Private envio_datos_papeleros As Button
'Private r1 As RadioButton
'Private r2 As RadioButton
'Private r3 As RadioButton
'Dim servicios As Int
Private comentario As EditText
Dim codigo1 As String
Private mapacerca As Button
Dim WebView1 As WebView
'Dim WebViewSettings1 As WebViewSettings
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("papeleros_pantalla")
papeleros111.Initialize("carga",Me)
'invisible
enviar_cod.Visible=False
opciones.visible=False
mapa1.Visible=False
historial.Visible=False
servicio.visible=False
' Panel2.visible=False
Try
If File.ExternalWritable Then
ruta =File.DirDefaultExternal
Else
ruta =File.DirInternal
End If
'''MEDULAR
If File.Exists(ruta,"munimovil2.db")=False Then
File.Copy(File.DirAssets,"munimovil2.db",ruta,"munimovil2.db")
End If
Catch
Log(LastException.Message)
End Try
sql.Initialize(ruta,"munimovil2.db",True)
End Sub
Sub Activity_Resume
'cuando vuelve de otra pantalla.
enviar_cod.Visible=False
opciones.visible=False
mapa1.Visible=False
historial.Visible=False
servicio.visible=False
cod.Visible=True
enviar_cod.Visible=True
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub volver_Click
StartActivity("smart")
End Sub
Sub enviar_cod_Click
'consultamos en la bd la existencia del codigo
Dim query,fecha As String
query="select * from papeleros where codigo="&cod.Text&""
ToastMessageShow (query,True)
cursor=sql.ExecQuery(query)
If cursor.RowCount>0 Then
For i=0 To cursor.RowCount-1
cursor.Position=i
codigo1=cursor.GetString("codigo")
fecha=cursor.GetString("fecha")
latitud=cursor.GetString("latitud")
longitud=cursor.GetString("longitud")
ToastMessageShow("Encontrado",True)
Next
'invisible
enviar_cod.Visible=True
opciones.visible=True
mapa1.Visible=True
historial.Visible=True
servicio.visible=True
End If
If cursor.RowCount=0 Then
ToastMessageShow("No encontrado",True)
'invisible
enviar_cod.Visible=False
opciones.visible=False
mapa1.Visible=False
historial.Visible=False
servicio.visible=False
End If
'OCULTAR TECLADO
Dim phone1 As Phone
phone1.HideKeyboard(Activity)
End Sub
Sub cod_TextChanged (Old As String, New As String)
enviar_cod.Visible=True
End Sub
Sub actualizar_LongClick
ProgressDialogShow("Conectando para actualizar")
'INVISIBLE
actualizar.Visible=False
actualiza_papeleros
End Sub
Sub actualiza_papeleros
sql.ExecNonQuery("delete from papeleros")
ProgressDialogShow("Iniciamos actualización")
Try
miniruta=""&smart.ruta_s&"cargar_papeleros.php"
''''MEDULAR''''''
papeleros111.PostString(miniruta, "pin_movil="&smart.pin_movil&"&dispo="&smart.androidID&"")
Log("miniruta :"&miniruta)
Catch
' voz.Speak("error en envio de datos , verifique que tenga conexión a internet",True)
Msgbox("Error en carga de datos","Error internet")
Activity.Finish
End Try
End Sub
Sub actualizar_Click
End Sub
Sub JobDone(Job As HttpJob)
Dim m As Map
Dim respuesta,query As String
Dim fecha,hora,latitud,longitud As String
m.Initialize()
Log("entramos....."&Job.Success)
If Job.Success Then
Dim res As String
res = Job.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Log("NOMBRE....."&Job.JobName)
Select Job.JobName
Case "carga"
Dim tipo_i As List
tipo_i= parser.NextArray 'returns a list with maps
sql.BeginTransaction
For i = 0 To tipo_i.Size - 1
Dim m As Map
m = tipo_i.Get(i)
'We are using a custom type named TwoLines (declared in Sub Globals).
'It allows us to later get the two values when the user presses on an item.
'Dim tl As TwoLines
codigo1= m.Get("codigo")
fecha= m.Get("fecha")
hora= m.Get("hora")
latitud=m.Get("latitud")
longitud=m.Get("longitud")
respuesta= m.Get("respuesta")
Log("TOTAL"& respuesta)
If (respuesta="entregado") Then
''''''MEDULAR''''''
query=" INSERT INTO `papeleros`(`id`,`codigo`,`fecha`,`latitud`,`longitud`) VALUES (Null,"&codigo1&",'"&fecha&"','"&latitud&"','"&longitud&"')"
Log ("QUERI"&query)
sql.ExecNonQuery(query)
End If
m.Clear
Next
sql.TransactionSuccessful
sql.EndTransaction
End Select
Else
'ToastMessageShow("Error: " & Job.ErrorMessage, True)
ProgressDialogHide
End If
Job.Release
ToastMessageShow("TERMINAMOS",True)
ProgressDialogHide
'Ver cantidad
chequea_cantiadad
End Sub
Sub chequea_cantiadad
Dim query,total As String
query="select count(*) as total from papeleros"
cursor=sql.ExecQuery(query)
If cursor.RowCount>0 Then
For i=0 To cursor.RowCount-1
cursor.Position=i
total=cursor.GetString("total")
ToastMessageShow("TOTAL PAPELEROS "&total,True)
Next
End If
End Sub
Sub mapa1_LongClick
Dim cadena As String
cadena="http://maps.google.com/?q="&latitud&","&longitud
StartActivity(p.OpenBrowser(cadena))
End Sub
Sub servicio_Click
Dim nombre,id_general_contrato As String
'Pone todo invisible
cod.Visible=False
enviar_cod.Visible=False
opciones.Visible=False
historial.Visible=False
mapa1.Visible=False
servicio.Visible=False
Panel1.visible=False
'visible panel2
' Panel2.Visible=True
StartActivity("registrar_servicios_papeleros")
End Sub
Sub listado_servicios_ItemLongClick (Position As Int, Value As Object)
End Sub
End Sub