- Se agregó nuevamente la opción de importar la base de datos directamente desde Whatsapp, hay que ingresar al engrane con el usuario KMTS1.

- Se cambio el nombre del archivo que se envia por WhatsApp cuando se envia la base de datos, ahora es kmt_mariana.db
This commit is contained in:
2024-05-20 11:53:26 -06:00
parent 2a8817aa02
commit 38c1fca015
18 changed files with 582 additions and 517 deletions

View File

@@ -19,6 +19,8 @@ Sub Class_Globals
Dim reqsList As List
Dim reqError As Boolean = False
Private subsLogs As Boolean = False
Dim in As Intent
Dim intentUsado As Boolean = False
End Sub
'You can add more parameters here.
@@ -604,4 +606,49 @@ Sub borraPedidoClienteActual As String
Starter.skmt.ExecNonQuery("delete from pedido where pe_cliente in (Select CUENTA from cuentaa)")
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
Return 1
End Sub
'Regresa si se debe de usar el intent de importar la base d datos desde Whatsapp.
Sub traeUsarIntentBDWA As Boolean 'ignore
Private BDWA As Boolean = False
Private x As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'"$)
If x.RowCount > 0 Then
x.Position = 0
If x.GetString("CAT_VA_VALOR") = "true" Then BDWA = True
End If
' Log($"cb_importarBDWA = ${BDWA}"$)
Return BDWA
End Sub
' Se revisa si hay una intención (intent) de abrir una base de datos y si es así, entonces se importa esa base de datos.
Sub importaBDDesdeWhatsApp
Private tmpBDWA As Boolean = traeUsarIntentBDWA
If Not(in.IsInitialized) Then in = B4XPages.GetNativeParent(B4XPages.MainPage).GetStartingIntent ' Si se usa esta funcion en Mainpage, se pone "Me" en lugar de B4XPages.MainPage.
If Not(intentUsado) And in <> Null Then
' Log(in)
intentUsado = True
' Log(in.As(String))
If in.GetData <> Null Then
Dim XmlData As String
XmlData = in.GetData
Try
Dim OutStr As OutputStream = File.OpenOutput(File.DirInternal,"kmt.db",False)
Dim InStr As InputStream = File.OpenInput("ContentDir",XmlData)
File.Copy2(InStr,OutStr)
LogColor("BD copiada a interna.", Colors.Blue)
OutStr.Close
If in.As(String).Contains("whatsapp") Then ToastMessageShow("BD cargada desde Whatsapp", False)
Catch
Log(LastException)
End Try
' ExitApplication
db.ExecNonQuery("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'")
db.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('IMPORTAR_BD_WA', '${tmpBDWA}')"$)
Private a As Cursor = db.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'APP_NAME'"$)
If a.RowCount > 0 Then
a.Position = 0
ToastMessageShow($"BD de "${a.GetString("CAT_VA_VALOR")}" cargada."$, True)
End If
End If
End If
End Sub