mirror of
https://github.com/KeymonSoft/Intmex_Preventa.git
synced 2026-04-19 21:59:24 +00:00
8/9/23 - Código para respaldo diario
Se agregó una clase para el respaldo diario en una base de datos en SDCARD/kmts, para usar el almacenamiento externo es necesario usar la clase "ManageExternalStorage".
This commit is contained in:
@@ -91,6 +91,8 @@ Sub Class_Globals
|
|||||||
Private b_enviarbd As Button
|
Private b_enviarbd As Button
|
||||||
Private b_importarBD As Button
|
Private b_importarBD As Button
|
||||||
Dim ime As IME
|
Dim ime As IME
|
||||||
|
Dim MES1 As ManageExternalStorage
|
||||||
|
Dim device As Phone
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub Initialize
|
Public Sub Initialize
|
||||||
@@ -142,7 +144,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
LogColor("copiamos kmt.db de "&File.DirAssets & " a " & ruta,Colors.Green)
|
LogColor("copiamos kmt.db de "&File.DirAssets & " a " & ruta,Colors.Green)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Log(ruta)
|
' Log(ruta)
|
||||||
skmt.Initialize(ruta,"kmt.db", True)
|
skmt.Initialize(ruta,"kmt.db", True)
|
||||||
Subs.guardaAppInfo(skmt)
|
Subs.guardaAppInfo(skmt)
|
||||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_CUOTAS (HC_META6 TEXT, HC_META5 TEXT, HC_META4 TEXT, HC_META3 TEXT, HC_META2 TEXT, HC_META1 TEXT, HC_RUTA TEXT, HC_CUOTA1 TEXT, HC_CUOTA2 TEXT, HC_CUOTA3 TEXT, HC_CUOTA4 TEXT, HC_CUOTA5 TEXT, HC_CUOTA6 TEXT)")
|
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_CUOTAS (HC_META6 TEXT, HC_META5 TEXT, HC_META4 TEXT, HC_META3 TEXT, HC_META2 TEXT, HC_META1 TEXT, HC_RUTA TEXT, HC_CUOTA1 TEXT, HC_CUOTA2 TEXT, HC_CUOTA3 TEXT, HC_CUOTA4 TEXT, HC_CUOTA5 TEXT, HC_CUOTA6 TEXT)")
|
||||||
@@ -172,11 +174,11 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
' reqManager.Initialize(Me, server)
|
' reqManager.Initialize(Me, server)
|
||||||
l_version.Text = Application.VersionName
|
l_version.Text = Application.VersionName
|
||||||
'este codigo es para lo del menu
|
'este codigo es para lo del menu
|
||||||
PopupMenu.Initialize("PopupMenu", b_menu)
|
' PopupMenu.Initialize("PopupMenu", b_menu)
|
||||||
PopupMenu.AddMenuItem(0, 0, "View")
|
' PopupMenu.AddMenuItem(0, 0, "View")
|
||||||
PopupMenu.AddMenuItem(1, 1, "Edit")
|
' PopupMenu.AddMenuItem(1, 1, "Edit")
|
||||||
PopupMenu.AddMenuItem(2, 2, "Details")
|
' PopupMenu.AddMenuItem(2, 2, "Details")
|
||||||
PopupMenu.AddMenuItem(3, 3, "Remove")
|
' PopupMenu.AddMenuItem(3, 3, "Remove")
|
||||||
' menu fin
|
' menu fin
|
||||||
montoActual = 0
|
montoActual = 0
|
||||||
clientesTotal = 0
|
clientesTotal = 0
|
||||||
@@ -217,7 +219,27 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
' Else
|
' Else
|
||||||
' ToastMessageShow("No permission", True)
|
' ToastMessageShow("No permission", True)
|
||||||
' End If
|
' End If
|
||||||
|
MES1.Initialize(Me, "MES1")
|
||||||
|
' 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.CheckAndRequest(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(MES1.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")
|
||||||
|
MES1.GetPermission
|
||||||
|
Wait For MES_StorageAvailable
|
||||||
|
End If
|
||||||
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ Sub B4XPage_Appear
|
|||||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||||
End If
|
End If
|
||||||
Log("appear")
|
' Log("appear")
|
||||||
cb_factura.Checked = False
|
cb_factura.Checked = False
|
||||||
p_abono.Visible = False
|
p_abono.Visible = False
|
||||||
Subs.centraPanel(p_abono, Root.Width)
|
Subs.centraPanel(p_abono, Root.Width)
|
||||||
@@ -492,7 +492,7 @@ Sub Guardar_Click
|
|||||||
c.Close
|
c.Close
|
||||||
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, COUNT(*) AS CUANTOS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, COUNT(*) AS CUANTOS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||||
c.Position=0
|
c.Position=0
|
||||||
Log("xxxxxxxxxxxxxxx " & c.GetString("CUANTOS"))
|
' Log("xxxxxxxxxxxxxxx " & c.GetString("CUANTOS"))
|
||||||
If c.GetString("CUANTOS") > 0 Then
|
If c.GetString("CUANTOS") > 0 Then
|
||||||
Private cbFactura As Int = 0
|
Private cbFactura As Int = 0
|
||||||
If cb_factura.Checked Then cbFactura = 1
|
If cb_factura.Checked Then cbFactura = 1
|
||||||
@@ -864,12 +864,12 @@ Sub mandaPendientes
|
|||||||
ab.Close
|
ab.Close
|
||||||
|
|
||||||
'CLIENTES NUEVOS
|
'CLIENTES NUEVOS
|
||||||
Log("Entre aqui")
|
' Log("Entre aqui")
|
||||||
Dim bb As Cursor = B4XPages.MainPage.skmt.ExecQuery($"SELECT * from CLIENTE_NUEVO where CN_enviado is null"$)
|
Dim bb As Cursor = B4XPages.MainPage.skmt.ExecQuery($"SELECT * from CLIENTE_NUEVO where CN_enviado is null"$)
|
||||||
Dim cb As Cursor = B4XPages.MainPage.skmt.ExecQuery("SELECT ID_ALMACEN from CAT_ALMACEN")
|
Dim cb As Cursor = B4XPages.MainPage.skmt.ExecQuery("SELECT ID_ALMACEN from CAT_ALMACEN")
|
||||||
cb.Position = 0
|
cb.Position = 0
|
||||||
Log("Entre aqui x2")
|
' Log("Entre aqui x2")
|
||||||
Log(bb.RowCount)
|
' Log(bb.RowCount)
|
||||||
If bb.RowCount > 0 Then
|
If bb.RowCount > 0 Then
|
||||||
For i=0 To bb.RowCount -1
|
For i=0 To bb.RowCount -1
|
||||||
bb.Position = i
|
bb.Position = i
|
||||||
@@ -915,7 +915,6 @@ Sub JobDone(Job As HttpJob)
|
|||||||
Private cliente As String= resultado.Tag
|
Private cliente As String= resultado.Tag
|
||||||
cliente = cliente.SubString(cliente.IndexOf("_")+24)
|
cliente = cliente.SubString(cliente.IndexOf("_")+24)
|
||||||
Log($"Cliente1:${cliente}"$)
|
Log($"Cliente1:${cliente}"$)
|
||||||
|
|
||||||
For Each records() As Object In resultado.Rows
|
For Each records() As Object In resultado.Rows
|
||||||
For Each k As String In resultado.Columns.Keys
|
For Each k As String In resultado.Columns.Keys
|
||||||
Log(resultado.Tag & ": " & k & ": " & records(resultado.Columns.Get(k)))
|
Log(resultado.Tag & ": " & k & ": " & records(resultado.Columns.Get(k)))
|
||||||
|
|||||||
@@ -11,12 +11,25 @@ Sub Class_Globals
|
|||||||
Dim rp As RuntimePermissions
|
Dim rp As RuntimePermissions
|
||||||
Dim safePath As String
|
Dim safePath As String
|
||||||
Dim fechaHoy As String
|
Dim fechaHoy As String
|
||||||
|
Dim skmtAttached As Boolean = False
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'You can add more parameters here.
|
'You can add more parameters here.
|
||||||
Public Sub Initialize As Object
|
Public Sub Initialize As Object
|
||||||
Log("************************** " & safePath)
|
' Log("************************** " & safePath)
|
||||||
safePath = rp.GetSafeDirDefaultExternal("./")
|
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 = rp.GetSafeDirDefaultExternal("./")
|
||||||
|
safePath = Dirp & Dir
|
||||||
rkmt.Initialize(safePath,"rkmt.km", True)
|
rkmt.Initialize(safePath,"rkmt.km", True)
|
||||||
skmt.Initialize(File.DirInternal,"kmt.db", False)
|
skmt.Initialize(File.DirInternal,"kmt.db", False)
|
||||||
rkmt.ExecNonQuery($"create table if not exists pedidos (pe_folio NUMERIC, pe_desc NUMERIC, pe_costo_sin TEXT, pe_ruta TEXT, pe_cedis TEXT, pe_costo_tot NUMERIC, pe_costou NUMERIC, pe_cant NUMERIC, pe_pronombre TEXT, pe_proid TEXT, pe_cliente TEXT, pe_fecha TEXT, pe_usuario TEXT)"$)
|
rkmt.ExecNonQuery($"create table if not exists pedidos (pe_folio NUMERIC, pe_desc NUMERIC, pe_costo_sin TEXT, pe_ruta TEXT, pe_cedis TEXT, pe_costo_tot NUMERIC, pe_costou NUMERIC, pe_cant NUMERIC, pe_pronombre TEXT, pe_proid TEXT, pe_cliente TEXT, pe_fecha TEXT, pe_usuario TEXT)"$)
|
||||||
@@ -24,6 +37,7 @@ Public Sub Initialize As Object
|
|||||||
rkmt.ExecNonQuery($"create table if not exists paquetes (cat_dp_precio_simptos TEXT, cat_dp_precio TEXT, cat_dp_almacen TEXT, cat_dp_id TEXT, cat_dp_idprod TEXT, cat_dp_tipo TEXT, cat_dp_pzas TEXT, cat_dp_usuario TEXT, cat_dp_fecha TEXT, cat_dp_regalo TEXT, cat_dp_clasif TEXT, fecha TEXT)"$)
|
rkmt.ExecNonQuery($"create table if not exists paquetes (cat_dp_precio_simptos TEXT, cat_dp_precio TEXT, cat_dp_almacen TEXT, cat_dp_id TEXT, cat_dp_idprod TEXT, cat_dp_tipo TEXT, cat_dp_pzas TEXT, cat_dp_usuario TEXT, cat_dp_fecha TEXT, cat_dp_regalo TEXT, cat_dp_clasif TEXT, fecha TEXT)"$)
|
||||||
DateTime.DateFormat = "MM/dd/yyyy"
|
DateTime.DateFormat = "MM/dd/yyyy"
|
||||||
fechaHoy = DateTime.Date(DateTime.Now)
|
fechaHoy = DateTime.Date(DateTime.Now)
|
||||||
|
revisaSkmtAttached
|
||||||
Return Me
|
Return Me
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -33,33 +47,42 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
'load the layout to Root
|
'load the layout to Root
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Sub revisaSkmtAttached
|
||||||
|
skmtAttached = False
|
||||||
|
Dim rs As ResultSet = rkmt.ExecQuery("SELECT * FROM pragma_database_list")
|
||||||
|
Do While rs.NextRow 'Revisamos si esta montada "kmt.db" como "skmt" 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
|
||||||
|
End Sub
|
||||||
|
|
||||||
'Copia la tabla PEDIDO a rkmt.db en la tarjeta del celular.
|
'Copia la tabla PEDIDO a rkmt.db en la tarjeta del celular.
|
||||||
Sub respaldaPedido
|
Sub respaldaPedido
|
||||||
Private inicio As String = DateTime.Now
|
Private inicio As String = DateTime.Now
|
||||||
Log("copiando pedidos ...")
|
Log("copiando pedidos ...")
|
||||||
Private skmtAttached As Boolean = False
|
rkmt.BeginTransaction
|
||||||
rkmt.ExecNonQuery($"delete from pedidos where substr(pe_fecha, 1, 10) = '${fechaHoy}'"$)
|
rkmt.ExecNonQuery($"delete from pedidos where substr(pe_fecha, 1, 10) = '${fechaHoy}'"$)
|
||||||
Dim rs As ResultSet = rkmt.ExecQuery("SELECT * FROM pragma_database_list")
|
|
||||||
Do While rs.NextRow 'Revismos si esta montada "kmt.db" como "skmt" 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;"$)
|
|
||||||
rkmt.ExecNonQuery($"insert into pedidos (pe_folio, pe_desc, pe_costo_sin, pe_ruta, pe_cedis, pe_costo_tot, pe_costou, pe_cant, pe_pronombre, pe_proid, pe_cliente, pe_fecha, pe_usuario) select * from skmt1.pedido where substr(pe_fecha, 1, 10) = '${fechaHoy}'"$)
|
rkmt.ExecNonQuery($"insert into pedidos (pe_folio, pe_desc, pe_costo_sin, pe_ruta, pe_cedis, pe_costo_tot, pe_costou, pe_cant, pe_pronombre, pe_proid, pe_cliente, pe_fecha, pe_usuario) select * from skmt1.pedido where substr(pe_fecha, 1, 10) = '${fechaHoy}'"$)
|
||||||
|
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
||||||
|
rkmt.EndTransaction
|
||||||
Log(((DateTime.Now - inicio)/1000) & " segs")
|
Log(((DateTime.Now - inicio)/1000) & " segs")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
'Copia la tabla CAT_GUNAPRODS a rkmt.db en la tarjeta del celular.
|
'Copia la tabla CAT_GUNAPRODS a rkmt.db en la tarjeta del celular.
|
||||||
Sub respaldaInventarios
|
Sub respaldaInventarios
|
||||||
|
Log($"Borrando de fecha ${fechaHoy}"$)
|
||||||
Private inicio As String = DateTime.Now
|
Private inicio As String = DateTime.Now
|
||||||
Log("copiando inventarios ...")
|
Log("copiando inventarios ...")
|
||||||
Private skmtAttached As Boolean = False
|
' rkmt.ExecNonQuery($"delete from inventarios where substr(fecha, 1, 10) = '${fechaHoy}'"$)
|
||||||
rkmt.ExecNonQuery($"delete from inventarios where substr(fecha, 1, 10) = '${fechaHoy}'"$)
|
rkmt.BeginTransaction
|
||||||
Dim rs As ResultSet = rkmt.ExecQuery("SELECT * FROM pragma_database_list")
|
rkmt.ExecNonQuery($"delete from inventarios where fecha = '${fechaHoy}'"$)
|
||||||
Do While rs.NextRow 'Revismos si esta montada "kmt.db" como "skmt" 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;"$)
|
|
||||||
rkmt.ExecNonQuery($"insert into inventarios (cat_gp_iniciativa, cat_gp_tipoprod, cat_gp_dev, cat_gp_almacen, cat_gp_id, cat_gp_nombre, cat_gp_imp1, cat_gp_imp2, cat_gp_precio, cat_gp_clasif, cat_gp_sts, cat_gp_tipo, cat_gp_subtipo, fecha) select cat_gp_iniciativa, cat_gp_tipoprod, cat_gp_dev, cat_gp_almacen, cat_gp_id, cat_gp_nombre, cat_gp_imp1, cat_gp_imp2, cat_gp_precio, cat_gp_clasif, cat_gp_sts, cat_gp_tipo, cat_gp_subtipo, '${fechaHoy}' as fecha from skmt1.cat_gunaprod"$)
|
rkmt.ExecNonQuery($"insert into inventarios (cat_gp_iniciativa, cat_gp_tipoprod, cat_gp_dev, cat_gp_almacen, cat_gp_id, cat_gp_nombre, cat_gp_imp1, cat_gp_imp2, cat_gp_precio, cat_gp_clasif, cat_gp_sts, cat_gp_tipo, cat_gp_subtipo, fecha) select cat_gp_iniciativa, cat_gp_tipoprod, cat_gp_dev, cat_gp_almacen, cat_gp_id, cat_gp_nombre, cat_gp_imp1, cat_gp_imp2, cat_gp_precio, cat_gp_clasif, cat_gp_sts, cat_gp_tipo, cat_gp_subtipo, '${fechaHoy}' as fecha from skmt1.cat_gunaprod"$)
|
||||||
|
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
||||||
|
rkmt.EndTransaction
|
||||||
Log(((DateTime.Now - inicio)/1000) & " segs")
|
Log(((DateTime.Now - inicio)/1000) & " segs")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -67,14 +90,12 @@ End Sub
|
|||||||
Sub respaldaPaquetes
|
Sub respaldaPaquetes
|
||||||
Private inicio As String = DateTime.Now
|
Private inicio As String = DateTime.Now
|
||||||
Log("copiando paquetes ...")
|
Log("copiando paquetes ...")
|
||||||
Private skmtAttached As Boolean = False
|
rkmt.BeginTransaction
|
||||||
rkmt.ExecNonQuery($"delete from paquetes where substr(fecha, 1, 10) = '${fechaHoy}'"$)
|
' rkmt.ExecNonQuery($"delete from paquetes where substr(fecha, 1, 10) = '${fechaHoy}'"$)
|
||||||
Dim rs As ResultSet = rkmt.ExecQuery("SELECT * FROM pragma_database_list")
|
rkmt.ExecNonQuery($"delete from paquetes where fecha = '${fechaHoy}'"$)
|
||||||
Do While rs.NextRow 'Revismos si esta montada "kmt.db" como "skmt" 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;"$)
|
|
||||||
rkmt.ExecNonQuery($"insert into paquetes (cat_dp_precio_simptos, cat_dp_precio, cat_dp_almacen, cat_dp_id, cat_dp_idprod, cat_dp_tipo, cat_dp_pzas, cat_dp_usuario, cat_dp_fecha, cat_dp_regalo, cat_dp_clasif, fecha) select cat_dp_precio_simptos, cat_dp_precio, cat_dp_almacen, cat_dp_id, cat_dp_idprod, cat_dp_tipo, cat_dp_pzas, cat_dp_usuario, cat_dp_fecha, cat_dp_regalo, cat_dp_clasif, '${fechaHoy}' as fecha from skmt1.cat_detalles_paq"$)
|
rkmt.ExecNonQuery($"insert into paquetes (cat_dp_precio_simptos, cat_dp_precio, cat_dp_almacen, cat_dp_id, cat_dp_idprod, cat_dp_tipo, cat_dp_pzas, cat_dp_usuario, cat_dp_fecha, cat_dp_regalo, cat_dp_clasif, fecha) select cat_dp_precio_simptos, cat_dp_precio, cat_dp_almacen, cat_dp_id, cat_dp_idprod, cat_dp_tipo, cat_dp_pzas, cat_dp_usuario, cat_dp_fecha, cat_dp_regalo, cat_dp_clasif, '${fechaHoy}' as fecha from skmt1.cat_detalles_paq"$)
|
||||||
|
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
||||||
|
rkmt.EndTransaction
|
||||||
Log(((DateTime.Now - inicio)/1000) & " segs")
|
Log(((DateTime.Now - inicio)/1000) & " segs")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
79
B4A/ManageExternalStorage.bas
Normal file
79
B4A/ManageExternalStorage.bas
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=10.7
|
||||||
|
@EndOfDesignText@
|
||||||
|
' Version 1.00
|
||||||
|
#Event: StorageAvailable
|
||||||
|
Sub Class_Globals
|
||||||
|
Private ion As Object
|
||||||
|
Private mCallback As Object
|
||||||
|
Private mEventName As String
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
' This pretty trivial class is modelled on (plagiarised from!) Erel's ExternalStorage class
|
||||||
|
' It applies to devices implementing SDK30 and later
|
||||||
|
' It allows apps to access the internal 'external' storage as was possible on earlier Android versions ussing traditional file I/O
|
||||||
|
' You must manually add 'AddPermission(android.permission.MANAGE_EXTERNAL_STORAGE)' to the manifest
|
||||||
|
' You must ensure that you provide the package name of your app in Sub GetPermission
|
||||||
|
' This class uses the MANAGE_APP_ALL_FILES_ACCESS_PERMISSION intent action to direct users to a system settings page
|
||||||
|
' They must enable the option on that page to give permission
|
||||||
|
|
||||||
|
'Initializes the object
|
||||||
|
Public Sub Initialize (Callback As Object, EventName As String)
|
||||||
|
mCallback = Callback
|
||||||
|
mEventName = EventName
|
||||||
|
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 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 GetPermission
|
||||||
|
If 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 : " & mEventName & "_StorageAvailable")
|
||||||
|
CallSubDelayed(mCallback, mEventName & "_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 = GetBA
|
||||||
|
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
|
||||||
|
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub GetBA As Object
|
||||||
|
Dim jo As JavaObject = Me
|
||||||
|
Return jo.RunMethod("getBA", Null)
|
||||||
|
End Sub
|
||||||
|
|
||||||
@@ -924,7 +924,7 @@ End Sub
|
|||||||
'Revisa si tenemos los productos variables requeridos para la promoción (mapa).
|
'Revisa si tenemos los productos variables requeridos para la promoción (mapa).
|
||||||
'Hay que darle como parametro un mapa (traePromo(promo)) con toda la informacion de la promocion.
|
'Hay que darle como parametro un mapa (traePromo(promo)) con toda la informacion de la promocion.
|
||||||
Sub alcanzanLosVariablesParaPromo(promoMap As Map, inventarioSinFijos As Map) As Boolean 'ignore
|
Sub alcanzanLosVariablesParaPromo(promoMap As Map, inventarioSinFijos As Map) As Boolean 'ignore
|
||||||
Private thisLog As Boolean = True 'Si es verdadero, muestra los logs de este sub.
|
Private thisLog As Boolean = False 'Si es verdadero, muestra los logs de este sub.
|
||||||
If thisLog Then LogColor("Inventario inicial: "&inventarioSinFijos, Colors.Gray) 'Inventario inicial.
|
If thisLog Then LogColor("Inventario inicial: "&inventarioSinFijos, Colors.Gray) 'Inventario inicial.
|
||||||
Private totalProdsVariables As Int = 0
|
Private totalProdsVariables As Int = 0
|
||||||
Private totalProdsVariables2 As Int = 0
|
Private totalProdsVariables2 As Int = 0
|
||||||
@@ -951,7 +951,7 @@ Sub alcanzanLosVariablesParaPromo(promoMap As Map, inventarioSinFijos As Map) As
|
|||||||
If thisLog Then Log("Total prods variables2=" & totalProdsVariables2 & ", requeridos2=" & promoMap.Get("prodsVariables2Requeridos"))
|
If thisLog Then Log("Total prods variables2=" & totalProdsVariables2 & ", requeridos2=" & promoMap.Get("prodsVariables2Requeridos"))
|
||||||
Private res As Boolean = False
|
Private res As Boolean = False
|
||||||
|
|
||||||
Log($"${totalProdsVariables2} >= ${promoMap.Get("prodsVariables2Requeridos")}"$)
|
' Log($"${totalProdsVariables2} >= ${promoMap.Get("prodsVariables2Requeridos")}"$)
|
||||||
|
|
||||||
If totalProdsVariables >= promoMap.Get("prodsVariablesRequeridos") Then res = True 'Si el total de inventario de productos variables (totalProdsVariables) es mayor o igual a los productos requeridos entonces regresamos TRUE
|
If totalProdsVariables >= promoMap.Get("prodsVariablesRequeridos") Then res = True 'Si el total de inventario de productos variables (totalProdsVariables) es mayor o igual a los productos requeridos entonces regresamos TRUE
|
||||||
If totalProdsVariables2 >= promoMap.Get("prodsVariables2Requeridos") Then res = True 'Si el total de inventario de productos variables (totalProdsVariables) es mayor o igual a los productos requeridos entonces regresamos TRUE
|
If totalProdsVariables2 >= promoMap.Get("prodsVariables2Requeridos") Then res = True 'Si el total de inventario de productos variables (totalProdsVariables) es mayor o igual a los productos requeridos entonces regresamos TRUE
|
||||||
@@ -1274,7 +1274,7 @@ Sub pedidoGuardado As Boolean
|
|||||||
g.Position=0
|
g.Position=0
|
||||||
If g.GetString("gestion") = "2" Then guardado = True
|
If g.GetString("gestion") = "2" Then guardado = True
|
||||||
End If
|
End If
|
||||||
Log($"Guardado=${guardado}"$)
|
' Log($"Guardado=${guardado}"$)
|
||||||
Return guardado
|
Return guardado
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user