diff --git a/B4A/B4XMainPage.bas b/B4A/B4XMainPage.bas index 7a5f665..20c00af 100644 --- a/B4A/B4XMainPage.bas +++ b/B4A/B4XMainPage.bas @@ -10,12 +10,13 @@ Version=9.85 'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip '########################################################################################################### '###################### PULL ############################################################# -'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=..\..\gitpull.bat +'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull '########################################################################################################### '###################### PUSH ############################################################# -'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=github&Args=..\..\ +'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=github&Args=..\..\ '########################################################################################################### #End Region +'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=github&Args=..\..\ Sub Class_Globals Private Root As B4XView @@ -53,7 +54,7 @@ Sub Class_Globals Private et_nuevaRuta As EditText Private et_nuevoAlmacen As EditText Private p_clientes As Panel - Private lv_clientes As ListView +' Private lv_clientes As ListView Private clv_clientes As CustomListView Private p_item As Panel Private l_item As Label @@ -76,6 +77,7 @@ Private Sub B4XPage_Created (Root1 As B4XView) Subs.centraPanel(p_editaRuta, Root.Width) Subs.centraPanel(p_editaAlmacen, Root.Width) Subs.centraPanel(p_clientes, Root.Width) + ime.Initialize("ime") End Sub 'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage. @@ -106,46 +108,75 @@ Sub B4XPage_Appear Log($"Existe BD: ${File.Exists(File.DirInternal, "kmt.db") }"$) If File.Exists(File.DirInternal, "kmt.db") Then If Not(skmt.IsInitialized) Then skmt.Initialize(File.DirInternal,"kmt.db", True) - Dim ai As Cursor = skmt.ExecQuery($"select CAT_VA_DESCRIPCION, CAT_VA_VALOR from cat_variables where CAT_VA_DESCRIPCION = 'EMPRESA' or CAT_VA_DESCRIPCION = 'APP_VERSION'"$) - If ai.RowCount > 1 Then - For i = 0 To ai.RowCount -1 - ai.Position = i - If ai.GetString("CAT_VA_DESCRIPCION") = "EMPRESA" Then empresa = ai.GetString("CAT_VA_VALOR") - If ai.GetString("CAT_VA_DESCRIPCION") = "APP_VERSION" Then appVersion = ai.GetString("CAT_VA_VALOR") - Next - l_appInfo.Text = $"${empresa} ${appVersion}"$ - End If - Dim c As Cursor = skmt.ExecQuery($"select count(distinct pe_cliente) as pedidos, group_concat(distinct substr(pe_fecha, 4,2)) as diasVenta, sum(pe_costo_tot) as total, (select PE_CANT from pedido where PE_CANT = 0) as cantsEnCero, (select count(distinct PE_CLIENTE) from pedido where printf("%d", PE_CLIENTE) <> PE_CLIENTE ) as clienteNoNumerico from pedido"$) - Log(c.RowCount) - If c.RowCount > 0 Then - c.Position = 0 - l_pedidos2.Text = c.GetString("pedidos") - l_diasVenta.Text = "N/A" - If c.GetString("diasVenta") <> Null Then l_diasVenta.Text = c.GetString("diasVenta") - If c.GetString("total") <> Null Then l_totalVenta.Text = "$" & NumberFormat2(c.GetString("total"), 1, 2, 2, True) Else l_totalVenta.Text = "0" - l_cantsEnCero.Text = "0" - If c.GetString("cantsEnCero") <> Null Then l_cantsEnCero.Text = c.GetString("cantsEnCero") - l_clienteNoNumerico.Text = c.GetString("clienteNoNumerico") - End If - Dim c As Cursor = skmt.ExecQuery("select pe_ruta from pedido") - If c.RowCount > 0 Then - c.Position = 0 - ruta = c.GetString("PE_RUTA") - l_ruta2.Text = ruta - End If - Dim c As Cursor = skmt.ExecQuery("select USUARIO from usuarioa") - If c.RowCount > 0 Then - c.Position = 0 - usuario = c.GetString("USUARIO") - l_usuario2.Text = usuario - End If - Dim c As Cursor = skmt.ExecQuery("select ID_ALMACEN from cat_almacen") - If c.RowCount > 0 Then - c.Position = 0 - almacen = c.GetString("ID_ALMACEN") - l_almacen2.Text = almacen - End If - c.Close + Try + Dim ai As Cursor = skmt.ExecQuery($"select CAT_VA_DESCRIPCION, CAT_VA_VALOR from cat_variables where CAT_VA_DESCRIPCION = 'EMPRESA' or CAT_VA_DESCRIPCION = 'APP_VERSION'"$) + If ai.RowCount > 1 Then + For i = 0 To ai.RowCount -1 + ai.Position = i + If ai.GetString("CAT_VA_DESCRIPCION") = "EMPRESA" Then empresa = ai.GetString("CAT_VA_VALOR") + If ai.GetString("CAT_VA_DESCRIPCION") = "APP_VERSION" Then appVersion = ai.GetString("CAT_VA_VALOR") + Next + l_appInfo.Text = $"${empresa} ${appVersion}"$ + End If + ai.Close + Catch + Log(LastException) + LogColor("Error en CAT_VARIABLES", Colors.red) + End Try + Try + Dim c As Cursor = skmt.ExecQuery($"select count(distinct pe_cliente) as pedidos, group_concat(distinct substr(pe_fecha, 4,2)) as diasVenta, sum(pe_costo_tot) as total, (select PE_CANT from pedido where PE_CANT = 0) as cantsEnCero, (select count(distinct PE_CLIENTE) from pedido where printf("%d", PE_CLIENTE) <> PE_CLIENTE ) as clienteNoNumerico from pedido"$) + Log(c.RowCount) + If c.RowCount > 0 Then + c.Position = 0 + l_pedidos2.Text = c.GetString("pedidos") + l_diasVenta.Text = "N/A" + If c.GetString("diasVenta") <> Null Then l_diasVenta.Text = c.GetString("diasVenta") + If c.GetString("total") <> Null Then l_totalVenta.Text = "$" & NumberFormat2(c.GetString("total"), 1, 2, 2, True) Else l_totalVenta.Text = "0" + l_cantsEnCero.Text = "0" + If c.GetString("cantsEnCero") <> Null Then l_cantsEnCero.Text = c.GetString("cantsEnCero") + l_clienteNoNumerico.Text = c.GetString("clienteNoNumerico") + End If + c.Close + Catch + Log(LastException) + LogColor("Error en PEDIDO", Colors.red) + End Try + Try + Dim c As Cursor = skmt.ExecQuery("select pe_ruta from pedido") + If c.RowCount > 0 Then + c.Position = 0 + ruta = c.GetString("PE_RUTA") + l_ruta2.Text = ruta + End If + c.Close + Catch + Log(LastException) + LogColor("Error en PEDIDO", Colors.red) + End Try + Try + Dim c As Cursor = skmt.ExecQuery("select USUARIO from usuarioa") + If c.RowCount > 0 Then + c.Position = 0 + usuario = c.GetString("USUARIO") + l_usuario2.Text = usuario + End If + c.Close + Catch + Log(LastException) + LogColor("Error en USUARIOA", Colors.red) + End Try + Try + Dim c As Cursor = skmt.ExecQuery("select ID_ALMACEN from cat_almacen") + If c.RowCount > 0 Then + c.Position = 0 + almacen = c.GetString("ID_ALMACEN") + l_almacen2.Text = almacen + End If + c.Close + Catch + Log(LastException) + LogColor("Error en CAT_ALMACEN", Colors.red) + End Try End If End Sub @@ -475,7 +506,7 @@ End Sub Sub CreateListItem(mostrar As String) As Panel Dim p As B4XView = xui.CreatePanel("") - p.SetLayoutAnimated(0, 0, 0, 1, 10) + p.SetLayoutAnimated(0, 0, 0, 1, 10) 'ignore p.LoadLayout("listItem") p.Height= 36dip p.Width = clv_clientes.GetBase.Width