diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..618d244
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+**/Objects
+**/AutoBackups
+*.meta
\ No newline at end of file
diff --git a/DBRequestManager.bas b/DBRequestManager.bas
new file mode 100644
index 0000000..b10711a
--- /dev/null
+++ b/DBRequestManager.bas
@@ -0,0 +1,271 @@
+B4A=true
+Group=Default Group
+ModulesStructureVersion=1
+Type=Class
+Version=6.8
+@EndOfDesignText@
+'Class module
+Sub Class_Globals
+ Private mTarget As Object
+ Type DBResult (Tag As Object, Columns As Map, Rows As List)
+ Type DBCommand (Name As String, Parameters() As Object)
+ Private link As String
+ Private bc As ByteConverter
+ Private T_NULL = 0, T_STRING = 1, T_SHORT = 2, T_INT = 3, T_LONG = 4, T_FLOAT = 5 _
+ ,T_DOUBLE = 6, T_BOOLEAN = 7, T_BLOB = 8 As Byte
+ Private VERSION As Float = 0.9
+ Private tempArray(1) As Object
+ Dim jobTagAnterior As String = "" 'Mod por CHV - 211027
+End Sub
+
+'Target - The module that handles JobDone (usually Me).
+'ConnectorLink - URL of the Java server.
+Public Sub Initialize (Target As Object, ConnectorLink As String)
+ mTarget = Target
+ link = ConnectorLink
+End Sub
+
+'Sends a query request.
+'Command - Query name and parameters.
+'Limit - Maximum rows to return or 0 for no limit.
+'Tag - An object that will be returned in the result.
+'Timeout - The http request timeout in ms, or 0 if default (30 secs)
+Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object, Timeout As Int) 'Mod por CHV, agregué el parametro Timeout - 211229
+ Dim j As HttpJob
+ Dim ms As OutputStream
+ Dim out2 As OutputStream = StartJob(j,ms, Tag)
+ WriteObject(Command.Name, out2)
+ WriteInt(Limit, out2)
+ WriteList(Command.Parameters, out2)
+ out2.Close
+ j.PostBytes(link & "?method=query", ms.ToBytesArray)
+ If Timeout <> 0 Then j.GetRequest.Timeout = Timeout
+End Sub
+
+'Executes a batch of (non-select) commands.
+'ListOfCommands - List of the commands that will be executes.
+'Tag - An object that will be returned in the result.
+Public Sub ExecuteBatch(ListOfCommands As List, Tag As Object)
+ Dim j As HttpJob
+ Dim ms As OutputStream
+ Dim out2 As OutputStream = StartJob(j,ms, Tag)
+ WriteInt(ListOfCommands.Size, out2)
+ For Each Command As DBCommand In ListOfCommands
+ WriteObject(Command.Name, out2)
+ WriteList(Command.Parameters, out2)
+ Next
+ out2.Close
+ j.PostBytes(link & "?method=batch", ms.ToBytesArray)
+End Sub
+
+'Similar to ExecuteBatch. Sends a single command.
+Public Sub ExecuteCommand(Command As DBCommand, Tag As Object)
+ ExecuteBatch(Array As DBCommand(Command), Tag)
+End Sub
+
+Private Sub StartJob(j As HttpJob, MemoryStream As OutputStream, Tag As Object) As OutputStream
+ j.Initialize("DBRequest", mTarget)
+ j.Tag = Tag
+ MemoryStream.InitializeToBytesArray(0)
+ Dim compress As CompressedStreams
+ Dim out As OutputStream = compress.WrapOutputStream(MemoryStream, "gzip")
+ WriteObject(VERSION, out)
+ Return out
+End Sub
+
+Private Sub WriteList(Parameters As List, out As OutputStream)
+ Dim data() As Byte
+ If Parameters = Null Or Parameters.IsInitialized = False Then
+ Dim Parameters As List
+ Parameters.Initialize
+ End If
+ data = bc.IntsToBytes(Array As Int(Parameters.Size))
+ out.WriteBytes(data, 0, data.Length)
+ For Each o As Object In Parameters
+ WriteObject(o, out)
+ Next
+End Sub
+
+Private Sub WriteObject(o As Object, out As OutputStream)
+ Dim data() As Byte
+ tempArray(0) = o
+ If tempArray(0) = Null Then
+ out.WriteBytes(Array As Byte(T_NULL), 0, 1)
+ Else If tempArray(0) Is Short Then
+ out.WriteBytes(Array As Byte(T_SHORT), 0, 1)
+ data = bc.ShortsToBytes(Array As Short(o))
+ Else If tempArray(0) Is Int Then
+ out.WriteBytes(Array As Byte(T_INT), 0, 1)
+ data = bc.IntsToBytes(Array As Int(o))
+ Else If tempArray(0) Is Float Then
+ out.WriteBytes(Array As Byte(T_FLOAT), 0, 1)
+ data = bc.FloatsToBytes(Array As Float(o))
+ Else If tempArray(0) Is Double Then
+ out.WriteBytes(Array As Byte(T_DOUBLE), 0, 1)
+ data = bc.DoublesToBytes(Array As Double(o))
+ Else If tempArray(0) Is Long Then
+ out.WriteBytes(Array As Byte(T_LONG), 0, 1)
+ data = bc.LongsToBytes(Array As Long(o))
+ Else If tempArray(0) Is Boolean Then
+ out.WriteBytes(Array As Byte(T_BOOLEAN), 0, 1)
+ Dim b As Boolean = 0
+ Dim data(1) As Byte
+ If b Then data(0) = 1 Else data(0) = 0
+ Else If GetType(tempArray(0)) = "[B" Then
+ data = o
+ out.WriteBytes(Array As Byte(T_BLOB), 0, 1)
+ WriteInt(data.Length, out)
+ Else 'If o Is String Then (treat all other values as string)
+ out.WriteBytes(Array As Byte(T_STRING), 0, 1)
+ data = bc.StringToBytes(o, "UTF8")
+ WriteInt(data.Length, out)
+ End If
+ If data.Length > 0 Then out.WriteBytes(data, 0, data.Length)
+End Sub
+
+Private Sub ReadObject(In As InputStream) As Object
+ Dim data(1) As Byte
+ In.ReadBytes(data, 0, 1)
+ Select data(0)
+ Case T_NULL
+ Return Null
+ Case T_SHORT
+ Dim data(2) As Byte
+ Return bc.ShortsFromBytes(ReadBytesFully(In, data, data.Length))(0)
+ Case T_INT
+ Dim data(4) As Byte
+ Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
+ Case T_LONG
+ Dim data(8) As Byte
+ Return bc.LongsFromBytes(ReadBytesFully(In, data, data.Length))(0)
+ Case T_FLOAT
+ Dim data(4) As Byte
+ Return bc.FloatsFromBytes(ReadBytesFully(In, data, data.Length))(0)
+ Case T_DOUBLE
+ Dim data(8) As Byte
+ Return bc.DoublesFromBytes(ReadBytesFully(In, data, data.Length))(0)
+ Case T_BOOLEAN
+ Dim b As Byte = ReadByte(In)
+ Return b = 1
+ Case T_BLOB
+ Dim len As Int = ReadInt(In)
+ Dim data(len) As Byte
+ Return ReadBytesFully(In, data, data.Length)
+ Case Else
+ Dim len As Int = ReadInt(In)
+ Dim data(len) As Byte
+ ReadBytesFully(In, data, data.Length)
+ Return BytesToString(data, 0, data.Length, "UTF8")
+ End Select
+End Sub
+
+Private Sub ReadBytesFully(In As InputStream, Data() As Byte, Len As Int) As Byte()
+ Dim count = 0, read As Int
+ Do While count < Len And read > -1
+ read = In.ReadBytes(Data, count, Len - count)
+ count = count + read
+ Loop
+ Return Data
+End Sub
+
+Private Sub WriteInt(i As Int, out As OutputStream)
+ Dim data() As Byte
+ data = bc.IntsToBytes(Array As Int(i))
+ out.WriteBytes(data, 0, data.Length)
+End Sub
+
+Private Sub ReadInt(In As InputStream) As Int
+ Dim data(4) As Byte
+ Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
+End Sub
+
+Private Sub ReadByte(In As InputStream) As Byte
+ Dim data(1) As Byte
+ In.ReadBytes(data, 0, 1)
+ Return data(0)
+End Sub
+
+'Handles the Job result and returns a DBResult.
+Public Sub HandleJob(Job As HttpJob) As DBResult
+' Dim start As Long = DateTime.Now
+ Dim In As InputStream = Job.GetInputStream
+ Dim cs As CompressedStreams
+ In = cs.WrapInputStream(In, "gzip")
+ Dim serverVersion As Float = ReadObject(In) 'ignore
+ Dim method As String = ReadObject(In)
+ Dim table As DBResult
+ table.Initialize
+ table.Columns.Initialize
+ table.rows.Initialize
+ table.Tag = Job.Tag
+ If jobTagAnterior <> Job.Tag Then LogColor("HandleJob: '"&Job.Tag&"'", Colors.Blue) 'Mod por CHV - 211023
+ jobTagAnterior = Job.Tag 'Mod por CHV - 211023
+ If method = "query" Then
+ Dim numberOfColumns As Int = ReadInt(In)
+ For i = 0 To numberOfColumns - 1
+ table.Columns.Put(ReadObject(In), i)
+ Next
+ Do While ReadByte(In) = 1
+ Dim rowObjects(numberOfColumns) As Object
+ table.rows.Add(rowObjects)
+ For col = 0 To numberOfColumns - 1
+ Dim o As Object = ReadObject(In)
+ rowObjects(col) = o
+ Next
+ Loop
+ Else If method = "batch" Then
+ table.Columns.Put("AffectedRows", 0)
+ Dim rows As Int = ReadInt(In)
+ For i = 0 To rows - 1
+ table.rows.Add(Array As Object(ReadInt(In)))
+ Next
+ End If
+ In.Close
+' Log("HandleJob: " & (DateTime.Now - start))
+ Return table
+End Sub
+'Reads a file and returns the file as a bytes array.
+Public Sub FileToBytes(Dir As String, FileName As String) As Byte()
+ Dim out As OutputStream
+ out.InitializeToBytesArray(0)
+ Dim In As InputStream = File.OpenInput(Dir, FileName)
+ File.Copy2(In, out)
+ out.Close
+ Return out.ToBytesArray
+End Sub
+'Converts an image to a bytes array (for BLOB fields).
+Public Sub ImageToBytes(Image As Bitmap) As Byte()
+ Dim out As OutputStream
+ out.InitializeToBytesArray(0)
+ Image.WriteToStream(out, 100, "JPEG")
+ out.Close
+ Return out.ToBytesArray
+End Sub
+'Converts a bytes array to an image (for BLOB fields).
+Public Sub BytesToImage(bytes() As Byte) As Bitmap
+ Dim In As InputStream
+ In.InitializeFromBytesArray(bytes, 0, bytes.Length)
+ Dim bmp As Bitmap
+ bmp.Initialize2(In)
+ Return bmp
+End Sub
+'Prints the table to the logs.
+Public Sub PrintTable(Table As DBResult)
+ Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size)
+ Dim sb As StringBuilder
+ sb.Initialize
+ For Each col In Table.Columns.Keys
+ sb.Append(col).Append(TAB)
+ Next
+ Log(sb.ToString)
+ For Each row() As Object In Table.Rows
+ Dim sb As StringBuilder
+ sb.Initialize
+ For Each record As Object In row
+ sb.Append(record).Append(TAB)
+ Next
+ ToastMessageShow(sb.ToString, True)
+ Next
+End Sub
+
+
\ No newline at end of file
diff --git a/DBRequestManagerV2.bas b/DBRequestManagerV2.bas
new file mode 100644
index 0000000..93bff84
--- /dev/null
+++ b/DBRequestManagerV2.bas
@@ -0,0 +1,149 @@
+B4J=true
+Group=Default Group
+ModulesStructureVersion=1
+Type=Class
+Version=5.45
+@EndOfDesignText@
+'Requires support for resumable subs
+'Class module
+
+Sub Class_Globals
+ Private mTarget As Object
+ Private link As String
+ Private VERSION As Float = 2
+
+End Sub
+
+'Target - The module that handles JobDone (usually Me).
+'ConnectorLink - URL of the Java server.
+Public Sub Initialize (Target As Object, ConnectorLink As String)
+ mTarget = Target
+ link = ConnectorLink
+End Sub
+
+'Sends a query request.
+'Command - Query name and parameters.
+'Limit - Maximum rows to return or 0 for no limit.
+'Tag - An object that will be returned in the result.
+Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object, Timeout As Int) As HttpJob
+ Dim ser As B4XSerializator
+ Dim data() As Byte = ser.ConvertObjectToBytes(CreateMap("command": Command, "limit": Limit, "version": VERSION))
+ Return SendJob(CreateJob, data, Tag, "query2", Timeout)
+End Sub
+
+Private Sub SendJob(j As HttpJob, Data() As Byte, Tag As Object, Method As String, Timeout As Int) As HttpJob
+ j.Tag = Tag
+ j.PostBytes(link & "?method=" & Method , Data)
+ If Timeout <> 0 Then j.GetRequest.Timeout = Timeout
+ Return j
+End Sub
+
+Private Sub CreateJob As HttpJob
+ Dim j As HttpJob
+ j.Initialize("DBRequest", mTarget)
+ Return j
+End Sub
+
+'Executes a batch of (non-select) commands.
+'ListOfCommands - List of the commands that will be executes.
+'Tag - An object that will be returned in the result.
+Public Sub ExecuteBatch(ListOfCommands As List, Tag As Object) As HttpJob
+ Dim j As HttpJob = CreateJob
+ ExecuteBatchImpl(j, ListOfCommands, Tag)
+ Return j
+End Sub
+
+Private Sub ExecuteBatchImpl(Job As HttpJob, ListOfCommands As List, Tag As Object)
+ Dim ser As B4XSerializator
+ ser.ConvertObjectToBytesAsync(CreateMap("commands": ListOfCommands, "version": VERSION), "ser")
+ Wait For (ser) ser_ObjectToBytes (Success As Boolean, Bytes() As Byte)
+ If Success = False Then
+ Log("Error building command: " & LastException)
+ Return
+ End If
+ Dim ser As B4XSerializator = Sender
+ SendJob(Job, Bytes, Tag, "batch2", 0)
+End Sub
+
+
+'Similar to ExecuteBatch. Sends a single command.
+Public Sub ExecuteCommand(Command As DBCommand, Tag As Object) As HttpJob
+ Return ExecuteBatch(Array As DBCommand(Command), Tag)
+End Sub
+
+'Handles the Job result and returns a DBResult.
+'It is recommended to use HandleJobAsync instead.
+Public Sub HandleJob(Job As HttpJob) As DBResult
+ Dim ser As B4XSerializator
+ Dim data() As Byte = Bit.InputStreamToBytes(Job.GetInputStream)
+ Dim res As DBResult = ser.ConvertBytesToObject(data)
+ res.Tag = Job.Tag
+ Return res
+End Sub
+'Handles the Job result and raises the Result event when the data is ready.
+
+Public Sub HandleJobAsync(Job As HttpJob, EventName As String)
+ Dim ser As B4XSerializator
+ Dim data() As Byte = Bit.InputStreamToBytes(Job.GetInputStream)
+ ser.ConvertBytesToObjectAsync(data, "ser")
+ Wait For (ser) ser_BytesToObject (Success As Boolean, NewObject As Object)
+ If Success = False Then
+ Log("Error reading response: " & LastException)
+ Return
+ End If
+ Dim res As DBResult = NewObject
+ res.Tag = Job.Tag
+ CallSubDelayed2(mTarget, EventName & "_result", res)
+End Sub
+
+
+
+
+'Reads a file and returns the file as a bytes array.
+Public Sub FileToBytes(Dir As String, FileName As String) As Byte()
+ Dim out As OutputStream
+ out.InitializeToBytesArray(0)
+ Dim In As InputStream = File.OpenInput(Dir, FileName)
+ File.Copy2(In, out)
+ out.Close
+ Return out.ToBytesArray
+End Sub
+#if Not(B4J)
+'Converts an image to a bytes array (for BLOB fields).
+Public Sub ImageToBytes(Image As Bitmap) As Byte()
+ Dim out As OutputStream
+ out.InitializeToBytesArray(0)
+ Image.WriteToStream(out, 100, "JPEG")
+ out.Close
+ Return out.ToBytesArray
+End Sub
+'Converts a bytes array to an image (for BLOB fields).
+Public Sub BytesToImage(bytes() As Byte) As Bitmap
+ Dim In As InputStream
+ In.InitializeFromBytesArray(bytes, 0, bytes.Length)
+ Dim bmp As Bitmap
+ bmp.Initialize2(In)
+ Return bmp
+End Sub
+#End If
+
+'Prints the table to the logs.
+Public Sub PrintTable(Table As DBResult)
+ Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size)
+ Dim sb As StringBuilder
+ sb.Initialize
+ For Each col In Table.Columns.Keys
+ sb.Append(col).Append(TAB)
+ Next
+ Log(sb.ToString)
+ For Each row() As Object In Table.Rows
+ Dim sb As StringBuilder
+ sb.Initialize
+ For Each record As Object In row
+ sb.Append(record).Append(TAB)
+ Next
+ Log(sb.ToString)
+ Next
+End Sub
+
+
diff --git a/Files/cat.gif b/Files/cat.gif
new file mode 100644
index 0000000..466aea6
Binary files /dev/null and b/Files/cat.gif differ
diff --git a/Files/conf.ini b/Files/conf.ini
new file mode 100644
index 0000000..53f64d6
--- /dev/null
+++ b/Files/conf.ini
@@ -0,0 +1 @@
+mayusculasDesbloqueo=1
diff --git a/Files/ew.gif b/Files/ew.gif
new file mode 100644
index 0000000..b8055b3
Binary files /dev/null and b/Files/ew.gif differ
diff --git a/Files/kelloggs.bal b/Files/kelloggs.bal
new file mode 100644
index 0000000..5773c92
Binary files /dev/null and b/Files/kelloggs.bal differ
diff --git a/Files/layout1.bal b/Files/layout1.bal
new file mode 100644
index 0000000..3d24962
Binary files /dev/null and b/Files/layout1.bal differ
diff --git a/Files/logo_keymon.png b/Files/logo_keymon.png
new file mode 100644
index 0000000..e798416
Binary files /dev/null and b/Files/logo_keymon.png differ
diff --git a/Starter.bas b/Starter.bas
new file mode 100644
index 0000000..0afda6c
--- /dev/null
+++ b/Starter.bas
@@ -0,0 +1,50 @@
+B4A=true
+Group=Default Group
+ModulesStructureVersion=1
+Type=Service
+Version=8.8
+@EndOfDesignText@
+#Region Service Attributes
+ #StartAtBoot: False
+ #ExcludeFromLibrary: 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.
+ Dim citas As List
+ Dim confMap As Map
+ Dim mayusculasDesbloqueo As String = "0"
+ Dim ruta As String
+ Dim rp As RuntimePermissions
+End Sub
+
+Sub Service_Create
+ 'This is the program entry point.
+ 'This is a good place to load resources that are not specific to a single activity.
+ LogColor("///////////////////////////////////////////////////////////////////////////////////", Colors.Green)
+ LogColor("////////////////////////////// Iniciamos Starter ///////////////////////////////", Colors.Green)
+ LogColor("///////////////////////////////////////////////////////////////////////////////////", Colors.Green)
+End Sub
+
+Sub Service_Start (StartingIntent As Intent)
+ citas.Initialize
+ confMap.Initialize
+ ruta = File.DirInternal 'Ruta de la configuracion por defecto.
+ If File.ExternalWritable Then ruta = rp.GetSafeDirDefaultExternal("") 'Si podemos escribir a la tarjeta, cambiamos la ruta.
+ If Not(File.Exists(ruta, "conf.ini")) Then File.Copy(File.DirAssets, "conf.ini", ruta, "conf.ini") 'Copiamos el archivo de configuracion a la ruta especificada.
+ Subs.procesaConfiguracion
+End Sub
+
+Sub Service_TaskRemoved
+ 'This event will be raised when the user removes the app from the recent apps list.
+End Sub
+
+'Return true to allow the OS default exceptions handler to handle the uncaught exception.
+Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
+ Return True
+End Sub
+
+Sub Service_Destroy
+
+End Sub
diff --git a/Subs.bas b/Subs.bas
new file mode 100644
index 0000000..820e3fb
--- /dev/null
+++ b/Subs.bas
@@ -0,0 +1,171 @@
+B4A=true
+Group=Default Group
+ModulesStructureVersion=1
+Type=StaticCode
+Version=11.2
+@EndOfDesignText@
+'Code module
+'Subs in this code module will be accessible from all modules.
+Sub Process_Globals
+ 'These global variables will be declared once when the application starts.
+ 'These variables can be accessed from all modules.
+
+End Sub
+
+'Hace visible el panel con los parametros "Top" y "Left" dados
+'y lo hace del ancho y alto de la pantalla
+Sub panelVisible(panel As Panel, top As Int, left As Int, actividad As Activity) 'ignore
+' panel.BringToFront
+ panel.Width=actividad.Width
+ panel.Height=actividad.Height '-(WobbleMenu1.GetHeight-20)
+ panel.Visible = True
+ panel.Top = top
+ panel.Left = left
+End Sub
+
+'Oculta el panel especificado y lo manda al fondo
+Sub panelOculto(panel As Panel) 'ignore
+ panel.SendToBack
+ panel.Visible = False
+End Sub
+
+'Centra un boton horizontalmente en el panel superior
+Sub centraBotonEnPanel(boton As Button, panel As Panel)
+ boton.left = (panel.Width/2)-(boton.Width/2)
+End Sub
+
+'Centra una etiqueta horizontalmente en el panel superior
+Sub centraEtiquetaEnPanel(etiqueta As Label, panel As Panel)
+ etiqueta.left = (panel.Width/2)-(etiqueta.Width/2)
+End Sub
+
+'Centra un campo de texto horizontalmente en el panel superior
+Sub centraETEnPanel(et As EditText, panel As Panel)
+ et.left = (panel.Width/2)-(et.Width/2)
+End Sub
+
+'Centra un panel horizontalmente en el panel superior
+Sub centraPanelEnPanel(p1 As Panel, panel As Panel)
+ p1.left = (panel.Width/2)-(p1.Width/2)
+End Sub
+
+'Regresa una cita al azar, va borrando cada cita que regresa para que no se repitan, y cuando quedan pocas vuelve a llenar la lista.
+Sub dameCita(citas As List) As String
+ If citas.Size < 2 Then
+ citas.Add("No les hagas a tus hijos la vida difícil, haciéndoles la vida fácil.")
+ citas.Add("Nunca subestimes el poder de la estupidez humana.")
+ citas.Add("Se vive y se aprende ... o no se vive mucho.")
+ citas.Add("La verdad de una afirmación no tiene nada que ver con su credibilidad ... y viceversa.")
+ citas.Add("Nunca apeles al ''buen corazón'' de un hombre, puede que no tenga, saldrás ganando si invocas su interés.")
+ citas.Add("La teología de uno es la carcajada de otro.")
+ citas.Add("¡Todo en exceso! Para saborear la vida hay que tomarla a grandes tragos, la moderación es para los monjes.")
+ citas.Add("La generación que ignora la historia no tiene pasado … ni futuro.")
+ citas.Add("Si no puede expresarse en cifras, no es ciencia, es opinión.")
+ citas.Add("Escucha siempre a los expertos, te dirán lo que no se puede hacer, y por qué ... entonces ve y hazlo!!")
+ citas.Add("El juego está arreglado, naturalmente, pero no te detengas por eso: si no apuestas, no puedes ganar.")
+ citas.Add("Conservarse joven exige el cultivar con tenacidad la capacidad de desaprender las viejas falsedades.")
+ citas.Add("El dinero es veraz, si un hombre habla de su honor, hazle pagar en efectivo.")
+ citas.Add("Cuando la tentación se cruce en tu camino, aprovéchala, puede que no vuelva a presentarse.")
+ citas.Add("La libertad empieza cuando uno manda a la gente a freír espárragos.")
+ citas.Add("Cuando la tentación se cruce en tu camino, aprovéchala, puede que no vuelva a presentarse.")
+ End If
+ Private citaNum As Int = Rnd(1, citas.Size)
+' Log(citas.Size & "|" & (citaNum-1))
+ Private laCita As String = citas.Get(citaNum-1)
+ citas.RemoveAt(citaNum-1)
+ Return laCita
+End Sub
+
+'Compara dos versiones (string) con el formato "1.10.09", regresa 1 si la primera es mayor, 0 si es igual y -1 si es menor
+Sub comparaVersiones(ver1 As String, ver2 As String) As Int
+' Logcolor($"${ver1} - ${ver2}"$, Colors.Magenta)
+ Private m1(), m2() As String
+ Private pri1, pri2, sec1, sec2, ter1, ter2 As String
+ m1 = Regex.Split("\.", ver1)
+ m2 = Regex.Split("\.", ver2)
+ pri1 = m1(0)
+ pri2 = m2(0)
+' Log(pri1 & "|" & pri2)
+ If pri1 > pri2 Then Return 1 'Si el primer numero es mayor, regresamos 1
+ If pri1 < pri2 Then Return -1 'Si el primer numero es menor, regresamos -1
+
+ 'Si son iguales entones revisamos el segundo numero
+ If m1.Length > 1 And m2.Length > 1 Then
+ sec1 = "1." & m1(1)
+ sec2 = "1." & m2(1)
+ ' Log(sec1 & "|" & sec2)
+ If sec1 > sec2 Then Return 1 'Si el segundo numero es mayor, regresamos 1
+ If sec1 < sec2 Then Return -1 'Si el segundo numero es menor, regresamos -1
+ End If
+
+ 'Si son iguales entones revisamos el tercer numero
+ If m1.Length > 2 And m2.Length > 2 Then
+ ter1 = "1." & m1(2)
+ ter2 = "1." & m2(2)
+ ' Log(ter1 & "|" & ter2)
+ If ter1 > ter2 Then Return 1 'Si el tercer numero es mayor, regresamos 1
+ If ter1 < ter2 Then Return -1 'Si el tercer numero es menor, regresamos -1
+ End If
+ Return 0 'Regersamos 0 porque son iguales
+End Sub
+
+'Lee un arhchivo de texto y lo convierte en un mapa.
+Sub procesaConfiguracion
+ Private t As String
+ Private c As List = File.ReadList(Starter.ruta, "conf.ini")
+ For i = 0 To c.Size - 1
+ t = c.get(i)
+ Log(t.IndexOf("="))
+ If t.IndexOf("=") > -1 Then
+ Starter.confMap.Put(t.SubString2(0, t.IndexOf("=")), t.SubString(t.IndexOf("=")+1))
+ Log(Starter.confMap)
+ End If
+ Next
+ If Starter.confMap.ContainsKey("mayusculasDesbloqueo") Then Starter.mayusculasDesbloqueo = Starter.confMap.Get("mayusculasDesbloqueo")
+End Sub
+
+'Guarda la configuracion (mapa) en un archivo de texto.
+Sub escribreConf
+ Private l As List
+ l.Initialize
+ For Each k As Object In Starter.confMap.Keys
+ l.Add($"${k}=${Starter.confMap.Get(k)}"$)
+ Next
+ Log(l)
+ File.WriteList(Starter.ruta, "conf.ini", l)
+End Sub
+
+'Centra horizontalmente una vista en otra vista.
+Sub centraVistaEnVista(v As View, p As View) 'ignore
+ v.Left = (p.Width/2) - (v.Width/2)
+End Sub
+
+'Sets the elevation of a view
+Sub SetElevation(v As View, e As Float)
+ Dim jo As JavaObject
+ Dim p As Phone
+ If p.SdkVersion >= 21 Then
+ jo = v
+ jo.RunMethod("setElevation", Array As Object(e))
+ End If
+End Sub
+
+'Regresa buenos dias, tardes o noches dependiendo de la hora.
+Sub generaSaludo As String
+ Private saludo As String = ""
+ If DateTime.GetHour(DateTime.Now) > 4 And DateTime.GetHour(DateTime.Now) < 12 Then saludo = "Buenos dias, "
+ If DateTime.GetHour(DateTime.Now) >= 12 And DateTime.GetHour(DateTime.Now) < 19 Then saludo = "Buenas tardes, "
+ If DateTime.GetHour(DateTime.Now) >= 19 Or DateTime.GetHour(DateTime.Now) < 4 Then saludo = "Buenas noches, "
+' Log(DateTime.GetHour(DateTime.Now)&"|"&saludo&"|")
+ Return saludo
+End Sub
+
+'Muestra en el Log los campos y valores que regresan en el JobDone.
+Sub logJobDoneResultados(resultado As DBResult)
+ For Each records() As Object In resultado.Rows
+ LogColor($"====== ${resultado.Tag} - REGISTROS = ${resultado.Rows.Size}"$, Colors.RGB(215,37,0))
+ For Each k As String In resultado.Columns.Keys
+ LogColor(k & " = " & records(resultado.Columns.Get(k)), Colors.RGB(215,37,0))
+ Next
+ Next
+End Sub
\ No newline at end of file
diff --git a/notis.bas b/notis.bas
new file mode 100644
index 0000000..0a8d782
--- /dev/null
+++ b/notis.bas
@@ -0,0 +1,37 @@
+B4A=true
+Group=Default Group
+ModulesStructureVersion=1
+Type=Service
+Version=11.5
+@EndOfDesignText@
+#Region Service Attributes
+ #StartAtBoot: 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.
+
+End Sub
+
+Sub Service_Create
+
+End Sub
+
+Sub Service_Start (StartingIntent As Intent)
+ Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
+ Service.StartForeground(12345, CreateNotification("..."))
+End Sub
+
+Sub Service_Destroy
+
+End Sub
+
+Sub CreateNotification (Body As String) As Notification
+ Dim notification As Notification
+ notification.Initialize2(notification.IMPORTANCE_LOW)
+ notification.Icon = "icon"
+ notification.SetInfo("Soporte", Body, Main)
+ Return notification
+End Sub
diff --git a/soporteKMS.b4a b/soporteKMS.b4a
new file mode 100644
index 0000000..364eea5
--- /dev/null
+++ b/soporteKMS.b4a
@@ -0,0 +1,1425 @@
+Build1=Default,soporte.keymon.lat
+File1=cat.gif
+File2=conf.ini
+File3=ew.gif
+File4=kelloggs.bal
+File5=layout1.bal
+File6=logo_Keymon.png
+FileGroup1=Default Group
+FileGroup2=Default Group
+FileGroup3=Default Group
+FileGroup4=Default Group
+FileGroup5=Default Group
+FileGroup6=Default Group
+Group=Default Group
+Library1=bitmapcreator
+Library10=wobblemenu
+Library11=b4xgifview
+Library2=byteconverter
+Library3=clipboard
+Library4=core
+Library5=ime
+Library6=okhttputils2
+Library7=phone
+Library8=randomaccessfile
+Library9=runtimepermissions
+ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~~\n~)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~CreateResourceFromFile(Macro, Themes.DarkTheme)~\n~'End of default text.~\n~SetActivityAttribute(main, android:windowSoftInputMode, adjustPan|stateHidden)
+Module1=DBRequestManager
+Module2=Starter
+Module3=Subs
+NumberOfFiles=6
+NumberOfLibraries=11
+NumberOfModules=3
+Version=12.2
+@EndOfDesignText@
+#Region Project Attributes
+ #ApplicationLabel: Soporte Keymonsoft
+ #VersionName: 3.08.27
+ 'SupportedOrientations possible values: unspecified, landscape or portrait.
+ #SupportedOrientations: portrait
+ #CanInstallToExternalStorage: False
+ #BridgeLogger: True
+'Ctrl + click to sync files con Github Desktop ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=github&Args=..\
+#End Region
+
+'Ver 3.01.23 - Se agregó el nombre del producto al query cuando se borra el producto de un ticket, para evitar que borre cambios y no cambios por igual.
+'Ver 3.08.27 - Se implementó el borrar venta de todas las empresas desde una misma pantalla.
+
+#Region Activity Attributes
+ #FullScreen: False
+ #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 DBRSGuna1872 As String = "http://keymon.lat:1782"
+ Dim DBRSMards1873 As String = "http://keymon.lat:1782"
+' Dim DBRSGuna1872 As String = "http://11.0.0.231:1783" 'Para pruebas locales
+' Dim DBRSGuna1872 As String = "http://187.189.244.154:1782" 'Para pruebas locales
+ Dim conexionDBRS As String = "externa"
+ Dim DBRChecked As Boolean = False
+ Dim atrasPresionado As Boolean = False
+ Dim pruebaPaso As Int = 0
+ Dim pass1, usrDesbloqueo As String
+ Dim versionOk As Boolean = False
+ Dim prodsList As List
+' Dim buscarDonde As String = "Usuario"
+' Dim buscarQue As String = ""
+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 reqManager As DBRequestManager
+ Dim cmd As DBCommand
+ Dim kb As IME
+ Private WobbleMenu1 As WobbleMenu
+ Private Panel1 As Panel
+ Private PanelKelloggs As Panel
+ Private Panel3 As Panel
+ Private Panel4 As Panel
+ Private Panel5 As Panel
+ Private b_desbloquea As Button
+ Private l_almacen As Label
+ Private s_almacen1 As Spinner
+ Private et_ruta1 As EditText
+ Private s_almacen3 As Spinner
+ Private et_ruta3 As EditText
+ Private b_borrarVenta1 As Button
+ Private b_borrarVenta3 As Button
+ Private s_almacen4 As Spinner
+ Private et_ruta4 As EditText
+ Private b_borrarVenta4 As Button
+ Private b_forzarVenta1 As Button
+ Private b_forzarVenta3 As Button
+ Private b_forzarVenta4 As Button
+ Private s_almacen2 As Spinner
+ Private et_ruta2 As EditText
+ Private b_borrarVenta2 As Button
+ Private b_forzarVenta2 As Button
+ Private s_tipoVenta As Spinner
+ Private et_usuario As EditText
+ Dim empresasMap As Map
+ Dim spinnerGunaMap, spinnerKelloggsMap, spinnerKelloggs2Map, spinnerSalmaMap, spinnerDanvitMap, spinnerMardsMap, spinnerEmpresaMap As Map
+ Dim almacenGuna, almacenKelloggs, almacenKelloggs2, almacenSalma, almacenDanvit, almacenDeRuta, almacenMards, almacenEmpresa As String
+ Dim tipoVentaKelloggs As String = "VENTA"
+ Private l_version As Label
+ Private l_cita As Label
+ Private l_copyright As Label
+ Private l_copyright1 As Label
+ Private p_login As Panel
+ Private et_login As EditText
+ Private p_backLogin As Panel
+ Private l_toast As Label
+ Private p_toast As Panel
+ Private cb_usrMayusc As CheckBox
+ Private p_opcDesbloqueo As Panel
+ Private p_copyright As Panel
+ Private p_buscar As Panel
+ Private et_usr As EditText
+ Private et_almacen As EditText
+ Private et_ruta As EditText
+ Private b_buscarUsr As Button
+ Private lv_resultadosBusqueda As ListView
+ Private b_revisaVenta As Button
+ Private b_revisaVenta2 As Button
+ Private p_botones1 As Panel
+ Private p_botones2 As Panel
+ Private p_botones3 As Panel
+ Private p_botones4 As Panel
+ Private s_usrEmpresa As Spinner
+ Private usrEmpresa As String = "GUNA"
+ Private b_login As Button
+ Private s_almacen2_2 As Spinner
+ Private et_cliente As EditText
+ Private b_borrarTicket As Button
+ Private p_botones_k2 As Panel
+ Private b_revisaTicket As Button
+ Private lv_ticket As ListView
+ Private sv_kelloggs As ScrollView
+ Private et_referencia As EditText
+ Private et_folio As EditText
+ Private et_monto As EditText
+ Private b_borrarPagare As Button
+' Private Panel2 As Panel
+ Private Panel16 As Panel
+ Private PanelFacturacion As Panel
+ Private b_libBanderaFactura As Button
+ Private b_libBanderaCargaForanea As Button
+ Private gv_gato As B4XGifView
+ Private gv_bicho As B4XGifView
+ Dim timerBicho As Timer
+ Private p_ticket As Panel
+ Private b_cerrarTicket As Button
+ Private Panel2 As Panel
+ Private l_SinProductos As Label
+ Dim liquidada As Boolean = False
+ Private p_Mards As Panel
+ Private b_forzarVentaMards As Button
+ Private b_borrarVentaMards As Button
+ Private b_revisaVentaMards As Button
+ Private p_botonesMards As Panel
+ Private s_almacenMards As Spinner
+ Private et_rutaMards As EditText
+ Private p_borrarVenta As Panel
+ Private s_empresaBV As Spinner
+ Private s_almacenBV As Spinner
+ Private et_rutaBV As EditText
+ Private s_tipoVentaBV As Spinner
+ Private b_revisarVentaBV As Button
+ Private b_borrarVentaBV As Button
+ Private b_forzarVentaBV As Button
+ Dim laEmpresa As String = ""
+ Private l_tipoVentaBV As Label
+ Private p_tipoVentaBV As Panel
+ dim elTipoDeVenta as string
+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("Layout1")
+ If FirstTime Then
+ DateTime.DateFormat = "yyyy"
+ l_copyright1.Text = $"KeymonSoft ${DateTime.Date(DateTime.Now)}."$
+ End If
+ prodsList.Initialize
+' sv_kelloggs.Panel.LoadLayout("Kelloggs")
+ p_login.BringToFront
+ Subs.panelVisible(p_login, 0, 0, Activity)
+ Subs.centraETEnPanel(et_login, p_login)
+ Subs.centraPanelEnPanel(p_backLogin, p_login)
+ l_version.text = "Version " & Application.VersionName
+ ProgressDialogShow("Descargando información")
+ Log("DBServer: " & DBRSGuna1872)
+ reqManager.Initialize(Me, DBRSGuna1872)
+' ToastMessageShow("Probando: " & DBRSGuna1872, False)
+ cmd.Initialize
+ cmd.Name = "select_soporte" 'Intentamos conectarnos al servido publico y si no responde cambiamos al interno.
+ reqManager.ExecuteQuery(cmd , 0, "pruebaConexion", 750) 'request con timeout corto en ms.
+ DBRChecked = False
+ Do While Not(DBRChecked) ' Esperamos a que termine la prueba de conexion.
+ Sleep(20)
+ Loop
+ et_usuario.InputType = Bit.Or(et_usuario.InputType, 4096) 'Esta linea es para que cuando se escriba en el campo, sea con mayusculas, para mas tipos vaya a: https://developer.android.com/reference/android/text/InputType.html#TYPE_TEXT_FLAG_CAP_CHARACTERS
+ et_usr.InputType = Bit.Or(et_usuario.InputType, 4096) 'Esta linea es para que cuando se escriba en el campo, sea con mayusculas, para mas tipos vaya a: https://developer.android.com/reference/android/text/InputType.html#TYPE_TEXT_FLAG_CAP_CHARACTERS
+ et_almacen.InputType = Bit.Or(et_usuario.InputType, 4096) 'Esta linea es para que cuando se escriba en el campo, sea con mayusculas, para mas tipos vaya a: https://developer.android.com/reference/android/text/InputType.html#TYPE_TEXT_FLAG_CAP_CHARACTERS
+ et_ruta.InputType = Bit.Or(et_usuario.InputType, 4096) 'Esta linea es para que cuando se escriba en el campo, sea con mayusculas, para mas tipos vaya a: https://developer.android.com/reference/android/text/InputType.html#TYPE_TEXT_FLAG_CAP_CHARACTERS
+ WobbleMenu1.SetTabTextIcon(1,"Guna", Chr(0xF0C0), Typeface.FONTAWESOME)
+ WobbleMenu1.SetTabTextIcon(2,"Kellogg's", Chr(0xF007), Typeface.FONTAWESOME)
+ WobbleMenu1.SetTabTextIcon(3,"Salma", Chr(0xF2BE), Typeface.FONTAWESOME)
+ WobbleMenu1.SetTabTextIcon(4,"Danvit", Chr(0xF21B), Typeface.FONTAWESOME)
+ WobbleMenu1.SetTabTextIcon(5,"Borrar Venta", Chr(0xF29D), Typeface.FONTAWESOME)
+ WobbleMenu1.SetTabTextIcon(6,"Facturacion", Chr(0xF2D9), Typeface.FONTAWESOME)
+ WobbleMenu1.SetTabTextIcon(7,"Otro", Chr(0xF2D9), Typeface.FONTAWESOME)
+' WobbleMenu1.SetBadge(4,5,Colors.White,Colors.Blue)
+ Subs.panelVisible(Panel1, 0, 0, Activity)
+' Subs.centraBotonEnPanel(b_borrarVenta1, Panel1)
+' Subs.centraBotonEnPanel(b_forzarVenta1, Panel1)
+
+ s_tipoVenta.AddAll(Array As String("VENTA", "ABORDO"))
+ s_usrEmpresa.AddAll(Array As String("GUNA", "KELLOGGS", "SALMA", "DANVIT"))
+' s_buscarD.AddAll(Array As String("Usuario", "Nombre", "Almacen", "Ruta"))
+ empresasMap.Initialize
+ spinnerGunaMap.Initialize
+ spinnerKelloggsMap.Initialize
+ spinnerKelloggs2Map.Initialize
+ spinnerSalmaMap.Initialize
+ spinnerDanvitMap.Initialize
+ spinnerMardsMap.Initialize
+ spinnerEmpresaMap.Initialize
+ s_empresaBV.Clear
+ s_empresaBV.AddAll(Array As String("-= Seleccione =-", "Danvit", "Guna", "Kelloggs", "Mards", "Salma"))
+ s_tipoVentaBV.AddAll(Array As String("VENTA", "ABORDO"))
+ s_tipoVentaBV.SelectedIndex = 0
+ 'Traemos los almacenes de Guna
+ cmd.Initialize
+ cmd.Name = "select_almacenes_GUNA"
+ reqManager.ExecuteQuery(cmd , 0, "almacenesGuna", 0)
+ 'Traemos los almacenes de Kelloggs
+' cmd.Initialize
+ cmd.Name = "select_almacenes_KELL"
+ reqManager.ExecuteQuery(cmd , 0, "almacenesKelloggs", 0)
+ 'Traemos los almacenes de Salma
+' cmd.Initialize
+ cmd.Name = "select_almacenes_SALMA"
+ reqManager.ExecuteQuery(cmd , 0, "almacenesSalma", 0)
+ 'Traemos los almacenes de Danvit
+' cmd.Initialize
+ cmd.Name = "select_almacenes_DANVIT"
+ reqManager.ExecuteQuery(cmd , 0, "almacenesDanvit", 0)
+ 'Traemos los almacenes de Mards
+ reqManager.Initialize(Me, DBRSMards1873)
+ cmd.Name = "select_almacenes_Mards"
+ reqManager.ExecuteQuery(cmd , 0, "almacenesMards", 0)
+ kb.Initialize("kb")
+ gv_gato.SetGif(File.DirAssets, "cat.gif")
+ gv_bicho.SetGif(File.DirAssets, "ew.gif")
+ timerBicho.Initialize("timerBicho", 5000)
+ timerBicho.Enabled = True
+ reqManager.Initialize(Me, DBRSGuna1872)
+End Sub
+
+Sub Activity_Resume
+' reqManager.Initialize(Me, DBRSGuna1872)
+ If Starter.mayusculasDesbloqueo = "1" Then cb_usrMayusc.Checked = True
+ Dim label1 As Label = lv_resultadosBusqueda.TwoLinesLayout.Label
+ label1.TextSize = 13
+ label1.TextColor = Colors.Black
+ Dim label2 As Label = lv_resultadosBusqueda.TwoLinesLayout.SecondLabel
+ label2.TextSize = 13
+ label2.TextColor = Colors.Black
+
+ Dim label12 As Label = lv_ticket.TwoLinesLayout.Label
+ label12.TextSize = 13
+ label12.TextColor = Colors.Black
+' label12.Height = 12dip
+ Dim label22 As Label = lv_ticket.TwoLinesLayout.SecondLabel
+ label22.TextSize = 13
+ label22.TextColor = Colors.Black
+' label22.Height = 12dip
+ lv_ticket.TwoLinesLayout.ItemHeight = 50dip
+
+ b_login.Height = Activity.Height
+ b_login.Width = Activity.Width
+ b_login.Top = 0 : b_login.left = 0
+ Subs.SetElevation(et_login, 10)
+End Sub
+
+Sub Activity_Pause (UserClosed As Boolean)
+
+End Sub
+
+Sub timerBicho_Tick
+ Private rand As Int = Rnd(1,3)
+ If rand = 1 Then gv_bicho.mBase.Visible = True Else gv_bicho.mBase.Visible = False
+' Log("Bicho visible = " & rand)
+End Sub
+
+Sub WobbleMenu1_Tab1Click
+ reqManager.Initialize(Me, DBRSGuna1872)
+' Log("Tab 1")
+' sv_kelloggs.Visible = False
+ WobbleMenu1.RemoveBadge(4)
+ Subs.panelVisible(Panel1, 0, 0, Activity)
+' Subs.panelOculto(PanelKelloggs)
+' sv_kelloggs.Visible = False
+ Subs.panelOculto(Panel2)
+ Subs.panelOculto(Panel3)
+ Subs.panelOculto(Panel4)
+ Subs.panelOculto(p_borrarVenta)
+ Subs.panelOculto(PanelFacturacion)
+ Subs.panelOculto(Panel5)
+' Subs.centraBotonEnPanel(b_borrarVenta1, Panel1)
+' Subs.centraBotonEnPanel(b_forzarVenta1, Panel1)
+ Subs.centraPanelEnPanel(p_botones1, Panel1)
+End Sub
+
+Sub WobbleMenu1_Tab2Click
+' Log("Tab 2")
+ reqManager.Initialize(Me, DBRSGuna1872)
+ WobbleMenu1.RemoveBadge(4)
+' sv_kelloggs.Top = 0
+' sv_kelloggs.Left = 0
+' sv_kelloggs.Width = Activity.Width
+' sv_kelloggs.Height = Activity.Height - 50
+' sv_kelloggs.Visible = True
+
+' PanelKelloggs.Height = Activity.Height
+ lv_ticket.Width = Activity.Width * 0.9
+ lv_ticket.Left = (Activity.Width/2) - (lv_ticket.Width/2)
+
+' Subs.panelVisible(PanelKelloggs, 0, 0, Activity)
+' PanelKelloggs.Visible = True
+' PanelKelloggs.Width = Activity.Width
+ Subs.panelVisible(Panel2, 0, 0, Activity)
+ Panel2.Width = Activity.Width
+ Subs.panelOculto(Panel1)
+ Subs.panelOculto(Panel3)
+ Subs.panelOculto(Panel4)
+ Subs.panelOculto(p_borrarVenta)
+ Subs.panelOculto(PanelFacturacion)
+ Subs.panelOculto(Panel5)
+' Subs.centraPanelEnPanel(p_botones2, PanelKelloggs)
+' Subs.centraPanelEnPanel(p_botones_k2, PanelKelloggs)
+' Subs.centraBotonEnPanel(b_borrarPagare, PanelKelloggs)
+End Sub
+
+Sub WobbleMenu1_Tab3Click
+ reqManager.Initialize(Me, DBRSGuna1872)
+ WobbleMenu1.RemoveBadge(4)
+ Subs.panelVisible(Panel3, 0, 0, Activity)
+ Subs.panelOculto(Panel1)
+ Subs.panelOculto(Panel2)
+' Subs.panelOculto(PanelKelloggs)
+' sv_kelloggs.Visible = False
+ Subs.panelOculto(Panel4)
+ Subs.panelOculto(p_borrarVenta)
+ Subs.panelOculto(PanelFacturacion)
+ Subs.panelOculto(Panel5)
+' Log("Tab 3")
+' Subs.centraBotonEnPanel(b_borrarVenta3, Panel3)
+' Subs.centraBotonEnPanel(b_forzarVenta3, Panel3)
+ Subs.centraPanelEnPanel(p_botones3, Panel3)
+End Sub
+
+Sub WobbleMenu1_Tab4Click
+ reqManager.Initialize(Me, DBRSGuna1872)
+ WobbleMenu1.RemoveBadge(4)
+ Subs.panelVisible(Panel4, 0, 0, Activity)
+ Subs.panelOculto(Panel1)
+' Subs.panelOculto(PanelKelloggs)
+' sv_kelloggs.Visible = False
+ Subs.panelOculto(Panel2)
+ Subs.panelOculto(Panel3)
+ Subs.panelOculto(p_borrarVenta)
+ Subs.panelOculto(PanelFacturacion)
+ Subs.panelOculto(Panel5)
+' Log("Tab 4")
+' Subs.centraBotonEnPanel(b_borrarVenta4, Panel4)
+' Subs.centraBotonEnPanel(b_forzarVenta4, Panel4)
+ Subs.centraPanelEnPanel(p_botones4, Panel4)
+End Sub
+
+Sub WobbleMenu1_Tab5Click
+' WobbleMenu1.RemoveBadge(4)
+' reqManager.Initialize(Me, DBRSMards1873)
+ Subs.panelVisible(p_borrarVenta, 0, 0, Activity)
+ Subs.panelOculto(Panel1)
+ Subs.panelOculto(Panel2)
+' Subs.panelOculto(PanelKelloggs)
+' sv_kelloggs.Visible = False
+ Subs.panelOculto(Panel3)
+ Subs.panelOculto(Panel4)
+ Subs.panelOculto(PanelFacturacion)
+ Subs.panelOculto(Panel5)
+' Log("Tab 3")
+' Subs.centraBotonEnPanel(b_borrarVenta3, Panel3)
+' Subs.centraBotonEnPanel(b_forzarVenta3, Panel3)
+ Subs.centraPanelEnPanel(p_botonesMards, p_borrarVenta)
+ s_empresaBV.SelectedIndex = 0
+ s_almacenBV.SelectedIndex = 0
+End Sub
+
+'Sub WobbleMenu1_Tab5Click '(Antes usuarios)
+' Subs.panelVisible(p_buscar, 0, 0, Activity)
+' gv_bicho.mBase.Visible = True
+'' Subs.panelOculto(PanelKelloggs)
+'' sv_kelloggs.Visible = False
+' Subs.panelOculto(Panel1)
+' Subs.panelOculto(Panel2)
+' Subs.panelOculto(Panel3)
+' Subs.panelOculto(Panel4)
+' Subs.panelOculto(PanelFacturacion)
+' Subs.panelOculto(Panel5)
+' Subs.centraBotonEnPanel(b_buscarUsr, p_buscar)
+' lv_resultadosBusqueda.Left = (p_buscar.Width/2)-(lv_resultadosBusqueda.Width/2)
+' lv_resultadosBusqueda.Height = Activity.Height - lv_resultadosBusqueda.Top - 200
+'End Sub
+
+Sub WobbleMenu1_Tab6Click
+' Log("Tab Facturacion")
+ reqManager.Initialize(Me, DBRSGuna1872)
+ l_cita.Text = Subs.dameCita(Starter.citas)
+ Subs.panelVisible(PanelFacturacion, 0, 0, Activity)
+' Subs.panelOculto(PanelKelloggs)
+ Subs.panelOculto(Panel1)
+' sv_kelloggs.Visible = False
+ Subs.panelOculto(Panel2)
+ Subs.panelOculto(Panel3)
+ Subs.panelOculto(Panel4)
+ Subs.panelOculto(Panel5)
+ Subs.panelOculto(p_borrarVenta)
+ Subs.centraBotonEnPanel(b_borrarPagare, PanelFacturacion)
+' Subs.centraPanelEnPanel(Panel16, PanelFacturacion)
+ Subs.centraBotonEnPanel(b_libBanderaFactura, PanelFacturacion)
+ Subs.centraBotonEnPanel(b_libBanderaCargaForanea, PanelFacturacion)
+End Sub
+
+Sub WobbleMenu1_Tab7Click
+' Log("Tab Otro")
+ reqManager.Initialize(Me, DBRSGuna1872)
+' WobbleMenu1.RemoveBadge(4)
+ l_cita.Text = Subs.dameCita(Starter.citas)
+ Subs.panelVisible(Panel5, 0, 0, Activity)
+ gv_bicho.mBase.Visible = False
+ Subs.panelOculto(Panel1)
+' Subs.panelOculto(PanelKelloggs)
+' sv_kelloggs.Visible = False
+ Subs.panelOculto(Panel2)
+ Subs.panelOculto(Panel3)
+ Subs.panelOculto(Panel4)
+ Subs.panelOculto(PanelFacturacion)
+ Subs.panelOculto(p_borrarVenta)
+ Subs.centraEtiquetaEnPanel(l_version, Panel5)
+ Subs.centraEtiquetaEnPanel(l_cita, Panel5)
+ Subs.centraPanelEnPanel (p_copyright, Panel5)
+End Sub
+
+'Desbloquea el usuario de Guna especificado en "et_usuario".
+Private Sub b_desbloquea_Click
+ If et_usuario.Text <> "" Then
+ cmd.Initialize
+ cmd.Name = "update_usuario_guna"
+ Dim tempUsr As String = et_usuario.Text
+ tempUsr = tempUsr.Trim 'Quitamos espacios de antes y despues.
+ If Starter.mayusculasDesbloqueo = "1" Then tempUsr = tempUsr.ToUpperCase 'Mandamos el usuario en mayusculas.
+ cmd.Parameters = Array As Object(tempUsr)
+ Log("Mandamos DBRequest desbloqueo: " & tempUsr)
+ usrDesbloqueo = tempUsr
+ reqManager.ExecuteCommand(cmd , "desbloqueaUsuario")
+ Else
+ Toast("Por favor ingrese el usuario a desbloquear. 🙄", 650)
+ End If
+ kb.HideKeyboard
+End Sub
+
+Sub s_almacen1_ItemClick (Position As Int, Value As Object)
+ almacenGuna = spinnerGunaMap.Get(Value)
+ almacenDeRuta = Value
+ Log(Value)
+ Log($"Almacén ${almacenGuna} de Guna seleccionado"$ )
+End Sub
+
+Sub s_almacen2_ItemClick (Position As Int, Value As Object)
+ almacenKelloggs = spinnerKelloggsMap.Get(Value)
+ almacenDeRuta = Value
+ Log($"Almacén ${almacenKelloggs} de Kelloggs seleccionado"$ )
+End Sub
+
+Private Sub s_tipoVenta_ItemClick (Position As Int, Value As Object)
+ tipoVentaKelloggs = Value
+End Sub
+
+Sub s_almacen3_ItemClick (Position As Int, Value As Object)
+ almacenSalma = spinnerSalmaMap.Get(Value)
+ almacenDeRuta = Value
+ Log($"Almacén ${almacenSalma} de Salma seleccionado"$ )
+End Sub
+
+Sub s_almacen4_ItemClick (Position As Int, Value As Object)
+ almacenDanvit = spinnerDanvitMap.Get(Value)
+ almacenDeRuta = Value
+ Log($"Almacén ${almacenDanvit} de Danvit seleccionado"$ )
+End Sub
+
+Private Sub s_almacenMards_ItemClick (Position As Int, Value As Object)
+ almacenMards = spinnerMardsMap.Get(Value)
+ almacenDeRuta = Value
+ Log($"Almacén ${almacenMards} de Mards seleccionado"$ )
+End Sub
+
+'Revisa si la venta de Guna se puede borrar, y si SI se puede, la borra.
+Private Sub b_borrarVenta1_Click
+ kb.HideKeyboard
+ Log(et_ruta1.Text & "|" & almacenGuna)
+ If et_ruta1.Text.Trim <> "" And almacenGuna <> "" Then
+ cmd.Initialize
+ cmd.Name = "revisa_liquidada_Guna" 'Primero revisamos que no este liquidada o con descuento.
+ cmd.Parameters = Array As Object(almacenGuna, et_ruta1.Text.Trim)
+ Log($"Revisamos venta liquidada Guna: almacen: ${almacenGuna}, ruta: ${et_ruta1.Text} "$)
+ reqManager.ExecuteQuery(cmd , 0, "revisa_liquidada_Guna", 0)
+ Else
+ Toast("Por favor ingrese ruta y almacén 🤦🏽♂️", 600)
+ End If
+End Sub
+
+'Forzamos borrar venta de Guna en clic
+Private Sub b_forzarVenta1_Click
+ borrarVentaForzadaGuna
+End Sub
+
+'Revisa si la venta de Kelloggs se puede borrar, y si SI se puede, la borra.
+Private Sub b_borrarVenta2_Click
+ kb.HideKeyboard
+ If et_ruta2.Text.Trim <> "" And almacenKelloggs <> "" Then
+ cmd.Initialize
+ cmd.Name = "revisa_liquidada_Kell" 'Primero revisamos que no este liquidada o con descuento.
+ cmd.Parameters = Array As Object(almacenKelloggs, et_ruta2.Text.Trim, tipoVentaKelloggs)
+ Log($"Revisamos venta liquidada Kelloggs: almacen: ${almacenKelloggs}, ruta: ${et_ruta2.Text}"$)
+ reqManager.ExecuteQuery(cmd , 0, "revisa_liquidada_Kell", 0)
+ Else
+ Toast("Por favor ingrese ruta y almacén 🤦🏽♂️", 600)
+ End If
+End Sub
+
+'Forzamos borrar venta de Kelloggs en clic
+Private Sub b_forzarVenta2_Click
+ borrarVentaForzadaKelloggs
+End Sub
+
+'Forzamos el borrado de la venta de Kelloggs
+Sub borrarVentaForzadaKelloggs
+ Private rutaVenta As Int
+ If p_borrarVenta.Visible Then
+ rutaVenta = et_rutaBV.Text.trim
+ Else
+ rutaVenta = et_ruta2.Text.Trim
+ End If
+ Private usrSoporte As String = "appSoporte"
+' Private tipoVenta As String = tipoVentaKelloggs
+ Private bandera As Int = 1
+ cmd.Initialize 'Se borra la venta forzada
+ cmd.Name = "proc_QUITAR_VENTA_KELL"
+ cmd.Parameters = Array As Object(almacenKelloggs, rutaVenta, usrSoporte, tipoVentaKelloggs, bandera)
+ Log("Madamos borrar venta Kellogs: " & almacenKelloggs&"|"& rutaVenta&"|"&usrSoporte&"|"&tipoVentaKelloggs&"|"&bandera)
+ reqManager.ExecuteCommand(cmd , "borrarVentaKelloggs")
+End Sub
+
+'Forzamos el borrado de la venta de Guna
+Sub borrarVentaForzadaGuna
+ Private rutaVenta As Int
+ If p_borrarVenta.Visible Then
+ rutaVenta = et_rutaBV.Text.trim
+ Else
+ rutaVenta = et_ruta1.Text.Trim
+ End If
+ Private usrSoporte As String = "appSoporte"
+ Private bandera As Int = 1
+ Log("Llamamos proc_QUITAR_VENTA_GUNA")
+ cmd.Initialize 'Se borra la venta forzada
+ cmd.Name = "proc_QUITAR_VENTA_GUNA"
+ cmd.Parameters = Array As Object(almacenGuna, rutaVenta, usrSoporte, bandera)
+ Log("Madamos borrar venta Guna: " & almacenGuna&"|"& rutaVenta&"|"&usrSoporte&"|"&bandera)
+ reqManager.ExecuteCommand(cmd , "borrarVentaGuna")
+End Sub
+
+'Borramos la venta de Salma
+Private Sub b_borrarVenta3_Click
+ If et_ruta3.text <> "" And almacenSalma <> "" Then
+ kb.HideKeyboard
+ Private rutaVenta As Int = et_ruta3.Text.Trim
+ Private usrSoporte As String = "appSoporte"
+ cmd.Initialize
+ cmd.Name = "proc_QUITAR_VENTA_SALMA"
+ cmd.Parameters = Array As Object(almacenSalma, rutaVenta, usrSoporte)
+ Log($"Mandamos borrar venta de Salma, almacen: ${almacenSalma}, ruta: ${rutaVenta}, usuario: '${usrSoporte}'"$)
+ reqManager.ExecuteCommand(cmd , "borrarVentaSalma")
+ Else
+ Toast("Por favor ingrese ruta y almacén 🙄", 600)
+ End If
+End Sub
+
+'Borramos venta de Danvit
+Private Sub b_borrarVenta4_Click
+ If et_ruta4.text <> "" And almacenDanvit <> "" Then
+ kb.HideKeyboard
+ Private rutaVenta As Int = et_ruta4.Text.Trim
+ Private usrSoporte As String = "appSoporte"
+ cmd.Initialize
+ cmd.Name = "proc_QUITAR_VENTA_DANVIT"
+ cmd.Parameters = Array As Object(almacenDanvit, rutaVenta, usrSoporte)
+ Log($"Madamos borrar venta Danvit, almacen: ${almacenDanvit}, ruta: ${rutaVenta}, usuario: '${usrSoporte}'"$)
+ reqManager.ExecuteCommand(cmd , "borrarVentaDanvit")
+ Else
+ Toast("Por favor ingrese ruta y almacén 🤦🏽♂️", 600)
+ End If
+End Sub
+
+Private Sub et_ruta2_TextChanged (Old As String, New As String)
+ b_forzarVenta2.Visible = False
+End Sub
+
+'Detectamos clics en actividad para poner en 'False' la variable 'atrasPresionado' y para ocultar el panel de opciones de desbloqueo.
+Sub activity_Click
+ If atrasPresionado Then atrasPresionado = False
+ If p_opcDesbloqueo.Visible Then p_opcDesbloqueo.Visible = False
+End Sub
+
+Sub Activity_KeyPress (key As Int) As Boolean
+ ' BACK key pressed
+ If key=KeyCodes.KEYCODE_BACK Then
+ If atrasPresionado Then ExitApplication 'Solo salimos de la aplicación si se presiona 'Atras' 2 veces seguidas.
+ ToastMessageShow("Presiona 'Atras' nuevamente para salir de la aplicación.", True)
+ atrasPresionado = True
+' Log("atrasPresionado: True")
+ ' I want to capture the key here so I return True
+ Return True
+ End If
+' Returning 'False' signals the system to handle the key
+ Return False
+End Sub
+
+Sub JobDone(Job As HttpJob)
+ LogColor("jobDone: " & Job.Tag, Colors.Magenta)
+ If Job.Success = False Then
+ LogColor("***** jobDone Error *****", Colors.Red)
+ If Job.Tag = "borrarVentaKelloggs" Then
+ Toast("Venta Eliminada.", 0) 'El request de eliminar venta (Stored Procedure) siempre regresa error, asi que asumimos que SI se borro la venta.
+ b_forzarVenta2.Visible = False
+ else If Job.Tag = "borrarVentaGuna" Then
+ Toast("Venta Eliminada.", 0) 'El request de eliminar venta (Stored Procedure) siempre regresa error, asi que asumimos que SI se borro la venta.
+ b_forzarVenta1.Visible = False
+' else If Job.Tag = "borrarVentaSalma" Or Job.Tag = "borrarVentaDanvit" Then
+' ToastMessageShow("Venta Eliminada.", False) 'El request de eliminar venta (Stored Procedure) siempre regresa error, asi que asumimos que SI se borro la venta.
+ '/////////////////// Si hay error de conexion con keymon.lat nos cambiamos a 10.0.0.205 ///////////////////////
+ else If Job.Tag = "pruebaConexion" And Job.ErrorMessage.IndexOf("Failed to connect to keymon.lat") = -1 Then
+ DBRSGuna1872 = "http://10.0.0.205:1782"
+ Dim DBRSMards1873 As String = "http://10.0.0.205:1782"
+' DBRSGuna1872 = "http://11.0.0.231:1783" 'Para pruebas locales
+ reqManager.Initialize(Me, DBRSGuna1872)
+ conexionDBRS = "interna"
+ pruebaPaso = pruebaPaso + 1
+ Toast("Cambiando a servidor interno. 🕵🏼", 0)
+' ToastMessageShow("Cambiando a servidor interno. 🕵🏼", False)
+ LogColor("Cambiando a servidor interno.", Colors.RGB(255,123,0))
+ If pruebaPaso < 2 Then
+ Log("Reintentamos conexión con servidor nuevo.")
+ cmd.Initialize
+ cmd.Name = "select_soporte" 'Reintentamos conexión.
+ reqManager.ExecuteQuery(cmd , 0, "pruebaConexion", 0)
+ End If
+ Else
+ LogColor("JobDone Error: " & Job.ErrorMessage, Colors.red)
+ Toast("Error: " & Job.ErrorMessage, 0)
+ End If
+ DBRChecked = True 'Prueba de conexión finalizada.
+ '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ Else
+ DBRChecked = True 'Prueba de conexión finalizada.
+ LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211027
+ If Job.JobName = "DBRequest" Then 'Para desbloquear un usuario Guna.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "desbloqueaUsuario" Then 'query tag
+ For Each records() As Object In result.Rows
+ et_usuario.Text = ""
+ Private pp As BClipboard
+ pp.setText($"${Subs.generaSaludo}usuario *${usrDesbloqueo}* desbloqueado, por favor cerrar navegadores y reingresar."$) 'Copiamos el texto al portapapeles.
+' ToastMessageShow("Mensaje copiado al portapapeles.", False)
+ Log("Usuario desbloqueado! 🔓")
+ Toast("Usuario desbloqueado 🔓", 0)
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Traemos info de soporte.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "pruebaConexion" Then 'query tag
+ Log($"Conectado a ${DBRSGuna1872} - ${conexionDBRS}"$)
+ For Each records() As Object In result.Rows
+' For Each k As String In result.Columns.Keys
+' Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+' Next
+ pass1 = records(result.Columns.Get("CONTRASENA"))
+ Next
+ 'Si la version de la aplicacion es menor que la autorizada, salimos de la aplicación.
+ If Subs.comparaVersiones(Application.VersionName, records(result.Columns.Get("VERSIONAUTORIZADA"))) = -1 Then
+ versionOk = False
+ Msgbox("Disculpe las molestias que estas obras le ocasionan, estamos trabajando para mejorar. 🤹🏽♂️", "VERSION EN MANTENIMIENTO") 'ignore
+ ExitApplication
+ End If
+ versionOk = True
+ p_backLogin.Visible = True
+ et_login.Visible = True
+ ProgressDialogHide
+ End If
+ End If
+' If Job.JobName = "DBRequest" Then 'Para borrar venta de Guna.
+' Dim result As DBResult = reqManager.HandleJob(Job) 'El procedimiento de borrar venta, aunque SI borra la venta, siempre regresa error, así que este IF en realidad no se usa!!
+' If result.Tag = "borrarVentaGuna" Then 'query tag
+' For Each records() As Object In result.Rows
+' For Each k As String In result.Columns.Keys
+' Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+' Next
+' Log("Rows - " & result.Rows.Size)
+' Toast("Venta Eliminada.", 0)
+' Next
+' End If
+' End If
+ If Job.JobName = "DBRequest" Then 'Traemos los almacenes de Guna.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "almacenesGuna" Then 'query tag
+ s_almacen1.Add("-= Selecciona =-")
+ For Each records() As Object In result.Rows
+ s_almacen1.Add(records(result.Columns.Get("CAT_AG_NOMBRE")))
+ spinnerGunaMap.Put(records(result.Columns.Get("CAT_AG_NOMBRE")), records(result.Columns.Get("CAT_AG_ID")))
+ empresasMap.Put("Guna", spinnerGunaMap)
+' Log(spinnerGunaMap)
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Traemos los almacenes de Kelloggs.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "almacenesKelloggs" Then 'query tag
+ s_almacen2.Add("-= Selecciona =-")
+ s_almacen2_2.Add("-= Selecciona =-")
+ For Each records() As Object In result.Rows
+ s_almacen2.Add(records(result.Columns.Get("CAT_AG_NOMBRE")))
+ s_almacen2_2.Add(records(result.Columns.Get("CAT_AG_NOMBRE")))
+ spinnerKelloggsMap.Put(records(result.Columns.Get("CAT_AG_NOMBRE")), records(result.Columns.Get("CAT_AG_ID")))
+ spinnerKelloggs2Map.Put(records(result.Columns.Get("CAT_AG_NOMBRE")), records(result.Columns.Get("CAT_AG_ID")))
+ empresasMap.Put("Kelloggs", spinnerKelloggsMap)
+' Log(spinnerKelloggsMap)
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Traemos los almacenes de Salma.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "almacenesSalma" Then 'query tag
+ s_almacen3.Add("-= Selecciona =-")
+ For Each records() As Object In result.Rows
+ s_almacen3.Add(records(result.Columns.Get("CAT_AG_NOMBRE")))
+ spinnerSalmaMap.Put(records(result.Columns.Get("CAT_AG_NOMBRE")), records(result.Columns.Get("CAT_AG_ID")))
+ empresasMap.Put("Salma", spinnerSalmaMap)
+' Log(spinnerSalmaMap)
+ Next
+ End If
+ If result.Tag = "almacenesMards" Then 'query tag
+ s_almacenMards.Add("-= Selecciona =-")
+ For Each records() As Object In result.Rows
+ s_almacenMards.Add(records(result.Columns.Get("CAT_AG_NOMBRE")))
+ spinnerMardsMap.Put(records(result.Columns.Get("CAT_AG_NOMBRE")), records(result.Columns.Get("CAT_AG_ID")))
+ empresasMap.Put("Mards", spinnerMardsMap)
+' Log(spinnerMardsMap)
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Traemos los almacenes de Danvit.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "almacenesDanvit" Then 'query tag
+ s_almacen4.Add("-= Selecciona =-")
+ For Each records() As Object In result.Rows
+ s_almacen4.Add(records(result.Columns.Get("CAT_AG_NOMBRE")))
+ spinnerDanvitMap.Put(records(result.Columns.Get("CAT_AG_NOMBRE")), records(result.Columns.Get("CAT_AG_ID")))
+ empresasMap.Put("Danvit", spinnerDanvitMap)
+' Log(spinnerDanvitMap)
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Regresamos validación de si la venta esta liquidada (Kellogg's).
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "revisa_liquidada_Kell" Then 'query tag
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ If records(result.Columns.Get("LIQUIDADA")) > 0 Then
+ Log("La venta ya esta impresa, forzar el borrado??")
+' ToastMessageShow("La ruta ya esta impresa!", True)
+ Msgbox("La venta ya esta impresa, no es posible borrarla!", "VENTA IMPRESA") 'ignore
+ If p_borrarVenta.Visible Then
+ b_forzarVentaBV.Visible = True
+ Else
+ b_forzarVenta2.Visible = True
+ End If
+ Else
+ borrarVentaForzadaKelloggs
+ End If
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Regresamos validación de si la venta esta liquidada (Guna).
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "revisa_liquidada_Guna" Then 'query tag
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ If records(result.Columns.Get("LIQUIDADA")) > 0 Then
+ Log("La venta ya esta impresa, forzar el borrado??")
+' ToastMessageShow("La ruta ya esta impresa!", True)
+ Msgbox("La venta ya esta impresa, no es posible borrarla!", "VENTA IMPRESA") 'ignore
+ b_forzarVenta1.Visible = True
+ Else
+ borrarVentaForzadaGuna
+ End If
+ Next
+ End If
+ End If
+' If Job.JobName = "DBRequest" Then 'Borramos la venta de Salma o Danvit.
+' Dim result As DBResult = reqManager.HandleJob(Job)
+' If result.Tag = "borrarVentaSalma" Or result.Tag = "borrarVentaDanvit" Then 'query tag
+' For Each records() As Object In result.Rows
+' For Each k As String In result.Columns.Keys
+' Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+' Next
+' Toast("Venta Eliminada.", 0)
+' Next
+' End If
+' End If
+ If Job.JobName = "DBRequest" Then 'Borramos la venta de Guna, Kelloggs, Danvit, Salma o Mards.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ Private rutaBorrada As String = ""
+ If result.Tag = "borrarVentaGuna" Or _
+ result.Tag = "borrarVentaKelloggs" Or _
+ result.Tag = "borrarVentaSalma" Or _
+ result.Tag = "borrarVentaMards" Or _
+ result.Tag = "borrarVentaDanvit" Then 'query tag
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ Log("ProcSuccess - Rows: " & result.Rows.Size)
+ Toast("Venta Eliminada.", 0)
+ If result.Tag = "borrarVentaGuna" Then rutaBorrada = et_ruta1.Text
+ If result.Tag = "borrarVentaKelloggs" Then rutaBorrada = et_ruta2.Text
+ If result.Tag = "borrarVentaSalma" Then rutaBorrada = et_ruta3.Text
+ If result.Tag = "borrarVentaMards" Then rutaBorrada = et_rutaMards.Text
+ If result.Tag = "borrarVentaDanvit" Then rutaBorrada = et_ruta4.Text
+ Log(spinnerGunaMap.Keys)
+ Private pp As BClipboard
+ pp.setText($"${Subs.generaSaludo}venta de la ruta *${rutaBorrada}*, del almacén *${almacenDeRuta}* eliminada!"$) 'Copiamos el texto al portapapeles.
+ et_ruta1.Text = ""
+ et_ruta2.Text = ""
+ et_ruta3.Text = ""
+ et_ruta4.Text = ""
+ et_rutaMards.Text = ""
+ et_rutaBV.Text = ""
+ s_almacen1.SelectedIndex = 0
+ s_almacen2.SelectedIndex = 0
+ s_almacen3.SelectedIndex = 0
+ s_almacen4.SelectedIndex = 0
+ s_almacenMards.SelectedIndex = 0
+ s_almacenBV.SelectedIndex = 0
+ s_tipoVentaBV.SelectedIndex = 0
+ b_forzarVenta1.Visible = False 'Escondemos el boton de forzar borrado de Guna.
+ b_forzarVenta2.Visible = False 'Escondemos el boton de forzar borrado de Kelloggs.
+ b_forzarVentaBV.Visible = False 'Escondemos el boton de forzar borrado de Global.
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Buscams datos de usuario.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "select_todos_soporte" Then 'query tag
+ Dim cs, cs2 As CSBuilder
+ lv_resultadosBusqueda.Clear
+ For Each records() As Object In result.Rows
+ cs.Initialize
+ cs2.Initialize
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ lv_resultadosBusqueda.AddTwoLines(cs.Color(Colors.RGB(255,0,0)).Append("U: ").Pop.Append(records(result.Columns.Get("CAT_LO_USUARIO"))).Color(Colors.RGB(255,0,0)).Append(" N: ").Pop.Append(records(result.Columns.Get("CAT_LO_NOMBRE"))).PopAll, _
+ cs2.Color(Colors.RGB(255,0,0)).Append("A: ").Pop.Append(records(result.Columns.Get("CAT_AG_NOMBRE"))).Color(Colors.RGB(255,0,0)).Append(" R: ").Pop.Append(records(result.Columns.Get("CAT_RU_RUTA"))).Color(Colors.RGB(255,0,0)).Append(" E: ").Pop.Append(records(result.Columns.Get("CAT_LO_ESTATUS"))).Color(Colors.RGB(255,0,0)).Append(" C: ").Pop.Append(records(result.Columns.Get("CAT_LO_CONTRASENA"))).PopAll)
+ Next
+ If result.Rows.Size > 19 Then Toast("Solo se muestran los primeros 20 resultados.", 600)
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Buscamos si existe la venta.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "select_ventaXrutaGuna_soporte" Then 'query tag
+' Log(reqManager.HandleJob(Job).Rows.Size)
+' Log(result.Rows.Size)
+ For Each records() As Object In result.Rows
+' For Each k As String In result.Columns.Keys
+' Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+' Next
+ Toast($"Ruta ${records(result.Columns.Get("HVD_RUTA"))}${CRLF}$$1.2{records(result.Columns.Get("MONTO"))}, ${records(result.Columns.Get("HVD_TIPOVENTA"))}"$, 0)
+ Next
+ Subs.logJobDoneResultados(result)
+ If result.Rows.Size = 0 Then Toast("NO HAY VENTA", 0)
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Buscamos si existe la venta.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "select_ventaXrutaKelloggs_soporte" Then 'query tag
+ Log(reqManager.HandleJob(Job).Rows.Size)
+ Log(result.Rows.Size)
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ Toast($"Ruta ${records(result.Columns.Get("HVD_RUTA"))}${CRLF}$$1.2{records(result.Columns.Get("MONTO"))}, ${records(result.Columns.Get("HVD_TIPOVENTA"))}"$, 0)
+ Next
+ If result.Rows.Size = 0 Then Toast("NO HAY VENTA", 0)
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Buscamos si existe la venta.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "select_ventaXrutaSalma_soporte" Then 'query tag
+' Log(reqManager.HandleJob(Job).Rows.Size)
+' Log(result.Rows.Size)
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ Toast($"Ruta ${records(result.Columns.Get("HVD_RUTA"))}${CRLF}$$1.2{records(result.Columns.Get("MONTO"))}"$, 0)
+ Next
+ If result.Rows.Size = 0 Then Toast("NO HAY VENTA", 0)
+ End If
+ If result.Tag = "select_ventaXrutaMards_soporte" Then 'query tag
+' Log(reqManager.HandleJob(Job).Rows.Size)
+' Log(result.Rows.Size)
+ Subs.logJobDoneResultados(result)
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ Toast($"Ruta ${records(result.Columns.Get("HVD_RUTA"))}${CRLF}$$1.2{records(result.Columns.Get("MONTO"))}"$, 0)
+ Next
+ If result.Rows.Size = 0 Then Toast("NO HAY VENTA", 0)
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Buscamos si existe la venta.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "select_ventaXrutaDanvit_soporte" Then 'query tag
+' Log(reqManager.HandleJob(Job).Rows.Size)
+' Log(result.Rows.Size)
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ Toast($"Ruta ${records(result.Columns.Get("HVD_RUTA"))}${CRLF}$$1.2{records(result.Columns.Get("MONTO"))}"$, 0)
+ Next
+ If result.Rows.Size = 0 Then Toast("NO HAY VENTA", 0)
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Borramos el ticket de Kelloggs.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "revisaTicketLiquidadoKelloggs" Then 'query tag
+ For Each records() As Object In result.Rows
+' For Each k As String In result.Columns.Keys
+' Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+' Next
+ If records(result.Columns.Get("ESTATUS")) = "Liquidado" Then
+ Toast("Ticket LIQUIDADO, no se puede borrar", 600)
+ Else
+ cmd.Name = "proc_QUITAR_TICKET_KELLOGGS"
+ cmd.Parameters = Array As Object(records(result.Columns.Get("HVD_CEDIS")), records(result.Columns.Get("CLIENTE")), "appSoporte")
+ Log($"Mandamos borrar: almacen=${records(result.Columns.Get("HVD_CEDIS"))}, cliente=${records(result.Columns.Get("CLIENTE"))}"$)
+ reqManager.ExecuteCommand(cmd, "borrarTicketKelloggs")
+ End If
+ Log("Success - Rows: " & result.Rows.Size)
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Borramos el ticket de Kelloggs.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "borrarTicketKelloggs" Then 'query tag
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ Log("ProcSuccess - Rows: " & result.Rows.Size)
+ Toast("Ticket Eliminado.", 0)
+ et_cliente.Text = ""
+ s_almacen2_2.SelectedIndex = 0
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Revisamos el ticket de Kelloggs.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ Private costoTotal As Float = 0
+ liquidada = False
+ If result.Tag = "revisaTicketKelloggs" Then 'query tag
+ Dim cs, cs2 As CSBuilder
+ lv_ticket.Clear
+ prodsList.Initialize
+ If result.Rows.Size > 0 Then p_ticket.Visible = True
+ For Each records() As Object In result.Rows
+ cs.Initialize
+ cs2.Initialize
+' For Each k As String In result.Columns.Keys
+' Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+' Next
+ Private esteStatus As String = records(result.Columns.Get("ESTATUS"))
+ If esteStatus = "Liquidado" Then liquidada = True
+ prodsList.Add(CreateMap("id":records(result.Columns.Get("PRODUCTO_ID")), "P":records(result.Columns.Get("NOMBRE_PRODUCTO")), "cant":records(result.Columns.Get("CANTIDAD")), "almacen":records(result.Columns.Get("HVD_CEDIS")), "tipo":records(result.Columns.Get("TIPOVENTA"))))
+ lv_ticket.AddTwoLines(cs.Color(Colors.RGB(255,0,0)).Append("ID:").Pop.Append(records(result.Columns.Get("PRODUCTO_ID"))).Color(Colors.RGB(255,0,0)).Append(" P: ").Pop.Append(records(result.Columns.Get("NOMBRE_PRODUCTO"))).PopAll, _
+ cs2.Color(Colors.RGB(255,0,0)).Append("Cant: ").Pop.Append(records(result.Columns.Get("CANTIDAD"))).Color(Colors.RGB(255,0,0)).Append(" Costo Total: ").Pop.Append($"$$1.2{records(result.Columns.Get("COSTO_TOTAL"))}"$).Color(Colors.RGB(255,0,0)).Append(" Almacen: ").Pop.Append(records(result.Columns.Get("HVD_CEDIS"))).Color(Colors.RGB(255,0,0)).Append(" " & esteStatus.ToUpperCase ).PopAll)
+ If records(result.Columns.Get("COSTO_TOTAL")) <> "" Then costoTotal = costoTotal + records(result.Columns.Get("COSTO_TOTAL"))
+' Log($"|${records(result.Columns.Get("COSTO_TOTAL"))}| - |${costoTotal}|"$)
+ Next
+' For i=0 To 10
+' cs.Initialize
+' cs2.Initialize
+' prodsList.Add(CreateMap("id":i, "P":i, "cant":i, "almacen":i))
+'' lv_ticket.
+' lv_ticket.AddTwoLines(cs.Color(Colors.RGB(255,0,0)).Append("ID:").Pop.Append(i).Color(Colors.RGB(255,0,0)).Append(" P: ").Pop.Append(i).PopAll, _
+' cs2.Color(Colors.RGB(255,0,0)).Append("Cant: ").Pop.Append(i).Color(Colors.RGB(255,0,0)).Append(" Costo Total: ").Pop.Append($"$$1.2{i}"$).Color(Colors.RGB(255,0,0)).Append(" Almacen: ").Pop.Append(i).Color(Colors.RGB(255,0,0)).Append(" " & esteStatus.ToUpperCase ).PopAll)
+' Next
+ Toast("Productos: " & result.Rows.Size & " Total $" & $"$1.2{costoTotal}"$, 350)
+ If result.Rows.Size = 0 Then l_SinProductos.Visible = True Else l_SinProductos.Visible = False
+ If liquidada Then
+ MsgboxAsync("Ya no se pueden borrar productos de este ticket.", "Ticket Liquidado")
+ End If
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Borramos pago duplicado de pagare de Kelloggs.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "borrarPagoPagareDuplicado" Then 'query tag
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ Log("ProcSuccess - Rows: " & result.Rows.Size)
+ Toast("Pago duplicado Eliminado.", 0)
+ et_cliente.Text = ""
+ s_almacen2_2.SelectedIndex = 0
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Liberamos la bandera de facturación de Kelloggs.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "liberaBanderaFacturacion" Then 'query tag
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ Log("ProcSuccess - Rows: " & result.Rows.Size)
+ Toast("Bandera de Facturacion LIBERADA.", 0)
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Liberamos la bandera de carga foranea de Kelloggs.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "liberaBanderaCargaForanea" Then 'query tag
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ Log("ProcSuccess - Rows: " & result.Rows.Size)
+ Toast("Bandera de Carga Foranea LIBERADA.", 0)
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Liberamos la bandera de carga foranea de Kelloggs.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "borraProductoTicket" Then 'query tag
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+' Log("ProcSuccess - Rows: " & result.Rows.Size)
+' Toast("Bandera de Carga Foranea LIBERADA.", 0)
+ Next
+ End If
+ End If
+ If Job.JobName = "DBRequest" Then 'Liberamos la bandera de carga foranea de Kelloggs.
+ Dim result As DBResult = reqManager.HandleJob(Job)
+ If result.Tag = "copiaProdHVD2" Then 'query tag
+ For Each records() As Object In result.Rows
+ For Each k As String In result.Columns.Keys
+ Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
+ Next
+ Log("Producto copiado a hist_ventas_detalle_2")
+' Toast("Bandera de Carga Foranea LIBERADA.", 0)
+ Next
+ End If
+ If result.Tag = "borrarVentaGlobal" Then
+ Subs.logJobDoneResultados(result)
+ s_almacenBV.SelectedIndex = 0
+ et_rutaBV.Text = ""
+ s_tipoVentaBV.SelectedIndex = 0
+ Toast("Venta Eliminada.", 0)
+ End If
+ End If
+ Job.Release
+ End If
+End Sub
+
+'Revisamos que la contraseña ingresada sea la correcta para el día y hora.
+Private Sub et_login_TextChanged (Old As String, New As String)
+ Private contrasenaHoy As String = pass1 & DateTime.GetDayOfMonth(DateTime.Now) & DateTime.GetHour(DateTime.now)
+ If New = contrasenaHoy Then
+ p_login.Visible = False
+ Sleep(80)
+ et_usuario.Text = ""
+ If Not(versionOk) Then ExitApplication 'Si la version no es correcta, salimos de la aplicacion.
+ kb.HideKeyboard
+ End If
+End Sub
+
+'Muestra un toast con texto y ancho dados, si el ancho es 0, entonces se queda el default.
+Sub Toast(texto As String, ancho As Int)
+ p_toast.BringToFront
+ If ancho <> 0 Then p_toast.Width = ancho
+ p_toast.left = (Activity.Width/2)-(p_toast.Width/2) 'Centramos el panel en la actividad.
+ l_toast.Width = p_toast.Width
+ p_toast.top = (Activity.Height * 0.8) 'Ponemos el toast a 3/4 de la pantalla.
+ l_toast.Text = texto
+ p_toast.SetVisibleAnimated(1000, True)
+ Sleep(2000)
+ p_toast.SetVisibleAnimated(1000, False)
+End Sub
+
+'Mostramos u ocultamos el panel de opciones de desbloqueo.
+Sub b_desbloquea_longClick
+ If p_opcDesbloqueo.Visible Then
+ p_opcDesbloqueo.Visible = False
+ Else
+ p_opcDesbloqueo.Visible = True
+ End If
+End Sub
+
+'Si se modifica el checkbox de "Forzar mayusculas" de las opciones de desbloqueo, guardamos la configuración.
+Private Sub cb_usrMayusc_CheckedChange(Checked As Boolean)
+ p_opcDesbloqueo.Visible = False
+ Private cb As String = "0"
+ If cb_usrMayusc.Checked Then cb = "1"
+ Starter.mayusculasDesbloqueo = cb
+ Starter.confMap.Put("mayusculasDesbloqueo", cb)
+ Subs.escribreConf
+End Sub
+
+Private Sub et_usr_TextChanged (Old As String, New As String)
+ If New.Length > 2 Then buscaUsuario
+End Sub
+
+Private Sub et_almacen_TextChanged (Old As String, New As String)
+ If New.Length > 2 Then buscaUsuario
+End Sub
+
+Private Sub et_ruta_TextChanged (Old As String, New As String)
+ If New.Length > 1 Then buscaUsuario
+End Sub
+
+Private Sub b_buscarUsr_Click
+ buscaUsuario
+ kb.HideKeyboard
+End Sub
+
+Sub buscaUsuario
+ Private usr As String = et_usr.text.Trim
+ Private alm As String = et_almacen.text.Trim
+ Private rut As String = et_ruta.text.Trim
+ cmd.Initialize
+ cmd.Name = $"select_todos${usrEmpresa}_soporte"$
+ cmd.Parameters = Array As Object(usr, usr, alm, rut)
+ Log($"Buscar: ${usrEmpresa}, ${alm}, ${usr}, ${rut}"$)
+ reqManager.ExecuteQuery(cmd, 0 , $"select_todos_soporte"$, 0)
+End Sub
+
+Private Sub b_revisaVenta_Click
+ kb.HideKeyboard
+ Private rut As String = et_ruta1.text.Trim
+ cmd.Name = "select_ventaXrutaGuna_soporte"
+ cmd.Parameters = Array As Object(rut, almacenGuna)
+ Log($"mandamos: ruta=${rut}, almacen=${almacenGuna}"$)
+ reqManager.ExecuteQuery(cmd, 0 , "select_ventaXrutaGuna_soporte", 0)
+End Sub
+
+Private Sub b_revisaVenta2_Click
+ kb.HideKeyboard
+ Private rut As String = et_ruta2.text.Trim
+ cmd.Name = "select_ventaXrutaKelloggs_soporte"
+ cmd.Parameters = Array As Object(rut, almacenKelloggs, tipoVentaKelloggs)
+ Log($"mandamos: ruta=${rut}, almacen=${almacenKelloggs}"$)
+ reqManager.ExecuteQuery(cmd, 0 , "select_ventaXrutaKelloggs_soporte", 0)
+End Sub
+
+Private Sub b_revisaVenta3_Click
+ kb.HideKeyboard
+ Private rut As String = et_ruta3.text.Trim
+ cmd.Name = "select_ventaXrutaSalma_soporte"
+ cmd.Parameters = Array As Object(rut, almacenSalma)
+ Log($"mandamos: ruta=${rut}, almacen=${almacenSalma}"$)
+ reqManager.ExecuteQuery(cmd, 0 , "select_ventaXrutaSalma_soporte", 0)
+End Sub
+
+Private Sub b_revisaVenta4_Click
+ kb.HideKeyboard
+ Private rut As String = et_ruta4.text.Trim
+ cmd.Name = "select_ventaXrutaDanvit_soporte"
+ cmd.Parameters = Array As Object(rut, almacenDanvit)
+ Log($"mandamos: ruta=${rut}, almacen=${almacenDanvit}"$)
+ reqManager.ExecuteQuery(cmd, 0 , "select_ventaXrutaDanvit_soporte", 0)
+End Sub
+
+Private Sub s_usrEmpresa_ItemClick (Position As Int, Value As Object)
+ usrEmpresa = Value
+End Sub
+
+Private Sub s_almacen2_2_ItemClick (Position As Int, Value As Object)
+ almacenKelloggs2 = spinnerKelloggs2Map.Get(Value)
+ Log($"Almacén ${almacenKelloggs2} de Kelloggs 2 seleccionado"$ )
+End Sub
+
+Private Sub b_borrarTicket_Click
+ kb.HideKeyboard
+ cmd.Name = "select_prodsTicket_Kelloggs"
+ cmd.Parameters = Array As Object(almacenKelloggs2, et_cliente.Text.Trim)
+ Log($"Mandamos: almacen=${almacenKelloggs2}, cliente=${et_cliente.Text}"$)
+ reqManager.ExecuteQuery(cmd, 1, "revisaTicketLiquidadoKelloggs", 0)
+End Sub
+
+Private Sub b_revisaTicket_Click
+ Log("revisando")
+ kb.HideKeyboard
+ p_ticket.Width = Activity.Width * 0.95
+ p_ticket.Left = (Activity.Width/2) - (p_ticket.Width/2)
+ Subs.centraEtiquetaEnPanel(l_SinProductos, p_ticket)
+ Subs.centraBotonEnPanel(b_cerrarTicket, p_ticket)
+ p_ticket.BringToFront
+' p_ticket.Visible = True
+ lv_ticket.Clear
+ cmd.Name = "select_prodsTicket_Kelloggs"
+ cmd.Parameters = Array As Object(almacenKelloggs2, et_cliente.Text.Trim)
+ Log($"Mandamos: almacen=${almacenKelloggs2}, cliente=${et_cliente.Text}"$)
+ reqManager.ExecuteQuery(cmd, 0, "revisaTicketKelloggs", 0)
+End Sub
+
+Private Sub b_borrarPagare_Click
+ kb.HideKeyboard
+ cmd.Name = "proc_QUITAR_PAGOPAGARE_KELLOGGS"
+ cmd.Parameters = Array As Object(et_referencia.text.Trim, et_folio.Text.Trim, et_monto.Text.Trim)
+ Log($"Mandamos: ref:${et_referencia.text}, folio:${et_folio.Text}, monto:${et_monto.Text}"$)
+ reqManager.ExecuteCommand(cmd, "borrarPagoPagareDuplicado")
+End Sub
+
+Private Sub b_libBanderaFactura_Click
+ kb.HideKeyboard
+ cmd.Name = "proc_LIBERA_BANDERA_FACTURACION_KELLOGGS"
+' cmd.Parameters = Array As Object(et_referencia.text, et_folio.Text, et_monto.Text)
+' Log($"Mandamos: ref:${et_referencia.text}, folio:${et_folio.Text}, monto:${et_monto.Text}"$)
+ Log("Llamamos procedimiento liberar bandera facturacion")
+ reqManager.ExecuteCommand(cmd, "liberaBanderaFacturacion")
+End Sub
+
+Private Sub b_libBanderaCargaForanea_Click
+ kb.HideKeyboard
+ cmd.Name = "proc_LIBERA_BANDERA_CARGAFORANEA_KELLOGGS"
+ cmd.Parameters = Array As Object("101", "")
+ Log("Llamamos procedimiento liberar carga foranea")
+ reqManager.ExecuteCommand(cmd, "liberaBanderaCargaForanea")
+End Sub
+
+Private Sub b_cerrarTicket_Click
+ p_ticket.Visible = False
+ l_SinProductos.Visible = False
+End Sub
+
+Private Sub p_ticket_Click
+
+End Sub
+
+Private Sub lv_ticket_ItemClick (Position As Int, Value As Object)
+ Log(prodsList.get(Position)) ' SUR 9120761
+ If Not(liquidada) And prodsList.Size > 1 Then
+ Msgbox2Async($"Deseas borrar el producto ${prodsList.Get(Position).As(Map).Get("id")}"$, "Borrar Producto", "Borrar", "Cancelar", "", Null, True)
+ Wait For Msgbox_Result (Result As Int)
+ If Result = DialogResponse.POSITIVE Then
+ ' borrarProducto
+ Log("Borramos producto " & prodsList.Get(Position).As(Map).Get("id"))
+ Private m As Map = prodsList.get(Position)
+ Log(m)
+ lv_ticket.RemoveAt(Position)
+ prodsList.RemoveAt(Position)
+
+ cmd.Name = "insertIntoHVD2"
+ cmd.Parameters = Array As Object(et_cliente.Text, m.Get("id"), m.Get("cant"), m.Get("tipo"), m.Get("almacen"))
+ Log($"Mandamos ${et_cliente.Text}, ${m.Get("id")}, ${m.Get("cant")}, ${m.Get("tipo")}, ${m.Get("almacen")}"$)
+ reqManager.ExecuteCommand(cmd, "copiaProdHVD2")
+
+ cmd.Name = "delete_ProdTicket"
+ cmd.Parameters = Array As Object(et_cliente.Text, m.Get("id"), m.Get("cant"), m.Get("tipo"), m.Get("almacen"), m.Get("P"))
+ Log($"Mandamos ${et_cliente.Text}, ${m.Get("id")}, ${m.Get("cant")}, ${m.Get("tipo")}, ${m.Get("almacen")}, ${m.Get("P")}"$)
+ reqManager.ExecuteCommand(cmd, "borraProductoTicket")
+ End If
+ Log(prodsList)
+ End If
+End Sub
+
+Private Sub b_revisaVentaMards_Click
+ kb.HideKeyboard
+ Private rut As String = et_rutaMards.text.Trim
+ cmd.Name = "select_ventaXrutaMards_soporte"
+ cmd.Parameters = Array As Object(rut, almacenMards)
+ Log($"mandamos: ruta=${rut}, almacen=${almacenMards}"$)
+ reqManager.ExecuteQuery(cmd, 0 , "select_ventaXrutaMards_soporte", 0)
+End Sub
+
+Private Sub b_borrarVentaMards_Click
+ If et_rutaMards.text <> "" And almacenMards <> "" Then
+ kb.HideKeyboard
+ Private rutaVenta As Int = et_rutaMards.Text.Trim
+ Private usrSoporte As String = "appSoporte"
+ cmd.Initialize
+ cmd.Name = "proc_QUITAR_VENTA_MARDS"
+ cmd.Parameters = Array As Object(almacenMards, rutaVenta, usrSoporte)
+ Log($"Mandamos borrar venta de Mards, almacen: ${almacenMards}, ruta: ${rutaVenta}, usuario: '${usrSoporte}'"$)
+ reqManager.ExecuteCommand(cmd , "borrarVentaMards")
+ Else
+ Toast("Por favor ingrese ruta y almacén 🙄", 600)
+ End If
+End Sub
+
+Private Sub b_forzarVentaBV_Click
+
+End Sub
+
+Private Sub b_borrarVentaBV_Click
+ If et_rutaBV.text <> "" And almacenEmpresa <> "" Then
+ kb.HideKeyboard
+ Private rutaVenta As Int = et_rutaBV.Text.Trim
+ Private usrSoporte As String = "appSoporte"
+ cmd.Initialize
+ Private laEmp As String = laEmpresa.ToUpperCase
+
+ If laEmp = "KELLOGGS" Then
+ cmd.Name = "revisa_liquidada_Kell" 'Primero revisamos que no este liquidada o con descuento.
+ cmd.Parameters = Array As Object(almacenEmpresa, rutaVenta, elTipoDeVenta)
+ Log($"Revisamos venta liquidada Kelloggs: almacen: ${almacenEmpresa}, ruta: ${rutaVenta}, tipoVenta:${elTipoDeVenta}"$)
+ reqManager.ExecuteQuery(cmd , 0, "revisa_liquidada_Kell", 0)
+ else if laEmp = "GUNA" Then
+ cmd.Name = "revisa_liquidada_Guna" 'Primero revisamos que no este liquidada o con descuento.
+ cmd.Parameters = Array As Object(almacenEmpresa, rutaVenta)
+ Log($"Revisamos venta liquidada Guna: almacen: ${almacenEmpresa}, ruta: ${rutaVenta} "$)
+ reqManager.ExecuteQuery(cmd , 0, "revisa_liquidada_Guna", 0)
+ Else
+ If laEmpresa = "Kelloggs" Then laEmp = "KELL"
+ cmd.Name = $"proc_QUITAR_VENTA_${laEmp}"$
+ Log($"proc_QUITAR_VENTA_${laEmp}"$)
+ cmd.Parameters = Array As Object(almacenEmpresa, rutaVenta, usrSoporte)
+ Log($"Mandamos borrar venta de Mards, almacen: ${almacenEmpresa}, ruta: ${rutaVenta}, usuario: '${usrSoporte}'"$)
+ reqManager.ExecuteCommand(cmd , "borrarVentaGlobal")
+
+ End If
+
+
+ Else
+ Toast("Por favor ingrese ruta y almacén 🙄", 600)
+ End If
+End Sub
+
+Private Sub b_revisarVentaBV_Click
+ kb.HideKeyboard
+ Private rut As String = et_rutaBV.text.Trim
+ cmd.Name = $"select_ventaXruta${laEmpresa}_soporte"$
+ cmd.Parameters = Array As Object(rut, almacenEmpresa)
+ Log($"mandamos: ruta=${rut}, almacen=${almacenEmpresa}, select_ventaXruta${laEmpresa}_soporte"$)
+ reqManager.ExecuteQuery(cmd, 0 , $"select_ventaXruta${laEmpresa}_soporte"$, 0)
+End Sub
+
+Private Sub s_tipoVentaBV_ItemClick (Position As Int, Value As Object)
+ elTipoDeVenta = value
+End Sub
+
+Private Sub et_rutaBV_TextChanged (Old As String, New As String)
+
+End Sub
+
+Private Sub s_almacenBV_ItemClick (Position As Int, Value As Object)
+ almacenEmpresa = spinnerEmpresaMap.Get(Value)
+ almacenDeRuta = Value
+ Log(Value)
+ Log($"Almacén ${almacenEmpresa} de ${laEmpresa} seleccionado"$ )
+End Sub
+
+Private Sub s_empresaBV_ItemClick (Position As Int, Value As Object)
+ laEmpresa = Value
+ If laEmpresa = "Kelloggs" Then
+ l_tipoVentaBV.Visible = True
+ s_tipoVentaBV.Visible = True
+ p_tipoVentaBV.Visible = True
+ Else
+ l_tipoVentaBV.Visible = False
+ s_tipoVentaBV.Visible = False
+ p_tipoVentaBV.Visible = False
+ End If
+ If laEmpresa = "Mards" Then
+ reqManager.Initialize(Me, DBRSMards1873)
+ Else
+ reqManager.Initialize(Me, DBRSGuna1872)
+ End If
+ spinnerEmpresaMap = empresasMap.Get(Value)
+' Log(empresasMap & "|" & Value)
+' Log($"${spinnerEmpresaMap}"$)
+ s_almacenBV.Clear
+ s_almacenBV.Add("-= Seleccione =-")
+ For Each e In empresasMap.Get(Value).As(Map).Keys
+' Log(e)
+ s_almacenBV.Add(e)
+ Next
+ s_almacenBV.SelectedIndex = 0
+ Log($"Empresa seleccionada: ${Value}"$ )
+End Sub
\ No newline at end of file