mirror of
https://github.com/KeymonSoft/Guna_Preventa.git
synced 2026-04-17 21:06:32 +00:00
- VERSION 4.10.17
- Se modificó la sección del engrane para que se pueda modificar el servidor de DBRequest. - Se agregó en el engrane la opción de importar una base de datos desde Whatsapp.
This commit is contained in:
@@ -91,6 +91,10 @@ Sub Class_Globals
|
||||
Dim buscandoActualizacion As Boolean = False
|
||||
Dim actualizacionRevisada As Boolean = False 'Parte de la funcionalidad "appUpdater"
|
||||
Private b_actualizacion As Button
|
||||
Private et_server As EditText
|
||||
Dim intentUsado As Boolean = False
|
||||
Private p_importarBDWA As Panel
|
||||
Private cb_importarBDWA As CheckBox
|
||||
End Sub
|
||||
|
||||
Public Sub Initialize
|
||||
@@ -230,6 +234,10 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
almacen = 0
|
||||
rutaPreventa = 0
|
||||
p_appUpdate.Visible = False
|
||||
'Revisamos si se disparo el intent de cargar la base de datos desde WhatApp.
|
||||
If Subs.traeUsarIntentBDWA Then
|
||||
Subs.importaBDDesdeWhatsApp
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
@@ -241,6 +249,12 @@ Sub B4XPage_Appear
|
||||
' Entrar.Enabled = False
|
||||
' revisaActualizacion
|
||||
' End If
|
||||
cb_importarBDWA.Checked = Subs.traeUsarIntentBDWA
|
||||
If user.Text.Trim = "KMTS1" Then
|
||||
p_importarBDWA.Visible = True
|
||||
Else
|
||||
p_importarBDWA.Visible = False
|
||||
End If
|
||||
reqManager.Initialize(Me, Starter.server)
|
||||
If Starter.muestraProgreso = 1 Then
|
||||
muestraProgreso("Descargando nueva versión, un momento por favor.")
|
||||
@@ -330,25 +344,23 @@ Sub B4XPage_Appear
|
||||
B4XSwitch1.Value = False
|
||||
End If
|
||||
Subs.guardaAppInfo
|
||||
|
||||
' If Subs.traeAlmacen <> "NA" Then
|
||||
' Dim cmd As DBCommand
|
||||
' cmd.Initialize
|
||||
' cmd.Name = "selectVersionAppGuna" 'Antes select_usuario_guna_GV2_1
|
||||
' cmd.Parameters = Array As Object(almacen)
|
||||
' reqManager.ExecuteQuery(cmd , 0, "versionApp")
|
||||
' End If
|
||||
End Sub
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub Entrar_Click
|
||||
|
||||
Dim reqManager9000 As DBRequestManager
|
||||
reqManager9000.Initialize(Me, "http://keymon.lat:9000")
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "selectVersionGuna"
|
||||
cmd.Parameters = Array As Object("1")
|
||||
Log("#### TEST QUERY FALSO")
|
||||
reqManager9000.ExecuteQuery(cmd , 0, "testQueryFalso")
|
||||
|
||||
|
||||
Dim r As Reflector
|
||||
Dim Api As Int
|
||||
Dim PP As Phone
|
||||
user.Text = user.Text.trim
|
||||
LogColor(Starter.server, Colors.Blue)
|
||||
Api = r.GetStaticField("android.os.Build$VERSION", "SDK_INT")
|
||||
If Api < 9 Then
|
||||
'Old device
|
||||
@@ -412,29 +424,35 @@ Sub Entrar_Click
|
||||
c=skmt.ExecQuery2("select count(*) as EXISTE1 from usuarioa where usuario = ?", Array As String(user.Text))
|
||||
c.Position=0
|
||||
existe = c.GetString("EXISTE1")
|
||||
|
||||
If existe = 0 Then
|
||||
If IMEI = "" Then
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_usuario_guna_GV2_10" 'Antes select_usuario_guna_GV2_1
|
||||
cmd.Parameters = Array As Object(user.Text.Trim, pass.Text.Trim)
|
||||
reqManager.ExecuteQuery(cmd , 0, "usuario_10") 'Antes usuario
|
||||
Else
|
||||
If IMEI = "" Then
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_usuario_guna_GV2_10"
|
||||
cmd.Parameters = Array As Object(user.Text.Trim, pass.Text.Trim)
|
||||
reqManager.ExecuteQuery(cmd , 0, "usuario_10")
|
||||
Else
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_usuario_guna_GV2_10" 'Antes select_usuario_guna_GV2
|
||||
cmd.Parameters = Array As Object(user.Text.Trim, pass.Text.trim)
|
||||
Log("Mandamos: "&user.Text&"|"& pass.Text)
|
||||
reqManager.ExecuteQuery(cmd , 0, "usuario_10") 'Antes usuario
|
||||
End If
|
||||
End If
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_usuario_guna_GV2_10" 'Antes select_usuario_guna_GV2_1
|
||||
cmd.Parameters = Array As Object(user.Text.Trim, pass.Text.Trim)
|
||||
reqManager.ExecuteQuery(cmd , 0, "usuario_10")
|
||||
' If IMEI = "" Then
|
||||
' Dim cmd As DBCommand
|
||||
' cmd.Initialize
|
||||
' cmd.Name = "select_usuario_guna_GV2_10" 'Antes select_usuario_guna_GV2_1
|
||||
' cmd.Parameters = Array As Object(user.Text.Trim, pass.Text.Trim)
|
||||
' reqManager.ExecuteQuery(cmd , 0, "usuario_10")
|
||||
' Else
|
||||
' If IMEI = "" Then
|
||||
' Dim cmd As DBCommand
|
||||
' cmd.Initialize
|
||||
' cmd.Name = "select_usuario_guna_GV2_10"
|
||||
' cmd.Parameters = Array As Object(user.Text.Trim, pass.Text.Trim)
|
||||
' reqManager.ExecuteQuery(cmd , 0, "usuario_10")
|
||||
' Else
|
||||
' Dim cmd As DBCommand
|
||||
' cmd.Initialize
|
||||
' cmd.Name = "select_usuario_guna_GV2_10" 'Antes select_usuario_guna_GV2
|
||||
' cmd.Parameters = Array As Object(user.Text.Trim, pass.Text.trim)
|
||||
' Log("Mandamos: "&user.Text&"|"& pass.Text)
|
||||
' reqManager.ExecuteQuery(cmd , 0, "usuario_10")
|
||||
' End If
|
||||
' End If
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_version_GV2"
|
||||
@@ -456,8 +474,8 @@ End Sub
|
||||
Sub JobDone(Job As HttpJob)
|
||||
Log(Job.Success)
|
||||
If Job.Success = False Then
|
||||
LogColor("Error: " & Job.tag & " : " & Job.ErrorMessage, Colors.red)
|
||||
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
LogColor("Error: " & Job.tag & " : " & Subs.parseHTTPError(Job.ErrorMessage), Colors.red)
|
||||
' ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Else
|
||||
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211027
|
||||
If Job.JobName = "DBRequest" Then
|
||||
@@ -520,8 +538,18 @@ Sub JobDone(Job As HttpJob)
|
||||
Dim name As String = records(result.Columns.Get("USUARIO"))
|
||||
Dim ID_ALMACEN As String = records(result.Columns.Get("CAT_LO_AGENCIA"))
|
||||
Dim IMEI_BASE As String = records(result.Columns.Get("CAT_LO_IDTELEFONO"))
|
||||
Private version As String = records(result.Columns.Get("CAT_AL_VERSION"))
|
||||
Private versionador As String = records(result.Columns.Get("CAT_AL_VERSIONADOR"))
|
||||
Private actualizarAplicacion As String = records(result.Columns.Get("CAT_AL_ACTUALIZACION"))
|
||||
Next
|
||||
skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("VERSION_NUEVA"))
|
||||
skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("VERSION_NUEVA", version))
|
||||
skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("FORZAR_ACTUALIZACION"))
|
||||
skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("FORZAR_ACTUALIZACION", actualizarAplicacion))
|
||||
' skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("VERSION_NUEVA"))
|
||||
' skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("VERSION_NUEVA", version))
|
||||
Log("|"&name&"|")
|
||||
Log($">>>> GUARDAMOS NUEVA VERSION: ${version}, ${actualizarAplicacion}"$)
|
||||
paso1 = 1
|
||||
IMEI_BASE = ""
|
||||
IMEI = ""
|
||||
@@ -740,6 +768,7 @@ Sub i_engrane_Click
|
||||
lv_server.AddSingleLine("http://keymon.lat:1782")
|
||||
If user.Text = "KMTS1" Then lv_server.AddSingleLine("http://10.0.0.205:1782")
|
||||
l_server.Text = Starter.server
|
||||
et_server.Text = Starter.server
|
||||
Subs.panelVisible(p_appUpdate,0,0)
|
||||
p_appUpdate.Height = Root.Height
|
||||
c = skmt.ExecQuery("SELECT HABILITADA FROM IMPRESORA")
|
||||
@@ -750,10 +779,19 @@ Sub i_engrane_Click
|
||||
If c.RowCount = 0 Then
|
||||
skmt.ExecNonQuery2("INSERT INTO GPS VALUES (?)", Array As Object(0))
|
||||
End If
|
||||
If user.Text.Trim = "KMTS1" Then
|
||||
p_importarBDWA.Visible = True
|
||||
Else
|
||||
p_importarBDWA.Visible = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub b_regesar_Click
|
||||
Subs.panelVisible(p_Main,0,0)
|
||||
skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("DBReqServer"))
|
||||
skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("DBReqServer", et_server.Text))
|
||||
Starter.server = et_server.Text
|
||||
Starter.reqManager.Initialize(Me, et_server.Text)
|
||||
End Sub
|
||||
|
||||
Sub i_engrane_LongClick
|
||||
@@ -763,6 +801,9 @@ End Sub
|
||||
Private Sub lv_server_ItemClick (Position As Int, Value As Object)
|
||||
Starter.server = Value
|
||||
l_server.Text = Value
|
||||
et_server.Text = Value
|
||||
skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("DBReqServer"))
|
||||
skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("DBReqServer", Value))
|
||||
Starter.reqManager.Initialize(Me, Value)
|
||||
ToastMessageShow("Servidor modificado", False)
|
||||
End Sub
|
||||
@@ -963,3 +1004,9 @@ End Sub
|
||||
Private Sub b_actualizacion_Click
|
||||
CallSubDelayed(appUpdater, "download_newApk")
|
||||
End Sub
|
||||
|
||||
Private Sub cb_importarBDWA_CheckedChange(Checked As Boolean)
|
||||
' LogColor($"cb_importarBDWA_CheckedChange = ${Checked}"$, Colors.Red)
|
||||
Starter.skmt.ExecNonQuery("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'")
|
||||
Starter.skmt.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('IMPORTAR_BD_WA', '${Checked}')"$)
|
||||
End Sub
|
||||
@@ -508,6 +508,13 @@ Sub B4XPage_Appear
|
||||
b_Inicio_Fin_venta.Visible = False
|
||||
End If
|
||||
|
||||
If Subs.hayPedido Then 'Si hay pedido, deshabilitamos el boton de "No Venta"
|
||||
Log(">>>>> HAY PEDIDO")
|
||||
Tels.Enabled = False
|
||||
Else
|
||||
Tels.Enabled = True
|
||||
End If
|
||||
|
||||
If Not(Starter.gps.GPSEnabled) Then
|
||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
@@ -537,7 +544,7 @@ Sub B4XPage_Appear
|
||||
If META2 < 1 Then
|
||||
META2 = "CUBIERTO"
|
||||
End If
|
||||
la_saldooper.Text = META2
|
||||
la_saldooper.Text = numberformat2(META2, 0, 2, 2, True)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
|
||||
If c.RowCount>0 Then
|
||||
C.Position=0
|
||||
@@ -1116,7 +1123,7 @@ End Sub
|
||||
Sub JobDone(Job As HttpJob)
|
||||
If Job.Success = False Then
|
||||
' ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
LogColor("Error: " & Job.tag & " : " & Job.ErrorMessage, Colors.red)
|
||||
LogColor("Error: " & Job.tag & " : " & subs.parseHTTPError(Job.ErrorMessage), Colors.red)
|
||||
' LogColor("Error: " & Job.ErrorMessage, Colors.red)
|
||||
Else
|
||||
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211110
|
||||
|
||||
@@ -233,6 +233,9 @@ Sub Class_Globals
|
||||
Private Label4 As Label
|
||||
Private Label2 As Label
|
||||
Private Label25 As Label
|
||||
Dim p_transparenteActualizacion As Panel
|
||||
Private p_forzarActualizacion As Panel
|
||||
Dim l_forzarActualizacion As Label
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
@@ -330,22 +333,26 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
l_rutasuplencia.Visible = True
|
||||
l_rutasuplencia.Text = s.GetString("RS_RUTA")
|
||||
End If
|
||||
|
||||
p_transparenteActualizacion.Width = Root.Width
|
||||
p_transparenteActualizacion.Height = Root.Height
|
||||
Subs.centraPanel(p_forzarActualizacion, p_transparenteActualizacion.Width)
|
||||
End Sub
|
||||
|
||||
'Descargar: GP_https://keymon.lat/movil/guna/GP_4.10.10.EP_d.apk
|
||||
|
||||
Sub B4XPage_Appear
|
||||
p_principal.Visible = True
|
||||
Subs.validaPromoProcterPRO3009
|
||||
HORAINGRESO ="000000"
|
||||
Btn_Ubicar.Left = (Root.Width/2) - (Btn_Ubicar.Width/2)
|
||||
' B4XPages.MainPage.reqManager.Initialize(Me, B4XPages.MainPage.SERVER)
|
||||
PASO =0
|
||||
PASO = 0
|
||||
If Not(Starter.gps.GPSEnabled) Then
|
||||
If Starter.marcaCel <> "Sony" Then ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
End If
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("select count(*) as CUANTOS from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("FECHA"))
|
||||
c.Position =0
|
||||
c.Position = 0
|
||||
If c.GetString("CUANTOS") = 0 Then
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_fecha"
|
||||
@@ -353,11 +360,11 @@ Sub B4XPage_Appear
|
||||
Msgbox("AJUSTAR FECHA","AVISO") 'ignore
|
||||
B4XPage_Appear
|
||||
Else
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("FECHA"))
|
||||
c.Position=0
|
||||
Dim sDate,sTime As String
|
||||
c = B4XPages.MainPage.skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("FECHA"))
|
||||
c.Position = 0
|
||||
Dim sDate, sTime As String
|
||||
DateTime.DateFormat = "yyyyMMdd"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sDate = DateTime.Date(DateTime.Now)
|
||||
If c.GetString("CAT_VA_VALOR") > sDate Then
|
||||
Msgbox("AJUSTAR LA FECHA YA QUE ES MENOR AL SISTEMA" ,"AVISO") 'ignore
|
||||
c.Close
|
||||
@@ -366,7 +373,7 @@ Sub B4XPage_Appear
|
||||
c.Close
|
||||
End If
|
||||
c.Close
|
||||
If EJECUTANDO =0 Then
|
||||
If EJECUTANDO = 0 Then
|
||||
Listo1 = 0
|
||||
Listo2 = 0
|
||||
Listo3 = 0
|
||||
@@ -378,11 +385,10 @@ Sub B4XPage_Appear
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
fecha=DateTime.Date(DateTime.Now)
|
||||
b=B4XPages.MainPage.skmt.ExecQuery("Select count(*) as CUANTOS from pedido_cliente")
|
||||
b.Position=0
|
||||
b.Position = 0
|
||||
Cuantos = b.GetString("CUANTOS")
|
||||
b.Close
|
||||
If Starter.marcaCel <> "Sony" Then ToastMessageShow(Cuantos , True)
|
||||
|
||||
d=B4XPages.MainPage.skmt.ExecQuery("select count(*) as TOTAL_VISITAR from kmt_info2 where gestion = 0")
|
||||
d.Position=0
|
||||
e=B4XPages.MainPage.skmt.ExecQuery("select count(*) as POR_VISITAR from kmt_info2")
|
||||
@@ -399,7 +405,7 @@ Sub B4XPage_Appear
|
||||
l_ruta.Text = f.GetString("CAT_CL_RUTA")
|
||||
f.Close
|
||||
End If
|
||||
If Cuantos = 0 Then
|
||||
If Cuantos = 0 Then
|
||||
L_MONTOD.Text =0
|
||||
l_cuantosc.Text = 0
|
||||
l_cuantosn.Text = 0
|
||||
@@ -412,7 +418,6 @@ Sub B4XPage_Appear
|
||||
l_porvisitar.Text = e.GetString("POR_VISITAR")
|
||||
d.Close
|
||||
e.Close
|
||||
|
||||
b=B4XPages.MainPage.skmt.ExecQuery("select count(*) as CUANTOS from noventa")
|
||||
b.Position=0
|
||||
l_cuantosn.Text = b.GetString("CUANTOS")
|
||||
@@ -424,12 +429,10 @@ Sub B4XPage_Appear
|
||||
b.Position=0
|
||||
L_MONTOD.Text = c.GetString("MONTO_DIA")
|
||||
l_cuantosc.Text = c.GetString("CLIENTES_DIA")
|
||||
|
||||
D2=B4XPages.MainPage.skmt.ExecQuery("select COUNT(*) AS CUANTOS from PEDIDO ")
|
||||
D2.Position = 0
|
||||
LPT = D2.GetString("CUANTOS") / l_cuantosc.Text
|
||||
D2.Close
|
||||
|
||||
l_cuantosn.Text = b.GetString("CUANTOS")
|
||||
efectiva = c.GetString("CLIENTES_DIA") / e.GetString("POR_VISITAR")
|
||||
l_efectiva.text = Round2(efectiva*100,2)
|
||||
@@ -466,12 +469,10 @@ Sub B4XPage_Appear
|
||||
c.Close
|
||||
bu.Initialize
|
||||
batterystatus = bu.BatteryInformation
|
||||
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select usuario from usuarioa")
|
||||
c.Position = 0
|
||||
usuario = c.GetString("USUARIO")
|
||||
c.Close
|
||||
|
||||
B4XPages.MainPage.montoActual = L_MONTOD.Text
|
||||
B4XPages.MainPage.clientestotal = L_CUANTOST.Text
|
||||
B4XPages.MainPage.clientesventa = l_cuantosc.Text
|
||||
@@ -493,19 +494,14 @@ Sub B4XPage_Appear
|
||||
Private s As Cursor = B4XPages.MainPage.skmt.ExecQuery("select count(RS_RUTA) as cuenta, RS_RUTA FROM RUTA_SUPLENCIA")
|
||||
s.Position = 0
|
||||
If s.GetString("cuenta") = 0 Then
|
||||
|
||||
Label22.Visible = False
|
||||
l_rutasuplencia.Visible = False
|
||||
l_rutasuplencia.Text = ""
|
||||
|
||||
Else If s.GetString("cuenta") > 0 Then
|
||||
|
||||
Label22.Visible = True
|
||||
l_rutasuplencia.Visible = True
|
||||
l_rutasuplencia.Text = s.GetString("RS_RUTA")
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Subir_Click
|
||||
@@ -556,8 +552,8 @@ Sub Subir_Click
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
' PEDIO_CLIENTE
|
||||
|
||||
' PEDIO_CLIENTE
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("SELECT PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT, PC_COSTO_SIN, PC_RUTA, PC_ALMACEN FROM PEDIDO_CLIENTE ")
|
||||
d=B4XPages.MainPage.skmt.ExecQuery("SELECT COUNT(*) as CUANTOS_PEDIDOSC FROM PEDIDO_CLIENTE ")
|
||||
If c.RowCount>0 Then
|
||||
@@ -577,7 +573,6 @@ Sub Subir_Click
|
||||
|
||||
' ENVIO DE LOS CODIGOS QR
|
||||
'c=skmt.ExecQuery2("SELECT CAT_CL_NUM_SERIEFISICO,CAT_CL_CODIGO ,CAT_CL_LONG,CAT_CL_LAT, CAT_CL_FOTO FROM kmt_info2 where CAT_CL_NUM_SERIEFISICO = ?", Array As String("OK"))
|
||||
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("SELECT CODIGOKMTS, CODIGOB, LAT, LON FROM HIST_CODIGO_BARRAS" )
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
@@ -1148,7 +1143,7 @@ Sub JobDone(Job As HttpJob)
|
||||
' End If
|
||||
'Log(Job.Tag)
|
||||
If Job.Success = False Then
|
||||
If Job.ErrorMessage <> "STREAM" Then LogColor("Error: " & Job.tag & " : " & Job.ErrorMessage, Colors.red)
|
||||
If Job.ErrorMessage <> "STREAM" Then LogColor("Error: " & Job.tag & " : " & subs.parseHTTPError(Job.ErrorMessage), Colors.red)
|
||||
'ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
If Job.ErrorMessage = "STREAM" Then
|
||||
If CARGA = "SUBIR" Then
|
||||
@@ -1173,7 +1168,7 @@ Sub JobDone(Job As HttpJob)
|
||||
If n = "OKActivo" Then
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_ruta_GV2_70_8"
|
||||
cmd.Name = "select_ruta_GV2_70_9"
|
||||
cmd.Parameters = Array As Object(ALMACEN,e_ruta.text)
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "ruta")
|
||||
'Log("Usuario guardado en BD es 'Valido'")
|
||||
@@ -1967,70 +1962,79 @@ Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
End Sub
|
||||
|
||||
Sub connecta_Click
|
||||
B4XPages.MainPage.reqManager.Initialize(Me, Starter.server)
|
||||
teclado.HideKeyboard
|
||||
connecta1 = connecta1 + 1
|
||||
'imei = p.GetDeviceId
|
||||
conn = "1"
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_version_GV2"
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "version")
|
||||
' Cuando nos conectamos verificamos que el usuario guardado en BD sea VALIDO.
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO, PASS from usuarioa")
|
||||
c.Position=0
|
||||
If c.RowCount > 0 And c.GetString("USUARIO") <> "KMTS1" Then
|
||||
Private usrT As String = c.GetString("USUARIO")
|
||||
Private passT As String = c.GetString("PASS")
|
||||
Log(">>> REVISAMOS ACTUALIZACION")
|
||||
Private revisaActualizacion As Map = Subs.revisaForzarActualizacion
|
||||
Log(revisaActualizacion)
|
||||
If revisaActualizacion.Get("forzar") = 1 Then ' Hay actualización, la forzamos.
|
||||
' Starter.newApp.appLink = $"https://keymon.lat/movil/guna/GP_${revisaActualizacion.Get("nuevaVersion")}.apk"$ 'Liga a nuevo apk
|
||||
' Starter.newApp.newMsg = "Nueva version" 'Texto de que hay actualizacion
|
||||
' Starter.newApp.okMsg = "Aceptar" 'Texto de app al corriente
|
||||
' Starter.newApp.version = revisaActualizacion.Get("nuevaVersion") 'Version actual
|
||||
l_forzarActualizacion.TextColor = Colors.black
|
||||
l_forzarActualizacion.Text = "Hay una nueva actualización para la aplicación, por favor revise que tenga DATOS y espere mientras se descarga."
|
||||
p_transparenteActualizacion.Visible = True
|
||||
p_transparenteActualizacion.BringToFront
|
||||
Starter.nuevoLink = $"https://keymon.lat/movil/guna/GP_${revisaActualizacion.Get("nuevaVersion")}.apk"$
|
||||
Log("Descargar: GP_" & Starter.newApp.appLink)
|
||||
CallSubDelayed(appUpdater, "download_newApk")
|
||||
else if revisaActualizacion.Get("forzar") = 2 Then ' No hay datos, regresamos al login y borramos usuario par que traiga los datos.
|
||||
l_forzarActualizacion.TextColor = Colors.red
|
||||
l_forzarActualizacion.Text = "Es necesaria una conexión a internet, por favor revise su conexión y vuelva a intentar."
|
||||
p_transparenteActualizacion.Visible = True
|
||||
p_transparenteActualizacion.BringToFront
|
||||
Sleep(4500)
|
||||
Starter.skmt.ExecNonQuery("delete from usuarioa")
|
||||
p_transparenteActualizacion.Visible = False
|
||||
B4XPages.ShowPage("Login")
|
||||
Else ' No hay actualización, continuamos con la carga.
|
||||
p_transparenteActualizacion.Visible = False
|
||||
B4XPages.MainPage.reqManager.Initialize(Me, Starter.server)
|
||||
teclado.HideKeyboard
|
||||
connecta1 = connecta1 + 1
|
||||
'imei = p.GetDeviceId
|
||||
conn = "1"
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_usuario_guna_GV2_10"
|
||||
cmd.Parameters = Array As Object(usrT, passT)
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "usuarioA")
|
||||
End If
|
||||
c.Close
|
||||
|
||||
' If imei = "" Then
|
||||
' cmd.Initialize
|
||||
|
||||
' cmd.Name = "select_ruta_GV2_70_2"
|
||||
' cmd.Parameters = Array As Object(ALMACEN,e_ruta.text,imei)
|
||||
' B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "ruta")
|
||||
' Else
|
||||
' Dim cmd As DBCommand
|
||||
' cmd.Initialize
|
||||
' cmd.Name = "select_ruta_GV2_70_2"
|
||||
' cmd.Parameters = Array As Object(ALMACEN,e_ruta.text,imei)
|
||||
' B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "ruta")
|
||||
' End If
|
||||
|
||||
If e_ruta.Text = "KMTS1" Then
|
||||
cargar.Visible = True
|
||||
Subir.Visible = True
|
||||
e_ruta.Text = ""
|
||||
End If
|
||||
|
||||
If e_ruta.Text = "BERNA1" Then
|
||||
cargar.Visible = True
|
||||
Subir.Visible = True
|
||||
e_ruta.Text = ""
|
||||
End If
|
||||
|
||||
ToastMessageShow("Validando Conexión." , True)
|
||||
|
||||
If connecta1 / 2 = 1 Then
|
||||
'SERVER = "http://177.244.63.54:1782"
|
||||
'SERVER = "http://keymon.com.mx:1782"
|
||||
'SERVER = "http://201.99.139.28:1782"
|
||||
cmd.Name = "select_version_GV2"
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "version")
|
||||
' Cuando nos conectamos verificamos que el usuario guardado en BD sea VALIDO.
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO, PASS from usuarioa")
|
||||
c.Position=0
|
||||
If c.RowCount > 0 And c.GetString("USUARIO") <> "KMTS1" Then
|
||||
Private usrT As String = c.GetString("USUARIO")
|
||||
Private passT As String = c.GetString("PASS")
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_usuario_guna_GV2_10"
|
||||
cmd.Parameters = Array As Object(usrT, passT)
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "usuarioA")
|
||||
End If
|
||||
c.Close
|
||||
If e_ruta.Text = "KMTS1" Then
|
||||
cargar.Visible = True
|
||||
Subir.Visible = True
|
||||
e_ruta.Text = ""
|
||||
End If
|
||||
If e_ruta.Text = "BERNA1" Then
|
||||
cargar.Visible = True
|
||||
Subir.Visible = True
|
||||
e_ruta.Text = ""
|
||||
End If
|
||||
ToastMessageShow("Validando Conexión." , True)
|
||||
If connecta1 / 2 = 1 Then
|
||||
'SERVER = "http://177.244.63.54:1782"
|
||||
'SERVER = "http://keymon.com.mx:1782"
|
||||
'SERVER = "http://201.99.139.28:1782"
|
||||
' B4XPages.MainPage.SERVER = "http://187.189.244.154:1782"
|
||||
' SERVER = "http://10.0.0.205:1782"
|
||||
B4XPages.MainPage.reqManager.Initialize(Me, Starter.server)
|
||||
Else
|
||||
'SERVER = "http://keymon.com.mx:1782"
|
||||
'SERVER = "http://201.99.139.28:1782"
|
||||
'SERVER = "http://177.244.63.54:1782"
|
||||
B4XPages.MainPage.reqManager.Initialize(Me, Starter.server)
|
||||
Else
|
||||
'SERVER = "http://keymon.com.mx:1782"
|
||||
'SERVER = "http://201.99.139.28:1782"
|
||||
'SERVER = "http://177.244.63.54:1782"
|
||||
' B4XPages.MainPage.SERVER = "http://187.189.244.154:1782"
|
||||
' SERVER = "http://10.0.0.205:1782"
|
||||
B4XPages.MainPage.reqManager.Initialize(Me, Starter.server)
|
||||
B4XPages.MainPage.reqManager.Initialize(Me, Starter.server)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -2072,6 +2076,8 @@ Sub t2_tick
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("DELETE FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?",Array As String("pasword"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("DELETE FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?",Array As String("LATITUD"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("DELETE FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?",Array As String("LONGITUD"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("DELETE FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?",Array As String("FORZAR_ACTUALIZACION"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("DELETE FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?",Array As String("VERSION_NUEVA"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE GPS SET HABILITADO = (?)",Array As Object(0))
|
||||
B4XPage_Appear
|
||||
E_RUTA2.Visible = False
|
||||
@@ -2086,18 +2092,14 @@ End Sub
|
||||
|
||||
Sub e_ruta_EnterPressed
|
||||
If e_ruta.Text = "FIN DIA" Then
|
||||
|
||||
RES = Msgbox2("Seguro que desa hacer el cierre todos los datos se borraran?","Cierre", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
|
||||
If RES = DialogResponse.POSITIVE Then
|
||||
Subs.bitacora(Subs.fechanormal(DateTime.Now),usuario,Subs.traeAlmacen, Subs.traeRuta,"Fin Día", "",Subs.fechanormal(DateTime.Now),Subs.fechanormal(DateTime.Now),B4XPages.MainPage.lat_gps,B4XPages.MainPage.lon_gps,"2","","")
|
||||
|
||||
t2.Initialize("T2", 1000) ' 1000 = 1 second
|
||||
t2.Enabled = True
|
||||
Label22.Visible = False
|
||||
l_rutasuplencia.Visible = False
|
||||
l_rutasuplencia.Text = ""
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -2215,6 +2217,7 @@ Sub B_OK_PAS_Click
|
||||
Resumen.Visible= True
|
||||
img2.Visible=False
|
||||
Subs.panelVisible(p_principal, 0, 0)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("DELETE FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String("CARGA_DIA"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("CARGA_DIA",1))
|
||||
|
||||
If E_RUTA2.Visible = True Then
|
||||
@@ -2693,4 +2696,8 @@ End Sub
|
||||
|
||||
Private Sub p_sombra_Click
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub p_transparenteActualizacion_Click
|
||||
|
||||
End Sub
|
||||
@@ -122,7 +122,7 @@ Sub B4XPage_Appear
|
||||
c = B4XPages.MainPage.skmt.ExecQuery("select count(*) as hayPromos from cat_gunaprod where CAT_GP_TIPOPROD = 'PROMOS'")
|
||||
c.Position = 0
|
||||
If c.GetInt("hayPromos") > 0 Then
|
||||
lv_catalogos.AddSingleLine("PROMOS")
|
||||
If Not(Subs.traeCliente.StartsWith("N")) Then lv_catalogos.AddSingleLine("PROMOS") 'No se venden promos a clientes nuevos.
|
||||
End If
|
||||
Sleep(100)
|
||||
l_total.Visible = False
|
||||
@@ -212,7 +212,7 @@ Sub lv_catalogos_ItemClick (Position As Int, Value As Object)
|
||||
Private yaComproPRO3054 As Boolean = Subs.revisaPRO3054(Subs.traeCliente)
|
||||
Private yaComproPRO3055 As Boolean = Subs.revisaPRO3055(Subs.traeCliente)
|
||||
If c2.RowCount > 0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
For i=0 To c2.RowCount - 1
|
||||
c2.Position = i
|
||||
' jpeg = c2.GetBlob("CAT_GP_IMG")
|
||||
' ins.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
|
||||
@@ -225,8 +225,7 @@ Sub lv_catalogos_ItemClick (Position As Int, Value As Object)
|
||||
LogColor("Ya compro la PRO2265, ya no se muestra la PRO3015", Colors.Red)
|
||||
Else
|
||||
If (yaComproPRO3054 And c2.GetString("CAT_GP_ID") = "PRO3054") Or _
|
||||
(yaComproPRO3055 And c2.GetString("CAT_GP_ID") = "PRO3055") Or _
|
||||
(Subs.traeCliente.StartsWith("N")) Then ' Si la promo es la PRO3054 o PRO3055 y ya compro, NO la mostramos.
|
||||
(yaComproPRO3055 And c2.GetString("CAT_GP_ID") = "PRO3055") Then ' Si la promo es la PRO3054 o PRO3055 y ya compro, NO la mostramos.
|
||||
LogColor("Ya compro prods de la PRO3054 o PRO3055 o es cliente nuevo, ya no se muestra.", Colors.Red)
|
||||
Else
|
||||
lv_promos.AddTwoLines(c2.GetString("CAT_GP_NOMBRE"),"# " & c2.GetString("CAT_GP_ALMACEN") & " $ " & c2.GetString("CAT_GP_PRECIO") & " F:" & tm.Get("mp").As(Map).Get("prodsFijosCant") & " V:" & tm.Get("mp").As(Map).Get("prodsVariablesCant"))
|
||||
|
||||
@@ -57,35 +57,25 @@ Sub B4XPage_Appear
|
||||
nombre_boton = "NOVENTA"
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select PC_CLIENTE,PC_MONTO,PC_NOART,(select CAT_CL_NOMBRE from kmt_info2 where cat_cl_codigo = pc_cliente ) as NOMBRE FROM PEDIDO_CLIENTE ORDER BY PC_FECHA asc")
|
||||
ListView1.Clear
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
If c.RowCount > 0 Then
|
||||
For i = 0 To c.RowCount - 1
|
||||
c.Position = i
|
||||
|
||||
'AQUI CAMBIAR
|
||||
|
||||
|
||||
|
||||
Private s3 As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select * FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and PE_RECALCULO <> ? OR PE_RECALCULO <> ? OR PE_RECALCULO IS NOT NULL",Array As String("","null"))
|
||||
LogColor(s3.RowCount,Colors.Yellow)
|
||||
' LogColor(s3.RowCount,Colors.Yellow)
|
||||
If s3.RowCount > 0 Then
|
||||
|
||||
Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and (PE_RECALCULO = ? or PE_RECALCULO = ? or PE_RECALCULO IS NULL)",Array As String("","null"))
|
||||
s.Position=0
|
||||
Private s5 As Cursor = B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(PE_RECALCULOTOT),0) as TOTAL_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and (PE_RECALCULO <> ? or PE_RECALCULO <> ? OR PE_RECALCULO IS NOT NULL)",Array As String("","null"))
|
||||
s5.Position = 0
|
||||
|
||||
Private suma As Float =NumberFormat2( s.GetString("TOTAL_CLIE") + s5.GetString("TOTAL_CLIE"),0,2,2,False)
|
||||
|
||||
|
||||
|
||||
s.Close
|
||||
|
||||
|
||||
Else If s3.RowCount = 0 Then
|
||||
Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO WHERE PE_CLIENTE = ?",Array As String(c.GetString("PC_CLIENTE")))
|
||||
s.Position=0
|
||||
|
||||
Private suma As Float = NumberFormat2( s.GetString("TOTAL_CLIE"),0,2,2,False)
|
||||
|
||||
s.Close
|
||||
End If
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -55,14 +55,14 @@ ModuleClosedNodes1=11,13,14
|
||||
ModuleClosedNodes10=
|
||||
ModuleClosedNodes11=
|
||||
ModuleClosedNodes12=6
|
||||
ModuleClosedNodes13=
|
||||
ModuleClosedNodes13=3
|
||||
ModuleClosedNodes14=
|
||||
ModuleClosedNodes15=
|
||||
ModuleClosedNodes16=
|
||||
ModuleClosedNodes17=4
|
||||
ModuleClosedNodes18=
|
||||
ModuleClosedNodes19=
|
||||
ModuleClosedNodes2=2,4,5
|
||||
ModuleClosedNodes2=6
|
||||
ModuleClosedNodes20=
|
||||
ModuleClosedNodes21=
|
||||
ModuleClosedNodes22=3,4
|
||||
@@ -76,6 +76,6 @@ ModuleClosedNodes6=8,9,10,11
|
||||
ModuleClosedNodes7=
|
||||
ModuleClosedNodes8=
|
||||
ModuleClosedNodes9=
|
||||
NavigationStack=C_Productos,lv_catalogos_ItemClick,206,0,C_Principal,cargar_Click,1017,0,C_Principal,Subir_Click,558,0,B4XMainPage,Entrar_Click,440,6,B4XMainPage,user_EnterPressed,447,0,Subs,revisaPRO3054,1486,0,C_Promos,Class_Globals,14,0,B4XMainPage,B4XPage_Created,94,3,DBRequestManager,HandleJob,187,0,B4XMainPage,JobDone,458,4
|
||||
NavigationStack=Subs,traeUsarIntentBDWA,1599,0,Subs,parseHTTPError,1547,0,B4XMainPage,Class_Globals,88,0,B4XMainPage,cb_importarBDWA_CheckedChange,999,0,Subs,importaBDDesdeWhatsApp,1549,6,B4XMainPage,i_engrane_Click,773,0,B4XMainPage,b_actualizacion_Click,1000,0,Visual Designer,login.bal,-100,6,B4XMainPage,B4XPage_Appear,245,1,B4XMainPage,B4XPage_Created,227,2
|
||||
SelectedBuild=0
|
||||
VisibleModules=23,2,24,13,14,15,4,19
|
||||
VisibleModules=23,2,24,13,1,14,4
|
||||
|
||||
@@ -36,6 +36,7 @@ Sub Process_Globals
|
||||
Dim enVenta As Boolean = False
|
||||
Dim muestraProgreso = 0 'Parte de la funcionalidad "appUpdater"
|
||||
Public newApp As mNewVersion 'Parte de la funcionalidad "appUpdater"
|
||||
Dim nuevoLink As String
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
@@ -70,6 +71,14 @@ Sub Service_Start (StartingIntent As Intent)
|
||||
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
||||
Subs.revisaBD
|
||||
Log(marcaCel)
|
||||
Private s As Cursor = skmt.ExecQuery("select * from cat_variables where cat_va_descripcion = 'DBReqServer'")
|
||||
If s.RowCount > 0 Then 'Si tenemso valor en BD lo tomamos.
|
||||
s.Position = 0
|
||||
server = s.GetString("CAT_VA_VALOR")
|
||||
Else 'Si no hay valor de BD usamos el defaut.
|
||||
skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("DBReqServer"))
|
||||
skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("DBReqServer", server))
|
||||
End If
|
||||
reqManager.Initialize(Me, server)
|
||||
End Sub
|
||||
|
||||
|
||||
98
B4A/Subs.bas
98
B4A/Subs.bas
@@ -21,6 +21,8 @@ Sub Process_Globals
|
||||
' Dim rutaInicioHoy As String = ""
|
||||
Private subsLogs As Boolean = False
|
||||
Dim skmt As SQL
|
||||
Dim in As Intent
|
||||
Dim intentUsado As Boolean = False
|
||||
End Sub
|
||||
|
||||
'Pone el valor de phn.Model en la variable global "devModel"
|
||||
@@ -633,7 +635,7 @@ End Sub
|
||||
'Regresa el almacen actual de la base de datos.
|
||||
Sub traeAlmacen As String 'ignore
|
||||
Private c As Cursor
|
||||
Private a As String
|
||||
Private a As String = "NA"
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
|
||||
c.Position = 0
|
||||
a = C.GetString("ID_ALMACEN")
|
||||
@@ -1510,3 +1512,97 @@ Sub revisaPRO3055(idCliente As String) As Boolean
|
||||
Log($">>>> revisaPRO3055 ${idCliente} = ${x}"$)
|
||||
Return x
|
||||
End Sub
|
||||
|
||||
'Revisa si hay actualizacion, si es necesario relaizarla y cual es la liga del APK de la actualización.
|
||||
' Regresa 0, 1 o 2 dependiendo de CAT_VARIABLES (Sin actualizacion, Forzar actualizacion, Sin adtos, forzar descarga de datos)
|
||||
Sub revisaForzarActualizacion As Map
|
||||
Private ra As ResultSet = Starter.skmt.ExecQuery($"select * from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'VERSION_NUEVA' or CAT_VA_DESCRIPCION = 'FORZAR_ACTUALIZACION'"$)
|
||||
Private nuevaVersion As String = ""
|
||||
Private forzarActualizacion As Int = 2
|
||||
Private m As Map
|
||||
m.Initialize
|
||||
Do While ra.NextRow
|
||||
If ra.GetString("CAT_VA_DESCRIPCION") = "VERSION_NUEVA" Then nuevaVersion = ra.GetString("CAT_VA_VALOR")
|
||||
If ra.GetString("CAT_VA_DESCRIPCION") = "FORZAR_ACTUALIZACION" Then forzarActualizacion = ra.GetInt("CAT_VA_VALOR")
|
||||
Loop
|
||||
' Log(nuevaVersion)
|
||||
' Log(forzarActualizacion)
|
||||
If nuevaVersion <> Application.VersionName And forzarActualizacion = 1 Then
|
||||
m.Put("forzar", 1)
|
||||
m.Put("nuevaVersion", nuevaVersion)
|
||||
else if forzarActualizacion = 2 Then 'Si no existen los datos en CAT_VARIABLES, entonces los recargamos
|
||||
m.Put("forzar", 2)
|
||||
m.Put("nuevaVersion", "Recargar")
|
||||
Else
|
||||
m.Put("forzar", 0)
|
||||
m.Put("nuevaVersion", nuevaVersion)
|
||||
End If
|
||||
Return m
|
||||
End Sub
|
||||
|
||||
Sub parseHTTPError(error As String) As String
|
||||
Private nuevoError As String = error
|
||||
Private inicio As Int = error.IndexOf("<title>")
|
||||
Private final As Int = error.IndexOf("</title>")
|
||||
Log("|" & inicio & "|" & final & "|")
|
||||
If inicio > 0 And final > 0 Then
|
||||
nuevoError = error.SubString2(inicio + 17, final)
|
||||
' LogColor(error.SubString2(inicio + 17, final), Colors.Blue)
|
||||
End If
|
||||
Return nuevoError
|
||||
End Sub
|
||||
|
||||
' Se revisa si hay una intención (intent) de abrir una base de datos y si es así, entonces se importa esa base de datos.
|
||||
Sub importaBDDesdeWhatsApp
|
||||
' Private tmpBDWA As Boolean = traeUsarIntentBDWA
|
||||
Log("Revisamos intent de importar desde whatsapp")
|
||||
Log(B4XPages.MainPage.intentUsado)
|
||||
Log(in)
|
||||
If Not(in.IsInitialized) Then in = B4XPages.GetNativeParent(B4XPages.MainPage).GetStartingIntent ' Si se usa esta funcion en Mainpage, se pone "Me" en lugar de B4XPages.MainPage.
|
||||
If Not(B4XPages.MainPage.intentUsado) And in <> Null Then
|
||||
' Log(in)
|
||||
LogColor("Importamos base de datos desde Whatsapp.", Colors.blue)
|
||||
B4XPages.MainPage.intentUsado = True
|
||||
' Log(in.As(String))
|
||||
If in.GetData <> Null Then
|
||||
Dim XmlData As String
|
||||
XmlData = in.GetData
|
||||
Try
|
||||
Dim OutStr As OutputStream = File.OpenOutput(File.DirInternal,"kmt.db",False)
|
||||
Dim InStr As InputStream = File.OpenInput("ContentDir",XmlData)
|
||||
File.Copy2(InStr,OutStr)
|
||||
LogColor("BD copiada a interna.", Colors.Blue)
|
||||
OutStr.Close
|
||||
If in.As(String).Contains("whatsapp") Then ToastMessageShow("BD cargada desde Whatsapp", False)
|
||||
Catch
|
||||
Log(LastException)
|
||||
End Try
|
||||
' ExitApplication
|
||||
' Starter.skmt.ExecNonQuery("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'")
|
||||
' Starter.skmt.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('IMPORTAR_BD_WA', '${tmpBDWA}')"$)
|
||||
Private a As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'APP_NAME'"$)
|
||||
If a.RowCount > 0 Then
|
||||
a.Position = 0
|
||||
ToastMessageShow($"BD de "${a.GetString("CAT_VA_VALOR")}" cargada."$, True)
|
||||
End If
|
||||
a = Starter.skmt.ExecQuery($"select * from usuarioa"$)
|
||||
If a.RowCount > 0 Then
|
||||
a.Position = 0
|
||||
B4XPages.MainPage.user.Text = a.GetString("USUARIO")
|
||||
B4XPages.MainPage.pass.Text = a.GetString("PASS")
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Regresa si se debe de usar el intent de importar la base d datos desde Whatsapp.
|
||||
Sub traeUsarIntentBDWA As Boolean 'ignore
|
||||
Private BDWA As Boolean = False
|
||||
Private x As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'"$)
|
||||
If x.RowCount > 0 Then
|
||||
x.Position = 0
|
||||
If x.GetString("CAT_VA_VALOR") = "true" Then BDWA = True
|
||||
End If
|
||||
Log($"cb_importarBDWA = ${BDWA}"$)
|
||||
Return BDWA
|
||||
End Sub
|
||||
@@ -171,14 +171,17 @@ Sub download_newApk
|
||||
B4XPages.MainPage.muestraProgreso("Descargando nueva versión, un momento por favor.")
|
||||
Dim job_newAPP As HttpJob
|
||||
If job_newAPP.IsInitialized Then job_newAPP.Release
|
||||
' Log(">>>> LOGIN LINK : " & Starter.newApp.appLink)
|
||||
If Starter.newApp.appLink <> "" Then newApp = Starter.newApp
|
||||
Log(">>>> LOGIN LINK2: " & Starter.nuevoLink)
|
||||
If Starter.nuevoLink <> "" Then newApp.appLink = Starter.nuevoLink
|
||||
job_newAPP.Initialize("job_newAPP",Me)
|
||||
' Log(newApp.appLink & "?dummy=" & DateTime.Now)
|
||||
Log(newApp.appLink & "?dummy=" & DateTime.Now)
|
||||
job_newAPP.Download(newApp.appLink & "?dummy=" & DateTime.Now)
|
||||
Log("Vamos a descargar: " & newApp.appLink & "?dummy=" & DateTime.Now)
|
||||
Wait for (job_newAPP) JobDone (job_newAPP As HttpJob)
|
||||
Private downladSuccess As Boolean = False
|
||||
If job_newAPP.Success = True Then
|
||||
' // Delete existing file
|
||||
downladSuccess = True
|
||||
If File.Exists(SharedFolder,"newapp.apk") Then
|
||||
' Log(">>>>>> Borramos achivo anterior")
|
||||
File.Delete(SharedFolder,"newapp.apk")
|
||||
@@ -190,15 +193,25 @@ Sub download_newApk
|
||||
Log("APK dir: "&SharedFolder)
|
||||
End If
|
||||
job_newAPP.Release
|
||||
' // Install the app
|
||||
Dim in As Intent
|
||||
in.Initialize(in.ACTION_VIEW,"" )
|
||||
SetFileUriAsIntentData(in, "newapp.apk")
|
||||
' // Type must be set after calling SetFileUriAsIntentData
|
||||
in.SetType("application/vnd.android.package-archive")
|
||||
StartActivity(in)
|
||||
n2.Cancel(nNewAppnID)
|
||||
B4XPages.MainPage.ocultaProgreso
|
||||
If downladSuccess Then
|
||||
' // Install the app
|
||||
Dim in As Intent
|
||||
in.Initialize(in.ACTION_VIEW,"" )
|
||||
SetFileUriAsIntentData(in, "newapp.apk")
|
||||
' // Type must be set after calling SetFileUriAsIntentData
|
||||
in.SetType("application/vnd.android.package-archive")
|
||||
StartActivity(in)
|
||||
Else
|
||||
B4XPages.MainPage.principal.l_forzarActualizacion.TextColor = Colors.red
|
||||
B4XPages.MainPage.principal.l_forzarActualizacion.text = "Hubo un error en la descarga, por favor revise que tenga conexion a internet e intente de nuevo."
|
||||
Log("ERROR EN CONEXION")
|
||||
Sleep(5000)
|
||||
ExitApplication
|
||||
End If
|
||||
Starter.muestraProgreso = 0
|
||||
B4XPages.MainPage.principal.p_transparenteActualizacion.Visible = False
|
||||
' Service.StopForeground(nNewAppnID)
|
||||
StopService(Me)
|
||||
' CallSubDelayed(Main,"ocultaProgreso")
|
||||
|
||||
Reference in New Issue
Block a user