#Region Project Attributes
#Region Project Attributes
#ApplicationLabel: XXX
#VersionCode: 1
#VersionName: 1.00
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#AdditionalJar: com.android.support:support-v4
#End Region
#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.
Type DBResult (Tag As Object, Columns As Map, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
Private const rdcLink As String = "http://XXX.XXX.XX.XX:178/rdc"
End Sub
Sub Globals
'Generales
Private estaciones_manual As Spinner
Private TabStrip1 As TabStrip
Dim nombres_array(300) As String
Dim posicion_list (300) As Int
Dim myABBarcode As ABZxing
'Login
Private qr_log As Button
Private num_serie As EditText
Private Login As Button
Private login_pass As EditText
Private EditText1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.RemoveAllViews
Activity.LoadLayout("Main")
TabStrip1.LoadLayout("login", "LOGIN")
nombres_estacion
num_serie.text=GetDeviceId
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
'CONSULTAS SQL ------------------------------------------------------------------------------------------------
Sub CreateRequest As DBRequestManager
Dim req As DBRequestManager
req.Initialize(Me, rdcLink)
Return req
End Sub
Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = Name
If Parameters <> Null Then cmd.Parameters = Parameters
Return cmd
End Sub
Sub nombres_estacion ' WORKS FINE
ProgressDialogShow2("Espere..",True)
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("select_nombres",Array("1"))
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(res As DBResult)
Dim x As Int=0
For Each row() As Object In res.Rows
estaciones_manual.Add(row(1))
nombres_array(row(0))=row(1)
posicion_list(x)=row(0)
x=x+1
Next
Else
Msgbox("ERROR: " & j.ErrorMessage,"yo")
End If
j.Release
ProgressDialogHide
End Sub
'CODIGO QR EVENTOS ------------------------------------------------------------------------------------------------------
Sub qr_log_Click
myABBarcode.ABGetBarcode("myabbarcode", "")
End Sub
Sub myABBarcode_BarcodeFound(barCode As String, formatName As String)
End Sub
Sub myABBarcode_Canceled
Msgbox("Canceled","")
End Sub
' LOGIN ---------------------------------------------------------------------------------------------------------------------
Sub Login_Click ' NO WORKS , GIVE ME ERROR 500
Dim login_ok As Boolean
ProgressDialogShow2("Espere..",True)
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("select_login",Array(num_serie.Text,login_pass.text))
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(x As HttpJob)
If x.Success Then
req.HandleJobAsync(x, "req")
Wait For (req) req_Result(res As DBResult)
For Each row() As Object In res.Rows
login_ok=True
Next
Else
Msgbox("ERROR: " & x.ErrorMessage,"yo")
End If
x.Release
ProgressDialogHide
If login_ok =True Then
Msgbox("LOGIN CORRECTO","INFORMACIÓN")
Else
Msgbox("LOGIN INCORRECTO","INFORMACIÓN")
End If
End Sub
'Eventos keypress ------------------------------------------------------------------------------------------------------------
Sub Activity_KeyPress (KeyCode As Int) As Boolean
Dim salgo As Boolean=False
If KeyCode = KeyCodes.KEYCODE_BACK Then
'If info_estados.Visible =True Then
' info_estados.Visible =False
' salgo=True
' Return True
'End If
If salgo=False Then
Dim result As Int
result = Msgbox2("Salir de la App?", "labici Usuarios", "Si", "", "No", LoadBitmap(File.DirAssets, "advertencia.png"))
If result = DialogResponse.Positive Then
ExitApplication
Else:
Return True
End If
End If
End If
End Sub
'UTILES
Sub GetDeviceId As String
Dim p As Phone
Dim id As String
Dim r As Reflector
Dim Api As Int
Api = r.GetStaticField("android.os.Build$VERSION", "SDK_INT")
If Api < 9 Then
'Old device
id= p.GetSettings("android_id")
Else
'New device
id= r.GetStaticField("android.os.Build", "SERIAL")
If id.ToLowerCase = "unknown" Then id= p.GetSettings("android_id")
End If
Return id
End Sub