mirror of
https://github.com/KeymonSoft/Guna_Preventa.git
synced 2026-04-17 21:06:32 +00:00
27/10/23 - Se agregó el respaldo diario a Principal
This commit is contained in:
@@ -349,6 +349,7 @@ Sub Class_Globals
|
|||||||
Private CH_FACTURA As CheckBox
|
Private CH_FACTURA As CheckBox
|
||||||
Private que_modulo As String
|
Private que_modulo As String
|
||||||
Private CUENTA_MODULO As String
|
Private CUENTA_MODULO As String
|
||||||
|
Private l_version As Label
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'You can add more parameters here.
|
'You can add more parameters here.
|
||||||
@@ -362,6 +363,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
'load the layout to Root
|
'load the layout to Root
|
||||||
' Activity.RemoveAllViews
|
' Activity.RemoveAllViews
|
||||||
Root.LoadLayout("cliente")
|
Root.LoadLayout("cliente")
|
||||||
|
l_version.Text = Application.VersionName
|
||||||
ruta = File.DirInternal
|
ruta = File.DirInternal
|
||||||
If File.Exists(ruta, "kmt.db") = False Then
|
If File.Exists(ruta, "kmt.db") = False Then
|
||||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||||
@@ -401,10 +403,8 @@ End Sub
|
|||||||
|
|
||||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Sub B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
If Subs.traeUsuarioDeBD = "KMTS1" Then gest.Visible = True
|
||||||
que_modulo = 1
|
que_modulo = 1
|
||||||
B4XPages.MainPage.tipo_venta = tipo_venta
|
B4XPages.MainPage.tipo_venta = tipo_venta
|
||||||
encuentasmapa.Initialize
|
encuentasmapa.Initialize
|
||||||
@@ -554,6 +554,7 @@ Sub B4XPage_Appear
|
|||||||
Else
|
Else
|
||||||
b_like.Visible = False
|
b_like.Visible = False
|
||||||
End If
|
End If
|
||||||
|
Log(usuario)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub GPS_LocationChanged (Location1 As Location)
|
Sub GPS_LocationChanged (Location1 As Location)
|
||||||
@@ -577,7 +578,7 @@ Sub GPS_LocationChanged (Location1 As Location)
|
|||||||
Dim distance As Long
|
Dim distance As Long
|
||||||
distance = l1.DistanceTo(l2) 'the result is in meter
|
distance = l1.DistanceTo(l2) 'the result is in meter
|
||||||
gest.Visible = True
|
gest.Visible = True
|
||||||
If distance < 100 Then
|
If distance < 100 Or usuario = "KMTS1" Then
|
||||||
LA_GEO.TextColor = Colors.Blue
|
LA_GEO.TextColor = Colors.Blue
|
||||||
Tels.Visible = True
|
Tels.Visible = True
|
||||||
gest.Visible = True
|
gest.Visible = True
|
||||||
@@ -730,10 +731,7 @@ End Sub
|
|||||||
|
|
||||||
Private Sub b_preguntag_Click
|
Private Sub b_preguntag_Click
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE kmt_info SET CAT_CL_GIRO = ? WHERE CAT_CL_CODIGO = ? And CAT_CL_NOMBRE = ?", Array As Object (girotienda, la_cuenta.text,La_nombre.Text))
|
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE kmt_info SET CAT_CL_GIRO = ? WHERE CAT_CL_CODIGO = ? And CAT_CL_NOMBRE = ?", Array As Object (girotienda, la_cuenta.text,La_nombre.Text))
|
||||||
|
If girotienda = "Tienda de Abarrotes (Abarrotes, Misceláneas, Minisupers, Particulares con Venta y Cremerías)" Then
|
||||||
If girotienda = "Tienda de Abarrotes (Abarrotes, Misceláneas, Minisupers, Particulares con Venta y Cremerías)" Then
|
|
||||||
|
|
||||||
|
|
||||||
If ALMACEN = "35" Or ALMACEN = "43" Or ALMACEN = "54" Or ALMACEN = "73" Or ALMACEN = "56" Then 'ALMACEN = "7" Then '
|
If ALMACEN = "35" Or ALMACEN = "43" Or ALMACEN = "54" Or ALMACEN = "73" Or ALMACEN = "56" Then 'ALMACEN = "7" Then '
|
||||||
''Or ALMACEN = "56" ATIZAPAN PEDIGRI
|
''Or ALMACEN = "56" ATIZAPAN PEDIGRI
|
||||||
p_pregunta1.Visible = False
|
p_pregunta1.Visible = False
|
||||||
@@ -750,13 +748,10 @@ If girotienda = "Tienda de Abarrotes (Abarrotes, Misceláneas, Minisupers, Parti
|
|||||||
b_venta.Visible = False
|
b_venta.Visible = False
|
||||||
Guardar.Visible = False
|
Guardar.Visible = False
|
||||||
HIST.Visible = False
|
HIST.Visible = False
|
||||||
|
Else
|
||||||
|
|
||||||
Else
|
|
||||||
If que_modulo = Null Or que_modulo = " " Then que_modulo = "1"
|
If que_modulo = Null Or que_modulo = " " Then que_modulo = "1"
|
||||||
' Msgbox(que_modulo,"ALO")
|
' Msgbox(que_modulo,"ALO")
|
||||||
If que_modulo = "1" Then
|
If que_modulo = "1" Then
|
||||||
|
|
||||||
' esto para la primera encuesta m1
|
' esto para la primera encuesta m1
|
||||||
p_pregunta1.Visible = False
|
p_pregunta1.Visible = False
|
||||||
p_cliente.Visible = False
|
p_cliente.Visible = False
|
||||||
@@ -765,10 +760,7 @@ If que_modulo = "1" Then
|
|||||||
Panel5.Width = Root.Width * 0.94
|
Panel5.Width = Root.Width * 0.94
|
||||||
SV_ENCUESTA.Panel.Height = Panel5.Height + 60
|
SV_ENCUESTA.Panel.Height = Panel5.Height + 60
|
||||||
Panel7.Visible = False
|
Panel7.Visible = False
|
||||||
|
|
||||||
else if que_modulo = "2" Then
|
else if que_modulo = "2" Then
|
||||||
|
|
||||||
|
|
||||||
'' para la m2
|
'' para la m2
|
||||||
p_pregunta1.Visible = False
|
p_pregunta1.Visible = False
|
||||||
p_cliente.Visible = False
|
p_cliente.Visible = False
|
||||||
@@ -786,7 +778,6 @@ If que_modulo = "1" Then
|
|||||||
Panel5.Width = Root.Width * 0.94
|
Panel5.Width = Root.Width * 0.94
|
||||||
SV_ENCUESTA.Panel.Height = Panel5.Height + 60
|
SV_ENCUESTA.Panel.Height = Panel5.Height + 60
|
||||||
else if que_modulo = "4" Then
|
else if que_modulo = "4" Then
|
||||||
|
|
||||||
'' para la m4
|
'' para la m4
|
||||||
p_pregunta1.Visible = False
|
p_pregunta1.Visible = False
|
||||||
p_cliente.Visible = False
|
p_cliente.Visible = False
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ Version=11.5
|
|||||||
Sub Class_Globals
|
Sub Class_Globals
|
||||||
Private Root As B4XView 'ignore
|
Private Root As B4XView 'ignore
|
||||||
Private xui As XUI 'ignore
|
Private xui As XUI 'ignore
|
||||||
|
Dim kh As kms_helperSubs
|
||||||
Dim conectado As String
|
Dim conectado As String
|
||||||
Dim reqManager As DBRequestManager
|
Dim reqManager As DBRequestManager
|
||||||
Dim t1 As Timer
|
Dim t1 As Timer
|
||||||
@@ -237,6 +238,8 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
Root = Root1
|
Root = Root1
|
||||||
'load the layout to Root
|
'load the layout to Root
|
||||||
Root.LoadLayout("principal")
|
Root.LoadLayout("principal")
|
||||||
|
kh.Initialize(Me, "kh")
|
||||||
|
kh.RD_Init
|
||||||
l_version.Text = Application.VersionName
|
l_version.Text = Application.VersionName
|
||||||
SCROLL_RESDIA.Width = Root.Width
|
SCROLL_RESDIA.Width = Root.Width
|
||||||
SCROLL_RESDIA.Height = Root.Height
|
SCROLL_RESDIA.Height = Root.Height
|
||||||
@@ -306,6 +309,14 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
If kh.RD_Init_IsInitialized Then
|
||||||
|
kh.RD_respalda_cat_detalle_paq
|
||||||
|
kh.RD_respalda_cat_gunaprod
|
||||||
|
kh.RD_respalda_kmt_info
|
||||||
|
kh.RD_respalda_pedido
|
||||||
|
Else
|
||||||
|
Log("****** RD NO INICIALIZADO ********")
|
||||||
|
End If
|
||||||
p_principal.Visible = True
|
p_principal.Visible = True
|
||||||
reqManager.Initialize(Me, Starter.server)
|
reqManager.Initialize(Me, Starter.server)
|
||||||
HORAINGRESO ="000000"
|
HORAINGRESO ="000000"
|
||||||
|
|||||||
Binary file not shown.
@@ -159,10 +159,11 @@ Module17=DBRequestManager
|
|||||||
Module18=FileHandler
|
Module18=FileHandler
|
||||||
Module19=FirebaseMessaging
|
Module19=FirebaseMessaging
|
||||||
Module2=B4XMainPage
|
Module2=B4XMainPage
|
||||||
Module20=MAPA_RUTAS
|
Module20=kms_helperSubs
|
||||||
Module21=Starter
|
Module21=MAPA_RUTAS
|
||||||
Module22=Subs
|
Module22=Starter
|
||||||
Module23=Tracker
|
Module23=Subs
|
||||||
|
Module24=Tracker
|
||||||
Module3=BatteryUtilities
|
Module3=BatteryUtilities
|
||||||
Module4=C_Cliente
|
Module4=C_Cliente
|
||||||
Module5=C_Clientes
|
Module5=C_Clientes
|
||||||
@@ -172,13 +173,13 @@ Module8=C_Nota
|
|||||||
Module9=C_NoVenta
|
Module9=C_NoVenta
|
||||||
NumberOfFiles=58
|
NumberOfFiles=58
|
||||||
NumberOfLibraries=30
|
NumberOfLibraries=30
|
||||||
NumberOfModules=23
|
NumberOfModules=24
|
||||||
Version=11.5
|
Version=11.5
|
||||||
@EndOfDesignText@
|
@EndOfDesignText@
|
||||||
#Region Project Attributes
|
#Region Project Attributes
|
||||||
#ApplicationLabel: Guna V3.1
|
#ApplicationLabel: Guna V3.1
|
||||||
#VersionCode: 1
|
#VersionCode: 1
|
||||||
#VersionName: 2.12.29ENC
|
#VersionName: 2.10.27ENC
|
||||||
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||||
#SupportedOrientations: portrait
|
#SupportedOrientations: portrait
|
||||||
#CanInstallToExternalStorage: False
|
#CanInstallToExternalStorage: False
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ ModuleBookmarks20=
|
|||||||
ModuleBookmarks21=
|
ModuleBookmarks21=
|
||||||
ModuleBookmarks22=
|
ModuleBookmarks22=
|
||||||
ModuleBookmarks23=
|
ModuleBookmarks23=
|
||||||
|
ModuleBookmarks24=
|
||||||
ModuleBookmarks3=
|
ModuleBookmarks3=
|
||||||
ModuleBookmarks4=
|
ModuleBookmarks4=
|
||||||
ModuleBookmarks5=
|
ModuleBookmarks5=
|
||||||
@@ -39,6 +40,7 @@ ModuleBreakpoints20=
|
|||||||
ModuleBreakpoints21=
|
ModuleBreakpoints21=
|
||||||
ModuleBreakpoints22=
|
ModuleBreakpoints22=
|
||||||
ModuleBreakpoints23=
|
ModuleBreakpoints23=
|
||||||
|
ModuleBreakpoints24=
|
||||||
ModuleBreakpoints3=
|
ModuleBreakpoints3=
|
||||||
ModuleBreakpoints4=
|
ModuleBreakpoints4=
|
||||||
ModuleBreakpoints5=
|
ModuleBreakpoints5=
|
||||||
@@ -50,7 +52,7 @@ ModuleClosedNodes0=
|
|||||||
ModuleClosedNodes1=5,7,8,9,10,11,12,13,14
|
ModuleClosedNodes1=5,7,8,9,10,11,12,13,14
|
||||||
ModuleClosedNodes10=
|
ModuleClosedNodes10=
|
||||||
ModuleClosedNodes11=6
|
ModuleClosedNodes11=6
|
||||||
ModuleClosedNodes12=2,4,5,6,7,9,10,11,12,13,14,15,16,17,18,19,20,21,27,28,29,30,31,32
|
ModuleClosedNodes12=1,3,5,6,7,9,10,11,12,13,14,15,16,17,18,19,20,21,27,28,29,30,31,32
|
||||||
ModuleClosedNodes13=
|
ModuleClosedNodes13=
|
||||||
ModuleClosedNodes14=
|
ModuleClosedNodes14=
|
||||||
ModuleClosedNodes15=
|
ModuleClosedNodes15=
|
||||||
@@ -58,11 +60,12 @@ ModuleClosedNodes16=
|
|||||||
ModuleClosedNodes17=
|
ModuleClosedNodes17=
|
||||||
ModuleClosedNodes18=
|
ModuleClosedNodes18=
|
||||||
ModuleClosedNodes19=
|
ModuleClosedNodes19=
|
||||||
ModuleClosedNodes2=6,9
|
ModuleClosedNodes2=9
|
||||||
ModuleClosedNodes20=3,4
|
ModuleClosedNodes20=
|
||||||
ModuleClosedNodes21=1
|
ModuleClosedNodes21=3,4
|
||||||
ModuleClosedNodes22=
|
ModuleClosedNodes22=1
|
||||||
ModuleClosedNodes23=
|
ModuleClosedNodes23=
|
||||||
|
ModuleClosedNodes24=
|
||||||
ModuleClosedNodes3=
|
ModuleClosedNodes3=
|
||||||
ModuleClosedNodes4=2,6,7,10,11
|
ModuleClosedNodes4=2,6,7,10,11
|
||||||
ModuleClosedNodes5=7
|
ModuleClosedNodes5=7
|
||||||
@@ -70,6 +73,6 @@ ModuleClosedNodes6=
|
|||||||
ModuleClosedNodes7=
|
ModuleClosedNodes7=
|
||||||
ModuleClosedNodes8=
|
ModuleClosedNodes8=
|
||||||
ModuleClosedNodes9=
|
ModuleClosedNodes9=
|
||||||
NavigationStack=Visual Designer,principal.bal,-100,6,Visual Designer,cliente.bal,-100,2,C_Cliente,Class_Globals,346,0,C_Cliente,B4XPage_Created,355,4,C_Principal,B4XPage_Created,229,4,C_Productos,B4XPage_CloseRequest,317,0,C_Productos,Class_Globals,0,0,C_Promos,Class_Globals,0,0,C_Promos,b_continuar_Click,361,0,C_Promos,b_terminar1_Click,351,0
|
NavigationStack=kms_helperSubs,Class_Globals,0,0,B4XMainPage,Entrar_Click,335,0,B4XMainPage,Initialize,96,0,C_Principal,Class_Globals,0,0,C_Principal,Initialize,226,0,C_Principal,B4XPage_Created,230,0,kms_helperSubs,RD_respalda_cat_gunaprod2,165,0,C_Principal,B4XPage_Appear,312,0,Main,Globals,25,0,B4XMainPage,Class_Globals,19,0
|
||||||
SelectedBuild=0
|
SelectedBuild=0
|
||||||
VisibleModules=21,2,22,14,12,13,4,8,17
|
VisibleModules=22,2,23,14,12,13,4,8,17,20
|
||||||
|
|||||||
664
B4A/kms_helperSubs.bas
Normal file
664
B4A/kms_helperSubs.bas
Normal file
@@ -0,0 +1,664 @@
|
|||||||
|
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
|
||||||
|
Dim skmt, rkmt As SQL
|
||||||
|
Private EventName As String 'ignore
|
||||||
|
Private CallBack As Object 'ignore
|
||||||
|
Dim rp As RuntimePermissions
|
||||||
|
Dim safePath As String
|
||||||
|
Dim fechaHoy As String
|
||||||
|
Dim fechaAnt As String
|
||||||
|
Dim skmtAttached As Boolean = False
|
||||||
|
Dim rkmtAttached As Boolean = False
|
||||||
|
'####### MES Vars ######
|
||||||
|
Private ion As Object
|
||||||
|
' Dim device As Phone
|
||||||
|
' Private mesCallback As Object
|
||||||
|
' Private mesEventName As String
|
||||||
|
Dim RD_Init_IsInitialized As Boolean = False
|
||||||
|
Dim btAdmin As BluetoothAdmin
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Inicializa la clase "kms_helperSubs".
|
||||||
|
Public Sub Initialize (vCallback As Object, vEventName As String) As Object
|
||||||
|
EventName = vEventName
|
||||||
|
CallBack = vCallback
|
||||||
|
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
|
||||||
|
'End Sub
|
||||||
|
|
||||||
|
'RD - Inicializa Respaldo Diario
|
||||||
|
Sub RD_Init
|
||||||
|
Dim Dirp As String = File.DirRootExternal
|
||||||
|
Dim Dir As String
|
||||||
|
' Dim Dir2 As String
|
||||||
|
Try
|
||||||
|
File.MakeDir(Dirp,"/kmts")
|
||||||
|
Dir = "/kmts"
|
||||||
|
' Log("creado en kmts " & Dirp & Dir)
|
||||||
|
Catch
|
||||||
|
Dir = ""
|
||||||
|
' Log("creado en raiz")
|
||||||
|
End Try
|
||||||
|
safePath = Dirp & Dir
|
||||||
|
If Starter.Logger Then Log($"Safepath:${safePath}"$)
|
||||||
|
Private name() As String = Regex.split(" ", Application.LabelName)
|
||||||
|
rkmt.Initialize(safePath,$"${name(0)}.rkmt.km"$, True)
|
||||||
|
skmt.Initialize(File.DirInternal,"kmt.db", False)
|
||||||
|
If chkIfTableExists(skmt, "PEDIDO") Then rkmt.ExecNonQuery($"create table if not exists PEDIDO (${getTableColumnList(skmt, "PEDIDO")}, FECHA TEXT)"$)
|
||||||
|
If chkIfTableExists(skmt, "CAT_DETALLES_PAQ") Then rkmt.ExecNonQuery($"create table if not exists CAT_DETALLES_PAQ (${getTableColumnList(skmt, "CAT_DETALLES_PAQ")}, FECHA TEXT)"$)
|
||||||
|
If chkIfTableExists(skmt, "CAT_GUNAPROD") Then rkmt.ExecNonQuery($"create table if not exists CAT_GUNAPROD (${getTableColumnList(skmt, "CAT_GUNAPROD")}, FECHA TEXT)"$)
|
||||||
|
If chkIfTableExists(skmt, "CAT_GUNAPROD2") Then rkmt.ExecNonQuery($"create table if not exists CAT_GUNAPROD2 (${getTableColumnList(skmt, "CAT_GUNAPROD2")}, FECHA TEXT)"$)
|
||||||
|
If chkIfTableExists(skmt, "kmt_info") Then rkmt.ExecNonQuery($"create table if not exists kmt_info (${getTableColumnList(skmt, "kmt_info")}, FECHA TEXT)"$)
|
||||||
|
DateTime.DateFormat = "yyyyMMdd"
|
||||||
|
fechaHoy = DateTime.Date(DateTime.Now)
|
||||||
|
If Starter.Logger Then Log("RKMTS: " & rkmt.IsInitialized)
|
||||||
|
If revisaSkmtAttached And rkmt.IsInitialized Then RD_Init_IsInitialized = True Else RD_Init_IsInitialized = False
|
||||||
|
' revisaRkmtAttached
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Revisa si esta montada "kmt.db" como "skmt1" y si no, la monta
|
||||||
|
'Para que "rkmt" vea a "skmt", es necesario montarla (attach).
|
||||||
|
Sub revisaSkmtAttached As Boolean
|
||||||
|
skmtAttached = False
|
||||||
|
Dim rs As ResultSet = rkmt.ExecQuery("SELECT * FROM pragma_database_list")
|
||||||
|
Do While rs.NextRow 'Revisamos si esta montada "kmt.db" como "skmt1" y si no, la montamos.
|
||||||
|
If rs.GetString("name") = "skmt1" Then skmtAttached = True
|
||||||
|
Loop
|
||||||
|
If Not(skmtAttached) Then
|
||||||
|
rkmt.ExecNonQuery($"attach database '${File.Combine(File.DirInternal, "kmt.db")}' as skmt1;"$)
|
||||||
|
skmtAttached = True
|
||||||
|
End If
|
||||||
|
Return skmtAttached
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Revisa si esta montada "kmt.db" como "rkmt1" y si no, la monta
|
||||||
|
'Para que "skmt" vea a "rkmt", es necesario montarla (attach).
|
||||||
|
Sub revisaRkmtAttached As Boolean
|
||||||
|
rkmtAttached = False
|
||||||
|
Dim rs As ResultSet = skmt.ExecQuery("SELECT * FROM pragma_database_list")
|
||||||
|
Do While rs.NextRow 'Revisamos si esta montada "kmt.db" como "rkmt1" y si no, la montamos.
|
||||||
|
If rs.GetString("name") = "rkmt1" Then rkmtAttached = True
|
||||||
|
Log(rs.GetString("name"))
|
||||||
|
Loop
|
||||||
|
If Not(rkmtAttached) Then
|
||||||
|
|
||||||
|
Private name() As String = Regex.split(" ", Application.LabelName)
|
||||||
|
skmt.ExecNonQuery($"attach database '${File.Combine(safePath,$"${name(0)}.rkmt.km"$)}' as rkmt1;"$)
|
||||||
|
rkmtAttached = True
|
||||||
|
End If
|
||||||
|
Return rkmtAttached
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Inicializa la BD con "kmt.db" en "File.DirInternal", si el archivo no existe, lo copia desde "File.DirAssets".
|
||||||
|
'Ej: dim skmt as sql = dbInit
|
||||||
|
Sub dbInit As SQL 'ignore
|
||||||
|
Private db As SQL
|
||||||
|
If File.Exists(File.DirInternal, "kmt.db") = False Then File.Copy(File.DirAssets, "kmt.db", File.DirInternal, "kmt.db")
|
||||||
|
db.Initialize(File.DirInternal,"kmt.db", True)
|
||||||
|
' dbOk(True)
|
||||||
|
' Log(db.IsInitialized)
|
||||||
|
Return db
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Copia la tabla PEDIDO a rkmt.db en la tarjeta del celular.
|
||||||
|
Sub RD_respalda_pedido
|
||||||
|
Private inicio As String = DateTime.Now
|
||||||
|
' Log("Copiando PEDIDO ...")
|
||||||
|
Private x As Cursor = skmt.ExecQuery("select * from PEDIDO")
|
||||||
|
If x.RowCount > 0 Then
|
||||||
|
Private lasCols As String = getTableColumnListName(skmt, "PEDIDO")
|
||||||
|
rkmt.BeginTransaction
|
||||||
|
rkmt.ExecNonQuery($"delete from PEDIDO where FECHA = '${fechaHoy}'"$)
|
||||||
|
rkmt.ExecNonQuery($"insert into PEDIDO (${lasCols}, FECHA) select ${lasCols}, '${fechaHoy}' as FECHA from skmt1.PEDIDO where substr(pe_fecha, 1, 10) = '${fechaHoy}'"$)
|
||||||
|
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
||||||
|
rkmt.EndTransaction
|
||||||
|
End If
|
||||||
|
x.Close
|
||||||
|
Log("P: " & ((DateTime.Now - inicio)/1000) & " segs")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Copia la tabla CAT_GUNAPRODS a rkmt.db en la tarjeta del celular.
|
||||||
|
Sub RD_respalda_cat_gunaprod
|
||||||
|
Private inicio As String = DateTime.Now
|
||||||
|
' Log("Copiando CAT_GUNAPROD ...")
|
||||||
|
Private x As Cursor = skmt.ExecQuery("select * from CAT_GUNAPROD")
|
||||||
|
If x.RowCount > 0 Then
|
||||||
|
Private lasCols As String = getTableColumnListName(skmt, "CAT_GUNAPROD")
|
||||||
|
lasCols = lasCols.Replace(", CAT_GP_IMG", "") 'Quitamos la imagen del respaldo.
|
||||||
|
rkmt.BeginTransaction
|
||||||
|
rkmt.ExecNonQuery($"delete from CAT_GUNAPROD where FECHA = '${fechaHoy}'"$)
|
||||||
|
rkmt.ExecNonQuery($"insert into CAT_GUNAPROD (${lasCols}, FECHA) select ${lasCols}, '${fechaHoy}' as FECHA from skmt1.CAT_GUNAPROD"$)
|
||||||
|
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
||||||
|
rkmt.EndTransaction
|
||||||
|
End If
|
||||||
|
x.Close
|
||||||
|
Log("GP: " & ((DateTime.Now - inicio)/1000) & " segs")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Copia la tabla CAT_GUNAPROD de rkmt.db al celular.
|
||||||
|
Sub RD_restaura_cat_gunaprod
|
||||||
|
Private inicio As String = DateTime.Now
|
||||||
|
' Log("Restaurando CAT_GUNAPROD ...")
|
||||||
|
Private lasCols As String = getTableColumnListName(rkmt, "CAT_GUNAPROD")
|
||||||
|
lasCols = lasCols.Replace(", FECHA", "") 'Quitamos la imagen del respaldo.
|
||||||
|
Private c As Cursor = rkmt.ExecQuery($"select distinct fecha from CAT_GUNAPROD order by fecha desc"$) 'where fecha <> '${fechaHoy}' 'Traemos la ultima fecha antes de hoy.
|
||||||
|
Log(c.RowCount)
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
Log(c.GetString("FECHA"))
|
||||||
|
skmt.ExecNonQuery("delete from CAT_GUNAPROD")
|
||||||
|
skmt.ExecNonQuery($"insert into CAT_GUNAPROD (${lasCols}) select ${lasCols} from rkmt1.CAT_GUNAPROD where fecha = '${c.GetString("FECHA")}'"$)
|
||||||
|
Log($"insert into CAT_GUNAPROD (${lasCols}) select ${lasCols} from rkmt1.CAT_GUNAPROD where fecha = '${c.GetString("FECHA")}'"$)
|
||||||
|
End If
|
||||||
|
Log("R-GP: " & ((DateTime.Now - inicio)/1000) & " segs")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Copia la tabla CAT_GUNAPROD2 a rkmt.db en la tarjeta del celular.
|
||||||
|
Sub RD_respalda_cat_gunaprod2
|
||||||
|
Private inicio As String = DateTime.Now
|
||||||
|
' Log("Copiando CAT_GUNAPROD2 ...")
|
||||||
|
Private x As Cursor = skmt.ExecQuery("select * from CAT_GUNAPROD2")
|
||||||
|
If x.RowCount > 0 Then
|
||||||
|
Private lasCols As String = getTableColumnListName(skmt, "CAT_GUNAPROD2")
|
||||||
|
lasCols = lasCols.Replace(", CAT_GP_IMG", "") 'Quitamos la fecha del respaldo.
|
||||||
|
rkmt.BeginTransaction
|
||||||
|
rkmt.ExecNonQuery($"delete from CAT_GUNAPROD2 where FECHA = '${fechaHoy}'"$)
|
||||||
|
rkmt.ExecNonQuery($"insert into CAT_GUNAPROD2 (${lasCols}, FECHA) select ${lasCols}, '${fechaHoy}' as FECHA from skmt1.CAT_GUNAPROD2"$)
|
||||||
|
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
||||||
|
rkmt.EndTransaction
|
||||||
|
End If
|
||||||
|
x.Close
|
||||||
|
Log("GP2: " & ((DateTime.Now - inicio)/1000) & " segs")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Copia la tabla CAT_GUNAPROD2 de rkmt.db al celular.
|
||||||
|
Sub RD_restaura_cat_gunaprod2
|
||||||
|
Private inicio As String = DateTime.Now
|
||||||
|
' Log("Restaurando CAT_GUNAPROD2 ...")
|
||||||
|
Private lasCols As String = getTableColumnListName(rkmt, "CAT_GUNAPROD2")
|
||||||
|
lasCols = lasCols.Replace(", FECHA", "") 'Quitamos la fecha del respaldo.
|
||||||
|
Private c As Cursor = rkmt.ExecQuery($"select distinct fecha from CAT_GUNAPROD2 order by fecha desc"$) 'where fecha <> '${fechaHoy}' 'Traemos la ultima fecha antes de hoy.
|
||||||
|
' Log(c.RowCount)
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
' Log(c.GetString("FECHA"))
|
||||||
|
skmt.ExecNonQuery("delete from CAT_GUNAPROD2")
|
||||||
|
skmt.ExecNonQuery($"insert into CAT_GUNAPROD2 (${lasCols}) select ${lasCols} from rkmt1.CAT_GUNAPROD2 where fecha = '${c.GetString("FECHA")}'"$)
|
||||||
|
Log($"insert into CAT_GUNAPROD2 (${lasCols}) select ${lasCols} from rkmt1.CAT_GUNAPROD2 where fecha = '${c.GetString("FECHA")}'"$)
|
||||||
|
End If
|
||||||
|
Log("R-GP2: " & ((DateTime.Now - inicio)/1000) & " segs")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Copia la tabla CAT_DETALLE_PAQ a rkmt.db en la tarjeta del celular.
|
||||||
|
Sub RD_respalda_cat_detalle_paq
|
||||||
|
Private inicio As String = DateTime.Now
|
||||||
|
' Log("Copiando CAT_DETALLES_PAQ ...")
|
||||||
|
Private x As Cursor = skmt.ExecQuery("select * from CAT_DETALLES_PAQ")
|
||||||
|
If x.RowCount > 0 Then
|
||||||
|
Private lasCols As String = getTableColumnListName(skmt, "CAT_DETALLES_PAQ")
|
||||||
|
rkmt.BeginTransaction
|
||||||
|
rkmt.ExecNonQuery($"delete from CAT_DETALLES_PAQ where fecha = '${fechaHoy}'"$)
|
||||||
|
rkmt.ExecNonQuery($"insert into CAT_DETALLES_PAQ (${lasCols}, FECHA) select ${lasCols}, '${fechaHoy}' as FECHA from skmt1.CAT_DETALLES_PAQ"$)
|
||||||
|
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
||||||
|
rkmt.EndTransaction
|
||||||
|
Log("DP: " & ((DateTime.Now - inicio)/1000) & " segs")
|
||||||
|
End If
|
||||||
|
x.Close
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Copia la tabla CAT_DETALLES_PAQ de rkmt.db al celular.
|
||||||
|
Sub RD_restaura_cat_detalle_paq
|
||||||
|
Private inicio As String = DateTime.Now
|
||||||
|
' Log("Restaurando CAT_DETALLES_PAQ ...")
|
||||||
|
Private lasCols As String = getTableColumnListName(rkmt, "CAT_DETALLES_PAQ")
|
||||||
|
lasCols = lasCols.Replace(", FECHA", "") 'Quitamos la fecha del respaldo.
|
||||||
|
Private c As Cursor = rkmt.ExecQuery($"select distinct fecha from CAT_DETALLES_PAQ order by fecha desc"$) 'where fecha <> '${fechaHoy}' 'Traemos la ultima fecha antes de hoy.
|
||||||
|
' Log(c.RowCount)
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
' Log(c.GetString("FECHA"))
|
||||||
|
skmt.ExecNonQuery("delete from CAT_DETALLES_PAQ")
|
||||||
|
skmt.ExecNonQuery($"insert into CAT_DETALLES_PAQ (${lasCols}) select ${lasCols} from rkmt1.CAT_DETALLES_PAQ where fecha = '${c.GetString("FECHA")}'"$)
|
||||||
|
Log($"insert into CAT_DETALLES_PAQ (${lasCols}) select ${lasCols} from rkmt1.CAT_DETALLES_PAQ where fecha = '${c.GetString("FECHA")}'"$)
|
||||||
|
End If
|
||||||
|
Log("R-DP: " & ((DateTime.Now - inicio)/1000) & " segs")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Copia la tabla kmt_info a rkmt.db en la tarjeta del celular.
|
||||||
|
Sub RD_respalda_kmt_info
|
||||||
|
Private inicio As String = DateTime.Now
|
||||||
|
' Log("Copiando kmt_info ...")
|
||||||
|
Private x As Cursor = skmt.ExecQuery("select * from kmt_info")
|
||||||
|
If x.RowCount > 0 Then
|
||||||
|
Private lasCols As String = getTableColumnListName(skmt, "kmt_info")
|
||||||
|
rkmt.BeginTransaction
|
||||||
|
rkmt.ExecNonQuery($"delete from kmt_info where fecha = '${fechaHoy}'"$)
|
||||||
|
rkmt.ExecNonQuery($"insert into kmt_info (${lasCols}, FECHA) select ${lasCols}, '${fechaHoy}' as FECHA from skmt1.kmt_info"$)
|
||||||
|
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
||||||
|
rkmt.EndTransaction
|
||||||
|
End If
|
||||||
|
x.Close
|
||||||
|
Log("KMT: " & ((DateTime.Now - inicio)/1000) & " segs")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Copia la tabla kmt_info de rkmt.db al celular.
|
||||||
|
Sub RD_restaura_kmt_info
|
||||||
|
Private inicio As String = DateTime.Now
|
||||||
|
' Log("Restaurando KMT_INFO ...")
|
||||||
|
Private lasCols As String = getTableColumnListName(rkmt, "kmt_info")
|
||||||
|
lasCols = lasCols.Replace(", FECHA", "") 'Quitamos la fecha del respaldo.
|
||||||
|
Private c As Cursor = rkmt.ExecQuery($"select distinct fecha from kmt_info order by fecha desc"$) 'where fecha <> '${fechaHoy}' 'Traemos la ultima fecha antes de hoy.
|
||||||
|
' Log(c.RowCount)
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
' Log(c.GetString("FECHA"))
|
||||||
|
skmt.ExecNonQuery("delete from kmt_info")
|
||||||
|
skmt.ExecNonQuery($"insert into kmt_info (${lasCols}) select ${lasCols} from rkmt1.kmt_info where fecha = '${c.GetString("FECHA")}'"$)
|
||||||
|
Log($"insert into kmt_info (${lasCols}) select ${lasCols} from rkmt1.kmt_info where fecha = '${c.GetString("FECHA")}'"$)
|
||||||
|
End If
|
||||||
|
Log("R-KMT: " & ((DateTime.Now - inicio)/1000) & " segs")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'RD - Realiza un "vacuum" de la base de datos "rkmt".
|
||||||
|
Sub RD_vacuum 'ignore
|
||||||
|
Log("Vacuum")
|
||||||
|
rkmt.ExecNonQuery("vacuum;")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Agrega una columna a la tabla especificada.
|
||||||
|
'Hay que indicar el "tipo" de la columna (TEXT, INTEGER, ETC)
|
||||||
|
'Ej. agregaColumna(DB, "TABLA", "COLUMNA", "TIPO")
|
||||||
|
Sub agregaColumna(db As SQL, tabla As String, columna As String, tipo As String) 'ignore
|
||||||
|
Try 'Intentamos usar "pragma_table_info" para revisar si existe la columna en la tabla
|
||||||
|
Private c As Cursor = db.ExecQuery($"SELECT COUNT(*) AS fCol FROM pragma_table_info('${tabla}') WHERE name='${columna}'"$)
|
||||||
|
c.Position = 0
|
||||||
|
If c.GetString("fCol") = 0 Then 'Si no esta la columna la agregamos
|
||||||
|
db.ExecNonQuery($"ALTER TABLE ${tabla} ADD COLUMN ${columna} ${tipo}"$)
|
||||||
|
Log($"Columna "${columna} ${tipo}", agregada a "${tabla}"."$)
|
||||||
|
End If
|
||||||
|
Catch 'Si no funciona "pragma_table_info" lo hacemos con try/catch
|
||||||
|
Try
|
||||||
|
db.ExecNonQuery($"ALTER TABLE ${tabla} ADD COLUMN ${columna} ${tipo}"$)
|
||||||
|
Log($"Columna "${columna} ${tipo}", agregada a "${tabla}".."$)
|
||||||
|
Catch
|
||||||
|
Log(LastException)
|
||||||
|
End Try
|
||||||
|
End Try
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa los nombres y tipos de las columnas de una tabla dada.
|
||||||
|
Sub getTableColumnList(db As SQL, table As String) As String 'ignore
|
||||||
|
Private l As String = ""
|
||||||
|
If chkIfTableExists(db, table) Then
|
||||||
|
Private c As Cursor = skmt.ExecQuery($"pragma table_info(${table})"$)
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
For i = 0 To c.RowCount - 1
|
||||||
|
c.Position = i
|
||||||
|
If l.Length = 0 Then
|
||||||
|
l = $"${c.GetString("name")} ${c.GetString("type")}"$
|
||||||
|
Else
|
||||||
|
l = $"${l}, ${c.GetString("name")} ${c.GetString("type")}"$
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
Return "No existe la tabla."
|
||||||
|
End If
|
||||||
|
c.Close
|
||||||
|
Return l
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa solo los nombres de las columnas de una tabla dada.
|
||||||
|
Sub getTableColumnListName(db As SQL, table As String) As String 'ignore
|
||||||
|
Private l As String = ""
|
||||||
|
If chkIfTableExists(db, table) Then
|
||||||
|
Private c As Cursor = skmt.ExecQuery($"pragma table_info(${table})"$)
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
For i = 0 To c.RowCount - 1
|
||||||
|
c.Position = i
|
||||||
|
If l.Length = 0 Then
|
||||||
|
l = $"${c.GetString("name")}"$
|
||||||
|
Else
|
||||||
|
l = $"${l}, ${c.GetString("name")}"$
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
Return "No existe la tabla."
|
||||||
|
End If
|
||||||
|
c.Close
|
||||||
|
Return l
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Revisa si una tabla dada existe en una base de datos dada, regresa true o false.
|
||||||
|
Sub chkIfTableExists(db As SQL, table As String) As Boolean 'ignore
|
||||||
|
Private t As Boolean = False 'ignore
|
||||||
|
If db.IsInitialized Then
|
||||||
|
Private c As Cursor = skmt.ExecQuery($"SELECT name FROM sqlite_master WHERE type='table' AND name='${table}'"$)
|
||||||
|
If c.RowCount > 0 Then t = True
|
||||||
|
c.Close
|
||||||
|
End If
|
||||||
|
Return t
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Hace visible y trae al frente el panel con los parametros "Top" y "Left" dados
|
||||||
|
Sub panelVisible(panel As Panel, top As Int, left As Int) 'ignore
|
||||||
|
panel.BringToFront
|
||||||
|
panel.Visible = True
|
||||||
|
panel.Top = top
|
||||||
|
panel.Left = left
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Centra una etiqueta dentro de un elemento superior
|
||||||
|
Sub centraEtiqueta(elemento As Label, anchoElementoSuperior As Int) 'ignore
|
||||||
|
elemento.Left = Round(anchoElementoSuperior/2)-(elemento.Width/2)
|
||||||
|
etiquetaCentrada(True)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub etiquetaCentrada(Success As Boolean)
|
||||||
|
If SubExists(CallBack, EventName & "_etiquetaCentrada") Then
|
||||||
|
CallSub2(CallBack, EventName & "_etiquetaCentrada", Success)
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Centra un panel horizontalmente dentro de un elemento superior
|
||||||
|
Sub centraPanel(elemento As Panel, anchoElementoSuperior As Int) 'ignore
|
||||||
|
elemento.Left = Round(anchoElementoSuperior/2)-(elemento.Width/2)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Centra un panel verticalmente dentro de un elemento superior
|
||||||
|
Sub centraPanelV(elemento As Panel, altoElementoSuperior As Int) 'ignore
|
||||||
|
elemento.Top = Round(altoElementoSuperior/2)-(elemento.Height/2)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Centra una barra de progreso dentro de un elemento superior
|
||||||
|
Sub centraProgressBar(elemento As ProgressBar, anchoElementoSuperior As Int) 'ignore
|
||||||
|
elemento.Left = Round(anchoElementoSuperior/2)-(elemento.Width/2)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa el usuario de la tabla USUARIOA, si no lo encuentra regresa "SinUsuario"
|
||||||
|
Sub traeUsuarioDeDB(db As SQL) As String 'ignore
|
||||||
|
Private c As Cursor
|
||||||
|
Private u As String = "SinUsuario"
|
||||||
|
c = skmt.ExecQuery("select USUARIO from usuarioa")
|
||||||
|
c.Position=0
|
||||||
|
If c.RowCount > 0 Then u = c.GetString("USUARIO")
|
||||||
|
c.Close
|
||||||
|
Return u
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa el almacen actual de la base de datos.
|
||||||
|
Sub traeAlmacen(db As SQL) As String 'ignore
|
||||||
|
Private c As Cursor
|
||||||
|
Private a As String
|
||||||
|
c = skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
|
||||||
|
c.Position = 0
|
||||||
|
a = c.GetString("ID_ALMACEN")
|
||||||
|
c.Close
|
||||||
|
Return a
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa el nombre del producto desde CAT_GUNAPROD.
|
||||||
|
Sub traeProdNombre(db As SQL, id As String) As String 'ignore
|
||||||
|
Private h As Cursor
|
||||||
|
Private n As String
|
||||||
|
h = skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(id.Trim))
|
||||||
|
If h.RowCount > 0 Then
|
||||||
|
h.Position = 0
|
||||||
|
n = h.GetString("CAT_GP_NOMBRE")
|
||||||
|
' Log(h.RowCount&"|"&id&"|"&n&"|")
|
||||||
|
End If
|
||||||
|
h.Close
|
||||||
|
If n = Null Or n="" Then n = "N/A"
|
||||||
|
' Log(h.RowCount&"|"&id&"|"&n&"|")
|
||||||
|
Return n
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa la ruta actual de la base de datos.
|
||||||
|
Sub traeRuta(db As SQL) As String 'ignore
|
||||||
|
Private c As Cursor
|
||||||
|
Private r As String
|
||||||
|
c = skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||||
|
r = "0"
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position=0
|
||||||
|
r = c.GetString("CAT_CL_RUTA")
|
||||||
|
End If
|
||||||
|
c.Close
|
||||||
|
Return r
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa el cliente actual de la base de dtos (CUENTAA).
|
||||||
|
Sub traeCliente(db As SQL) As String 'ignore
|
||||||
|
Private c As Cursor
|
||||||
|
Private cl As String
|
||||||
|
c = skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||||
|
c.Position=0
|
||||||
|
cl = c.GetString("CUENTA")
|
||||||
|
c.Close
|
||||||
|
Return cl
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa en un mapa el total de productos y monto del pedido del cliente actual
|
||||||
|
'resultado = {"productos":"antidad_de_productos", "monto":"costo_total"}
|
||||||
|
Sub traeTotalesClienteActual(db As SQL) As Map 'ignore
|
||||||
|
Private m As Map
|
||||||
|
m.Initialize
|
||||||
|
Private c_prodsX As Cursor = skmt.ExecQuery("select ifnull(sum(PE_CANT), 0) as cantProds, ifnull(sum(PE_COSTO_TOT), 0) as costoTotal FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order by PE_PRONOMBRE asc")
|
||||||
|
c_prodsX.Position = 0
|
||||||
|
' LogColor($"Productos de la orden: ${c_prodsX.GetString("cantProds")}, Total: ${c_prodsX.GetString("costoTotal")}"$, Colors.red)
|
||||||
|
m = CreateMap("productos": c_prodsX.GetString("cantProds"), "monto" : c_prodsX.GetString("costoTotal"))
|
||||||
|
Return m
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Borra el pedido del cliente actual.
|
||||||
|
'Borra los registros de la tabla "PEDIDO" y "PEDIDO_CLIENTE"
|
||||||
|
'Actualiza las tablas "cat_gunaprod" y "kmt_info".
|
||||||
|
Sub borraPedidoClienteActual(db As SQL) As String 'ignore
|
||||||
|
Private thisC As Cursor
|
||||||
|
thisC = skmt.ExecQuery("select PE_PROID,PE_CANT FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) ")
|
||||||
|
If thisC.RowCount>0 Then
|
||||||
|
For i=0 To thisC.RowCount -1
|
||||||
|
thisC.Position=i
|
||||||
|
skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?", Array As Object(thisC.GetString("PE_CANT"),thisC.GetString("PE_PROID")))
|
||||||
|
skmt.ExecNonQuery2("INSERT INTO INVENT_X_ENVIAR (ALMACEN , PROID , CANTIDAD ) VALUES(?,?,?) ", Array As Object (traeAlmacen(db), thisC.GetString("PE_PROID"),thisC.GetString("PE_CANT")* -1))
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
skmt.ExecNonQuery("delete from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||||
|
skmt.ExecNonQuery("delete from pedido where pe_cliente in (Select CUENTA from cuentaa)")
|
||||||
|
skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||||
|
Return 1
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa verdadero si la columna gestion en la tabla "kmt_info" tene valor 2.
|
||||||
|
'si no, entonces regresa falso.
|
||||||
|
Sub pedidoGuardado(db As SQL) As Boolean 'ignore
|
||||||
|
Private guardado As Boolean = False
|
||||||
|
Private g As Cursor = skmt.ExecQuery("select gestion from kmt_info where CAT_CL_CODIGO in (Select CUENTA from cuentaa)")
|
||||||
|
If g.RowCount > 0 Then
|
||||||
|
g.Position=0
|
||||||
|
If g.GetString("gestion") = "2" Then guardado = True
|
||||||
|
End If
|
||||||
|
Log($"Guardado=${guardado}"$)
|
||||||
|
Return guardado
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa verdadero si hay pedido en la tabla "PEDIDO" del cliente actual.
|
||||||
|
Sub hayPedido(db As SQL) As Boolean 'ignore
|
||||||
|
Private thisC As Cursor = skmt.ExecQuery($"select count(PE_CLIENTE) as hayPedido from PEDIDO where PE_CLIENTE = '${traeCliente(db)}'"$)
|
||||||
|
thisC.Position = 0
|
||||||
|
Private hay As Boolean = False
|
||||||
|
If thisC.GetInt("hayPedido") > 0 Then hay = True
|
||||||
|
' Log($"Cliente actual=${traeCliente}, hayPedido=${hay}"$)
|
||||||
|
Return hay
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub string2date(fecha As String)
|
||||||
|
Log(fecha)
|
||||||
|
DateTime.DateFormat = "MM/dd/yyyy"
|
||||||
|
Dim t As Long = DateTime.DateTimeParse(fecha, "00:00:00")
|
||||||
|
DateTime.DateFormat = "yy/MM/dd"
|
||||||
|
Log($"${t} - ${Subs.fechaKMT(t)}"$)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Guarda el nombre y version de la app en CAT_VARIABLES.
|
||||||
|
Sub guardaAppInfo(db As SQL) 'ignore
|
||||||
|
db.ExecNonQuery("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'EMPRESA' or CAT_VA_DESCRIPCION = 'APP_NAME' or CAT_VA_DESCRIPCION = 'APP_VERSION'")
|
||||||
|
db.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('APP_NAME', '${Application.LabelName}')"$)
|
||||||
|
db.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('APP_VERSION', '${Application.VersionName}')"$)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Muestra en el Log los campos y valores que regresan en el JobDone.
|
||||||
|
Sub logJobDoneResultados(resultado As DBResult) 'ignore
|
||||||
|
For Each records() As Object In resultado.Rows
|
||||||
|
LogColor($"====== ${resultado.Tag} - REGISTROS = ${resultado.Rows.Size}"$, Colors.RGB(215,37,0))
|
||||||
|
For Each k As String In resultado.Columns.Keys
|
||||||
|
LogColor(k & " = " & records(resultado.Columns.Get(k)), Colors.RGB(215,37,0))
|
||||||
|
Next
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Revisa si la aplicación tiene permiso para acceder a las notificaciones.
|
||||||
|
Sub CheckNotificationAccess As Boolean
|
||||||
|
Dim ph As Phone
|
||||||
|
Dim nstr, pstr As String
|
||||||
|
Dim r As Reflector
|
||||||
|
pstr = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
|
||||||
|
nstr = ph.GetSettings("enabled_notification_listeners")
|
||||||
|
Return nstr.Contains(pstr)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'################ Manage External Storage (MES) #########################
|
||||||
|
'
|
||||||
|
''Inicializa "Manage External Storage" (MES), que nos da acceso a la tarjeta de memoria en Android 11+
|
||||||
|
'Public Sub MES_Init (mCallBack As Object, mEventName As String)
|
||||||
|
' mesCallback = mCallBack
|
||||||
|
' mesEventName = mEventName
|
||||||
|
'End Sub
|
||||||
|
'
|
||||||
|
'Sub MES_checkPermission 'ignore
|
||||||
|
'' ' get the device SDK version
|
||||||
|
'' Dim SdkVersion As Int = device.SdkVersion
|
||||||
|
'' ' Choose which permission to request in order to access external storgage
|
||||||
|
'' If SdkVersion < 30 Then
|
||||||
|
''' Log("SDK = " & SdkVersion & " : Requesting WRITE_EXTERNAL_STORAGE permission")
|
||||||
|
'' Dim rp As RuntimePermissions
|
||||||
|
'' rp.CheckAndRequestPermission(rp.PERMISSION_WRITE_EXTERNAL_STORAGE) ' Implicit read capability if granted
|
||||||
|
'' Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
''' Log($"PERMISSION_WRITE_EXTERNAL_STORAGE = ${Result}"$)
|
||||||
|
'' Else
|
||||||
|
''' Log("SDK = " & SdkVersion & " : Requesting MANAGE_EXTERNAL_STORAGE permission")
|
||||||
|
''' Log("On Entry MANAGE_EXTERNAL_STORAGE = " & MES1.HasPermission)
|
||||||
|
'' If Not(MES_HasPermission) Then
|
||||||
|
'' MsgboxAsync("This app requires access to all files, please enable the option", "Manage All Files")
|
||||||
|
'' Wait For Msgbox_Result(Res As Int)
|
||||||
|
''' Log("Getting permission")
|
||||||
|
'' MES_GetPermission
|
||||||
|
'' Wait For MES_StorageAvailable
|
||||||
|
'' End If
|
||||||
|
'' End If
|
||||||
|
'End Sub
|
||||||
|
'
|
||||||
|
'' Determine if the app already has MANAGE_EXTERNAL_STORAGE call Environment.isExternalStorageManager()
|
||||||
|
'' Return True if this app already has MANAGE_EXTERNAL_STORAGE permission
|
||||||
|
'Public Sub MES_HasPermission As Boolean
|
||||||
|
' Dim has As Boolean
|
||||||
|
' Dim jo As JavaObject
|
||||||
|
' jo.InitializeStatic("android.os.Environment")
|
||||||
|
' has = jo.RunMethod("isExternalStorageManager", Null)
|
||||||
|
' Return has
|
||||||
|
'End Sub
|
||||||
|
'
|
||||||
|
'' Check whether this app has MANAGE_EXTERNAL_STORAGE permission
|
||||||
|
'' If not show the user a dialog to enable MANAGE_EXTERNAL_STORAGE permission for this app
|
||||||
|
'' Raises the StorageAvailable event in the calling activity when complete
|
||||||
|
'Public Sub MES_GetPermission
|
||||||
|
' If MES_HasPermission Then
|
||||||
|
' RaiseEvent
|
||||||
|
' Return
|
||||||
|
' End If
|
||||||
|
' Dim in As Intent
|
||||||
|
' ' Be sure to reference your app package name in "pakageg:xxx"
|
||||||
|
' in.Initialize("android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION", $"package:${Application.PackageName}"$)
|
||||||
|
' StartActivityForResult(in)
|
||||||
|
'End Sub
|
||||||
|
'
|
||||||
|
'Private Sub RaiseEvent
|
||||||
|
' Log("Calling : " & mesEventName & "_StorageAvailable")
|
||||||
|
' CallSubDelayed(mesCallback, mesEventName & "_StorageAvailable")
|
||||||
|
'End Sub
|
||||||
|
'
|
||||||
|
'Private Sub ion_Event (MethodName As String, Args() As Object) As Object
|
||||||
|
' RaiseEvent
|
||||||
|
' Return Null
|
||||||
|
'End Sub
|
||||||
|
'
|
||||||
|
'Private Sub StartActivityForResult(i As Intent)
|
||||||
|
' Dim jo As JavaObject = MES_GetBA
|
||||||
|
' ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
|
||||||
|
' jo.RunMethod("startActivityForResult", Array As Object(ion, i))
|
||||||
|
'End Sub
|
||||||
|
'
|
||||||
|
'Private Sub MES_GetBA As Object
|
||||||
|
' Dim jo As JavaObject = Me
|
||||||
|
' Return jo.RunMethod("getBA", Null)
|
||||||
|
'End Sub
|
||||||
|
'################ TERMINA Manage External Storage (MES) #########################
|
||||||
|
|
||||||
|
|
||||||
|
'################ INICIA ENABLE BLUETOOTH #########################
|
||||||
|
Sub StartBluetooth 'ignore
|
||||||
|
btAdmin.Initialize("btAdmin")
|
||||||
|
Log("btAdmin: " & btAdmin.IsEnabled)
|
||||||
|
If btAdmin.IsEnabled = False Then
|
||||||
|
Wait For (EnableBluetooth) Complete (Success As Boolean)
|
||||||
|
If Success = False Then
|
||||||
|
ToastMessageShow("Failed to enable bluetooth", True)
|
||||||
|
End If
|
||||||
|
Log(Success)
|
||||||
|
End If
|
||||||
|
Log($"BTADMIN: ${btAdmin.IsEnabled}"$)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub EnableBluetooth As ResumableSub
|
||||||
|
ToastMessageShow("Enabling Bluetooth adapter...", False)
|
||||||
|
Private ph As Phone
|
||||||
|
If ph.SdkVersion >= 31 Then
|
||||||
|
rp.CheckAndRequest("android.permission.BLUETOOTH_CONNECT")
|
||||||
|
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
If Result = False Then Return False
|
||||||
|
Log($"BTCONNECT: ${Result}"$)
|
||||||
|
If ph.SdkVersion >= 33 Then
|
||||||
|
Dim in As Intent
|
||||||
|
in.Initialize("android.bluetooth.adapter.action.REQUEST_ENABLE", "")
|
||||||
|
StartActivityForResult(in)
|
||||||
|
Wait For ion_Event (MethodName As String, Args() As Object)
|
||||||
|
Return btAdmin.IsEnabled
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Return btAdmin.Enable
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub GetBA As Object
|
||||||
|
Dim jo As JavaObject = Me
|
||||||
|
Return jo.RunMethod("getBA", Null)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub StartActivityForResult(i As Intent)
|
||||||
|
Dim jo As JavaObject = GetBA
|
||||||
|
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
|
||||||
|
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
|
||||||
|
End Sub
|
||||||
|
'################ TERMINA ENABLE BLUETOOTH #########################
|
||||||
Reference in New Issue
Block a user