23/9/23 - Commit inicial.
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
**/Objects
|
||||
**/AutoBackups
|
||||
76
B4A/B4XMainPage.bas
Normal file
@@ -0,0 +1,76 @@
|
||||
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
|
||||
Public principal As C_Principal
|
||||
Private i_logo As ImageView
|
||||
Private p_configuracion As Panel
|
||||
Private p_login As Panel
|
||||
Private b_regresar As Button
|
||||
Private b_entrar As Button
|
||||
Private b_envioBD As Button
|
||||
Private B_SERVER As Button
|
||||
Private ImageView4 As ImageView
|
||||
Private ImageView2 As ImageView
|
||||
Private Panel3 As Panel
|
||||
Private Label1 As Label
|
||||
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("login")
|
||||
principal.Initialize
|
||||
B4XPages.AddPage("Principal", principal)
|
||||
p_login.Width = Root.Width
|
||||
p_login.Height = Root.Height
|
||||
Subs.agregaColumna("cat_gunaprod", "CAT_PT_DESC", "TEXT")
|
||||
Subs.agregaColumna("cat_gunaprod", "CAT_PS_DESC", "TEXT")
|
||||
Subs.agregaColumna("cat_gunaprod", "CAT_PS_DESC", "TEXT")
|
||||
Subs.agregaColumna("cat_gunaprod", "CAT_GP_FECHA", "TEXT")
|
||||
Subs.agregaColumna("cat_gunaprod", "CAT_GP_FECHA_MOD", "TEXT")
|
||||
Starter.skmt.ExecNonQuery("delete from cuentaa")
|
||||
Starter.skmt.ExecNonQuery("insert into cuentaa (cuenta) values ('123456')")
|
||||
Starter.skmt.ExecNonQuery("delete from cat_almacen")
|
||||
Starter.skmt.ExecNonQuery("insert into cat_almacen (id_almacen) values ('1')")
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Private Sub i_logo_Click
|
||||
p_configuracion.Width = Root.Width
|
||||
p_configuracion.Height = Root.Height
|
||||
Subs.panelVisible(p_configuracion, 0, 0)
|
||||
End Sub
|
||||
|
||||
Private Sub b_regresar_Click
|
||||
Subs.panelVisible(p_login, 0, 0)
|
||||
End Sub
|
||||
|
||||
Private Sub b_entrar_Click
|
||||
B4XPages.ShowPage("principal")
|
||||
End Sub
|
||||
|
||||
Private Sub B_SERVER_Click
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub b_envioBD_Click
|
||||
|
||||
End Sub
|
||||
723
B4A/C_Principal.bas
Normal file
@@ -0,0 +1,723 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Private p_principal As Panel
|
||||
Private WobbleMenu1 As WobbleMenu
|
||||
Dim PCLV As PreoptimizedCLV
|
||||
Private p_productos As Panel
|
||||
Private clv_prods_ll, clv_carrito, clv As CustomListView
|
||||
Dim prodsMap As Map
|
||||
Private p_botonesVenta As Panel
|
||||
Private b_continuar As Button
|
||||
Private lfila As Label
|
||||
Private et_busca As EditText
|
||||
Private b_buscar As Button
|
||||
Dim etCantHasFocus, hayPedido As Boolean
|
||||
Dim clienteId As String
|
||||
Dim rutaUsuario, folio As String
|
||||
Dim query As String
|
||||
Dim listaProds, listaHints, list_prodsPedido As List
|
||||
Dim reiniciarlistaProds As Boolean= False
|
||||
Dim forzarBusqueda As Boolean = False
|
||||
Private lv_promos As ListView
|
||||
Private b_prodMenos As Button
|
||||
Private et_pCant As EditText
|
||||
Private l_pCant As Label
|
||||
Private b_prodMas As Button
|
||||
Private p_botMasMen As Panel
|
||||
Private l_prodX As Label
|
||||
Private i_prod As ImageView
|
||||
Private p_prods As Panel
|
||||
Private p_promos As Panel
|
||||
' Private lv_carrito As ListView
|
||||
Private p_carrito As Panel
|
||||
Private p_botonesCarrito As Panel
|
||||
Private b_continuar2 As Button
|
||||
Private p_botonesPromo As Panel
|
||||
Private b_terminar As Button
|
||||
Private p_historial As Panel
|
||||
Private p_botonesHist As Panel
|
||||
Private l_compraTerminada As Label
|
||||
Private l_carritoVacio As Label
|
||||
Private b_borrar As Button
|
||||
Private l_totalCarrito As Label
|
||||
Private l_historialVacio As Label
|
||||
Private lv_historial As ListView
|
||||
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
|
||||
'load the layout to Root
|
||||
Root.LoadLayout("principal")
|
||||
p_principal.Width = Root.Width
|
||||
p_principal.Height = Root.Height
|
||||
If File.Exists(Starter.ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
||||
End If
|
||||
PCLV.Initialize(Me, "PCLV", clv_prods_ll)
|
||||
WobbleMenu1.SetTabTextIcon(1,"Productos", Chr(0xF0C0), Typeface.FONTAWESOME)
|
||||
WobbleMenu1.SetTabTextIcon(2,"Promociones", Chr(0xF007), Typeface.FONTAWESOME)
|
||||
WobbleMenu1.SetTabTextIcon(3,"Carrito", Chr(0xF2BE), Typeface.FONTAWESOME)
|
||||
WobbleMenu1.SetTabTextIcon(4,"Historial", Chr(0xF21B), Typeface.FONTAWESOME)
|
||||
' WobbleMenu1.SetTabTextIcon(5,"Cinco", Chr(0xF29D), Typeface.FONTAWESOME)
|
||||
p_carrito.Width = Root.Width
|
||||
p_carrito.Height = Root.Height - WobbleMenu1.Height
|
||||
p_promos.Width = Root.Width
|
||||
p_promos.Height = Root.Height - WobbleMenu1.Height
|
||||
p_historial.Width = Root.Width
|
||||
p_historial.Height = Root.Height - WobbleMenu1.Height
|
||||
p_botonesVenta.Top = Root.Height - p_botonesVenta.Height - WobbleMenu1.Height + 10
|
||||
p_botonesPromo.Top = Root.Height - p_botonesPromo.Height - WobbleMenu1.Height + 10
|
||||
' p_botonesHist.Top = Root.Height - p_botonesHist.Height - WobbleMenu1.Height + 10
|
||||
p_botonesPromo.Width = p_promos.Width
|
||||
p_botonesCarrito.Top = Root.Height - p_botonesCarrito.Height - WobbleMenu1.Height + 10
|
||||
Dim ri As Cursor = Starter.skmt.ExecQuery($"select count(*) as cuantos from cat_gunaprod"$)
|
||||
ri.Position = 0
|
||||
If ri.GetString("cuantos") = "0" Then 'Si no hay productos, los descargamos
|
||||
Starter.reqManager.Initialize(Me, Starter.server)
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "selectPedigree"
|
||||
cmd.Parameters = Array As Object(DateTime.Date(DateTime.Now))
|
||||
Log($"Traemos productos, ${DateTime.Date(DateTime.Now)}"$)
|
||||
Starter.reqManager.ExecuteQuery(cmd , 0, "descargaProds")
|
||||
End If
|
||||
query = "cat_gunaprod"
|
||||
prodsMap.Initialize
|
||||
listaProds.Initialize
|
||||
listaHints.Initialize
|
||||
p_productos.Width = Root.Width
|
||||
' Log(p_productos.Width)
|
||||
Subs.panelVisible(p_productos, 0, 0)
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
clienteId = Subs.traeCliente
|
||||
rutaUsuario = Subs.traeRuta
|
||||
p_principal.Width = Root.Width
|
||||
p_principal.Height = Root.Height
|
||||
clv_prods_ll.GetBase.SetLayoutAnimated(0, 5dip, 130dip, Root.Width + 10, Root.Height * 0.65) 'Cambiamos el tamaño y posición de la lista de productos.
|
||||
clv_prods_ll.Base_Resize(clv_prods_ll.GetBase.Width, clv_prods_ll.GetBase.Height) 'Cambiamos el tamaño del panel interno de la lista para que se ajuste al nuevo tamaño.
|
||||
clv_carrito.GetBase.SetLayoutAnimated(0, 5dip, 80dip, Root.Width - 20, Root.Height * 0.65) 'Cambiamos el tamaño y posición de la lista del carrito.
|
||||
clv_carrito.Base_Resize(clv_prods_ll.GetBase.Width, clv_prods_ll.GetBase.Height) 'Cambiamos el tamaño del panel interno del carrito para que se ajuste al nuevo tamaño.
|
||||
' Log($"${clv_carrito.AsView.Width}, ${Root.Width}"$)
|
||||
clv = clv_prods_ll
|
||||
cuentaProds
|
||||
LlenaProdsLL(Null, Null)
|
||||
If clv_prods_ll.Size > 0 Then
|
||||
clv_prods_ll.JumpToItem(0) 'Vamos al primer artículo de la lista.
|
||||
PCLV.lblHint.SetTextSizeAnimated(0,13)
|
||||
PCLV.B4XSeekBar1.Color1=Colors.DarkGray
|
||||
PCLV.B4XSeekBar1.Color2=Colors.DarkGray
|
||||
PCLV.B4XSeekBar1.ThumbColor=Colors.red
|
||||
PCLV.B4XSeekBar1.Radius1 = 20
|
||||
PCLV.B4XSeekBar1.Radius2 = 30
|
||||
PCLV.B4XSeekBar1.mBase.Left=Root.Width *0.90
|
||||
' PCLV.B4XSeekBar1.mBase.Top=-50
|
||||
PCLV.B4XSeekBar1.mBase.Height=clv_prods_ll.AsView.Height
|
||||
PCLV.pnlOverlay.Height = clv_prods_ll.AsView.Height
|
||||
PCLV.pnlOverlay.Width = clv_prods_ll.AsView.Width - 100
|
||||
PCLV.B4XSeekBar1.Update
|
||||
Else
|
||||
PCLV.B4XSeekBar1.mBase.Left=Root.Width *1.5 'Si no hay productos, que NO se vea la barra de busqueda.
|
||||
End If
|
||||
p_productos.Height = Root.Height - WobbleMenu1.Height
|
||||
If et_busca.Text <> "" Then et_busca.Text =""
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
If Starter.Logger Then LogColor("Principal - JobDone", Colors.Magenta)
|
||||
If Job.Success = False Then
|
||||
' ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Else
|
||||
If Starter.Logger Then LogColor("JobDone: '" & Starter.reqManager.HandleJob(Job).tag & "' - Registros: " & Starter.reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211110
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = Starter.reqManager.HandleJob(Job)
|
||||
If result.Tag = "descargaProds" Then 'query tag
|
||||
' If Starter.Logger Then Subs.logJobDoneResultados(result)
|
||||
Starter.skmt.BeginTransaction
|
||||
For Each records() As Object In result.Rows
|
||||
Log($"ID: ${records(result.Columns.Get("CAT_GP_ID"))}, NOM: ${records(result.Columns.Get("CAT_GP_NOMBRE"))}"$)
|
||||
Dim CAT_GP_ID As String = records(result.Columns.Get("CAT_GP_ID"))
|
||||
Dim CAT_GP_NOMBRE As String = records(result.Columns.Get("CAT_GP_NOMBRE"))
|
||||
Dim CAT_GP_PRECIO As String = records(result.Columns.Get("CAT_GP_PRECIO"))
|
||||
Dim CAT_GP_ALMACEN As String = records(result.Columns.Get("CAT_GP_ALMACEN"))
|
||||
Dim CAT_PT_DESC As String = records(result.Columns.Get("CAT_PT_DESC"))
|
||||
Dim CAT_PS_DESC As String = records(result.Columns.Get("CAT_PS_DESC"))
|
||||
Dim CAT_GP_IMG() As Byte = records(result.Columns.Get("CAT_GP_IMG"))
|
||||
Dim CAT_GP_FECHA As String = records(result.Columns.Get("CAT_GP_FECHA"))
|
||||
Dim CAT_GP_FECHA_MOD As String = records(result.Columns.Get("CAT_GP_FECHA_MOD"))
|
||||
Dim CAT_GP_CLASIF As String = records(result.Columns.Get("CAT_GP_CLASIF"))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_GUNAPROD(CAT_GP_ID,CAT_GP_NOMBRE,CAT_GP_PRECIO,CAT_GP_ALMACEN,CAT_PT_DESC,CAT_PS_DESC,CAT_GP_IMG,CAT_GP_FECHA,CAT_GP_FECHA_MOD, CAT_GP_CLASIF) VALUES (?,?,?,?,?,?,?,?,?,?)", Array As Object (CAT_GP_ID,CAT_GP_NOMBRE,CAT_GP_PRECIO,CAT_GP_ALMACEN,CAT_PT_DESC,CAT_PS_DESC,CAT_GP_IMG,CAT_GP_FECHA,CAT_GP_FECHA_MOD,CAT_GP_CLASIF))
|
||||
Next
|
||||
' Starter.skmt.ExecNonQuery2("INSERT INTO kmt_info(CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_BFACTURA,CAT_CL_BCREDITO,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO,CAT_CL_DIAS_VISITA, gestion, IMPRESION) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,0,?,0,0) ",Array As Object ("0",e_ruta.TEXT, "VENTA ABORDO","null","null","null","null","null","null","null","null","null","null","null","null","NULL","null","null","NULL","NULL"))
|
||||
Starter.skmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
||||
Starter.skmt.EndTransaction
|
||||
LlenaProdsLL(Null, Null)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End Sub
|
||||
|
||||
Sub b_prodMenos_Click
|
||||
etCantHasFocus = False
|
||||
If WobbleMenu1.GetCurrentTab = 3 Then clv = clv_carrito Else clv = clv_prods_ll
|
||||
' Log(Sender.As(Button).text & "|" & Sender.As(Button).tag)
|
||||
Private buttonTag As String = Sender.As(Button).tag
|
||||
LogColor("b_prodMenos_Click", Colors.Magenta)
|
||||
Dim index As Int = clv.GetItemFromView(Sender)
|
||||
LogColor(clv.GetValue(index), Colors.Magenta)
|
||||
Private inv As Int = clv.GetValue(index).As(Map).Get("almacen")
|
||||
Dim pnl0 As B4XView = clv.GetPanel(index)
|
||||
Log(pnl0.As(Panel))
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(2)
|
||||
' Log(pnl.GetView(0).NumberOfViews)
|
||||
Dim elNombre As B4XView = pnl.GetView(1)
|
||||
If WobbleMenu1.GetCurrentTab = 3 Then laCant = pnl.GetView(2).GetView(4)
|
||||
Log($"${pnl.GetView(1)}${CRLF}${pnl.GetView(2).GetView(2)}${CRLF}${pnl.GetView(2).GetView(3)}${CRLF}${pnl.GetView(2).GetView(4)}"$)
|
||||
' Log($"precio|stock:${laCant.tag}"$)
|
||||
' Log("lacant.text="&laCant.text & "|" & buttonTag)
|
||||
If buttonTag = "vendido" And laCant.Text > 0 Then
|
||||
Log(clv.GetValue(index).As(Map))
|
||||
clv.GetValue(index).As(Map).Put("almacen",inv + 1)
|
||||
Log(clv.GetValue(index).As(Map))
|
||||
' clv.GetValue(index).As(Map).Get("almacen") = clv.GetValue(index).As(Map).Get("almacen") + 1
|
||||
End If
|
||||
If laCant.Text = "" Then laCant.Text = 0
|
||||
Log($"|${laCant.Text}|"$)
|
||||
laCant.Text = $"$1.0{laCant.Text-1}"$
|
||||
If laCant.Text < 0 Then laCant.Text = 0
|
||||
Private tmpMap As Map = clv.GetValue(index).As(Map)
|
||||
Private precio As String = clv.GetValue(index).As(Map).Get("precio")
|
||||
Private id As String=clv.GetValue(index).As(Map).Get("id")
|
||||
Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":Subs.traeAlmacen)
|
||||
' Log(tmpMap)
|
||||
prodsMap.Put(id, tmpMap)
|
||||
If laCant.Text = 0 Then prodsMap.Remove(id)
|
||||
' LogColor("prodsMap="&prodsMap, Colors.blue)
|
||||
' (Subs.traeAlmacen, p1.Get("precio"), p1.Get("cant"), pn, p, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, B4XPages.MainPage.tipo_venta)
|
||||
Private almacenX As String = Subs.traeAlmacen
|
||||
Private nombreX As String = Subs.traeProdNombre(id)
|
||||
Subs.actualizaProducto(almacenX, precio, laCant.text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov)
|
||||
cuentaProds
|
||||
Dim cs As CSBuilder
|
||||
cs.Initialize
|
||||
If WobbleMenu1.GetCurrentTab = 3 Then
|
||||
Private elTexto As String = clv.GetValue(index).As(Map).Get("prod")
|
||||
Private elPrecioU As String = clv.GetValue(index).As(Map).Get("precio")
|
||||
Private elTotal As String = elPrecioU * laCant.text
|
||||
elNombre.Text = cs.Color(Colors.red).append(elTexto).pop.append(CRLF).Color(0xFF017F01).Append($"Precio $${NumberFormat2(elTotal, 1, 2, 2, True)}"$).Popall
|
||||
End If
|
||||
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
||||
End Sub
|
||||
|
||||
Sub b_prodMas_Click
|
||||
etCantHasFocus = False
|
||||
If WobbleMenu1.GetCurrentTab = 3 Then clv = clv_carrito Else clv = clv_prods_ll
|
||||
Private buttonTag As String = Sender.As(Button).tag
|
||||
Dim index As Int = clv.GetItemFromView(Sender)
|
||||
LogColor("b_prodMas_Click", Colors.Magenta)
|
||||
Dim pnl0 As B4XView = clv.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(2)
|
||||
Dim elNombre As B4XView = pnl.GetView(1)
|
||||
If WobbleMenu1.GetCurrentTab = 3 Then laCant = pnl.GetView(2).GetView(4)
|
||||
Log($"${pnl.GetView(2).GetView(1)}${CRLF}${pnl.GetView(2).GetView(2)}${CRLF}${pnl.GetView(2).GetView(3)}${CRLF}${pnl.GetView(2).GetView(4)}"$)
|
||||
If laCant.Text = "" Then laCant.Text = 0
|
||||
' Private tmpMap As Map = clv.GetValue(index).As(Map)
|
||||
Private precio As String=clv.GetValue(index).As(Map).Get("precio")
|
||||
Private inv As Int = clv.GetValue(index).As(Map).Get("almacen")
|
||||
Log($"|${laCant.Text}, ${inv}"$)
|
||||
If buttonTag = "vendido" Then
|
||||
If inv > 0 And (laCant.Text + 1 <= inv) Then
|
||||
' Log(clv.GetValue(index).As(Map))
|
||||
clv.GetValue(index).As(Map).Put("almacen", (inv - 1))
|
||||
inv = inv - 1
|
||||
laCant.Text = $"$1.0{laCant.Text+1}"$
|
||||
' Log(clv.GetValue(index).As(Map))
|
||||
End If
|
||||
else If laCant.Text + 1 <= inv And lfila.Text = "PRODUCTOS" Then
|
||||
' LogColor(inv, Colors.blue)
|
||||
laCant.Text = $"$1.0{laCant.Text + 1}"$
|
||||
Log(Subs.totalPedido)
|
||||
End If
|
||||
Private id As String=clv.GetValue(index).As(Map).Get("id")
|
||||
Private almacenX As String = Subs.traeAlmacen
|
||||
Private nombreX As String = Subs.traeProdNombre(id)
|
||||
Private precioX As String = precio
|
||||
Subs.actualizaProducto(almacenX, precioX, laCant.text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov)
|
||||
cuentaProds
|
||||
Dim cs As CSBuilder
|
||||
cs.Initialize
|
||||
If WobbleMenu1.GetCurrentTab = 3 Then
|
||||
Private elTexto As String = clv.GetValue(index).As(Map).Get("prod")
|
||||
Private elPrecioU As String = clv.GetValue(index).As(Map).Get("precio")
|
||||
Private elTotal As String = elPrecioU * laCant.text
|
||||
elNombre.Text = cs.Color(Colors.red).append(elTexto).pop.append(CRLF).Color(0xFF017F01).Append($"Precio $${NumberFormat2(elTotal, 1, 2, 2, True)}"$).Popall
|
||||
End If
|
||||
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
||||
End Sub
|
||||
|
||||
Sub cuentaProds
|
||||
'LogColor($"Productos de la orden: ${c_prodsX.GetString("cantProds")}, Total: ${c_prodsX.GetString("costoTotal")}"$, Colors.red)
|
||||
' Log("===========================")
|
||||
Private c As Cursor = Starter.skmt.ExecQuery($"select sum(PE_COSTO_TOT) as total, sum(PE_CANT) as cant from PEDIDO where PE_CLIENTE IN (Select cuenta from cuentaa)"$)
|
||||
' LogColor("TIEMPO cuentaProds =" & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
||||
' LogColor(prodsMap, Colors.Magenta)
|
||||
p_botonesVenta.Visible = True
|
||||
p_botonesVenta.BringToFront
|
||||
c.Position=0
|
||||
' Log(Subs.totalPedido)
|
||||
Private cant0 As String = "0"
|
||||
Private total0 As String = "0"
|
||||
|
||||
If c.GetString("cant") <> Null And c.GetString("cant") <> "null" Then cant0 = c.GetString("cant")
|
||||
If c.GetString("total") <> Null And c.GetString("total") <> "null" Then total0 = c.GetString("total")
|
||||
|
||||
Log($"Total Prods: ${cant0}, Total Compra: $$1.2{total0}"$)
|
||||
l_totalCarrito.text = $"Total: $${NumberFormat2(total0,1,2,2,True)}"$
|
||||
c.Close
|
||||
If WobbleMenu1.GetCurrentTab = 3 Then LlenaProdsLL(Null, Null)
|
||||
If Subs.hayPedido Then WobbleMenu1.SetBadge(3, 1, Colors.white, Colors.red) Else WobbleMenu1.RemoveBadge(3)
|
||||
End Sub
|
||||
|
||||
Sub LlenaProdsLL(p As ResultSet, extra As String)
|
||||
' Log("LlenaProdsLL")
|
||||
listaProds.Initialize
|
||||
hayPedido = Subs.hayPedido
|
||||
' Log($"HAYPEDIDO: ${hayPedido}"$)
|
||||
If hayPedido Then 'Si hay pedido obtenemos las cantidades de los productos para agregarlos al CLV.
|
||||
Dim cantsMap As Map
|
||||
cantsMap.Initialize
|
||||
Dim pe As ResultSet = Starter.skmt.ExecQuery($"select PE_PROID, PE_CANT from PEDIDO where PE_CLIENTE = '${clienteId}' and PE_CEDIS = '${Subs.traeAlmacen}'"$)
|
||||
'Si EXTRA es igual a rmi, entonces regresamos los RMIs existentes.
|
||||
If extra = "rmi" Then pe = Starter.skmt.ExecQuery($"select PE_PROID, PE_CANT from PEDIDO where PE_CLIENTE = '${clienteId}' and PE_CEDIS = 'DUR'"$)
|
||||
' LogColor("Ponemos productos de pedido anterior: "&pe.RowCount, Colors.red)
|
||||
Do While pe.NextRow
|
||||
Private cant As Int = 0
|
||||
cantsMap.put(pe.GetString("PE_PROID"), pe.GetString("PE_CANT"))
|
||||
Loop
|
||||
' Log($"Con pedido: ${pe.RowCount}"$)
|
||||
' Log("CANTSMAP: " & cantsMap)
|
||||
pe.Close
|
||||
End If
|
||||
' Log(p.IsInitialized)
|
||||
If query = "" Or query = Null Then query = "cat_gunaprod2"
|
||||
If p.IsInitialized Then
|
||||
Log($"YA HAY RESULSET ${p.RowCount}"$)
|
||||
Else
|
||||
' Log("NO HAY RESULSET")
|
||||
Dim p As ResultSet = Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPOPROD, CAT_GP_IMG from cat_gunaprod where CAT_GP_PRECIO > 0 And CAT_GP_CLASIF <> 'PROMOS' order by CAT_GP_NOMBRE"$)
|
||||
End If
|
||||
' Log(p.RowCount)
|
||||
Do While p.NextRow
|
||||
Private cant As Int = 0
|
||||
Dim ins As InputStream
|
||||
Dim bmp As Bitmap
|
||||
Dim jpeg() As Byte
|
||||
jpeg = p.GetBlob("CAT_GP_IMG")
|
||||
ins.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
|
||||
bmp.Initialize2(ins)
|
||||
If hayPedido And cantsMap.ContainsKey(p.GetString("CAT_GP_ID")) Then cant = cantsMap.Get(p.GetString("CAT_GP_ID"))
|
||||
Dim tempMap As Map = CreateMap("prod":p.GetString("CAT_GP_NOMBRE"), "precio":p.GetString("CAT_GP_PRECIO"), "almacen":p.GetString("CAT_GP_ALMACEN"), "id":p.GetString("CAT_GP_ID"), "cant":cant, "img":bmp)
|
||||
listaProds.Add(tempMap)
|
||||
' Log($"${p.GetString("CAT_GP_ID")}, ${p.GetString("CAT_GP_NOMBRE")}, ${cant}"$)
|
||||
Loop
|
||||
p.Close
|
||||
|
||||
' Log("LISTAPRODS: " & listaProds)
|
||||
PCLV.Commit
|
||||
clv_prods_ll.Clear
|
||||
Private listaProdsConCant, listaProdsConCantIndex As List
|
||||
listaProdsConCant.Initialize
|
||||
listaProdsConCantIndex.Initialize
|
||||
listaHints.Initialize
|
||||
' Log(listaProds)
|
||||
For q = 0 To listaProds.Size - 1' Sacamos los productos con cantidad previa.
|
||||
If listaProds.Get(q).As(Map).Get("cant").As(Int) <> 0 Then
|
||||
' Log(listaProds.Get(q).As(Map).Get("prod"))
|
||||
listaProdsConCant.Add(listaProds.Get(q))
|
||||
listaProdsConCantIndex.Add(q)
|
||||
End If
|
||||
Next
|
||||
' Log("PRODCONCANT: " & listaProdsConCant)
|
||||
' Log(listaProdsConCantIndex)
|
||||
Private cont As Int = 0
|
||||
For pr0=0 To listaProdsConCant.Size - 1 'Agregamos los productos con cantidad previa.
|
||||
Private Pnl As B4XView = xui.CreatePanel("")
|
||||
Pnl.SetLayoutAnimated(0, 0, 0, clv_prods_ll.AsView.Width, 120dip)
|
||||
clv_prods_ll.Add(Pnl, listaProdsConCant.Get(pr0))
|
||||
listaHints.Add(listaProdsConCant.get(pr0).As(Map).Get("prod"))
|
||||
cont = cont + 1
|
||||
Next
|
||||
' LogColor(clv_prods_ll.Size, Colors.red)
|
||||
' Log(listaProds.Size)
|
||||
For pr = 0 To listaProds.Size - 1
|
||||
If listaProdsConCantIndex.IndexOf(pr) = -1 Then
|
||||
Private Pnl As B4XView = xui.CreatePanel("")
|
||||
If listaProds.Get(pr).As(Map).Get("almacen") < 1 Then
|
||||
' Log("EN CERO" & listaProds.Get(pr).As(Map).Get("prod") & "|" & listaProds.Get(pr).As(Map).Get("almacen"))
|
||||
Else
|
||||
Pnl.SetLayoutAnimated(0, 0, 0, clv_prods_ll.AsView.Width, 120dip)
|
||||
' Log(listaProds.Get(pr))
|
||||
clv_prods_ll.Add(Pnl, listaProds.Get(pr))
|
||||
listaHints.Add(listaProds.get(pr).As(Map).Get("prod"))
|
||||
cont = cont + 1
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
' LogColor(clv_prods_ll.Size, Colors.red)
|
||||
' PCLV.Commit
|
||||
' Log("CONT=" & cont)
|
||||
' Log("CLV_PRODSLL="&clv_prods_ll.Size)
|
||||
PCLV.B4XSeekBar1.MaxValue = clv_prods_ll.Size
|
||||
PCLV.B4XSeekBar1.MinValue = 0
|
||||
PCLV.B4XSeekBar1.Interval = clv_prods_ll.Size/20
|
||||
PCLV.B4XSeekBar1.Value = clv_prods_ll.Size
|
||||
PCLV.B4XSeekBar1.Update
|
||||
' Log($"Min:0, max:${clv_prods_ll.Size}, Interval:${clv_prods_ll.Size/20}"$)
|
||||
reiniciarlistaProds = False
|
||||
End Sub
|
||||
|
||||
Private Sub clv_prods_ll_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
|
||||
' Private inicioContador As String = DateTime.Now
|
||||
' Log($"clv_prods_ll_VisibleRangeChanged : ${FirstIndex}, ${LastIndex} "$)
|
||||
Dim ExtraSize As Int = 30 'List size
|
||||
For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, clv_prods_ll.Size - 1)
|
||||
Dim Pnl As B4XView = clv_prods_ll.GetPanel(i)
|
||||
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
|
||||
' Log(listaRenglones)
|
||||
If Pnl.NumberOfViews = 0 Then 'Add each item/layout to the list/main layout
|
||||
Pnl.LoadLayout("proditem")
|
||||
' p_botMasMen.Left = (p_prods.Width * 0.66) - (p_botMasMen.Width / 2)
|
||||
p_prods.Width = Root.Width * 0.92
|
||||
' p_botMasMen.Left = p_prods.Width - (p_botMasMen.Width + 5)
|
||||
' Log(Root.Width)
|
||||
p_botMasMen.Left = (p_prods.Width - i_prod.Width) - (p_botMasMen.Width / 2)
|
||||
' Log(p_botMasMen.left)
|
||||
Private cs As CSBuilder
|
||||
cs.Initialize
|
||||
l_prodX.SetTextSizeAnimated(0, 13)
|
||||
If clv_prods_ll.GetValue(i).As(Map).Get("cant") <> Null And clv_prods_ll.GetValue(i).As(Map).Get("cant") > 0 Then
|
||||
p_prods.Color=0xFFE2EEFF
|
||||
et_pCant.TextColor=Colors.Red
|
||||
' Log("VENDIDO ")
|
||||
b_prodMenos.Tag = "vendido"
|
||||
b_prodMas.Tag = "vendido"
|
||||
End If
|
||||
Private precio As String=NumberFormat2(clv_prods_ll.GetValue(i).As(Map).Get("precio").As(Double),1,2,2,False)
|
||||
If clv_prods_ll.GetValue(i).As(Map).Get("cant") <> Null Then et_pCant.Text = clv_prods_ll.GetValue(i).As(Map).Get("cant")
|
||||
l_prodX.Text = cs.Color(Colors.red).append(clv_prods_ll.GetValue(i).As(Map).Get("prod")).pop.append(CRLF).Color(0xFF017F01).Append($"Precio $${NumberFormat2(precio, 1, 2, 2, True)}"$).Popall
|
||||
l_prodX.Tag = clv_prods_ll.GetValue(i).As(Map).Get("almacen")
|
||||
l_pCant.Tag = clv_prods_ll.GetValue(i).As(Map).Get("id")
|
||||
' Log(clv_prods_ll.GetValue(i).As(Map).Get("id"))
|
||||
' Private rs_img As ResultSet = Starter.skmt.ExecQuery($"select CAT_GP_IMG from cat_gunaprod where CAT_GP_ID = '${clv_prods_ll.GetValue(i).As(Map).Get("id")}'"$)
|
||||
i_prod.Bitmap = clv_prods_ll.GetValue(i).As(Map).Get("img")
|
||||
End If
|
||||
' Log($"${i}, ${FirstIndex}, ${LastIndex}, ${Pnl.NumberOfViews}. ${clv_prods_ll.Size}"$)
|
||||
Else 'Not visible
|
||||
' If Pnl.NumberOfViews > 0 Then
|
||||
' Pnl.RemoveAllViews 'Remove none visable item/layouts from the list/main layout
|
||||
' End If
|
||||
End If
|
||||
PCLV.B4XSeekBar1.Value = clv_prods_ll.Size - FirstIndex
|
||||
' Log($"Bar value: ${PCLV.B4XSeekBar1.Value}"$)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Sub et_busca_TextChanged (Old As String, New As String)
|
||||
' Private inicioContador As String = DateTime.Now
|
||||
If (New.Length = 1 Or New.Length = 2) And Not(forzarBusqueda) Then Return
|
||||
forzarBusqueda = False
|
||||
If lfila.text = "PROMOCIONES" Then
|
||||
If Not(lv_promos.Visible) Then lv_promos.Visible = True
|
||||
Private cPromo As Cursor=Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from ${query} where CAT_GP_NOMBRE like '%${New}%' and CAT_GP_ALMACEN > 0 AND CAT_GP_TIPO = 'PROMOS' AND CAT_GP_SUBTIPO = 'PROMOS' AND CAT_GP_TIPOPROD <> 1 and (length(CAT_GP_CODPROMO) = 1 OR CAT_GP_CODPROMO = CAT_GP_ID)"$)
|
||||
Log($"res:${cPromo.RowCount}"$)
|
||||
If cPromo.RowCount > 0 Then
|
||||
lv_promos.Clear
|
||||
For i=0 To cPromo.RowCount -1
|
||||
cPromo.Position=i
|
||||
Private tm As Map = Subs.procesaPromocion(cPromo.GetString("CAT_GP_ID"), clienteId)
|
||||
If tm.Get("status") = "ok" Then 'Solo muestrala si hay producto.
|
||||
lv_promos.AddTwoLines(cPromo.GetString("CAT_GP_NOMBRE"),"# " & cPromo.GetString("CAT_GP_ALMACEN") & " $ " & cPromo.GetString("CAT_GP_PRECIO") & " F:" & tm.Get("mp").As(Map).Get("prodsFijosCant") & " V:" & tm.Get("mp").As(Map).Get("prodsVariablesCant"))
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
ToastMessageShow("No hay promociones disponibles.", False)
|
||||
End If
|
||||
cPromo.Close
|
||||
Else
|
||||
If Not(clv_prods_ll.AsView.Visible) Then clv_prods_ll.AsView.Visible = True
|
||||
clv_prods_ll.Clear
|
||||
listaProds.Initialize
|
||||
listaHints.Initialize
|
||||
Sleep(0)
|
||||
Dim p As ResultSet = Starter.skmt.ExecQuery($"Select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPOPROD, CAT_GP_IMG from cat_gunaprod where CAT_GP_NOMBRE like '%${New}%' and CAT_GP_PRECIO > 0 And CAT_GP_CLASIF <> 'PROMOS' order by CAT_GP_NOMBRE"$)
|
||||
Log($"Llamamos LlenaProdsLL con ${p.RowCount} registros"$)
|
||||
LlenaProdsLL(p, Null)
|
||||
p.Close
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub llenaCarrito
|
||||
Private totalPedido As String = 0
|
||||
Private cantPedido As String = 0
|
||||
lv_promos.Visible = False
|
||||
Subs.agrupador
|
||||
' lv_carrito.Clear
|
||||
clv_carrito.Clear
|
||||
list_prodsPedido.Initialize
|
||||
Private c_prods As Cursor=Starter.skmt.ExecQuery("select PE_PRONOMBRE,PE_COSTO_TOT, PE_COSTOU, PE_CANT, PE_FOLIO, PE_CEDIS, PE_PROID FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order by PE_CEDIS, PE_PRONOMBRE")
|
||||
' Log(c_prods.RowCount)
|
||||
If c_prods.RowCount > 0 Then
|
||||
c_prods.Position = 0
|
||||
' lv_carrito.BringToFront
|
||||
clv_carrito.AsView.BringToFront
|
||||
Private cs As CSBuilder
|
||||
For i = 0 To c_prods.RowCount -1
|
||||
cs.Initialize
|
||||
c_prods.Position = i
|
||||
' Dim label1 As Label
|
||||
' lv_carrito.TwoLinesLayout.ItemHeight = 50dip
|
||||
' label1 = lv_carrito.TwoLinesLayout.Label
|
||||
' label1.TextSize = 15
|
||||
' label1.TextColor = Colors.Black
|
||||
' label1.color = Colors.White
|
||||
' label1.Height = 30dip
|
||||
Private textColor As Int = Colors.black
|
||||
' Log(c_prods.GetString("PE_CEDIS"))
|
||||
If Not(IsNumber(c_prods.GetString("PE_CEDIS"))) Then textColor = Colors.RGB(210,105,30) 'Si es promo, cambiamos el color del texto.
|
||||
If c_prods.GetString("PE_CEDIS") = "DUR" Then textColor = Colors.red 'Si es promo, cambiamos el color del texto.
|
||||
' Dim label2 As Label
|
||||
' label2 = lv_carrito.TwoLinesLayout.SecondLabel
|
||||
' label2.TextSize = 10
|
||||
' label2.TextColor = Colors.Blue
|
||||
' label2.Tag = i
|
||||
' Log(c_prods.GetString("PE_PRONOMBRE"))
|
||||
' lv_carrito.AddTwoLines(cs.Color(textColor).append(c_prods.GetString("PE_PRONOMBRE")).pop,"Cantidad #"& c_prods.GetString("PE_CANT")& " SubTotal $"& c_prods.GetString("PE_COSTO_TOT")& " Folio "& c_prods.GetString("PE_FOLIO"))
|
||||
Private tempMap As Map = CreateMap("prod":c_prods.GetString("PE_PRONOMBRE"), "almacen":1000, "id": c_prods.GetString("PE_PROID"), "cant": c_prods.GetString("PE_CANT"), "precio": c_prods.GetString("PE_COSTOU"), "precioT": c_prods.GetString("PE_COSTO_TOT"))
|
||||
list_prodsPedido.Add(tempMap)
|
||||
Private bmp As Bitmap = Subs.traeImgDeDB(c_prods.GetString("PE_PROID"))
|
||||
' Private elTexto As String = cs.Color(Colors.red).append(c_prods.GetString("PE_PRONOMBRE")).pop.append(CRLF).Color(0xFF017F01).Append($"Precio $${NumberFormat2(c_prods.GetString("PE_COSTO_TOT"), 1, 2, 2, True)}"$).Popall
|
||||
clv_carrito.Add(CreateListItem(c_prods.GetString("PE_PRONOMBRE"), c_prods.GetString("PE_CANT"), c_prods.GetString("PE_COSTO_TOT"), 1000, clv_carrito.AsView.Width, 150dip, bmp, c_prods.GetString("PE_PROID")), tempMap)
|
||||
folio = 0
|
||||
totalPedido = totalPedido + (c_prods.GetString("PE_COSTOU") * c_prods.GetString("PE_CANT"))
|
||||
cantPedido = cantPedido + c_prods.GetString("PE_CANT")
|
||||
If c_prods.GetString("PE_FOLIO") <> Null Then folio = c_prods.GetString("PE_FOLIO")
|
||||
Next
|
||||
Else
|
||||
l_carritoVacio.Visible = True
|
||||
l_carritoVacio.Text = "No hay productos en tu carrito."
|
||||
End If
|
||||
' Log(list_prodsPedido)
|
||||
c_prods.Close
|
||||
' l_total2.Text = $"$1.2{totalPedido}"$
|
||||
' l_cant.Text = cantPedido
|
||||
' If Subs.revisaImpresa Then b_rechazar.Visible = False Else b_rechazar.Visible = True
|
||||
' p_vistaPreviaTrans.Width = Root.Width
|
||||
' p_vistaPreviaTrans.Height = Root.Height
|
||||
' Subs.centraPanel(p_vistaPrevia, Root.Width)
|
||||
' p_vistaPrevia.Visible=True
|
||||
' p_vistaPreviaTrans.Visible=True
|
||||
End Sub
|
||||
|
||||
'Return the hint that will be displayed when the user fast scrolls the list. It can be a string or CSBuilder.
|
||||
Sub PCLV_HintRequested(Index As Int) As Object
|
||||
Dim word As String = listaHints.get(Index)
|
||||
Return word
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Private Sub WobbleMenu1_Tab1Click
|
||||
Subs.panelVisible(p_productos, 0, 0)
|
||||
p_productos.Height = Root.Height - WobbleMenu1.Height
|
||||
p_promos.Visible = False
|
||||
p_carrito.Visible = False
|
||||
p_historial.Visible = False
|
||||
End Sub
|
||||
|
||||
Private Sub WobbleMenu1_Tab2Click
|
||||
Subs.panelVisible(p_promos, 0, 0)
|
||||
p_productos.Visible = False
|
||||
p_carrito.Visible = False
|
||||
p_historial.Visible = False
|
||||
End Sub
|
||||
|
||||
Private Sub WobbleMenu1_Tab3Click
|
||||
Subs.panelVisible(p_carrito, 0, 0)
|
||||
' p_carrito.BringToFront
|
||||
p_productos.Visible = False
|
||||
p_promos.Visible = False
|
||||
p_historial.Visible = False
|
||||
l_carritoVacio.Visible = False
|
||||
l_compraTerminada.Visible = False
|
||||
llenaCarrito
|
||||
If clv_carrito.Size > 0 Then p_botonesCarrito.Visible = True Else p_botonesCarrito.Visible = False
|
||||
End Sub
|
||||
|
||||
Private Sub WobbleMenu1_Tab4Click
|
||||
Subs.panelVisible(p_historial, 0, 0)
|
||||
p_productos.Visible = False
|
||||
p_carrito.Visible = False
|
||||
p_promos.Visible = False
|
||||
llenaHistorial
|
||||
End Sub
|
||||
|
||||
Private Sub b_continuar_Click
|
||||
WobbleMenu1.SetCurrentTab(2)
|
||||
End Sub
|
||||
|
||||
Private Sub p_botonesVenta_Click
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub lv_promos_ItemClick (Position As Int, Value As Object)
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub p_promos_Click
|
||||
'Para evitar que el clic en pantalla no se siga hacia atras
|
||||
End Sub
|
||||
|
||||
Private Sub p_historial_Click
|
||||
'Para evitar que el clic en pantalla no se siga hacia atras
|
||||
End Sub
|
||||
|
||||
Private Sub p_carrito_Click
|
||||
'Para evitar que el clic en pantalla no se siga hacia atras
|
||||
End Sub
|
||||
|
||||
Private Sub b_buscar_Click
|
||||
forzarBusqueda = True
|
||||
et_busca_TextChanged("",et_busca.Text)
|
||||
End Sub
|
||||
|
||||
Private Sub b_continuar2_Click
|
||||
WobbleMenu1.SetCurrentTab(3)
|
||||
End Sub
|
||||
|
||||
Private Sub b_terminar_Click
|
||||
DateTime.DateFormat= $"yyMMdd-HHmmss-${clienteId}"$
|
||||
Private id As String = DateTime.Date(DateTime.Now)
|
||||
Starter.skmt.ExecNonQuery($"insert into cat_hist_compras (H_IDCOMPRA, H_FOLIO, H_RUTA, H_CEDIS, H_COSTO_TOT, H_COSTOU, H_CANT, H_PRONOMBRE, H_PROID, H_CLIENTE, H_FECHA) select '${id}', PE_FOLIO, PE_RUTA, PE_CEDIS, PE_COSTO_TOT, PE_COSTOU, PE_CANT, PE_PRONOMBRE, PE_PROID, PE_CLIENTE, PE_FECHA from pedido where pe_cliente = '${clienteId}'"$)
|
||||
Starter.skmt.ExecNonQuery($"delete from pedido where pe_cliente = '${clienteId}'"$)
|
||||
' lv_carrito.Clear
|
||||
clv_carrito.Clear
|
||||
' et_busca_TextChanged("", et_busca.Text)
|
||||
LlenaProdsLL(Null, Null)
|
||||
l_compraTerminada.Text = $"¡Felicidades!${CRLF}${CRLF}Tu compra con número de orden ${id} ha sido registrada.${CRLF}${CRLF}Llegará en tu siguiente día de entrega."$
|
||||
l_compraTerminada.Visible = True
|
||||
l_compraTerminada.BringToFront
|
||||
l_totalCarrito.Text = ""
|
||||
End Sub
|
||||
|
||||
Sub llenaHistorial
|
||||
Dim rs_hist As ResultSet = Starter.skmt.ExecQuery($"Select h_idcompra, sum(h_costo_tot) as total, sum(h_cant) as cantidad, h_fecha from cat_hist_compras group by h_idcompra"$)
|
||||
If rs_hist.RowCount > 0 Then
|
||||
' c_prods.Position = 0
|
||||
' l_total2.Text = c_prods.GetString("PE_COSTO_TOT")
|
||||
' lv_historial.BringToFront
|
||||
Private cs As CSBuilder
|
||||
Do While rs_hist.NextRow
|
||||
' Private rs_do As ResultSet = Starter.skmt.ExecQuery($"select * from CAT_HIST_COMPRAS where H_IDCOMPRA = '${rs_hist.GetString("H_IDCOMPRA")}'"$)
|
||||
cs.Initialize
|
||||
Dim label1 As Label
|
||||
' lv_historial.TwoLinesLayout.ItemHeight = 50dip
|
||||
label1 = lv_historial.TwoLinesLayout.Label
|
||||
label1.TextSize = 16
|
||||
label1.TextColor = Colors.red
|
||||
label1.color = Colors.White
|
||||
label1.Height = 30dip
|
||||
' Private textColor As Int = Colors.black
|
||||
Dim label2 As Label
|
||||
label2 = lv_historial.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 14
|
||||
label2.TextColor = Colors.RGB(1,127,1)
|
||||
' Do While rs_do.NextRow
|
||||
' Log($"${rs_do.GetString("H_IDCOMPRA")}, ${rs_do.GetString("H_PRONOMBRE")}, ${rs_do.GetString("H_CANT")}"$)
|
||||
' Loop
|
||||
Private fecha = rs_hist.GetString("H_FECHA")
|
||||
fecha = fecha.SubString2(1,10)
|
||||
lv_historial.AddTwoLines("Orden: " & rs_hist.GetString("H_IDCOMPRA"), $"Fecha: ${fecha}, Productos: ${rs_hist.GetString("cantidad")}, Total: $${NumberFormat2(rs_hist.GetString("total"), 1, 2, 2, True)}"$)
|
||||
' totalPedido = totalPedido + (rs_hist.GetString("PE_COSTOU") * rs_hist.GetString("PE_CANT"))
|
||||
' cantPedido = cantPedido + rs_hist.GetString("PE_CANT")
|
||||
Loop
|
||||
' Private c As Cursor = Starter.skmt.ExecQuery("select pc_noart, pc_monto from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||
' c.Position=0
|
||||
'' l_cant.Text = c.GetString("PC_NOART")
|
||||
' c.Close
|
||||
Else
|
||||
l_historialVacio.Visible = True
|
||||
l_historialVacio.Text = "No hay ordenes en tu historial."
|
||||
End If
|
||||
rs_hist.Close
|
||||
End Sub
|
||||
|
||||
Sub CreateListItem(Text As String, cant As Int, precioU As String, inv As Int, Width As Int, Height As Int, img As Bitmap, prodId As String) As Panel
|
||||
Dim p As B4XView = xui.CreatePanel("")
|
||||
Dim cs As CSBuilder
|
||||
cs.Initialize
|
||||
p.SetLayoutAnimated(0, 0, 0, Width, Height)
|
||||
p.LoadLayout("prodItemCarrito")
|
||||
i_prod.Bitmap = img
|
||||
l_prodX.TextSize = 15
|
||||
p_prods.Height = Height
|
||||
p_prods.Width = Width - 10
|
||||
' Log($"${clv_carrito.AsView.Width}, ${Root.Width}, ${p_prods.Width}"$)
|
||||
p_botMasMen.Left = p_prods.Width - (p_botMasMen.Width + 30)
|
||||
l_prodX.Height = Height
|
||||
l_prodX.Text = Text&CRLF&"# " & inv & " $ " & precioU
|
||||
l_prodX.Text = cs.Color(Colors.red).append(Text).pop.append(CRLF).Color(0xFF017F01).Append($"Precio $${NumberFormat2(precioU, 1, 2, 2, True)}"$).Popall
|
||||
l_prodX.Tag = $"ID: ${prodId}${CRLF}${Text}${CRLF}Precio: $$1.2{precioU}${CRLF}Inv: ${inv} pzs"$
|
||||
l_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
||||
et_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
||||
et_pCant.Text = cant
|
||||
et_pCant.BringToFront
|
||||
Return p
|
||||
End Sub
|
||||
|
||||
Private Sub b_borrar_Click
|
||||
clv = clv_carrito
|
||||
Private buttonTag As String = Sender.As(Button).tag
|
||||
Dim index As Int = clv.GetItemFromView(Sender)
|
||||
Msgbox2Async("¿Seguro que deseas borrar este producto?", "Borrar Producto", "Si", "", "No", Null, False)
|
||||
Wait For Msgbox_Result (Result As Int)
|
||||
If Result = DialogResponse.POSITIVE Then
|
||||
LogColor("b_borrar_Click", Colors.Magenta)
|
||||
Private precio As String=clv.GetValue(index).As(Map).Get("precio")
|
||||
Private inv As Int = clv.GetValue(index).As(Map).Get("almacen")
|
||||
Dim pnl0 As B4XView = clv.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(2)
|
||||
If WobbleMenu1.GetCurrentTab = 3 Then laCant = pnl.GetView(2).GetView(4)
|
||||
Log(laCant.text)
|
||||
laCant.Text = "0"
|
||||
Private id As String=clv.GetValue(index).As(Map).Get("id")
|
||||
Private almacenX As String = Subs.traeAlmacen
|
||||
Private nombreX As String = Subs.traeProdNombre(id)
|
||||
Private precioX As String = precio
|
||||
Subs.actualizaProducto(almacenX, precioX, laCant.text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov)
|
||||
' Log($"${almacenX}, ${precioX}, ${laCant.text}, ${nombreX}, ${id}, ${clienteId}, ${Subs.traeFecha}, ${Subs.traeUsuarioDeBD}, ${rutaUsuario}, 0, ${Starter.tipov}"$)
|
||||
cuentaProds
|
||||
llenaCarrito
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub lv_historial_ItemClick (Position As Int, Value As Object)
|
||||
|
||||
End Sub
|
||||
277
B4A/DBRequestManager.bas
Normal file
@@ -0,0 +1,277 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=6.8
|
||||
@EndOfDesignText@
|
||||
'Necesita la libreria RandomAccessFile
|
||||
|
||||
'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
|
||||
Dim logger As Boolean = False
|
||||
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
|
||||
Dim In As InputStream = Job.GetInputStream
|
||||
Dim cs As CompressedStreams
|
||||
If Starter.Logger Then logger = Starter.Logger
|
||||
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
|
||||
|
||||
|
||||
BIN
B4A/Files/candado.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
B4A/Files/durakelo.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
B4A/Files/engrane.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
B4A/Files/engranes.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
B4A/Files/kmt.db
Normal file
BIN
B4A/Files/login.bal
Normal file
BIN
B4A/Files/logo.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
B4A/Files/mainpage.bal
Normal file
BIN
B4A/Files/principal.bal
Normal file
BIN
B4A/Files/proditem.bal
Normal file
BIN
B4A/Files/proditemcarrito.bal
Normal file
BIN
B4A/Files/usuario.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 15 KiB |
121
B4A/MarketPlace.b4a
Normal file
@@ -0,0 +1,121 @@
|
||||
Build1=Default,mp.keymon.lat,HU2_PUBLIC
|
||||
File1=candado.png
|
||||
File10=principal.bal
|
||||
File11=proditem.bal
|
||||
File12=proditemCarrito.bal
|
||||
File13=usuario.png
|
||||
File14=vecteezy_white-diagonal-stripes-with-red-line-isolated-on-white_12833309-[Convertido].png
|
||||
File2=durakelo.png
|
||||
File3=engrane.png
|
||||
File4=engranes.png
|
||||
File5=fondoblanco.png
|
||||
File6=kmt.db
|
||||
File7=login.bal
|
||||
File8=logo.png
|
||||
File9=MainPage.bal
|
||||
FileGroup1=Default Group
|
||||
FileGroup10=Default Group
|
||||
FileGroup11=Default Group
|
||||
FileGroup12=Default Group
|
||||
FileGroup13=Default Group
|
||||
FileGroup14=Default Group
|
||||
FileGroup2=Default Group
|
||||
FileGroup3=Default Group
|
||||
FileGroup4=Default Group
|
||||
FileGroup5=Default Group
|
||||
FileGroup6=Default Group
|
||||
FileGroup7=Default Group
|
||||
FileGroup8=Default Group
|
||||
FileGroup9=Default Group
|
||||
Group=Default Group
|
||||
Library1=appupdating
|
||||
Library10=wobblemenu
|
||||
Library11=preoptimizedclv
|
||||
Library2=b4xpages
|
||||
Library3=byteconverter
|
||||
Library4=compressstrings
|
||||
Library5=core
|
||||
Library6=json
|
||||
Library7=okhttputils2
|
||||
Library8=randomaccessfile
|
||||
Library9=sql
|
||||
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~<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="31"/>~\n~<supports-screens android:largeScreens="true" ~\n~ android:normalScreens="true" ~\n~ android:smallScreens="true" ~\n~ android:anyDensity="true"/>)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~CreateResourceFromFile(Macro, Themes.LightTheme)~\n~'End of default text.~\n~~\n~SetApplicationAttribute(android:usesCleartextTraffic, "true")
|
||||
Module1=B4XMainPage
|
||||
Module2=C_Principal
|
||||
Module3=DBRequestManager
|
||||
Module4=errorManager
|
||||
Module5=Starter
|
||||
Module6=Subs
|
||||
NumberOfFiles=14
|
||||
NumberOfLibraries=11
|
||||
NumberOfModules=6
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
#Region Project Attributes
|
||||
#ApplicationLabel: MarketPlace
|
||||
#VersionCode: 1
|
||||
#VersionName: 3.07.20
|
||||
'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.
|
||||
24
B4A/MarketPlace.b4a.meta
Normal file
@@ -0,0 +1,24 @@
|
||||
ModuleBookmarks0=
|
||||
ModuleBookmarks1=
|
||||
ModuleBookmarks2=
|
||||
ModuleBookmarks3=
|
||||
ModuleBookmarks4=
|
||||
ModuleBookmarks5=
|
||||
ModuleBookmarks6=
|
||||
ModuleBreakpoints0=
|
||||
ModuleBreakpoints1=
|
||||
ModuleBreakpoints2=
|
||||
ModuleBreakpoints3=
|
||||
ModuleBreakpoints4=
|
||||
ModuleBreakpoints5=
|
||||
ModuleBreakpoints6=
|
||||
ModuleClosedNodes0=
|
||||
ModuleClosedNodes1=1,2
|
||||
ModuleClosedNodes2=1,4,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,23,24,25,28
|
||||
ModuleClosedNodes3=14
|
||||
ModuleClosedNodes4=
|
||||
ModuleClosedNodes5=6
|
||||
ModuleClosedNodes6=47,48,51,52,53,54,55,58,59
|
||||
NavigationStack=C_Principal,b_prodMenos_Click,215,6,C_Principal,Class_Globals,44,0,C_Principal,b_terminar_Click,614,6,C_Principal,b_borrar_Click,708,0,Visual Designer,principal.bal,-100,6,Main,Globals,20,0,Main,Process_Globals,18,0,B4XMainPage,B4XPage_Created,40,0,C_Principal,WobbleMenu1_Tab3Click,561,6,C_Principal,B4XPage_Created,80,0,C_Principal,JobDone,161,0
|
||||
SelectedBuild=0
|
||||
VisibleModules=1,5,6,2
|
||||
118
B4A/Starter.bas
Normal file
@@ -0,0 +1,118 @@
|
||||
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 skmt, errorLog As SQL
|
||||
Dim server, ruta As String
|
||||
'Para los Logs
|
||||
Dim logs As StringBuilder
|
||||
Private logcat As LogCat
|
||||
Dim Logger As Boolean
|
||||
Dim rutav As String = ""
|
||||
Dim tipov As String = "VENTA"
|
||||
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.
|
||||
If Logger Then LogColor("'/////////////////////////////////////////////////////////////////////////////////////////////", Colors.Green)
|
||||
If Logger Then LogColor("'///////////////////////////////////// Iniciamos Starter /////////////////////////////////", Colors.Green)
|
||||
If Logger Then LogColor("'/////////////////////////////////////////////////////////////////////////////////////////////", Colors.Green)
|
||||
ruta = File.DirInternal
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
'Para los Logs
|
||||
#if RELEASE
|
||||
logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
|
||||
#end if
|
||||
logs.Initialize
|
||||
server = "http://keymon.lat:1787"
|
||||
If Logger Then Log($"Starter reqManager server: ${server}"$)
|
||||
Logger = False
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
||||
reqManager.Initialize(Me, server)
|
||||
Subs.revisaBD
|
||||
#if DEBUG
|
||||
Logger = True
|
||||
#else
|
||||
Logger = False
|
||||
#End If
|
||||
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. 'Para los Logs
|
||||
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
|
||||
'wait for 500ms to allow the logs to be updated.
|
||||
Dim jo As JavaObject
|
||||
Dim l As Long = 500: jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l)) 'Sleep 500ms
|
||||
logcat.LogCatStop
|
||||
logs.Initialize
|
||||
logs.Append("Ver " & Application.VersionName & CRLF)
|
||||
logs.Append("R:" & rutav & CRLF)
|
||||
logs.Append(StackTrace)
|
||||
Subs.revisaBD
|
||||
Subs.errorLog.ExecNonQuery2("INSERT INTO errores(fecha, error) VALUES (?,?)", Array As Object (Subs.fechaKMT(DateTime.now), logs))
|
||||
StartActivity(errorManager)
|
||||
Return True
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
' Timer1.Enabled=False
|
||||
If Logger Then LogColor("starter destroyed", Colors.red)
|
||||
End Sub
|
||||
|
||||
Sub reinicializaReqManager
|
||||
reqManager.Initialize(Me, server)
|
||||
If Logger Then Log(server)
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
LogColor("Starter - JobDone", Colors.Magenta)
|
||||
If Job.Success = False Then
|
||||
' ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Else
|
||||
If Logger Then LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211110
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||
If result.Tag = "updateKell_UTR" Then 'query tag
|
||||
If Logger Then Subs.logJobDoneResultados(result)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End Sub
|
||||
|
||||
'Para los Logs
|
||||
Private Sub logcat_LogCatData (Buffer() As Byte, Length As Int)
|
||||
logs.Append(BytesToString(Buffer, 0, Length, "utf8"))
|
||||
If logs.Length > 4000 Then
|
||||
logs.Remove(0, logs.Length - 2000) 'Obtenemos log de 2000 ~ 4000 chars
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Revisa que la conexion a la base de datos este bien.
|
||||
Sub revisaBD 'ignore
|
||||
If Logger Then Log("revisaBD")
|
||||
If Not(File.Exists(ruta, "kmt.db")) Then File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
If Not(skmt.IsInitialized) Then skmt.Initialize(ruta, "kmt.db", True)
|
||||
End Sub
|
||||
1341
B4A/Subs.bas
Normal file
167
B4A/errorManager.bas
Normal file
@@ -0,0 +1,167 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=10.2
|
||||
@EndOfDesignText@
|
||||
#Region Activity Attributes
|
||||
#FullScreen: False
|
||||
#IncludeTitle: True
|
||||
#End Region
|
||||
'******************************************************************************
|
||||
'Este modulo intercepta los errores de la aplicación mediante "Starter.Application_Error" y muestra una pantalla
|
||||
'con el log del error y lo manda al servidor con un query de DBRequestManager, se necesita que exista el query
|
||||
'en el "config.properties" llamado "guardaErrores" y que tenga el siguiente texto:
|
||||
'
|
||||
'sql.guardaErrores=INSERT INTO KELLOGGS.PUSH_INFO (ID, RUTA, FECHA, DATOS) VALUES((?),(?),(?),(?))
|
||||
'
|
||||
'Agregar estas lineas a "Starter.Process_Globals"
|
||||
' 'Para los Logs
|
||||
' Dim logs As StringBuilder
|
||||
' Private logcat As LogCat
|
||||
'
|
||||
'Agregar estas lineas a "Starter.Service_Create"
|
||||
' 'Para los Logs
|
||||
' #if RELEASE
|
||||
' logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
|
||||
' #end if
|
||||
' logs.Initialize
|
||||
'
|
||||
'Agregar este Sub a "Starter"
|
||||
'
|
||||
'Return true to allow the OS default exceptions handler to handle the uncaught exception. 'Para los Logs
|
||||
'Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
|
||||
' 'wait for 500ms to allow the logs to be updated.
|
||||
' Dim jo As JavaObject
|
||||
' Dim l As Long = 500: jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l)) 'Sleep 500ms
|
||||
' logcat.LogCatStop
|
||||
' logs.Append(StackTrace)
|
||||
' Subs.revisaBD
|
||||
' Subs.errorLog.ExecNonQuery2("INSERT INTO errores(fecha, error) VALUES (?,?)", Array As Object (Subs.fechaKMT(DateTime.now), logs))
|
||||
' StartActivity(errorManager)
|
||||
' Return True
|
||||
'End Sub
|
||||
'******************************************************************************
|
||||
|
||||
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 Globals
|
||||
'These global variables will be redeclared each time the activity is created.
|
||||
'These variables can only be accessed from this module.
|
||||
' Dim errorLog As SQL
|
||||
Dim c As Cursor
|
||||
Private p_principal As Panel
|
||||
Private l_titulo As Label
|
||||
Private svScroll As ScrollView
|
||||
Private etText As EditText
|
||||
Private c_continuar As Button
|
||||
Private p_botones As Panel
|
||||
Private b_salir As Button
|
||||
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("errorManager")
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
Dim elError As String = ""
|
||||
Dim laFecha As String = ""
|
||||
' svScroll.Initialize(500dip)
|
||||
' Activity.AddView(svScroll, 0, 300, 100%x, 80%y)
|
||||
p_principal.Height = Activity.Height
|
||||
p_principal.Width = Activity.Width
|
||||
svScroll.Width = Round(p_principal.Width * 0.9)
|
||||
svScroll.Left = Round(p_principal.Width/2)-Round(svScroll.Width/2)
|
||||
p_botones.Left = Round(p_principal.Width/2)-Round(p_botones.Width/2)
|
||||
p_botones.Top = Activity.Height - (p_botones.Height + 80)
|
||||
etText.Initialize("")
|
||||
svScroll.Panel.AddView(etText, 0, 0, 90%x, 80%y)
|
||||
etText.InputType = etText.INPUT_TYPE_NONE
|
||||
etText.Gravity = Gravity.TOP
|
||||
etText.SingleLine = False
|
||||
etText.Wrap = False
|
||||
' Dim lblText, edtText As StringBuilder
|
||||
Dim lbl As Label
|
||||
lbl.Initialize("")
|
||||
Activity.AddView(lbl, 0, 300, 100%x, 100%y) 'ignore
|
||||
etText.Text = ""
|
||||
Subs.revisaBD
|
||||
c = Subs.errorLog.ExecQuery("select * from errores order by fecha desc limit 1")
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
elError = c.GetString("error")
|
||||
laFecha = c.GetString("fecha")
|
||||
etText.Text = elError
|
||||
End If
|
||||
c.Close
|
||||
Dim usuario As String = ""
|
||||
c = Starter.skmt.ExecQuery("select usuario from usuarioa")
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
usuario = c.GetString("USUARIO")
|
||||
End If
|
||||
|
||||
' Log("++++++" & Starter.logsStr)
|
||||
' etText.Text = etText.Text & Starter.logsStr
|
||||
' lbl.TextSize = etText.TextSize
|
||||
' lbl.Text = etText.Text
|
||||
' Dim su As StringUtils
|
||||
' Dim edheight As Int = su.MeasureMultilineTextHeight(lbl, lbl.Text)
|
||||
' lbl.RemoveView
|
||||
' etText.Height = edheight
|
||||
' svScroll.Panel.Height = edheight
|
||||
svScroll.Height = Round(Activity.Height * 0.9)
|
||||
' Log(edheight)
|
||||
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "guardaErrores"
|
||||
cmd.Parameters = Array As Object(laFecha, usuario&"|"&Starter.rutaV, laFecha, elError)
|
||||
Log($"Mandamos: ${Subs.fechaKMT(DateTime.Now)}, |${usuario}|, ${Subs.fechaKMT(DateTime.Now)}"$)
|
||||
Starter.reqManager.ExecuteCommand(cmd,"guardaErrores")
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
Log("errorManager - JobDone")
|
||||
If Job.Success = False Then
|
||||
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Else
|
||||
LogColor("JobDone: '" & Starter.reqManager.HandleJob(Job).tag & "' - Registros: " & Starter.reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211110
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = Starter.reqManager.HandleJob(Job)
|
||||
If result.Tag = "guardaErrores" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
For Each k As String In result.Columns.Keys
|
||||
Log("GuardaErrores: " & k & ": " & records(result.Columns.Get(k)))
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End Sub
|
||||
|
||||
Private Sub c_continuar_Click
|
||||
' Subs.iniciaActividad("Principal")
|
||||
' B4XPages.ShowPage("Principal")
|
||||
End Sub
|
||||
|
||||
Private Sub b_salir_Click
|
||||
cierraActividades
|
||||
End Sub
|
||||
|
||||
Sub cierraActividades
|
||||
Log("closing activities")
|
||||
Dim jo As JavaObject
|
||||
jo.InitializeContext
|
||||
jo.RunMethod("finishAffinity", Null)
|
||||
End Sub
|
||||
1
gitpull.bat
Normal file
@@ -0,0 +1 @@
|
||||
git pull
|
||||