commit 587fad4ebbc5e631508a1332a5e145963de44594 Author: cheveguerra Date: Sun Sep 24 00:57:10 2023 -0600 23/9/23 - Commit inicial. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..af94e9d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +**/Objects +**/AutoBackups \ No newline at end of file diff --git a/B4A/B4XMainPage.bas b/B4A/B4XMainPage.bas new file mode 100644 index 0000000..f543d26 --- /dev/null +++ b/B4A/B4XMainPage.bas @@ -0,0 +1,103 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Class +Version=9.85 +@EndOfDesignText@ +#Region Shared Files +#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files" +'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True +#End Region + +'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip + +Sub Class_Globals + Private Root As B4XView + Private xui As XUI + Dim seleccion As C_seleccion + Dim picking As C_picking + Dim reqManager As DBRequestManager + Dim paso1 As String + Private Insesion As Button + Private Contraseña As EditText + Dim Usuario As EditText + Dim ID_ALMACEN As String + Dim user As String +End Sub + +Public Sub Initialize +' B4XPages.GetManager.LogEvents = True +End Sub + +'This event will be called once, before the page becomes visible. +Private Sub B4XPage_Created (Root1 As B4XView) + Root = Root1 + Root.LoadLayout("MainPage") + seleccion.Initialize + B4XPages.AddPage("seleccion",seleccion) + picking.Initialize + B4XPages.AddPage("picking",picking) + reqManager.Initialize(Me, Starter.DBReqServer) +End Sub + +'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage. + + + +Private Sub Insesion_Click + + If Usuario.Text <> "" Then + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "select_usuario_picking_SALMA" + cmd.Parameters = Array As Object(Usuario.Text, Contraseña.Text) + reqManager.ExecuteQuery(cmd , 0, "usuario") + + End If + +End Sub + +Sub JobDone(Job As HttpJob) + If Job.Success = False Then + + ToastMessageShow("Error: " & Job.ErrorMessage, True) + + Else + + If Job.JobName = "DBRequest" Then + Dim result As DBResult = reqManager.HandleJob(Job) + If result.Tag = "usuario" Then 'query tag + For Each records() As Object In result.Rows + Dim name As String = records(result.Columns.Get("STATUS")) + ID_ALMACEN = records(result.Columns.Get("CAT_LO_AGENCIA")) + Dim IMEI_BASE As String = records(result.Columns.Get("CAT_LO_IDTELEFONO")) + user = records(result.Columns.Get("CAT_LO_USUARIO")) + Log(user) + Next + paso1 = 1 + End If + End If + Job.Release + + + + If paso1 = 1 Then + If name = "OKActivo" Then +' Starter.skmt.ExecNonQuery("delete from usuarioa") +' Starter.skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(Usuario.Text, Contraseña.Text)) +' Starter.skmt.ExecNonQuery("delete from cat_almacen") +' Starter.skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (ID_ALMACEN)) + B4XPages.ShowPage ("Seleccion") + Else If name = "OKExpirado" Then + Msgbox("Usuario Expirado llamar al administrador","") 'ignore + Else If name = "OKCancelado" Then + Msgbox("Usuario Cancelado llamar al administrador","") 'ignore + Else + Msgbox("Usuario o password No validos","") 'ignore + End If + paso1 = 0 + End If + + End If +End Sub \ No newline at end of file diff --git a/B4A/C_picking.bas b/B4A/C_picking.bas new file mode 100644 index 0000000..497b5cd --- /dev/null +++ b/B4A/C_picking.bas @@ -0,0 +1,107 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Class +Version=11.8 +@EndOfDesignText@ +Sub Class_Globals + Private Root As B4XView 'ignore + Private xui As XUI 'ignore + Private lb_folioselec As Label + Dim c As Cursor + Dim cl_picking As CustomListView + Private l_nombre As Label + Private l_codigo As Label + Private l_inical As Label + Private et_picking As EditText + Private b_guardapicking As Button + Dim cmd As DBCommand + Dim reqManager As DBRequestManager +End Sub + +'You can add more parameters here. +Public Sub Initialize As Object + Return Me +End Sub + +'This event will be called once, before the page becomes visible. +Private Sub B4XPage_Created (Root1 As B4XView) + Root = Root1 + Root.LoadLayout("picking") + 'load the layout to Root + + reqManager.Initialize(Me, Starter.DBReqServer) + cl_picking.Clear + +End Sub + +Sub B4XPage_Appear + + lb_folioselec.Text = B4XPages.MainPage.seleccion.folioactual + c = Starter.skmt.ExecQuery("SELECT CAT_DF_ID, CAT_DF_NOMBRE, CAT_DF_CANTINICIAL FROM CAT_DETALLEFOLIO") + cl_picking.Clear + For i = 0 To c.RowCount - 1 + c.Position = i + cl_picking.Add(CreateListItem(c.GetString("CAT_DF_ID"),c.GetString("CAT_DF_NOMBRE"),c.GetString("CAT_DF_CANTINICIAL")),i) + Next + c.Close + +End Sub + +Sub CreateListItem(id As String, nombre As String, cantidad As String) As Panel + + Dim p As B4XView = xui.CreatePanel("") + p.SetLayoutAnimated(0, 0, 0, 1, 115) + p.LoadLayout("dpicking") + p.Height= 60dip +' p.Width = clv_orden.GetBase.Width + l_codigo.Text = id + l_nombre.Text = nombre + l_inical.Text = cantidad + et_picking.Text = cantidad +' Log(p.Width) + Return p + +End Sub + +Private Sub b_guardapicking_Click + + Dim cuantospicking As Int = cl_picking.Size +' Log (cuantospicking) + + c = Starter.skmt.ExecQuery("SELECT DISTINCT CAT_DF_RUTA FROM CAT_DETALLEFOLIO") + c.Position = 0 + For i=0 To cuantospicking-1 + + Dim pnl0 As B4XView = cl_picking.GetPanel(i) + Dim pnl As B4XView = pnl0.GetView(0) + Dim codigoproducto As B4XView = pnl.GetView(0) + Dim cantidadescrita As B4XView = pnl.GetView(3) + Log (codigoproducto.Text & " y " & cantidadescrita.Text) + Starter.skmt.ExecNonQuery2("UPDATE CAT_DETALLEFOLIO SET CAT_DF_CANTIDADESCRITA=(?) WHERE CAT_DF_ID = (?) AND CAT_DF_RUTA = (?)",Array As Object(cantidadescrita.Text,codigoproducto.text,c.GetString("CAT_DF_RUTA"))) +' + cmd.Initialize + cmd.Name = "update_picking2_SALMA" + cmd.Parameters = Array As Object(cantidadescrita.text,codigoproducto.Text,c.GetString("CAT_DF_RUTA"), B4XPages.MainPage.seleccion.almacen) + reqManager.ExecuteCommand(cmd, "update_picking2") + + Next + + cmd.Initialize + cmd.Name = "update_picking3_SALMA" + cmd.Parameters = Array As Object(B4XPages.MainPage.seleccion.folioactual,B4XPages.MainPage.seleccion.almacen,B4XPages.MainPage.seleccion.user) + reqManager.ExecuteCommand(cmd, "update_picking3") + + cmd.Initialize + cmd.Name = "update_picking4_SALMA" + cmd.Parameters = Array As Object(B4XPages.MainPage.seleccion.folioactual,B4XPages.MainPage.seleccion.almacen,B4XPages.MainPage.seleccion.user) + reqManager.ExecuteCommand(cmd, "update_picking4") + + B4XPages.ShowPage("seleccion") +' B4XPages.MainPage.seleccion.b_cargar_Click +' B4XPages.MainPage.seleccion.trabajos = 0 +' B4XPages.MainPage.seleccion.trabajo1 = 1 +' Log(B4XPages.MainPage.seleccion.trabajos) +' Log(B4XPages.MainPage.seleccion.trabajo1) + +End Sub \ No newline at end of file diff --git a/B4A/C_seleccion.bas b/B4A/C_seleccion.bas new file mode 100644 index 0000000..bed0b40 --- /dev/null +++ b/B4A/C_seleccion.bas @@ -0,0 +1,314 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Class +Version=11.8 +@EndOfDesignText@ +Sub Class_Globals + Private Root As B4XView 'ignore + Private xui As XUI 'ignore + Private b_cargar As Button + Dim reqManager As DBRequestManager + Dim trabajos = 0 As Int + Dim trabajo1 = 0 As Int + Private cl_folios As CustomListView + Dim c As Cursor + Private lb_folio As Label + Dim folioactual As String + Dim user As String + Dim almacen As String + Dim cuenta As String + Dim cuenta2 As String + Dim cuenta3 As String +End Sub + +'You can add more parameters here. +Public Sub Initialize As Object + Return Me +End Sub + +'This event will be called once, before the page becomes visible. +Private Sub B4XPage_Created (Root1 As B4XView) + Root = Root1 + Root.LoadLayout("seleccion") + 'load the layout to Root + reqManager.Initialize(Me, Starter.DBReqServer) + trabajos = 0 + trabajo1 = 0 + user = B4XPages.MainPage.user + almacen = B4XPages.MainPage.ID_ALMACEN +End Sub + +Sub B4XPage_Appear + + trabajos = 0 + trabajo1 = 1 + b_cargar_Click + +End Sub + +'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage. + +Sub b_cargar_Click + + cl_folios.Clear + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "select_folios_SALMA" + cmd.Parameters = Array As Object(B4XPages.MainPage.ID_ALMACEN) + reqManager.ExecuteQuery(cmd , 0, "folios") + trabajos = trabajos +1 + + + ProgressDialogShow ("Cargando") + + Log(trabajos) + Log(trabajo1) + +' If trabajos = 0 And trabajo1 = 1 Then +' ProgressDialogHide +' End If +End Sub + +Sub CreateListItem(mostrar As String) As Panel + + Dim p As B4XView = xui.CreatePanel("") + p.SetLayoutAnimated(0, 0, 0, 1, 115) + p.LoadLayout("folio") + p.Height= 60dip +' p.Width = clv_orden.GetBase.Width + lb_folio.Height = p.Height *0.8 + lb_folio.Text = mostrar +' Log(p.Width) + Return p + +End Sub + +Private Sub lb_folio_Click + folioactual = Sender.As(Label).Text + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "select_pickingtrabajo_SALMA" + cmd.Parameters = Array As Object(folioactual,almacen) + reqManager.ExecuteQuery(cmd , 0, "pickingt") + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "select_pickingtrabajo2_SALMA" + cmd.Parameters = Array As Object(folioactual,almacen,user) + reqManager.ExecuteQuery(cmd , 0, "pickingt2") + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "select_pickingtrabajo3_SALMA" + cmd.Parameters = Array As Object(folioactual,almacen) + reqManager.ExecuteQuery(cmd , 0, "pickingt3") +' +' Dim cmd As DBCommand +' cmd.Initialize +' cmd.Name = "select_detalle_folio_SALMA" +' cmd.Parameters = Array As Object(folioactual,B4XPages.MainPage.ID_ALMACEN) +' reqManager.ExecuteQuery(cmd , 0, "detallefolio") +' trabajo1 = trabajo1 + 1 +' ProgressDialogShow ("Cargando") + +End Sub + +Sub JobDone(Job As HttpJob) + If Job.Success = False Then + + ToastMessageShow("Error: " & Job.ErrorMessage, True) + + Else + + LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) + + If Job.JobName = "DBRequest" Then + Dim result As DBResult = reqManager.HandleJob(Job) + If result.Tag = "folios" Then 'query tag + trabajos = trabajos - 1 + trabajo1 = 1 + Starter.skmt.ExecNonQuery("delete from CAT_FOLIOS") + For Each records() As Object In result.Rows + + Dim FOLIO As String = records(result.Columns.Get("FOLIO")) + + Starter.skmt.ExecNonQuery2("INSERT INTO CAT_FOLIOS (CAT_FOLIO) VALUES (?)", Array As Object (FOLIO)) + + + Next + + c = Starter.skmt.ExecQuery("SELECT CAT_FOLIO FROM CAT_FOLIOS") + cl_folios.Clear + For i = 0 To c.RowCount - 1 + c.Position = i + cl_folios.Add(CreateListItem(c.GetString("CAT_FOLIO")),i) + Next + c.Close + + End If + End If + + + If Job.JobName = "DBRequest" Then + Dim result As DBResult = reqManager.HandleJob(Job) + If result.Tag = "pickingt" Then 'query tag +' B4XPages.MainPage.picking.cl_picking.Clear + + + For Each records() As Object In result.Rows + + cuenta = records(result.Columns.Get("COUNT(*)")) + Log(cuenta) + + Next + + + End If + End If + + + If Job.JobName = "DBRequest" Then + Dim result As DBResult = reqManager.HandleJob(Job) + If result.Tag = "pickingt2" Then 'query tag +' B4XPages.MainPage.picking.cl_picking.Clear + + + For Each records() As Object In result.Rows + + cuenta2 = records(result.Columns.Get("COUNT(*)")) + Log(cuenta2) + + + Next + + + + End If + End If + + If Job.JobName = "DBRequest" Then + Dim result As DBResult = reqManager.HandleJob(Job) + If result.Tag = "pickingt3" Then 'query tag +' B4XPages.MainPage.picking.cl_picking.Clear + + + For Each records() As Object In result.Rows + + cuenta3 = records(result.Columns.Get("COUNT(*)")) + Log(cuenta3) + + Next + + If cuenta = "1" Then + Log("entre") + If cuenta2 = "0" Then + + MsgboxAsync("Ruta trabajada por otro ususario","Atención") + + else if cuenta2 = "1" Then + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "select_detalle_folio_SALMA" + cmd.Parameters = Array As Object(folioactual,B4XPages.MainPage.ID_ALMACEN) + reqManager.ExecuteQuery(cmd , 0, "detallefolio") + trabajo1 = trabajo1 + 1 + ProgressDialogShow ("Cargando") + + Else if cuenta3 = "1" Then + + cmd.Initialize + cmd.Name = "update_picking5_SALMA" + cmd.Parameters = Array As Object(user,folioactual,almacen) + reqManager.ExecuteCommand(cmd, "update_picking5") + + cmd.Initialize + cmd.Name = "update_picking6_SALMA" + cmd.Parameters = Array As Object(user,folioactual,almacen) + reqManager.ExecuteCommand(cmd, "update_picking6") + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "select_detalle_folio_SALMA" + cmd.Parameters = Array As Object(folioactual,B4XPages.MainPage.ID_ALMACEN) + reqManager.ExecuteQuery(cmd , 0, "detallefolio") + trabajo1 = trabajo1 + 1 + ProgressDialogShow ("Cargando") + + End If + + Else if cuenta = "0" Then + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "insert_PICKING_TRABAJO_SALMA" + cmd.Parameters = Array As Object(folioactual,almacen,user,user) + reqManager.ExecuteCommand(cmd , "insert_PICKING_TRABAJO_SALMA") + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "insert_PICKING_TRABAJO_REP_SALMA" + cmd.Parameters = Array As Object(folioactual,almacen,user,user) + reqManager.ExecuteCommand(cmd , "insert_PICKING_TRABAJO_REP_SALMA") + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "insert_picking2_SALMA" + cmd.Parameters = Array As Object(user,folioactual,almacen,folioactual,almacen) + reqManager.ExecuteCommand(cmd , "insert_picking2_SALMA") + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "select_detalle_folio_SALMA" + cmd.Parameters = Array As Object(folioactual,B4XPages.MainPage.ID_ALMACEN) + reqManager.ExecuteQuery(cmd , 0, "detallefolio") + trabajo1 = trabajo1 + 1 + ProgressDialogShow ("Cargando") + + + + End If + + + End If + End If + + If Job.JobName = "DBRequest" Then + Dim result As DBResult = reqManager.HandleJob(Job) + If result.Tag = "detallefolio" Then 'query tag + trabajo1 = trabajo1 - 2 +' B4XPages.MainPage.picking.cl_picking.Clear + Starter.skmt.ExecNonQuery("delete from CAT_DETALLEFOLIO") + Log("Borre la tabla") + For Each records() As Object In result.Rows + + Dim ID As String = records(result.Columns.Get("ID")) + Dim NOMBRE As String = records(result.Columns.Get("NOMBRE")) + Dim CANTIDAD As String = records(result.Columns.Get("CANTIDAD")) + Dim ruta As String = folioactual + + Starter.skmt.ExecNonQuery2("INSERT INTO CAT_DETALLEFOLIO (CAT_DF_ID, CAT_DF_NOMBRE, CAT_DF_CANTINICIAL, CAT_DF_RUTA) VALUES (?,?,?,?)", Array As Object (ID,NOMBRE,CANTIDAD,ruta)) + + + Next + + + End If + End If + + + If trabajos = 0 And trabajo1 = 1 Then + ProgressDialogHide + Else If trabajo1 = 0 And trabajos = 0 Then + ProgressDialogHide + B4XPages.ShowPage("picking") + End If + +' If trabajos = 0 Then +' ProgressDialogHide +' End If + End If + +End Sub \ No newline at end of file diff --git a/B4A/DBRequestManager.bas b/B4A/DBRequestManager.bas new file mode 100644 index 0000000..31298ba --- /dev/null +++ b/B4A/DBRequestManager.bas @@ -0,0 +1,272 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Class +Version=6.8 +@EndOfDesignText@ +''Class module + +'' Requiere accesRandom File y requiere compressStrings, byte converter y okhhtputuils2 +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 - 211109 +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) + 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) +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 'ignore + 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 - 211109 + jobTagAnterior = Job.Tag 'Mod por CHV - 211109 + 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))'Comentado por CHV - 211112 + 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/B4A/Files/dpicking.bal b/B4A/Files/dpicking.bal new file mode 100644 index 0000000..3216ade Binary files /dev/null and b/B4A/Files/dpicking.bal differ diff --git a/B4A/Files/folio.bal b/B4A/Files/folio.bal new file mode 100644 index 0000000..675a964 Binary files /dev/null and b/B4A/Files/folio.bal differ diff --git a/B4A/Files/kmt.db b/B4A/Files/kmt.db new file mode 100644 index 0000000..2cbbb8e Binary files /dev/null and b/B4A/Files/kmt.db differ diff --git a/B4A/Files/mainpage.bal b/B4A/Files/mainpage.bal new file mode 100644 index 0000000..cc4d7b9 Binary files /dev/null and b/B4A/Files/mainpage.bal differ diff --git a/B4A/Files/picking.bal b/B4A/Files/picking.bal new file mode 100644 index 0000000..93fdd0c Binary files /dev/null and b/B4A/Files/picking.bal differ diff --git a/B4A/Files/salma13.png b/B4A/Files/salma13.png new file mode 100644 index 0000000..d1d3d2a Binary files /dev/null and b/B4A/Files/salma13.png differ diff --git a/B4A/Files/seleccion.bal b/B4A/Files/seleccion.bal new file mode 100644 index 0000000..a2377dd Binary files /dev/null and b/B4A/Files/seleccion.bal differ diff --git a/B4A/Salma_picking.b4a b/B4A/Salma_picking.b4a new file mode 100644 index 0000000..40d2828 --- /dev/null +++ b/B4A/Salma_picking.b4a @@ -0,0 +1,113 @@ +Build1=Default,salma_picking.keymon.com.mx +File1=dpicking.bal +File2=folio.bal +File3=kmt.db +File4=MainPage.bal +File5=picking.bal +File6=SALMA13.png +File7=seleccion.bal +FileGroup1=Default Group +FileGroup2=Default Group +FileGroup3=Default Group +FileGroup4=Default Group +FileGroup5=Default Group +FileGroup6=Default Group +FileGroup7=Default Group +Group=Default Group +Library1=accessibility +Library10=randomaccessfile +Library11=reflection +Library12=runtimepermissions +Library13=sql +Library14=stringutils +Library15=xcustomlistview +Library16=xui +Library17=xui views +Library2=b4xpages +Library3=bctoast +Library4=byteconverter +Library5=compressstrings +Library6=core +Library7=ime +Library8=okhttputils2 +Library9=phone +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.LightTheme)~\n~SetApplicationAttribute(android:usesCleartextTraffic, "true")~\n~'End of default text.~\n~ +Module1=|relative|..\B4XMainPage +Module2=C_picking +Module3=C_seleccion +Module4=DBRequestManager +Module5=Starter +Module6=Subs +NumberOfFiles=7 +NumberOfLibraries=17 +NumberOfModules=6 +Version=12.2 +@EndOfDesignText@ +#Region Project Attributes + #ApplicationLabel: Salma-Picking + #VersionCode: 1 + #VersionName: + 'SupportedOrientations possible values: unspecified, landscape or portrait. + #SupportedOrientations: portrait + #CanInstallToExternalStorage: False +#End Region + +#Region Activity Attributes + #FullScreen: False + #IncludeTitle: False +#End Region + +'#BridgeLogger: True + +Sub Process_Globals + Public ActionBarHomeClicked As Boolean +End Sub + +Sub Globals + +End Sub + +Sub Activity_Create(FirstTime As Boolean) + Dim pm As B4XPagesManager + pm.Initialize(Activity) +End Sub + +'Template version: B4A-1.01 +#Region Delegates + +Sub Activity_ActionBarHomeClick + ActionBarHomeClicked = True + B4XPages.Delegate.Activity_ActionBarHomeClick + ActionBarHomeClicked = False +End Sub + +Sub Activity_KeyPress (KeyCode As Int) As Boolean + Return B4XPages.Delegate.Activity_KeyPress(KeyCode) +End Sub + +Sub Activity_Resume + B4XPages.Delegate.Activity_Resume +End Sub + +Sub Activity_Pause (UserClosed As Boolean) + B4XPages.Delegate.Activity_Pause +End Sub + +Sub Activity_PermissionResult (Permission As String, Result As Boolean) + B4XPages.Delegate.Activity_PermissionResult(Permission, Result) +End Sub + +Sub Create_Menu (Menu As Object) + B4XPages.Delegate.Create_Menu(Menu) +End Sub + +#if Java +public boolean _onCreateOptionsMenu(android.view.Menu menu) { + processBA.raiseEvent(null, "create_menu", menu); + return true; + +} +#End If +#End Region + +'Program code should go into B4XMainPage and other pages. \ No newline at end of file diff --git a/B4A/Salma_picking.b4a.meta b/B4A/Salma_picking.b4a.meta new file mode 100644 index 0000000..7a0c361 --- /dev/null +++ b/B4A/Salma_picking.b4a.meta @@ -0,0 +1,24 @@ +ModuleBookmarks0= +ModuleBookmarks1= +ModuleBookmarks2= +ModuleBookmarks3= +ModuleBookmarks4= +ModuleBookmarks5= +ModuleBookmarks6= +ModuleBreakpoints0= +ModuleBreakpoints1= +ModuleBreakpoints2= +ModuleBreakpoints3= +ModuleBreakpoints4= +ModuleBreakpoints5= +ModuleBreakpoints6= +ModuleClosedNodes0= +ModuleClosedNodes1= +ModuleClosedNodes2= +ModuleClosedNodes3= +ModuleClosedNodes4= +ModuleClosedNodes5=1 +ModuleClosedNodes6= +NavigationStack=Starter,Service_Create,19,0,B4XMainPage,Insesion_Click,40,0,C_picking,Class_Globals,0,0,C_seleccion,JobDone,251,6,C_picking,b_guardapicking_Click,83,6,Starter,Service_Destroy,44,0,Starter,Process_Globals,11,0,C_seleccion,Class_Globals,0,0,Subs,revisaBD,14,0,C_seleccion,b_cargar_Click,50,5 +SelectedBuild=0 +VisibleModules=5,1,3,2,4,6 diff --git a/B4A/Starter.bas b/B4A/Starter.bas new file mode 100644 index 0000000..c3ee270 --- /dev/null +++ b/B4A/Starter.bas @@ -0,0 +1,50 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Service +Version=9.85 +@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. + + Public rp As RuntimePermissions + Dim reqManager As DBRequestManager + Dim DBReqServer As String = "http://keymon.lat:1787" '"http://keymon.lat:1782" "http://10.0.0.205:1782" "http://keymon.lat:1783" "http://11.0.0.48:1783" ""' CAMBIAR HACIA AFUERA O DENTRO DE LA OFNA +' Dim server As String = "http://10.0.0.205:1782" + Dim rutaBD As String = File.DirInternal + Dim skmt As SQL + Dim almacen As String + +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. + +End Sub + +Sub Service_Start (StartingIntent As Intent) + Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases. + Subs.revisaBD + reqManager.Initialize(Me, DBReqServer) + If Not(skmt.IsInitialized) Then skmt.Initialize(rutaBD, "kmt.db", True) +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/B4A/Subs.bas b/B4A/Subs.bas new file mode 100644 index 0000000..fc82b59 --- /dev/null +++ b/B4A/Subs.bas @@ -0,0 +1,23 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=StaticCode +Version=11.5 +@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 + +'Revisa que exista la BD y si es necesario crea algunas tablas dentro de ella +Sub revisaBD 'ignore + If Not(File.Exists(Starter.rutaBD, "kmt.db")) Then File.Copy(File.DirAssets, "kmt.db", Starter.rutaBD, "kmt.db") + If Not(Starter.skmt.IsInitialized) Then Starter.skmt.Initialize(Starter.rutaBD, "kmt.db", True) + Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_FOLIOS(CAT_FOLIO TEXT)") + Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_DETALLEFOLIO(CAT_DF_ID TEXT, CAT_DF_NOMBRE TEXT,CAT_DF_RUTA TEXT, CAT_DF_CANTINICIAL TEXT, CAT_DF_CANTIDADESCRITA TEXT)") + Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS PICKING (CODIGO TEXT, RUTA TEXT, CANTIDAD_INICIAL TEXT, CANTIDAD_FINAL TEXT,CANTIDAD_ESCRITA TEXT)") +' Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS PICKING") +' Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS CAT_DETALLEFOLIO") +End Sub \ No newline at end of file diff --git a/gitpull.bat b/gitpull.bat new file mode 100644 index 0000000..d0aed61 --- /dev/null +++ b/gitpull.bat @@ -0,0 +1 @@ +git pull diff --git a/logo-salma.jpg b/logo-salma.jpg new file mode 100644 index 0000000..2d35c74 Binary files /dev/null and b/logo-salma.jpg differ