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
'	'###########################################################################################################
'	'######################           PULL         #############################################################
'	'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull
'	'###########################################################################################################
'	'######################           PUSH         #############################################################
'	'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=github&Args=..\..\
'	'###########################################################################################################
'	'######################      PUSH TORTOISE GIT     #########################################################
'	'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=TortoiseGitProc&Args=/command:commit&Args=/path:"./../../"&Args=/closeonend:2
'	'###########################################################################################################
'#End Region
'
''Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
'
'Sub Class_Globals
'	Dim rp As RuntimePermissions
'	Private Root As B4XView
'	Private xui As XUI
'	Private Root As B4XView
'	Public rp As RuntimePermissions
'	Public login As B4XMainPage
'	Public principal As C_Principal
'	Public clientes As C_Clientes
'	Public cliente As C_Cliente
''	Public foto As C_Foto
'	Public productos As C_Productos
'	Public updateAvailable As C_UpdateAvailable
'	Public mapas As C_Mapas
'	Public nuevoCliente As C_NuevoCliente
'	Public ticketsDia As C_TicketsDia
'	Public noVenta As C_NoVenta
'	Public pedidos As C_Pedidos
'	Public buscar As C_Buscar
''	Public historico As C_Historico
'	Public detalleVenta As C_DetalleVenta
'	Public detalle_promo As C_Detalle_Promo
'	Dim reqManager As DBRequestManager
''	Dim ruta As String
'	Dim usuario As String
'	Dim logger As Boolean = True
'	Dim lat_gps, lon_gps As String
''	Dim skmt As SQL
'	Dim usuario As String
'	Dim server As String
'	Dim montoActual, clientesTotal, clientesVenta, clientesRechazo, clientesVisitados, almacen, rutaPreventa, CANTIDADPROD As String
'	Dim ultimaActualizacionGPS As String = 235959
'	Dim fechaRuta As String
''	Public wsServerLink As String = "ws://187.189.244.154:51042/push/b4a_ws2"
''	Public wsServerLink As String = "ws://10.0.0.214:51042/push/b4a_ws2"
'	Dim srvIp As String
'	Dim phn As Phone
'	Dim user As EditText
'	Dim pass As EditText
'	Dim c As Cursor
'	Dim existe As String
'	Dim paso1,paso2,paso3 As String
'	Private IMEN As Label
'	Dim IMEI As String
'	Private Label1 As Label
'	Dim server As String
'	Private p_principal As Panel
'	Private Entrar As Button
'	Public checklist As C_Cheklist
'	Public tabulador As C_tabulador
'	Dim batt As Int
'	Dim monto_entregadoactual As String
'	Dim piezas_entregdas As String
'	Dim porVisitar, entregas, rechazos, montoEntregado, montoRechazado As String
'	Private p_appUpdate As Panel
'	Private i_engrane As ImageView
'	Private b_server As Button
'	Private b_apk As Button
'	Private b_envioBD As Button
'	Private b_regesar As Button
'	Private et_server As EditText
'	Private p_serverList As Panel
'	Private lv_server As ListView
'	Public Provider As FileProvider
'	Public rutaBDBackup As String = ""
'	Private B_Can_Monto As Button
'	Private B_Aceptar_Monto As Button
'	Private ET_Add_Monto As EditText
'	Private p_add_monto As Panel
'	Dim sDate, sTime As String
'	Private p_validacion As Panel
'	Private b_cancelarcodigo As Button
'	Private b_aceptar As Button
'	Private et_codigo As EditText
'	Private P_CIEGO As Panel
'	Private b_terpc As Button
'	Private B_PC_ENV As Button
'	Private CLV_PICK_CIEGO As CustomListView
'	Private et_buspc As EditText
'	Dim q_buscar As String
'	Dim d As Cursor
'	Private L_PICK_CIEGO As Label
'	Private ET_PICK_CIEGO As EditText
'	Dim a As Cursor
'	Dim f As Cursor
'	Private b_abono As Button
'	
'	Dim codigo, usuariocheck As Int
'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
'	B4XPages.GetManager.LogEvents = True
'	Root.LoadLayout("login")
''	B4XPages.SetTitle(Me, "Guna Reparto")
'	login.Initialize
'	B4XPages.AddPage("Login", login)
'	principal.Initialize
'	B4XPages.AddPage("Principal", principal)
'	clientes.Initialize
'	B4XPages.AddPage("Clientes", clientes)
'	cliente.Initialize
'	B4XPages.AddPage("Cliente", cliente)
''	foto.Initialize
''	B4XPages.AddPage("Foto", foto)
'	productos.Initialize
'	B4XPages.AddPage("Productos", productos)
'	updateAvailable.Initialize
'	B4XPages.AddPage("updateAvailable", updateAvailable)
'	mapas.Initialize
'	B4XPages.AddPage("Mapas", mapas)
'	nuevoCliente.Initialize
'	B4XPages.AddPage("NuevoCliente", nuevoCliente)
'	ticketsDia.Initialize
'	B4XPages.AddPage("TicketsDia", ticketsDia)
'	noVenta.Initialize
'	B4XPages.AddPage("NoVenta", noVenta)
'	pedidos.Initialize
'	B4XPages.AddPage("Pedidos", pedidos)
'	buscar.Initialize
'	B4XPages.AddPage("Buscar", buscar)
''	historico.Initialize
''	B4XPages.AddPage("Historico", historico)
'	detalleVenta.Initialize
'	B4XPages.AddPage("DetalleVenta", detalleVenta)
'	detalle_promo.Initialize
'	B4XPages.AddPage("Detalle_Promo", detalle_promo)
'	tabulador.Initialize
'	B4XPages.AddPage("tabulador", tabulador)
'	checklist.Initialize
'	B4XPages.AddPage("checklist",checklist)
''	p_principal.Width = Root.Width
''	p_principal.Height = Root.Height * .90
'	Entrar.Left = (p_principal.Width - Entrar.Width) / 2
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_GUNAPROD3 (CAT_GP_INICIATIVA TEXT, CAT_GP_TIPOPROD TEXT, CAT_GP_DEV TEXT, CAT_GP_ALMACEN NUMERIC, CAT_GP_ID TEXT, CAT_GP_NOMBRE TEXT, CAT_GP_IMP1 TEXT, CAT_GP_IMP2 TEXT, CAT_GP_PRECIO TEXT, CAT_GP_CLASIF TEXT, CAT_GP_STS TEXT, CAT_GP_TIPO TEXT, CAT_GP_SUBTIPO TEXT, CAT_GP_IMG BLOB)")
'	Subs.agregaColumna("CAT_GUNAPROD3", "CAT_DP_CONVERSION1", "TEXT")
'	Subs.agregaColumna("CAT_GUNAPROD3", "CAT_DP_PRECIO4", "TEXT")
'	Subs.agregaColumna("CAT_GUNAPROD3", "CAT_DP_CANT_MIN_VENTA", "TEXT")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS ABONOS (a_usuario TEXT, a_ruta TEXT, a_cliente TEXT, a_abono TEXT, a_fecha TEXT, a_enviado TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS PAGARES (PA_ALMACEN TEXT, PA_RUTA_REP TEXT, PA_RUTAPREV TEXT, PA_FECHA_PREV TEXT, PA_CAPTURA TEXT, PA_MONTO TEXT, PA_USUARIO TEXT, PA_CLIENTE TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS PICK_CIEGO (PC_ID_PROD TEXT, PC_NOM_PROD TEXT, PC_CANT TEXT, PC_ALMACEN TEXT, PC_RUTA TEXT, PC_FECHA TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS ENV_MONTO_LIQ (EML_MONTO TEXT, EML_ALMACEN TEXT, EML_RUTA TEXT, EML_USUARIO TEXT, EML_FECHA_PED TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS TABULADOR_MONEDAS(VEINTE TEXT, DIEZ TEXT, CINCO TEXT, DOS TEXT, PESO TEXT, CENTAVO TEXT, TOTAL TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS TABULADOR_BILLETES(MIL TEXT, QUINIENTOS TEXT, DOCIENTOS TEXT, CIEN TEXT, CINCUENTA TEXT, VEINTE TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_VENTAS2 (HVD_PARCIAL TEXT, HVD_RECHAZO TEXT, HVD_NUM_REGISTRO TEXT, HVD_NUM_TICKET TEXT, HVD_PROID TEXT, HVD_CODPROMO TEXT, HVD_FECHA TEXT, HVD_ESTATUS TEXT, HVD_CLIENTE TEXT, HVD_PRONOMBRE TEXT, HVD_CANT TEXT, HVD_COSTO_TOT TEXT)")
''	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS VENTAS (V_FECHA TEXT, V_CLIENTE TEXT, V_CLIENTE_ORIG TEXT, V_PRODNOMBRE TEXT, V_PRODID TEXT, V_CANTIDAD TEXT, V_PRECIO TEXT, V_TOTAL TEXT, V_PRODREGISTRO TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS RECHAZOS (R_FECHA TEXT, R_CLIENTE TEXT, R_CLI_ORIG TEXT, R_PRODID TEXT, R_CANT TEXT, R_RECHAZO INT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS VENTAS (V_FECHA TEXT, V_CLIENTE TEXT, V_CLI_ORIG TEXT, V_PRODID TEXT, V_CANT TEXT, V_RECHAZO INT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS ABONOSP(NOTA TEXT, CLIENTE TEXT, SALDO_PENDIENTE TEXT)")
''	Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS PAGARES")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CHECADO_CHECK(CHECADO TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CODIGO_UNICO(CODIGO TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS INICIO_SESION(CONECTADO TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS BLOCKENVIO(ENVIADO TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_REPARTO_GEO(HIST_RG_MONTO TEXT, HIST_RG_CREDITO TEXT, HIST_RG_MONTO_CREDITO TEXT, HIST_RG_LAT TEXT, HIST_RG_LONG TEXT, HIST_RG_RECHAZO TEXT, HIST_RG_MOTIVO TEXT, HIST_RG_USUARIO_ENTREGO TEXT, HIST_RG_RUTA_REP TEXT, HIST_RG_ESTATUS_ENTREGA TEXT, HIST_RG_COMENTARIO_ENTREGA TEXT, HIST_RG_FORMA_PAGO TEXT, HIST_RG_GEOCERCA_MTS TEXT, HIST_RG_NO_ART TEXT, HIST_RG_CLIENTE TEXT, HIST_RG_FECHA TEXT, HIST_RG_ALMACEN TEXT, HIST_RG_RUTA_PRE TEXT)")
'	
''	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS PAGARES(TMP_MONTO_PAGARE TEXT, TMP_CLIENTE TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CHECKLIST(USUARIO TEXT, PLACA TEXT, FECHA_CAPTURA TEXT, TARJETA_CIRCULACION TEXT , POLIZA_SEGURO TEXT, LICENCIA_CONDUCIR TEXT, LIMPIA_EXTERNA TEXT, LIMPIA_INTERNA TEXT, TRIANGULO TEXT, GATO TEXT, LLANTA_REFACCION TEXT, CARROCERIA_BUENESTADO TEXT, CARROCERIA_MALESTADO TEXT, CARROCERIA_COMENTARIOS TEXT, LUCES_CORRECTO TEXT, LUCES_INCORRECTO TEXT, LUCES_COMENTARIOS TEXT, CONDICION_PLACAS_CORRECTO TEXT, CONDICION_PLACAS_INCORRECTO TEXT, CONDICION_PLACAS_COMENTARIOS TEXT, CONDICION_LLANTAS_DEL_DER TEXT, CONDICION_LLANTAS_DEL_IZQ TEXT, CONDICION_LLANTAS_TRASERA_DER TEXT, CONDICION_LLANTAS_TRASERA_IZQ TEXT, ACEITE TEXT, ANTICONGELANTE TEXT, FRENOS TEXT, AIRE TEXT, FUGAS TEXT, COMETARIOS_FUGAS TEXT, FOTO1 BLOB, FOTO12 BLOB, FOTO3 BLOB, FOTO4 BLOB)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CHECKLIST2(USUARIO TEXT, PLACA TEXT, FECHA_CAPTURA TEXT, TARJETA_CIRCULACION TEXT, POLIZA_SEGURO TEXT, LICENCIA_CONDUCIR TEXT, LIMPIA_EXTERNA TEXT, LIMPIA_INTERNA TEXT, TRIANGULO TEXT, GATO TEXT, LLANTA_REFACCION TEXT, CARROCERIA TEXT, CARROCERIA_COMENTARIOS TEXT, LUCES TEXT, LUCES_COMENTARIOS TEXT, CONDICION_PLACAS TEXT, CONDICION_PLACAS_COMENTARIOS TEXT, CONDICION_LLANTAS_DEL_DER TEXT, CONDICION_LLANTAS_DEL_IZQ TEXT, CONDICION_LLANTAS_TRASERA_DER TEXT, CONDICION_LLANTAS_TRASERA_IZQ TEXT, ACEITE TEXT, ANTICONGELANTE TEXT, FRENOS TEXT, AIRE TEXT, FUGAS TEXT, COMETARIOS_FUGAS TEXT, FOTO1 BLOB, FOTO12 BLOB, FOTO3 BLOB, FOTO4 BLOB, KILIMETRAJE TEXT, RUTA TEXT)")
'	Subs.agregaColumna("REPARTO", "REP_PRODREGISTRO", "TEXT")
'	Subs.agregaColumna("NOVENTA", "NV_RUTA", "TEXT")
'	Subs.agregaColumna("ABONOS", "a_ticket", "TEXT")
'	Subs.agregaColumna("ABONOS", "a_tipoabono", "TEXT")
'	
'	Subs.agregaColumna("PAGARES", "PA_CANCELADO", "TEXT")
'	Subs.agregaColumna("ABONOSP", "NOMBRE", "TEXT")
'	Subs.agregaColumna("kmt_info", "SECUENCIA", "INT")
'	Subs.agregaColumna("kmt_info", "HORAENT", "TEXT")
'	Subs.agregaColumna("REPARTO", "REP_PRODID", "TEXT")
'	Subs.agregaColumna("PEDIDO", "PE_CLIENTEOR", "TEXT")
'	Subs.agregaColumna("PAGARES", "PA_TICKET", "TEXT")
'	Subs.agregaColumna("PEDIDO", "PE_CAJAS", "TEXT")
'	Subs.agregaColumna("PEDIDO", "PE_REGALO", "TEXT")
'	Subs.agregaColumna("PEDIDO", "PE_BCAJAS", "TEXT")
'	Subs.agregaColumna("PEDIDO", "CONSECUTIVO", "TEXT")
'	Subs.agregaColumna("PEDIDO", "FECHA_PREV", "TEXT")
'	Subs.agregaColumna("PEDIDO", "RUTA_REP", "TEXT")
'	Subs.agregaColumna("REPARTO", "REP_CLI_ORIG", "TEXT")
'	Subs.agregaColumna("REPARTO", "REP_PRECIO", "TEXT")
'	Subs.agregaColumna("REPARTO", "REP_RECHAZO", "INTEGER")
'	Subs.agregaColumna("RECHAZOS", "R_PRECIO", "TEXT")
'	Subs.agregaColumna("VENTAS", "V_PRECIO", "TEXT")
'	Subs.agregaColumna("HIST_VENTAS","PLACA","TEXT")
'	Subs.agregaColumna("HIST_VENTAS","HVD_RECHAZOCANT","TEXT")
'	Subs.agregaColumna("HIST_VENTAS","CONSECUTIVO","TEXT")
'	Subs.agregaColumna("HIST_VENTAS","HVD_RECHAZOCANT","TEXT")
'	Subs.agregaColumna("HIST_VENTAS","ESPROMO","TEXT")
'	Subs.agregaColumna("HIST_VENTAS","HVD_RECHAZOCANTC","TEXT")
'	Subs.agregaColumna("HIST_VENTAS","BCAJAS","TEXT")
'	Subs.agregaColumna("HIST_VENTAS","CANTC","TEXT")
'	Subs.agregaColumna("HIST_VENTAS","BCAJAS_OR","TEXT")
'	Subs.agregaColumna("HIST_VENTAS","CANTC_OR","TEXT")
'	Subs.agregaColumna("CAT_GUNAPROD","CONVERSION","TEXT")
'	Subs.agregaColumna("kmt_info","CAT_CL_LIMITECREDITO","TEXT")
'	Subs.agregaColumna("CAT_GUNAPROD","PRECIOCONVER","TEXT")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS RUTAA (RUTAA TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS wayPoints (codigo TEXT, indice INT)")
'	Dim server As String = "http://keymon.net:1782"
''	Dim server As String = "http://192.168.100.10:1781"
''	Dim server As String = "http://keymon.lat:9000"
''	server = "http://10.0.0.205:1782"
''	Dim server As String = "http://192.168.100.10:1781"
''	server = "http://11.0.0.44:1782"
'	reqManager.Initialize(Me, B4XPages.MainPage.server)
'	LogColor($"ReqServer = ${B4XPages.MainPage.server}"$, Colors.red)
'	Label1.Text = Application.VersionName
''	Dim P As PhoneId
'	Log("provider")
'	Provider.Initialize
'	
'	Subs.guardaAppInfo
'
''	Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_PHONE_STATE)
''	Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
''	If Result Then
''		IMEN.Text = "" 'P.GetDeviceId
''		IMEI = "" 'P.GetDeviceId
''	End If
'End Sub
'
'Sub B4XPage_Appear
'	If Starter.muestraProgreso = 1 Then
'		muestraProgreso("Descargando actualización")
'		Starter.muestraProgreso = 0
'	End If
'	Subs.centraPanel(p_principal, Root.Width)
'	Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
''	LogColor("Start Tracker1", Colors.red)
'	Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
'	If Result Then
'		If Not(Tracker.Tracking) Then StartService(Tracker)
''		LogColor("Start Tracker", Colors.red)
'	Else
'		ToastMessageShow("No permission", True)
'		Log("Sin permisos")
'	End If
''	LogColor("Start Tracker3", Colors.red)
'	c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
'	If c.RowCount > 0 Then
''		c.Position=0
''		c=skmt.ExecQuery("select USUARIO from usuarioa")
'		c.Position=0
'		usuario = c.GetString("USUARIO")
'	End If
'	c.Close
''	Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
''	Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
''	If Result Then
''		Log("Con permisos de escritura externa")
''	End If
'
'	c=Starter.skmt.ExecQuery("select CODIGO from CODIGO_UNICO")  ''''Codigo de acceso unico
'	If c.RowCount = 0 Then
'		Dim Random5Digits As String
'		Random5Digits = NumberFormat2(Rnd(0, 100000), 5, 0, 0,False) ' Rellenado con ceros a la izquierda
'		Log("Número aleatorio de 5 dígitos (con ceros): " & Random5Digits)
'		Dim pascon As Cursor = Starter.skmt.ExecQuery("select * from USUARIOA")
'		pascon.Position = 0
'		Starter.skmt.ExecNonQuery2("INSERT INTO CODIGO_UNICO VALUES (?)", Array As Object(Random5Digits))
'	End If
'	c.Close
'End Sub
'
''You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
'
'Sub Entrar_Click
'	If pass.Text = "YA" Then
'		Starter.skmt.ExecNonQuery("delete from usuarioa")
'		Starter.skmt.ExecNonQuery("delete from VERSION")
'		Starter.skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object("ROOT", "ROOT"))
'		Starter.skmt.ExecNonQuery("delete from cat_almacen")
'		Starter.skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (user.Text))
'		Starter.skmt.ExecNonQuery2("INSERT INTO VERSION(NOVERSION) VALUES (?)", Array As Object ("2.1"))
''		principal.B_REGRESA_Click
''		B4XPages.MainPage.principal.Subir.Visible = True
'		B4XPages.ShowPage("Principal")
'	Else
'		c=Starter.skmt.ExecQuery2("select count(*) as EXISTE1 from usuarioa where usuario = ?", Array As String(user.Text))
'		c.Position=0
'		existe = c.GetString("EXISTE1")
'		c.Close
'		'existe = 1
'		If existe = 0 Then
'			'skmt.ExecNonQuery("delete from usuarioa")
'			Dim cmd As DBCommand
'			cmd.Initialize
'			cmd.Name = "select_usuario_GUNA_REPG_VN"
'			cmd.Parameters = Array As Object(user.Text, pass.Text)
'			reqManager.ExecuteQuery(cmd , 0, "usuario")
'			
'	
''			Dim cmd As DBCommand
''			cmd.Initialize
''			cmd.Name = "select_version_INTMEX"
''			reqManager.ExecuteQuery(cmd , 0, "version")
'		Else
'			
'			
'			Dim cmd As DBCommand
'			cmd.Initialize
'			cmd.Name = "select_cont_usuario_GUNA_REPG_VN"
'			cmd.Parameters = Array As Object(user.Text)
'			reqManager.ExecuteQuery(cmd , 0, "cuentausuario")
'					
'			c=Starter.skmt.ExecQuery("select CODIGO from CODIGO_UNICO")  ''''Codigo de acceso unico
'			c.Position = 0
'			Dim cmd As DBCommand
'			cmd.Initialize
'			cmd.Name = "select_cont_codigo_GUNA_REPG_VN"
'			cmd.Parameters = Array As Object(c.GetString("CODIGO"))
'			reqManager.ExecuteQuery(cmd , 0, "cuentacodigo")
'			c.Close
'		End If
'	End If
'End Sub
'
'Sub JobDone(Job As HttpJob)
'	If Job.Success = False Then
'		ToastMessageShow("Error: " & Job.ErrorMessage, True)
'	Else
'		If Job.JobName = "DBRequest" Then
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "version" Then 'query tag
'				For Each records() As Object In result.Rows
'					Starter.skmt.ExecNonQuery("delete from VERSION")
'					Dim CAT_VE_VERSION As String = records(result.Columns.Get("CAT_VE_VERSION"))
'					Starter.skmt.ExecNonQuery2("INSERT INTO VERSION(NOVERSION) VALUES (?)", Array As Object (CAT_VE_VERSION))
'				Next
'			End If
'		End If
'	 
'		If Job.JobName = "DBRequest" Then
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "agencia" Then 'query tag
'				For Each records() As Object In result.Rows
'           
'					Dim ID_ALMACEN As String = records(result.Columns.Get("ID_ALMACEN"))
'				Next
'				almacen = ID_ALMACEN
'			End If
'		End If
'
'		If Job.JobName = "DBRequest" Then
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "coords_almacen" Then 'query tag
'				For Each records() As Object In result.Rows
'					Log("Coordenadas del almacen: " & records(result.Columns.Get("CAT_AL_LATITUD")) & "," & records(result.Columns.Get("CAT_AL_LONGITUD")))
'					Private lat, lon As Double
'					lat = 0.0
'					lon = 0.0
'					If IsNumber(records(result.Columns.Get("CAT_AL_LATITUD"))) And IsNumber(records(result.Columns.Get("CAT_AL_LONGITUD"))) Then
'						lat = records(result.Columns.Get("CAT_AL_LATITUD"))
'						lon = records(result.Columns.Get("CAT_AL_LONGITUD"))
'					End If
'					Starter.cedisLocation.Latitude = lat
'					Starter.cedisLocation.Longitude = lon
'					Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("COORDS_ALMACEN"))
'					Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("COORDS_ALMACEN",lon&","&lat))
'					'19.48118148992086,-99.15295579261536
'				Next
'			End If
'		End If
'
'		If Job.JobName = "DBRequest" Then   ''' Codigo unico
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "usuario" Then 'query tag
'				Log("si hice 4")
'				For Each records() As Object In result.Rows
'					Dim name As String = records(result.Columns.Get("USUARIO"))
'					Dim ID_ALMACEN As String = records(result.Columns.Get("CAT_LO_AGENCIA"))
''					Dim IMEI_BASE As String = records(result.Columns.Get("CAT_LO_IDTELEFONO"))
'				Next
'				
''				B4XPages.ShowPage("Principal") '''mover
'				
'				
'				If name = "OKActivo" Then
'					Dim cmd As DBCommand
'					cmd.Initialize
'					cmd.Name = "select_cont_usuario_GUNA_REPG_VN"
'					cmd.Parameters = Array As Object(user.Text)
'					reqManager.ExecuteQuery(cmd , 0, "cuentausuario")
'					
'					c=Starter.skmt.ExecQuery("select CODIGO from CODIGO_UNICO")  ''''Codigo de acceso unico
'					c.Position = 0
'					Dim cmd As DBCommand
'					cmd.Initialize
'					cmd.Name = "select_cont_codigo_GUNA_REPG_VN"
'					cmd.Parameters = Array As Object(c.GetString("CODIGO"))
'					reqManager.ExecuteQuery(cmd , 0, "cuentacodigo")
'					c.Close
'						
'				Else If name  = "OKExpirado"& IMEI Then
'					Msgbox("Usuario Expirado llamar al administrador","") 'ignore
'				Else If name = "OKCancelado"& IMEI Then
'					Msgbox("Usuario Cancelado llamar al administrador","") 'ignore
'				Else
'					Msgbox("Usuario o password No validos","") 'ignore
'				End If
'					
''				paso1 = 1
'			End If
'		End If
'			
'		If Job.JobName = "DBRequest" Then   ''' Codigo unico
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "cuentacodigo" Then 'query tag
'				Log("si hice 1")
'				For Each records() As Object In result.Rows
'					Dim CUENTA_CODIGO As Int = records(result.Columns.Get("CUENTA_CODIGO"))
'				Next
'				codigo = CUENTA_CODIGO
'				Log(CUENTA_CODIGO)
'				paso1 = 1
'				entrada
'			End If
'		End If
'		
'		If Job.JobName = "DBRequest" Then   ''' Codigo unico
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "cuentausuario" Then 'query tag
'				Log("si hice 2")
'				For Each records() As Object In result.Rows
'					Dim CUENTA_USUARIO As Int = records(result.Columns.Get("CUENTA_USUARIO"))
'				Next
'				usuariocheck = CUENTA_USUARIO
'				Log(CUENTA_USUARIO)
'				paso2 = 1
'				entrada
'			End If
'		End If
'		
'		If Job.JobName = "DBRequest" Then   ''' Codigo unico
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "cuentacodigo2" Then 'query tag
'				Log("si hice 3")
'				For Each records() As Object In result.Rows
'					Dim TMP_CR_CODIGO As Int = records(result.Columns.Get("TMP_CR_CODIGO"))
'				Next
'				
'				
'				If TMP_CR_CODIGO = 1 Then
'					Log("si hice 5")
'					Starter.skmt.ExecNonQuery("delete from usuarioa")
'					Starter.skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(user.Text, pass.Text))
'					Starter.skmt.ExecNonQuery("delete from cat_almacen")
'					Starter.skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (almacen))
'					B4XPages.ShowPage("Principal")
'					
'				End If
'
'			End If
'		End If
'		
'
'		If Job.JobName = "DBRequest" Then
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "contrasena" Then 'query tag
'				For Each records() As Object In result.Rows
'					Dim CAT_PA_PASS As String = records(result.Columns.Get("CAT_PA_PASS"))
'					If CAT_PA_PASS = et_codigo.Text Then
'						Log(CAT_PA_PASS)
'						p_validacion.Visible = False
'						et_codigo.Text = ""
'						
'						Subs.panelVisible(P_CIEGO,0,0)
'						
'					Else
'						MsgboxAsync("Contraseña incorrecta","Atención")
'					End If
'				Next
'			End If
'		End If
'		
''		If Job.JobName = "DBRequest" Then
''			Dim result As DBResult = reqManager.HandleJob(Job)
''			If result.Tag.As(String).IndexOf("PICK_C_") > -1 Then 'query tag
'		''				Subs.logJobDoneResultados(result)
''				Private id As String= result.Tag
''				id = id.SubString(id.IndexOf("_")+3)
''				For Each records() As Object In result.Rows
''					Dim CUENTA As String = records(result.Columns.Get("CUENTA"))
''					Log(CUENTA)
''					Log(id)
''					If CUENTA = 0 Then
''						c = Starter.skmt.ExecQuery2("SELECT * FROM PICK_CIEGO WHERE PC_ID_PROD = ?", Array As String (id))
''						If c.RowCount > 0 Then
'		''							For i=0 To c.RowCount -1
''							c.Position=0
''							Dim cmd As DBCommand
''							cmd.Initialize
''							cmd.Name = "insert_PICKCIEGO_MAZAPA"
''							cmd.Parameters = Array As Object(c.GetString("PC_ID_PROD"), c.GetString("PC_NOM_PROD"), c.GetString("PC_CANT"), c.GetString("PC_ALMACEN"), c.GetString("PC_RUTA"), c.GetString("PC_FECHA"),"REPARTO")
''							reqManager.ExecuteCommand(cmd , "ins_PC")
'		''							Next
''						End If
''						c.Close
''					Else if CUENTA > 0 Then
''						c = Starter.skmt.ExecQuery2("SELECT * FROM PICK_CIEGO WHERE PC_ID_PROD= ?", Array As String (id))
''						If c.RowCount > 0 Then
'		''							For i=0 To c.RowCount -1
''							c.Position = 0
''							Dim cmd As DBCommand
''							cmd.Initialize
''							cmd.Name = "update_PICKCIEGO_MAZAPA"
''							Log("FECHA" & c.GetString("PC_FECHA"))
''							cmd.Parameters = Array As Object(c.GetString("PC_CANT"), c.GetString("PC_ID_PROD"), c.GetString("PC_ALMACEN"), c.GetString("PC_RUTA"), c.GetString("PC_FECHA"),"REPARTO")
''							reqManager.ExecuteCommand(cmd, "update_PC")
'		''							Next
''						End If
''						c.Close
''					End If
'		'
''				Next
''			End If
''		End If
'		
'		If Job.JobName = "DBRequest" Then
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "estatus" Then 'query tag
'				For Each records() As Object In result.Rows
'					Dim hvd_estatus As String = records(result.Columns.Get("HVD_ESTATUS"))
'					If hvd_estatus = "Liquidado" Then
'						' ToastMessageShow("rojo val ok 1 cuantosp." , True)
'						MsgboxAsync("La venta ya fue liquidada","Atención")
'					Else
'						enviarmonto
'					End If
'				Next
'			End If
'		End If
'		
'		If Job.JobName = "DBRequest" Then
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "estatus2" Then 'query tag
'				For Each records() As Object In result.Rows
'					Dim hvd_estatus As String = records(result.Columns.Get("HVD_ESTATUS"))
'					If hvd_estatus = "Liquidado" Then
'						' ToastMessageShow("rojo val ok 1 cuantosp." , True)
'						MsgboxAsync("La venta ya fue liquidada","Atención")
'					Else
'						passaquci
'					End If
'				Next
'			End If
'		End If
'		
'		If Job.JobName = "DBRequest" Then
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag = "SelectMontoLiq" Then
'				For Each records() As Object In result.Rows
'					Dim CUENTA As String = records(result.Columns.Get("CUENTA"))
'					
'					DateTime.DateFormat = "MM/dd/yyyy"
'					sDate=DateTime.Date(DateTime.Now)
'					sTime=DateTime.Time(DateTime.Now)
'					Private f As Cursor=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
'					f.Position=0
'					Private a As Cursor =Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
'					a.Position = 0
'					
'					Private c2 As Cursor
'					c2=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
'					c2.Position=0
'					If c2.RowCount > 0 Then c2.GetString("USUARIO")
'					
'					Log(CUENTA & "----------------------!!")
'					If CUENTA = "0" Then
'						
''						c = Starter.skmt.ExecQuery2("SELECT * FROM ENV_MONTO_LIQ WHERE EML_USUARIO = ? AND EML_ALMACEN = ? AND EML_RUTA = ?", Array As String (c2.GetString("USUARIO"), a.GetString("ID_ALMACEN"), f.GetString("RUTAA")))
''						If c.RowCount > 0 Then
'						''							For i=0 To c.RowCount -1
''							c.Position=0
''							Dim cmd As DBCommand
''							cmd.Initialize
''							cmd.Name = "insert_Monto_Liq_MAZAPArep"
''							cmd.Parameters = Array As Object(c.GetString("EML_MONTO"), c.GetString("EML_ALMACEN"), f.GetString("RUTAA"), c.GetString("EML_USUARIO"), "REPARTO", c.GetString("EML_FECHA_PED"))
''							reqManager.ExecuteCommand(cmd , "ins_Mon_Liq")
''							MsgboxAsync("Monto Enviado", "Atención")
'						''							Next
''						End If
''						c.Close
'					Else if CUENTA > "0" Then
'						
''						c = Starter.skmt.ExecQuery2("SELECT * FROM ENV_MONTO_LIQ WHERE EML_USUARIO = ? AND EML_ALMACEN = ? AND EML_RUTA = ?", Array As String (c2.GetString("USUARIO"), a.GetString("ID_ALMACEN"), f.GetString("RUTAA")))
''						If c.RowCount > 0 Then
'						''							For i=0 To c.RowCount -1
''							c.Position = 0
''							cmd.Initialize
''							cmd.Name = "update_MontoCuenta_MAZAPArep"
''							cmd.Parameters = Array As Object(c.GetString("EML_MONTO"), c.GetString("EML_ALMACEN"), c.GetString("EML_RUTA"), c.GetString("EML_USUARIO"),c.GetString("EML_FECHA_PED"),"REPARTO")
''							
''							Log(c.GetString("EML_MONTO")& " " & c.GetString("EML_ALMACEN")& " " & c.GetString("EML_RUTA")& " " & c.GetString("EML_USUARIO"))
''							reqManager.ExecuteCommand(cmd, "update_MC")
''							MsgboxAsync("Se sobre escribio el Monto", "Atención")
'						''							Next
''						End If
''						c2.Close
''						c.Close
'					End If
'					f.Close
'					a.Close
'				Next
'			End If
'		End If
'		
'		Job.Release
'	End If
'	
'	
'	
'	
'End Sub
'
'Sub entrada
'	If paso1 = 1 And paso2 = 1 Then
'		
'	
'		Log(codigo)
'		Log(usuariocheck)
'		If codigo = 1 And usuariocheck = 1 Then
'			c=Starter.skmt.ExecQuery("select CODIGO from CODIGO_UNICO")  ''''Codigo de acceso unico
'			c.Position = 0
'		
'			Dim cmd As DBCommand
'			cmd.Initialize
'			cmd.Name = "select_codigo_cuantosGUNA_REPG_VN"
'			cmd.Parameters = Array As Object(user.Text, c.GetString("CODIGO"))
'			reqManager.ExecuteQuery(cmd , 0, "cuentacodigo2")
'				
'			c.Close
'		Else If (codigo = 1 And usuariocheck = 0) Or (codigo = 0 And usuariocheck = 1) Then
'			MsgboxAsync("El celular ya esta registrado en otra cuenta, o el usuario esta registrado en otro telefono, favoir de contactar a tu supervisor","Atención")
'		Else If codigo = 0 And usuariocheck = 0 Then
'			Dim cod As Cursor=Starter.skmt.ExecQuery("select CODIGO from CODIGO_UNICO")  ''''Codigo de acceso unico
'			cod.Position = 0
'		
'			Dim cmd As DBCommand
'			cmd.Initialize
'			cmd.Name = "insert_codigo_REP_GUNA_VN"
'			cmd.Parameters = Array As Object(user.Text.Trim, pass.Text, cod.GetString("CODIGO"))
'			reqManager.ExecuteCommand(cmd , "ins_codigo")
'		
'			cod.Close
'			
'		
'			Starter.skmt.ExecNonQuery("delete from usuarioa")
'			Starter.skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(user.Text, pass.Text))
'			Starter.skmt.ExecNonQuery("delete from cat_almacen")
'			Starter.skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (almacen))
'			Starter.skmt.ExecNonQuery2("INSERT INTO INICIO_SESION(CONECTADO) VALUES (?)", Array As Object (1))
'			
'			B4XPages.ShowPage("Principal")
'		End If
'	End If
'End Sub
'
'Private Sub i_engrane_Click
'	p_appUpdate.Width = Root.Width
'	p_appUpdate.Height = Root.Height
'	Subs.centraPanel(p_serverList, Root.Width)
'	Subs.centraBoton(b_server, Root.Width)
'	Subs.centraBoton(b_apk, Root.Width)
'	Subs.centraBoton(b_envioBD, Root.Width)
'	Subs.centraBoton(b_regesar, Root.Width)
'	Subs.centraBoton(b_server, p_serverList.Width)
'	lv_server.Clear
'	lv_server.AddSingleLine("http://keymon.net:1782")
'	
'	If user.Text = "KMTS1" Then lv_server.AddSingleLine("http://10.0.0.205:1782")
''	l_server.Text = Starter.server
'	et_server.Text = server
'	Subs.panelVisible(p_appUpdate, 0, 0)
'End Sub
'
'Private Sub B4XPage_CloseRequest As ResumableSub
''	Log("closreq")
'	If p_appUpdate.Visible Then
'		p_appUpdate.Visible = False
'	Else
'		Sleep(0)
'		ExitApplication
'	End If
'	Return False
'End Sub
'
'Private Sub b_regesar_Click
'	p_principal.Visible = True
'	p_appUpdate.Visible = False
'End Sub
'
''Enviamos la base de datos por correo o Whatsapp
'Private Sub b_envioBD_Click
''	copiaDB
''	Sleep(1000)
'	Dim FileName As String = "kmt.db"
'	'copy the shared file to the shared folder
'	Log("xxxxxx:"&Provider.SharedFolder)
'	Sleep(1000)
'	File.Copy(File.DirInternal, FileName, Provider.SharedFolder, FileName)
'	Dim email As Email
'	email.To.Add("soporte@keymonsoft.com")
'	email.Subject = "Base de datos para revisión"
'	email.Attachments.Add(Provider.GetFileUri(FileName))
''	email.Attachments.Add(Provider.GetFileUri(FileName)) 'second attachment
'	Dim in As Intent = email.GetIntent
'	in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
'	StartActivity(in)
'End Sub
'
'Private Sub b_apk_Click
'	StartService(appUpdater)
'End Sub
'
'Private Sub b_server_Click
'	Log("Guardar servidor")
'	Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("SERVER"))
'	Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("SERVER",et_server.text))
'	B4XPages.MainPage.server = et_server.text
'	Starter.server = B4XPages.MainPage.server
'	If logger Then Log("Inicializamos reqManager con " & B4XPages.MainPage.server)
'	reqManager.Initialize(Me, B4XPages.MainPage.server)
'	LogColor($"ReqServer = ${B4XPages.MainPage.server}"$, Colors.red)
'	reinicializaReqManager
'	p_appUpdate.Visible = False
''	Entrar.Visible = True
'End Sub
'
'Private Sub lv_server_ItemClick (Position As Int, Value As Object)
'	server = Value
''	l_server.Text = Value
'	et_server.Text = Value
'	reqManager.Initialize(Me, Value)
'	LogColor($"ReqServer = ${Value}"$, Colors.red)
'	ToastMessageShow("Servidor modificado", False)
'End Sub
'
'Sub reinicializaReqManager
'	reqManager.Initialize(Me, B4XPages.MainPage.server)
'	If logger Then Log(B4XPages.MainPage.server)
'	LogColor($"ReqServer = ${B4XPages.MainPage.server}"$, Colors.red)
'End Sub
'
''appUpdater - Mostramos el anuncio de que se esta descargando el nuevo apk
'Sub muestraProgreso(mensaje As String)
'	ProgressDialogShow(mensaje)
'End Sub
'
''appUpdater - Ocultamos el anuncio de que se esta descargando el nuevo apk
'Sub ocultaProgreso
'	ProgressDialogHide
'End Sub
'
'Private Sub b_CargarMonto_Click
'	
'	c = Starter.skmt.ExecQuery("SELECT *  FROM kmt_info")
'	c.Position = 0
'	If c.RowCount < 0 Or c.RowCount = 0 Then
'		MsgboxAsync("No hay ruta cargada, favor de cargar día","Atención")
'	Else
'		Subs.panelVisible(p_add_monto,0,0)
'	End If
'	c.Close
'
'End Sub
'
'Private Sub p_add_monto_Click
'	
'End Sub
'
''Private Sub B_Aceptar_Monto_Click
''	Private f As Cursor=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
''	f.Position=0
''	Private a As Cursor =Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
''	a.Position = 0
''	Dim cmd As DBCommand
''	cmd.Initialize
''	cmd.Name = "select_estatus_MAZAPA"
''	cmd.Parameters = Array As Object(a.GetString("ID_ALMACEN"),f.GetString("RUTAA"))
''	reqManager.ExecuteQuery(cmd , 0, "estatus")
''	f.Close
''	a.Close
''End Sub
'
'Sub enviarmonto
'	
'	DateTime.DateFormat = "MM/dd/yyyy"
'	sDate=DateTime.Date(DateTime.Now)
'	sTime=DateTime.Time(DateTime.Now)
'	
'	Private f As Cursor=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
'	f.Position=0
'
'	Private a As Cursor=Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
'	If a.RowCount>0 Then
'		a.Position=0
'	End If
'	
'	Private a2 As Cursor = Starter.skmt.ExecQuery("SELECT HVD_FECHA FROM HIST_VENTAS")
'	If a2.RowCount>0 Then
'		a2.Position=0
'		Dim fecha() As String = Regex.Split(" ", a2.GetString("HVD_FECHA"))
'		Dim fecha2() As String = Regex.Split("-", fecha(0))
'		Dim fecha3 As String = fecha2(2)&"/"&fecha2(1)&"/"&fecha2(0)
'		Log(fecha3)
'		Dim hora() As String = Regex.Split("\.", fecha(1))
'		Log(hora(0))
'	End If
'	
'	
'	
'	Private cI As Cursor
'	Private u As String = "SinUsuario"
'	cI=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
'	cI.Position=0
'	If cI.RowCount > 0 Then u = cI.GetString("USUARIO")
'	Private g As Cursor = Starter.skmt.ExecQuery("select * from ENV_MONTO_LIQ")
''	If g.RowCount = 0 Then
''		Starter.skmt.ExecNonQuery2("INSERT INTO ENV_MONTO_LIQ VALUES (?,?,?,?,?)", Array As Object(ET_Add_Monto.Text, a.GetString("ID_ALMACEN"), f.GetString("RUTAA"), u, fecha3 & " " & hora(0)))
''		f.Close
''		a.Close
''	
''		c = Starter.skmt.ExecQuery("SELECT * FROM ENV_MONTO_LIQ")
''		If c.RowCount > 0 Then
''			c.Position = 0
''			Dim cmd As DBCommand
''			cmd.Initialize
''			cmd.Name = "select_MontoCuenta_MAZAPArep"
''			cmd.Parameters = Array As Object(c.GetString("EML_USUARIO"), c.GetString("EML_ALMACEN"), c.GetString("EML_RUTA"),c.GetString("EML_FECHA_PED"))
''			reqManager.ExecuteQuery(cmd , 0, "SelectMontoLiq")
''		End If
''		c.Close
''	Else
''		Starter.skmt.ExecNonQuery2("UPDATE ENV_MONTO_LIQ SET EML_MONTO = ? WHERE EML_ALMACEN = ? AND EML_RUTA = ? AND EML_USUARIO = ?", Array As String (ET_Add_Monto.Text ,a.GetString("ID_ALMACEN"), f.GetString("RUTAA"), cI.GetString("USUARIO")))
''		f.Close
''		a.Close
''	
''		c = Starter.skmt.ExecQuery("SELECT * FROM ENV_MONTO_LIQ")
''		If c.RowCount > 0 Then
''			c.Position = 0
''			Dim cmd As DBCommand
''			cmd.Initialize
''			cmd.Name = "select_MontoCuenta_MAZAPArep"
''			cmd.Parameters = Array As Object(c.GetString("EML_USUARIO"), c.GetString("EML_ALMACEN"), c.GetString("EML_RUTA"),c.GetString("EML_FECHA_PED"))
''			reqManager.ExecuteQuery(cmd , 0, "SelectMontoLiq")
''		End If
''		c.Close
''	End If
'
'	p_add_monto.Visible = False
'	
'End Sub
'
'Private Sub B_Can_Monto_Click
'	p_add_monto.Visible = False
'End Sub
'
'Private Sub b_arqueocieego_Click
'	c = Starter.skmt.ExecQuery("SELECT *  FROM CAT_GUNAPROD3")
'	If c.RowCount > 0 Then
'		Subs.panelVisible(p_validacion,0,0)
'	Else
'		MsgboxAsync("No hay ruta cargada, favor de cargar día","Atención")
'	End If
'End Sub
'
'Private Sub et_buspc_TextChanged (Old As String, New As String)
'	If New = "" Then
'		CLV_PICK_CIEGO.Clear
'	Else If New.Length >= 3 Then
'		CLV_PICK_CIEGO.Clear
'	
'		q_buscar = "%" & et_buspc.Text & "%"
'		Log(q_buscar)
'		c=Starter.skmt.ExecQuery2($"select CAT_GP_NOMBRE, CAT_GP_ID , ifnull(PC_CANT,0) AS PC_CANT FROM CAT_GUNAPROD3 INNER JOIN PICK_CIEGO ON PC_ID_PROD = CAT_GP_ID AND PC_NOM_PROD = CAT_GP_NOMBRE WHERE (CAT_GP_NOMBRE LIKE ? OR  CAT_GP_ID  LIKE ? ) and CAT_GP_CLASIF <> 'PROMOS'"$, Array As String(q_buscar,q_buscar))
'		If c.RowCount > 0 Then
'
'		
'			For i = 0 To c.RowCount - 1
'				c.Position = i
'				CLV_PICK_CIEGO.Add(CreateListItem(c.GetString("CAT_GP_ID"), c.GetString("CAT_GP_NOMBRE"), c.GetString("PC_CANT")),i)
''				Log(c.GetString("CAT_GP_ID") & ", " & c.GetString("CAT_GP_NOMBRE") & " ," & c.GetString("PC_CANT"))
'			Next
'			c.Close
'		
'			d=Starter.skmt.ExecQuery2($"select CAT_GP_NOMBRE, CAT_GP_ID FROM CAT_GUNAPROD3 WHERE (CAT_GP_NOMBRE LIKE ? OR  CAT_GP_ID  LIKE ? ) and CAT_GP_CLASIF <> 'PROMOS'AND CAT_GP_ID NOT IN (SELECT PC_ID_PROD FROM PICK_CIEGO)"$, Array As String(q_buscar,q_buscar))
'		
'			For i = 0 To d.RowCount - 1
'				d.Position = i
'				CLV_PICK_CIEGO.Add(CreateListItem2(d.GetString("CAT_GP_ID"), d.GetString("CAT_GP_NOMBRE")),i)
''				Log(d.GetString("CAT_GP_ID") & ", " & d.GetString("CAT_GP_NOMBRE"))
'			Next
'			d.Close
'		
'		Else If c.RowCount = 0 Then
'			d=Starter.skmt.ExecQuery2($"select CAT_GP_NOMBRE, CAT_GP_ID FROM CAT_GUNAPROD3 WHERE (CAT_GP_NOMBRE LIKE ? OR  CAT_GP_ID  LIKE ? ) and CAT_GP_CLASIF <> 'PROMOS'"$, Array As String(q_buscar,q_buscar))
'		
'			For i = 0 To d.RowCount - 1
'				d.Position = i
'				CLV_PICK_CIEGO.Add(CreateListItem2(d.GetString("CAT_GP_ID"), d.GetString("CAT_GP_NOMBRE")),i)
''				Log(d.GetString("CAT_GP_ID") & ", " & d.GetString("CAT_GP_NOMBRE"))
'			Next
'			d.Close
'		End If
'	End If
'End Sub
'
'Private Sub B_PC_ENV_Click
'	Dim sDate, sTime As String
'	DateTime.DateFormat = "dd/MM/yyyy"
'	DateTime.TimeFormat = "HH:mm:ss"
'	sDate = DateTime.Date(DateTime.Now)
'	sTime = DateTime.Time(DateTime.Now)
'	
'	
'	For i = 0 To CLV_PICK_CIEGO.Size - 1
'		' Retrieve the panel and child views for the current item
'		Dim itemPanel As B4XView = CLV_PICK_CIEGO.GetPanel(i)
'		Dim innerPanel As B4XView = itemPanel.GetView(0)
'		Dim editText As B4XView = innerPanel.GetView(1)
'		Dim inputText As String = editText.As(EditText).Text
'
'		' Check if the input text matches the regex pattern for zeros or if it's empty
'		If Regex.IsMatch("^[0]+$", inputText) Or inputText = "" Then
'			inputText = "0"
'		End If
'
'		' Retrieve and process the ID label
'		Dim idLabel As B4XView = innerPanel.GetView(0)
'		Dim idText As String = idLabel.As(Label).Text
'		Dim idParts() As String = Regex.Split(CRLF, idText)
''		Log(idParts(1))
'		f=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
'		f.Position=0
'		Log(f.GetString("RUTAA"))
'		a=Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
'		If a.RowCount>0 Then
'			a.Position=0
'		End If
'		Dim k As Cursor = Starter.skmt.ExecQuery("SELECT HVD_FECHA FROM HIST_VENTAS")
'		k.Position = 0
'		Dim fechatabulador() As String = Regex.Split(" ", k.GetString("HVD_FECHA"))
'		Dim fechatabulador2() As String = Regex.Split("-", fechatabulador(0))
'		Dim fechatabulador3 As String = fechatabulador2(2)&"/"&fechatabulador2(1)&"/"&fechatabulador2(0)
'		k.Close
'		If inputText <> "" Then
'			c = Starter.skmt.ExecQuery2("SELECT * FROM PICK_CIEGO where PC_ID_PROD = ?", Array As String (idParts(0)))
'			If c.RowCount = 0 Then
'				' Insert data into the database
'				Log(f.GetString("RUTAA"))
'				Starter.skmt.ExecNonQuery2("INSERT INTO PICK_CIEGO(PC_ID_PROD, PC_NOM_PROD, PC_CANT, PC_ALMACEN, PC_RUTA, PC_FECHA) VALUES(?,?,?,?,?,?)", Array As String(idParts(0), idParts(1), inputText, a.GetString("ID_ALMACEN"), f.GetString("RUTAA"), fechatabulador3&" "&sTime))
'			
'			Else
'				Log(f.GetString("RUTAA"))
'				Starter.skmt.ExecNonQuery2("Update PICK_CIEGO set PC_CANT = ?  WHERE PC_ID_PROD = ?" , Array As String(inputText ,idParts(0)))
'			End If
'
'		End If
'		f.Close
'		a.Close
'		Log("Processed item " & i)
'	Next
'	et_buspc.Text = ""
'	CLV_PICK_CIEGO.Clear
'End Sub
'
'Private Sub b_terpc_Click
'	Msgbox2Async("Una vez enviada la información no podras hacer modificaciones","Atención","SI","", "",LoadBitmap(File.DirAssets,"alert2.png"), False)
'	Wait For Msgbox_Result (resultado As Int)
'	If resultado = DialogResponse.POSITIVE Then
'		Msgbox2Async("Estas seguro de enviar la información?","Atención","SI","", "NO",LoadBitmap(File.DirAssets,"alert2.png"), False)
'		Wait For Msgbox_Result (resultado As Int)
'		If resultado = DialogResponse.POSITIVE Then
'		
'			Dim sDate, sTime As String
'			DateTime.DateFormat = "dd/MM/yyyy"
'			DateTime.TimeFormat = "HH:mm:ss"
'			sDate = DateTime.Date(DateTime.Now)
'			sTime = DateTime.Time(DateTime.Now)
'	
'			For i = 0 To CLV_PICK_CIEGO.Size - 1
'				' Retrieve the panel and child views for the current item
'				Dim itemPanel As B4XView = CLV_PICK_CIEGO.GetPanel(i)
'				Dim innerPanel As B4XView = itemPanel.GetView(0)
'				Dim editText As B4XView = innerPanel.GetView(1)
'				Dim inputText As String = editText.As(EditText).Text
'	
'				' Check if the input text matches the regex pattern for zeros or if it's empty
'				If Regex.IsMatch("^[0]+$", inputText) Or inputText = "" Then
'					inputText = "0"
'				End If
'	
'				' Retrieve and process the ID label
'				Dim idLabel As B4XView = innerPanel.GetView(0)
'				Dim idText As String = idLabel.As(Label).Text
'				Dim idParts() As String = Regex.Split(CRLF, idText)
''				Log(idParts(1))
'				f=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
'				f.Position=0
'				Log(f.GetString("RUTAA"))
'
'				a=Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
'				If a.RowCount>0 Then
'					a.Position=0
'				End If
'				Log(a.GetString("ID_ALMACEN"))
'				
'				Dim k As Cursor = Starter.skmt.ExecQuery("SELECT HVD_FECHA FROM HIST_VENTAS")
'				k.Position = 0
'				Dim fechatabulador() As String = Regex.Split(" ", k.GetString("HVD_FECHA"))
'				Dim fechatabulador2() As String = Regex.Split("-", fechatabulador(0))
'				Dim fechatabulador3 As String = fechatabulador2(2)&"/"&fechatabulador2(1)&"/"&fechatabulador2(0)
'				k.Close
'				If inputText <> "" Then
'					c = Starter.skmt.ExecQuery2("SELECT * FROM PICK_CIEGO where PC_ID_PROD = ?", Array As String (idParts(0)))
'					If c.RowCount = 0 Then
'						' Insert data into the database
'						Starter.skmt.ExecNonQuery2("INSERT INTO PICK_CIEGO(PC_ID_PROD, PC_NOM_PROD, PC_CANT, PC_ALMACEN, PC_RUTA, PC_FECHA) VALUES(?,?,?,?,?,?)", Array As String(idParts(0), idParts(1), inputText, a.GetString("ID_ALMACEN"), f.GetString("RUTAA"), fechatabulador3&" "&sTime))
'					Else
'						Starter.skmt.ExecNonQuery2("Update PICK_CIEGO set PC_CANT = ?  WHERE PC_ID_PROD = ?" , Array As String(inputText ,idParts(0)))
'					End If
'				End If
'				f.Close
'				a.Close
'				Log("Processed item " & i)
'			Next
'			Log("Finished processing all items")
'			P_CIEGO.Visible = False
'			et_buspc.Text = ""
'			CLV_PICK_CIEGO.Clear
'			c = Starter.skmt.ExecQuery("SELECT PC_ID_PROD, PC_ALMACEN, PC_RUTA, PC_FECHA FROM PICK_CIEGO")
''			If c.RowCount > 0 Then
''				For i = 0 To c.RowCount - 1
''					c.Position = i
''					Dim cmd As DBCommand
''					cmd.Initialize
''					cmd.Name = "select_HIST_PICKCIEGO_MAZAPA" '
''					cmd.Parameters = Array As Object(c.GetString("PC_ID_PROD"), c.GetString("PC_ALMACEN"), c.GetString("PC_RUTA"), c.GetString("PC_FECHA"),"REPARTO")
''					reqManager.ExecuteQuery(cmd , 0, $"PICK_C_${c.GetString("PC_ID_PROD")}"$)
''				Next
''			End If
'			c.close
'		Else
'		
'		End If
'	End If
'End Sub
'
'Private Sub P_CIEGO_Click
'	
'End Sub
'
'Private Sub b_aceptar_Click
'	Private f As Cursor=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
'	f.Position=0
'	Private a As Cursor =Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
'	a.Position = 0
''	Dim cmd As DBCommand
''	cmd.Initialize
''	cmd.Name = "select_estatus_MAZAPA"
''	cmd.Parameters = Array As Object(a.GetString("ID_ALMACEN"),f.GetString("RUTAA"))
''	reqManager.ExecuteQuery(cmd , 0, "estatus2")
'	f.Close
'	a.Close
''	p_validacion.Visible = False
''	et_codigo.Text = ""
''						
''	Subs.panelVisible(P_CIEGO,0,0)
'End Sub
'
'Sub passaquci
'	f=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info")
'	f.Position=0
'
'	a=Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
'	If a.RowCount>0 Then
'		a.Position=0
'	End If
'	Log(a.GetString("ID_ALMACEN"))
'	Log(f.GetString("CAT_CL_RUTA"))
'	
''	If et_codigo.Text = "KMTS1" Then
''		p_validacion.Visible = False
''		et_codigo.Text = ""
''		Subs.panelVisible(P_CIEGO,0,0)
''	Else
''		Dim cmd As DBCommand
''		cmd.Initialize
''		cmd.Name = "select_CAT_PASS_ARQUEO_MAZAPA"
''		cmd.Parameters = Array As Object(f.GetString("CAT_CL_RUTA"),a.GetString("ID_ALMACEN"),"REPARTO")
''		reqManager.ExecuteQuery(cmd , 0, "contrasena")
''		f.Close
''		a.Close
''	End If
'End Sub
'
'Private Sub b_cancelarcodigo_Click
'	p_validacion.Visible = False
'End Sub
'
'Private Sub p_validacion_Click
'	
'End Sub
'
'Sub CreateListItem(Id_prod As String, Prod As String,cant As String) As Panel
'	Dim pa As B4XView = xui.CreatePanel("")
'	pa.SetLayoutAnimated(0, 0, 0, 1, 10)
'	pa.LoadLayout("PANEL_PICK_CIEGO")
'	pa.Height = 55dip
'	pa.Width = 298dip
'	'pa.Width = clv_orden.GetBase.Width
'	L_PICK_CIEGO.Text = Id_prod &  CRLF & Prod
'	L_PICK_CIEGO.TextSize = 12
'	L_PICK_CIEGO.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
'	ET_PICK_CIEGO.Text = cant
'	'cxc.Id_prod = mostrar3
'	'Log(pa.Width)
'	Return pa
'End Sub
'
'Sub CreateListItem2(Id_prod As String, Prod As String) As Panel
'	Dim pa As B4XView = xui.CreatePanel("")
'	pa.SetLayoutAnimated(0, 0, 0, 1, 10)
'	pa.LoadLayout("PANEL_PICK_CIEGO")
'	pa.Height = 55dip
'	pa.Width = 298dip
'	'pa.Width = clv_orden.GetBase.Width
'	L_PICK_CIEGO.Text = Id_prod &  CRLF & Prod
'	L_PICK_CIEGO.TextSize = 12
'	L_PICK_CIEGO.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
'	'cxc.Id_prod = mostrar3
'	'Log(pa.Width)
'	Return pa
'End Sub
'
'Private Sub ImageView1_LongClick
'
'End Sub
'
'Private Sub p_appUpdate_Click
'	
'End Sub
'

#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
	'###########################################################################################################
	'######################           PULL         #############################################################
	'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull
	'###########################################################################################################
	'######################           PUSH         #############################################################
	'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=github&Args=..\..\
	'###########################################################################################################
	'######################      PUSH TORTOISE GIT     #########################################################
	'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=TortoiseGitProc&Args=/command:commit&Args=/path:"./../../"&Args=/closeonend:2
	'###########################################################################################################
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
	Dim rp As RuntimePermissions
	Private Root As B4XView
	Private xui As XUI
	Private Root As B4XView
	Public rp As RuntimePermissions
	Public login As B4XMainPage
	Public principal As C_Principal
	Public clientes As C_Clientes
	Public cliente As C_Cliente
'	Public foto As C_Foto
	Public productos As C_Productos
	Public updateAvailable As C_UpdateAvailable
	Public mapas As C_Mapas
	Public nuevoCliente As C_NuevoCliente
	Public ticketsDia As C_TicketsDia
	Public noVenta As C_NoVenta
	Public pedidos As C_Pedidos
	Public buscar As C_Buscar
'	Public historico As C_Historico
	Public detalleVenta As C_DetalleVenta
	Public detalle_promo As C_Detalle_Promo
	Dim reqManager As DBRequestManager
'	Dim ruta As String
	Dim usuario As String
	Dim logger As Boolean = True
	Dim lat_gps, lon_gps As String
'	Dim skmt As SQL
	Dim usuario As String
	Dim server As String
	Dim montoActual, clientesTotal, clientesVenta, clientesRechazo, clientesVisitados, almacen, rutaPreventa, CANTIDADPROD As String
	Dim ultimaActualizacionGPS As String = 235959
	Dim fechaRuta As String
'	Public wsServerLink As String = "ws://187.189.244.154:51042/push/b4a_ws2"
'	Public wsServerLink As String = "ws://10.0.0.214:51042/push/b4a_ws2"
	Dim srvIp As String
	Dim phn As Phone
	Dim user As EditText
	Dim pass As EditText
	Dim c As Cursor
	Dim existe As String
	Dim paso1 As String
	Private IMEN As Label
	Dim IMEI As String
	Private Label1 As Label
	Dim server As String
	Private p_principal As Panel
	Private Entrar As Button
	Public checklist As C_Cheklist
	Public tabulador As C_tabulador
	Dim batt As Int
	Dim monto_entregadoactual As String
	Dim piezas_entregdas As String
	Dim porVisitar, entregas, rechazos, montoEntregado, montoRechazado As String
	Private p_appUpdate As Panel
	Private i_engrane As ImageView
	Private b_server As Button
	Private b_apk As Button
	Private b_envioBD As Button
	Private b_regesar As Button
	Private et_server As EditText
	Private p_serverList As Panel
	Private lv_server As ListView
	Public Provider As FileProvider
	Public rutaBDBackup As String = ""
	Private B_Can_Monto As Button
	Private B_Aceptar_Monto As Button
	Private ET_Add_Monto As EditText
	Private p_add_monto As Panel
	Dim sDate, sTime As String
	Private p_validacion As Panel
	Private b_cancelarcodigo As Button
	Private b_aceptar As Button
	Private et_codigo As EditText
	Private P_CIEGO As Panel
	Private b_terpc As Button
	Private B_PC_ENV As Button
	Private CLV_PICK_CIEGO As CustomListView
	Private et_buspc As EditText
	Dim q_buscar As String
	Dim d As Cursor
	Private L_PICK_CIEGO As Label
	Private ET_PICK_CIEGO As EditText
	Dim a As Cursor
	Dim f As Cursor
	Private b_abono As Button
	Private cb_importarBDWA As CheckBox
	Private p_importarBDWA As Panel
	
	Dim intentUsado As Boolean = False
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
	B4XPages.GetManager.LogEvents = True
	Root.LoadLayout("login")
'	B4XPages.SetTitle(Me, "Guna Reparto")
	login.Initialize
	B4XPages.AddPage("Login", login)
	principal.Initialize
	B4XPages.AddPage("Principal", principal)
	clientes.Initialize
	B4XPages.AddPage("Clientes", clientes)
	cliente.Initialize
	B4XPages.AddPage("Cliente", cliente)
'	foto.Initialize
'	B4XPages.AddPage("Foto", foto)
	productos.Initialize
	B4XPages.AddPage("Productos", productos)
	updateAvailable.Initialize
	B4XPages.AddPage("updateAvailable", updateAvailable)
	mapas.Initialize
	B4XPages.AddPage("Mapas", mapas)
	nuevoCliente.Initialize
	B4XPages.AddPage("NuevoCliente", nuevoCliente)
	ticketsDia.Initialize
	B4XPages.AddPage("TicketsDia", ticketsDia)
	noVenta.Initialize
	B4XPages.AddPage("NoVenta", noVenta)
	pedidos.Initialize
	B4XPages.AddPage("Pedidos", pedidos)
	buscar.Initialize
	B4XPages.AddPage("Buscar", buscar)
'	historico.Initialize
'	B4XPages.AddPage("Historico", historico)
	detalleVenta.Initialize
	B4XPages.AddPage("DetalleVenta", detalleVenta)
	detalle_promo.Initialize
	B4XPages.AddPage("Detalle_Promo", detalle_promo)
	tabulador.Initialize
	B4XPages.AddPage("tabulador", tabulador)
	checklist.Initialize
	B4XPages.AddPage("checklist",checklist)
'	p_principal.Width = Root.Width
'	p_principal.Height = Root.Height * .90
	Entrar.Left = (p_principal.Width - Entrar.Width) / 2
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_GUNAPROD3 (CAT_GP_INICIATIVA TEXT, CAT_GP_TIPOPROD TEXT, CAT_GP_DEV TEXT, CAT_GP_ALMACEN NUMERIC, CAT_GP_ID TEXT, CAT_GP_NOMBRE TEXT, CAT_GP_IMP1 TEXT, CAT_GP_IMP2 TEXT, CAT_GP_PRECIO TEXT, CAT_GP_CLASIF TEXT, CAT_GP_STS TEXT, CAT_GP_TIPO TEXT, CAT_GP_SUBTIPO TEXT, CAT_GP_IMG BLOB)")
	Subs.agregaColumna("CAT_GUNAPROD3", "CAT_DP_CONVERSION1", "TEXT")
	Subs.agregaColumna("CAT_GUNAPROD3", "CAT_DP_PRECIO4", "TEXT")
	Subs.agregaColumna("CAT_GUNAPROD3", "CAT_DP_CANT_MIN_VENTA", "TEXT")
	Subs.agregaColumna("ABONOS","TIPO_PAGO","TEXT")
	Subs.agregaColumna("ABONOS","a_numpago","TEXT")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS ABONOS (a_usuario TEXT, a_ruta TEXT, a_cliente TEXT, a_abono TEXT, a_fecha TEXT, a_enviado TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS PAGARES (PA_ALMACEN TEXT, PA_RUTA_REP TEXT, PA_RUTAPREV TEXT, PA_FECHA_PREV TEXT, PA_CAPTURA TEXT, PA_MONTO TEXT, PA_USUARIO TEXT, PA_CLIENTE TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS PICK_CIEGO (PC_ID_PROD TEXT, PC_NOM_PROD TEXT, PC_CANT TEXT, PC_ALMACEN TEXT, PC_RUTA TEXT, PC_FECHA TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS ENV_MONTO_LIQ (EML_MONTO TEXT, EML_ALMACEN TEXT, EML_RUTA TEXT, EML_USUARIO TEXT, EML_FECHA_PED TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS TABULADOR_MONEDAS(VEINTE TEXT, DIEZ TEXT, CINCO TEXT, DOS TEXT, PESO TEXT, CENTAVO TEXT, TOTAL TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS TABULADOR_BILLETES(MIL TEXT, QUINIENTOS TEXT, DOCIENTOS TEXT, CIEN TEXT, CINCUENTA TEXT, VEINTE TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_VENTAS2 (HVD_PARCIAL TEXT, HVD_RECHAZO TEXT, HVD_NUM_REGISTRO TEXT, HVD_NUM_TICKET TEXT, HVD_PROID TEXT, HVD_CODPROMO TEXT, HVD_FECHA TEXT, HVD_ESTATUS TEXT, HVD_CLIENTE TEXT, HVD_PRONOMBRE TEXT, HVD_CANT TEXT, HVD_COSTO_TOT TEXT)")
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS VENTAS (V_FECHA TEXT, V_CLIENTE TEXT, V_CLIENTE_ORIG TEXT, V_PRODNOMBRE TEXT, V_PRODID TEXT, V_CANTIDAD TEXT, V_PRECIO TEXT, V_TOTAL TEXT, V_PRODREGISTRO TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS RECHAZOS (R_FECHA TEXT, R_CLIENTE TEXT, R_CLI_ORIG TEXT, R_PRODID TEXT, R_CANT TEXT, R_RECHAZO INT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS VENTAS (V_FECHA TEXT, V_CLIENTE TEXT, V_CLI_ORIG TEXT, V_PRODID TEXT, V_CANT TEXT, V_RECHAZO INT)")
'	Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS ABONOSP")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CHECADO_CHECK(CHECADO TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS BLOCKENVIO(ENVIADO TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_REPARTO_GEO(HIST_RG_MONTO TEXT, HIST_RG_CREDITO TEXT, HIST_RG_MONTO_CREDITO TEXT, HIST_RG_LAT TEXT, HIST_RG_LONG TEXT, HIST_RG_RECHAZO TEXT, HIST_RG_MOTIVO TEXT, HIST_RG_USUARIO_ENTREGO TEXT, HIST_RG_RUTA_REP TEXT, HIST_RG_ESTATUS_ENTREGA TEXT, HIST_RG_COMENTARIO_ENTREGA TEXT, HIST_RG_FORMA_PAGO TEXT, HIST_RG_GEOCERCA_MTS TEXT, HIST_RG_NO_ART TEXT, HIST_RG_CLIENTE TEXT, HIST_RG_FECHA TEXT, HIST_RG_ALMACEN TEXT, HIST_RG_RUTA_PRE TEXT)")
	
'	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS PAGARES(TMP_MONTO_PAGARE TEXT, TMP_CLIENTE TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CHECKLIST(USUARIO TEXT, PLACA TEXT, FECHA_CAPTURA TEXT, TARJETA_CIRCULACION TEXT , POLIZA_SEGURO TEXT, LICENCIA_CONDUCIR TEXT, LIMPIA_EXTERNA TEXT, LIMPIA_INTERNA TEXT, TRIANGULO TEXT, GATO TEXT, LLANTA_REFACCION TEXT, CARROCERIA_BUENESTADO TEXT, CARROCERIA_MALESTADO TEXT, CARROCERIA_COMENTARIOS TEXT, LUCES_CORRECTO TEXT, LUCES_INCORRECTO TEXT, LUCES_COMENTARIOS TEXT, CONDICION_PLACAS_CORRECTO TEXT, CONDICION_PLACAS_INCORRECTO TEXT, CONDICION_PLACAS_COMENTARIOS TEXT, CONDICION_LLANTAS_DEL_DER TEXT, CONDICION_LLANTAS_DEL_IZQ TEXT, CONDICION_LLANTAS_TRASERA_DER TEXT, CONDICION_LLANTAS_TRASERA_IZQ TEXT, ACEITE TEXT, ANTICONGELANTE TEXT, FRENOS TEXT, AIRE TEXT, FUGAS TEXT, COMETARIOS_FUGAS TEXT, FOTO1 BLOB, FOTO12 BLOB, FOTO3 BLOB, FOTO4 BLOB)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CHECKLIST2(USUARIO TEXT, PLACA TEXT, FECHA_CAPTURA TEXT, TARJETA_CIRCULACION TEXT, POLIZA_SEGURO TEXT, LICENCIA_CONDUCIR TEXT, LIMPIA_EXTERNA TEXT, LIMPIA_INTERNA TEXT, TRIANGULO TEXT, GATO TEXT, LLANTA_REFACCION TEXT, CARROCERIA TEXT, CARROCERIA_COMENTARIOS TEXT, LUCES TEXT, LUCES_COMENTARIOS TEXT, CONDICION_PLACAS TEXT, CONDICION_PLACAS_COMENTARIOS TEXT, CONDICION_LLANTAS_DEL_DER TEXT, CONDICION_LLANTAS_DEL_IZQ TEXT, CONDICION_LLANTAS_TRASERA_DER TEXT, CONDICION_LLANTAS_TRASERA_IZQ TEXT, ACEITE TEXT, ANTICONGELANTE TEXT, FRENOS TEXT, AIRE TEXT, FUGAS TEXT, COMETARIOS_FUGAS TEXT, FOTO1 BLOB, FOTO12 BLOB, FOTO3 BLOB, FOTO4 BLOB, KILIMETRAJE TEXT, RUTA TEXT)")
	Subs.agregaColumna("REPARTO", "REP_PRODREGISTRO", "TEXT")
	Subs.agregaColumna("NOVENTA", "NV_RUTA", "TEXT")
	Subs.agregaColumna("ABONOS", "a_ticket", "TEXT")
	Subs.agregaColumna("ABONOS", "a_tipoabono", "TEXT")
	
	Subs.agregaColumna("PAGARES", "PA_CANCELADO", "TEXT")
	
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS ABONOSP(NOTA TEXT, CLIENTE TEXT, SALDO_PENDIENTE TEXT)")
	Subs.agregaColumna("ABONOSP", "NOMBRE", "TEXT")
	Subs.agregaColumna("ABONOSP", "FECHA_PREVENTA", "DATE")
	Subs.agregaColumna("ABONOSP", "DIAS", "DATE")
	Subs.agregaColumna("ABONOSP", "DIASATRASO", "DATE")
	
	
	Subs.agregaColumna("kmt_info", "SECUENCIA", "INT")
	Subs.agregaColumna("NOVENTA", "NV_FOTO2", "BLOB")
	Subs.agregaColumna("kmt_info", "CAT_CL_SALDODISPONIBLE", "TEXT")
	Subs.agregaColumna("kmt_info", "CAT_CL_DIASCREDITO", "INT")
	Subs.agregaColumna("kmt_info", "HORAENT", "TEXT")
	Subs.agregaColumna("REPARTO", "REP_PRODID", "TEXT")
	Subs.agregaColumna("PEDIDO", "PE_CLIENTEOR", "TEXT")
	Subs.agregaColumna("PAGARES", "PA_TICKET", "TEXT")
	Subs.agregaColumna("PEDIDO", "PE_CAJAS", "TEXT")
	Subs.agregaColumna("PEDIDO", "PE_REGALO", "TEXT")
	Subs.agregaColumna("PEDIDO", "PE_BCAJAS", "TEXT")
	Subs.agregaColumna("PEDIDO", "CONSECUTIVO", "TEXT")
	Subs.agregaColumna("PEDIDO", "FECHA_PREV", "TEXT")
	Subs.agregaColumna("PEDIDO", "RUTA_REP", "TEXT")
	Subs.agregaColumna("REPARTO", "REP_CLI_ORIG", "TEXT")
	Subs.agregaColumna("REPARTO", "REP_PRECIO", "TEXT")
	Subs.agregaColumna("REPARTO", "REP_RECHAZO", "INTEGER")
	Subs.agregaColumna("RECHAZOS", "R_PRECIO", "TEXT")
	Subs.agregaColumna("VENTAS", "V_PRECIO", "TEXT")
	Subs.agregaColumna("HIST_VENTAS","PLACA","TEXT")
	Subs.agregaColumna("HIST_VENTAS","HVD_RECHAZOCANT","TEXT")
	Subs.agregaColumna("HIST_VENTAS","CONSECUTIVO","TEXT")
	Subs.agregaColumna("HIST_VENTAS","HVD_RECHAZOCANT","TEXT")
	Subs.agregaColumna("HIST_VENTAS","ESPROMO","TEXT")
	Subs.agregaColumna("HIST_VENTAS","HVD_RECHAZOCANTC","TEXT")
	Subs.agregaColumna("HIST_VENTAS","BCAJAS","TEXT")
	Subs.agregaColumna("HIST_VENTAS","CANTC","TEXT")
	Subs.agregaColumna("HIST_VENTAS","BCAJAS_OR","TEXT")
	Subs.agregaColumna("HIST_VENTAS","CANTC_OR","TEXT")
	Subs.agregaColumna("CAT_GUNAPROD","CONVERSION","TEXT")
	Subs.agregaColumna("kmt_info","CAT_CL_LIMITECREDITO","TEXT")
	Subs.agregaColumna("CAT_GUNAPROD","PRECIOCONVER","TEXT")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS RUTAA (RUTAA TEXT)")
	Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS wayPoints (codigo TEXT, indice INT)")
	Dim server As String = "http://keymon.net:1782"
'	Dim server As String = "http://192.168.100.10:1781"
'	Dim server As String = "http://keymon.lat:9000"
'	server = "http://10.0.0.205:1782"
'	Dim server As String = "http://192.168.100.10:1781"
'	server = "http://11.0.0.44:1782"
	reqManager.Initialize(Me, B4XPages.MainPage.server)
	LogColor($"ReqServer = ${B4XPages.MainPage.server}"$, Colors.red)
	Label1.Text = Application.VersionName
'	Dim P As PhoneId
	Log("provider")
	Provider.Initialize
	
	Subs.guardaAppInfo

'	Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_PHONE_STATE)
'	Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
'	If Result Then
'		IMEN.Text = "" 'P.GetDeviceId
'		IMEI = "" 'P.GetDeviceId
'	End If

	'Revisamos si se disparo el intent de cargar la base de datos desde WhatApp.
	If Subs.traeUsarIntentBDWA Then
		Subs.importaBDDesdeWhatsApp
	End If
End Sub

Sub B4XPage_Appear
	If Starter.muestraProgreso = 1 Then
		muestraProgreso("Descargando actualización")
		Starter.muestraProgreso = 0
	End If
	Subs.centraPanel(p_principal, Root.Width)
	Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
'	LogColor("Start Tracker1", Colors.red)
	Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
	If Result Then
'		If Not(Tracker.Tracking) Then StartService(Tracker)
'		LogColor("Start Tracker", Colors.red)
	Else
		ToastMessageShow("No permission", True)
		Log("Sin permisos")
	End If
'	LogColor("Start Tracker3", Colors.red)
	c=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
	If c.RowCount > 0 Then
'		c.Position=0
'		c=skmt.ExecQuery("select USUARIO from usuarioa")
		c.Position=0
		usuario = c.GetString("USUARIO")
	End If
	c.Close
	
	cb_importarBDWA.Checked = Subs.traeUsarIntentBDWA
	If user.Text.Trim = "KMTS1" Then
		p_importarBDWA.Visible = True
	Else
		p_importarBDWA.Visible = False
	End If
'	Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
'	Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
'	If Result Then
'		Log("Con permisos de escritura externa")
'	End If
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Sub Entrar_Click
	If pass.Text = "YA" Then
		Starter.skmt.ExecNonQuery("delete from usuarioa")
		Starter.skmt.ExecNonQuery("delete from VERSION")
		Starter.skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object("ROOT", "ROOT"))
		Starter.skmt.ExecNonQuery("delete from cat_almacen")
		Starter.skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (user.Text))
		Starter.skmt.ExecNonQuery2("INSERT INTO VERSION(NOVERSION) VALUES (?)", Array As Object ("2.1"))
'		principal.B_REGRESA_Click
'		B4XPages.MainPage.principal.Subir.Visible = True
		B4XPages.ShowPage("Principal")
	Else
		c=Starter.skmt.ExecQuery2("select count(*) as EXISTE1 from usuarioa where usuario = ?", Array As String(user.Text))
		c.Position=0
		existe = c.GetString("EXISTE1")
		c.Close
		'existe = 1
		If existe = 0 Then
			'skmt.ExecNonQuery("delete from usuarioa")
			Dim cmd As DBCommand
			cmd.Initialize
			cmd.Name = "select_usuario_GUNA_REPG_VN"
			cmd.Parameters = Array As Object(user.Text, pass.Text)
			reqManager.ExecuteQuery(cmd , 0, "usuario")
	
'			Dim cmd As DBCommand
'			cmd.Initialize
'			cmd.Name = "select_version_INTMEX"
'			reqManager.ExecuteQuery(cmd , 0, "version")
		Else
'			principal.B_REGRESA_Click
			B4XPages.ShowPage("Principal")
		End If
	End If
End Sub

Sub JobDone(Job As HttpJob)
	If Job.Success = False Then
		ToastMessageShow("Error: " & Job.ErrorMessage, True)
	Else
		If Job.JobName = "DBRequest" Then
			Dim result As DBResult = reqManager.HandleJob(Job)
			If result.Tag = "version" Then 'query tag
				For Each records() As Object In result.Rows
					Starter.skmt.ExecNonQuery("delete from VERSION")
					Dim CAT_VE_VERSION As String = records(result.Columns.Get("CAT_VE_VERSION"))
					Starter.skmt.ExecNonQuery2("INSERT INTO VERSION(NOVERSION) VALUES (?)", Array As Object (CAT_VE_VERSION))
				Next
			End If
		End If
	 
		If Job.JobName = "DBRequest" Then
			Dim result As DBResult = reqManager.HandleJob(Job)
			If result.Tag = "agencia" Then 'query tag
				For Each records() As Object In result.Rows
           
					Dim ID_ALMACEN As String = records(result.Columns.Get("ID_ALMACEN"))
				Next
			End If
		End If

		If Job.JobName = "DBRequest" Then
			Dim result As DBResult = reqManager.HandleJob(Job)
			If result.Tag = "coords_almacen" Then 'query tag
				For Each records() As Object In result.Rows
					Log("Coordenadas del almacen: " & records(result.Columns.Get("CAT_AL_LATITUD")) & "," & records(result.Columns.Get("CAT_AL_LONGITUD")))
					Private lat, lon As Double
					lat = 0.0
					lon = 0.0
					If IsNumber(records(result.Columns.Get("CAT_AL_LATITUD"))) And IsNumber(records(result.Columns.Get("CAT_AL_LONGITUD"))) Then
						lat = records(result.Columns.Get("CAT_AL_LATITUD"))
						lon = records(result.Columns.Get("CAT_AL_LONGITUD"))
					End If
					Starter.cedisLocation.Latitude = lat
					Starter.cedisLocation.Longitude = lon
					Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("COORDS_ALMACEN"))
					Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("COORDS_ALMACEN",lon&","&lat))
					'19.48118148992086,-99.15295579261536
				Next
			End If
		End If

		If Job.JobName = "DBRequest" Then
			Dim result As DBResult = reqManager.HandleJob(Job)
			If result.Tag = "usuario" Then 'query tag
				For Each records() As Object In result.Rows
					Dim name As String = records(result.Columns.Get("USUARIO"))
					Dim ID_ALMACEN As String = records(result.Columns.Get("CAT_LO_AGENCIA"))
					Dim IMEI_BASE As String = records(result.Columns.Get("CAT_LO_IDTELEFONO"))
				Next
				paso1 = 1
			End If
		End If
		
		If Job.JobName = "DBRequest" Then
			Dim result As DBResult = reqManager.HandleJob(Job)
			If result.Tag = "contrasena" Then 'query tag
				For Each records() As Object In result.Rows
					Dim CAT_PA_PASS As String = records(result.Columns.Get("CAT_PA_PASS"))
					If CAT_PA_PASS = et_codigo.Text Then
						Log(CAT_PA_PASS)
						p_validacion.Visible = False
						et_codigo.Text = ""
						
						Subs.panelVisible(P_CIEGO,0,0)
						
					Else
						MsgboxAsync("Contraseña incorrecta","Atención")
					End If
				Next
			End If
		End If
		
'		If Job.JobName = "DBRequest" Then
'			Dim result As DBResult = reqManager.HandleJob(Job)
'			If result.Tag.As(String).IndexOf("PICK_C_") > -1 Then 'query tag
		''				Subs.logJobDoneResultados(result)
'				Private id As String= result.Tag
'				id = id.SubString(id.IndexOf("_")+3)
'				For Each records() As Object In result.Rows
'					Dim CUENTA As String = records(result.Columns.Get("CUENTA"))
'					Log(CUENTA)
'					Log(id)
'					If CUENTA = 0 Then
'						c = Starter.skmt.ExecQuery2("SELECT * FROM PICK_CIEGO WHERE PC_ID_PROD = ?", Array As String (id))
'						If c.RowCount > 0 Then
		''							For i=0 To c.RowCount -1
'							c.Position=0
'							Dim cmd As DBCommand
'							cmd.Initialize
'							cmd.Name = "insert_PICKCIEGO_MAZAPA"
'							cmd.Parameters = Array As Object(c.GetString("PC_ID_PROD"), c.GetString("PC_NOM_PROD"), c.GetString("PC_CANT"), c.GetString("PC_ALMACEN"), c.GetString("PC_RUTA"), c.GetString("PC_FECHA"),"REPARTO")
'							reqManager.ExecuteCommand(cmd , "ins_PC")
		''							Next
'						End If
'						c.Close
'					Else if CUENTA > 0 Then
'						c = Starter.skmt.ExecQuery2("SELECT * FROM PICK_CIEGO WHERE PC_ID_PROD= ?", Array As String (id))
'						If c.RowCount > 0 Then
		''							For i=0 To c.RowCount -1
'							c.Position = 0
'							Dim cmd As DBCommand
'							cmd.Initialize
'							cmd.Name = "update_PICKCIEGO_MAZAPA"
'							Log("FECHA" & c.GetString("PC_FECHA"))
'							cmd.Parameters = Array As Object(c.GetString("PC_CANT"), c.GetString("PC_ID_PROD"), c.GetString("PC_ALMACEN"), c.GetString("PC_RUTA"), c.GetString("PC_FECHA"),"REPARTO")
'							reqManager.ExecuteCommand(cmd, "update_PC")
		''							Next
'						End If
'						c.Close
'					End If
		'
'				Next
'			End If
'		End If
		
		If Job.JobName = "DBRequest" Then
			Dim result As DBResult = reqManager.HandleJob(Job)
			If result.Tag = "estatus" Then 'query tag
				For Each records() As Object In result.Rows
					Dim hvd_estatus As String = records(result.Columns.Get("HVD_ESTATUS"))
					If hvd_estatus = "Liquidado" Then
						' ToastMessageShow("rojo val ok 1 cuantosp." , True)
						MsgboxAsync("La venta ya fue liquidada","Atención")
					Else
						enviarmonto
					End If
				Next
			End If
		End If
		
		If Job.JobName = "DBRequest" Then
			Dim result As DBResult = reqManager.HandleJob(Job)
			If result.Tag = "estatus2" Then 'query tag
				For Each records() As Object In result.Rows
					Dim hvd_estatus As String = records(result.Columns.Get("HVD_ESTATUS"))
					If hvd_estatus = "Liquidado" Then
						' ToastMessageShow("rojo val ok 1 cuantosp." , True)
						MsgboxAsync("La venta ya fue liquidada","Atención")
					Else
						passaquci
					End If
				Next
			End If
		End If
		
		If Job.JobName = "DBRequest" Then
			Dim result As DBResult = reqManager.HandleJob(Job)
			If result.Tag = "SelectMontoLiq" Then
				For Each records() As Object In result.Rows
					Dim CUENTA As String = records(result.Columns.Get("CUENTA"))
					
					DateTime.DateFormat = "MM/dd/yyyy"
					sDate=DateTime.Date(DateTime.Now)
					sTime=DateTime.Time(DateTime.Now)
					Private f As Cursor=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
					f.Position=0
					Private a As Cursor =Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
					a.Position = 0
					
					Private c2 As Cursor
					c2=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
					c2.Position=0
					If c2.RowCount > 0 Then c2.GetString("USUARIO")
					
					Log(CUENTA & "----------------------!!")
					If CUENTA = "0" Then
						
'						c = Starter.skmt.ExecQuery2("SELECT * FROM ENV_MONTO_LIQ WHERE EML_USUARIO = ? AND EML_ALMACEN = ? AND EML_RUTA = ?", Array As String (c2.GetString("USUARIO"), a.GetString("ID_ALMACEN"), f.GetString("RUTAA")))
'						If c.RowCount > 0 Then
						''							For i=0 To c.RowCount -1
'							c.Position=0
'							Dim cmd As DBCommand
'							cmd.Initialize
'							cmd.Name = "insert_Monto_Liq_MAZAPArep"
'							cmd.Parameters = Array As Object(c.GetString("EML_MONTO"), c.GetString("EML_ALMACEN"), f.GetString("RUTAA"), c.GetString("EML_USUARIO"), "REPARTO", c.GetString("EML_FECHA_PED"))
'							reqManager.ExecuteCommand(cmd , "ins_Mon_Liq")
'							MsgboxAsync("Monto Enviado", "Atención")
						''							Next
'						End If
'						c.Close
					Else if CUENTA > "0" Then
						
'						c = Starter.skmt.ExecQuery2("SELECT * FROM ENV_MONTO_LIQ WHERE EML_USUARIO = ? AND EML_ALMACEN = ? AND EML_RUTA = ?", Array As String (c2.GetString("USUARIO"), a.GetString("ID_ALMACEN"), f.GetString("RUTAA")))
'						If c.RowCount > 0 Then
						''							For i=0 To c.RowCount -1
'							c.Position = 0
'							cmd.Initialize
'							cmd.Name = "update_MontoCuenta_MAZAPArep"
'							cmd.Parameters = Array As Object(c.GetString("EML_MONTO"), c.GetString("EML_ALMACEN"), c.GetString("EML_RUTA"), c.GetString("EML_USUARIO"),c.GetString("EML_FECHA_PED"),"REPARTO")
'							
'							Log(c.GetString("EML_MONTO")& " " & c.GetString("EML_ALMACEN")& " " & c.GetString("EML_RUTA")& " " & c.GetString("EML_USUARIO"))
'							reqManager.ExecuteCommand(cmd, "update_MC")
'							MsgboxAsync("Se sobre escribio el Monto", "Atención")
						''							Next
'						End If
'						c2.Close
'						c.Close
					End If
					f.Close
					a.Close
				Next
			End If
		End If
		
		Job.Release
	End If
	
	If paso1 = 1 Then
		If name = "OKActivo" Then
			Starter.skmt.ExecNonQuery("delete from usuarioa")
			Starter.skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(user.Text, pass.Text))
			Starter.skmt.ExecNonQuery("delete from cat_almacen")
			Starter.skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (ID_ALMACEN))
			B4XPages.ShowPage("Principal")
		Else If name  = "OKExpirado"& IMEI Then
			Msgbox("Usuario Expirado llamar al administrador","") 'ignore
		Else If name = "OKCancelado"& IMEI Then
			Msgbox("Usuario Cancelado llamar al administrador","") 'ignore
		Else
			Msgbox("Usuario o password No validos","") 'ignore
		End If
		paso1 = 0
	End If
End Sub

Private Sub i_engrane_Click
	p_appUpdate.Width = Root.Width
	p_appUpdate.Height = Root.Height
	Subs.centraPanel(p_serverList, Root.Width)
	Subs.centraBoton(b_server, Root.Width)
	Subs.centraBoton(b_apk, Root.Width)
	Subs.centraBoton(b_envioBD, Root.Width)
	Subs.centraBoton(b_regesar, Root.Width)
	Subs.centraBoton(b_server, p_serverList.Width)
	lv_server.Clear
	lv_server.AddSingleLine("http://keymon.lat:1782")
	
	If user.Text = "KMTS1" Then lv_server.AddSingleLine("http://10.0.0.205:1782")
'	l_server.Text = Starter.server
	et_server.Text = server
	Subs.panelVisible(p_appUpdate, 0, 0)
	
	If user.Text.Trim = "KMTS1" Then
		p_importarBDWA.Visible = True
	Else
		p_importarBDWA.Visible = False
	End If
End Sub

Private Sub B4XPage_CloseRequest As ResumableSub
'	Log("closreq")
	If p_appUpdate.Visible Then
		p_appUpdate.Visible = False
	Else
		Sleep(0)
		ExitApplication
	End If
	Return False
End Sub

Private Sub b_regesar_Click
	p_principal.Visible = True
	p_appUpdate.Visible = False
End Sub

'Enviamos la base de datos por correo o Whatsapp
Private Sub b_envioBD_Click
'	copiaDB
'	Sleep(1000)
	Dim FileName As String = "kmt.db"
	'copy the shared file to the shared folder
	Log("xxxxxx:"&Provider.SharedFolder)
	Sleep(1000)
	File.Copy(File.DirInternal, FileName, Provider.SharedFolder, FileName)
	Dim email As Email
	email.To.Add("soporte@keymonsoft.com")
	email.Subject = "Base de datos para revisión"
	email.Attachments.Add(Provider.GetFileUri(FileName))
'	email.Attachments.Add(Provider.GetFileUri(FileName)) 'second attachment
	Dim in As Intent = email.GetIntent
	in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
	StartActivity(in)
End Sub

Private Sub b_apk_Click
	StartService(appUpdater)
End Sub

Private Sub b_server_Click
	Log("Guardar servidor")
	Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("SERVER"))
	Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("SERVER",et_server.text))
	B4XPages.MainPage.server = et_server.text
	Starter.server = B4XPages.MainPage.server
	If logger Then Log("Inicializamos reqManager con " & B4XPages.MainPage.server)
	reqManager.Initialize(Me, B4XPages.MainPage.server)
	LogColor($"ReqServer = ${B4XPages.MainPage.server}"$, Colors.red)
	reinicializaReqManager
	p_appUpdate.Visible = False
'	Entrar.Visible = True
End Sub

Private Sub lv_server_ItemClick (Position As Int, Value As Object)
	server = Value
'	l_server.Text = Value
	et_server.Text = Value
	reqManager.Initialize(Me, Value)
	LogColor($"ReqServer = ${Value}"$, Colors.red)
	ToastMessageShow("Servidor modificado", False)
End Sub

Sub reinicializaReqManager
	reqManager.Initialize(Me, B4XPages.MainPage.server)
	If logger Then Log(B4XPages.MainPage.server)
	LogColor($"ReqServer = ${B4XPages.MainPage.server}"$, Colors.red)
End Sub

'appUpdater - Mostramos el anuncio de que se esta descargando el nuevo apk
Sub muestraProgreso(mensaje As String)
	ProgressDialogShow(mensaje)
End Sub

'appUpdater - Ocultamos el anuncio de que se esta descargando el nuevo apk
Sub ocultaProgreso
	ProgressDialogHide
End Sub

Private Sub b_CargarMonto_Click
	
	c = Starter.skmt.ExecQuery("SELECT *  FROM kmt_info")
	c.Position = 0
	If c.RowCount < 0 Or c.RowCount = 0 Then
		MsgboxAsync("No hay ruta cargada, favor de cargar día","Atención")
	Else
		Subs.panelVisible(p_add_monto,0,0)
	End If
	c.Close

End Sub

Private Sub p_add_monto_Click
	
End Sub

'Private Sub B_Aceptar_Monto_Click
'	Private f As Cursor=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
'	f.Position=0
'	Private a As Cursor =Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
'	a.Position = 0
'	Dim cmd As DBCommand
'	cmd.Initialize
'	cmd.Name = "select_estatus_MAZAPA"
'	cmd.Parameters = Array As Object(a.GetString("ID_ALMACEN"),f.GetString("RUTAA"))
'	reqManager.ExecuteQuery(cmd , 0, "estatus")
'	f.Close
'	a.Close
'End Sub

Sub enviarmonto
	
	DateTime.DateFormat = "MM/dd/yyyy"
	sDate=DateTime.Date(DateTime.Now)
	sTime=DateTime.Time(DateTime.Now)
	
	Private f As Cursor=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
	f.Position=0

	Private a As Cursor=Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
	If a.RowCount>0 Then
		a.Position=0
	End If
	
	Private a2 As Cursor = Starter.skmt.ExecQuery("SELECT HVD_FECHA FROM HIST_VENTAS")
	If a2.RowCount>0 Then
		a2.Position=0
		Dim fecha() As String = Regex.Split(" ", a2.GetString("HVD_FECHA"))
		Dim fecha2() As String = Regex.Split("-", fecha(0))
		Dim fecha3 As String = fecha2(2)&"/"&fecha2(1)&"/"&fecha2(0)
		Log(fecha3)
		Dim hora() As String = Regex.Split("\.", fecha(1))
		Log(hora(0))
	End If
	
	
	
	Private cI As Cursor
	Private u As String = "SinUsuario"
	cI=Starter.skmt.ExecQuery("select USUARIO from usuarioa")
	cI.Position=0
	If cI.RowCount > 0 Then u = cI.GetString("USUARIO")
	Private g As Cursor = Starter.skmt.ExecQuery("select * from ENV_MONTO_LIQ")
'	If g.RowCount = 0 Then
'		Starter.skmt.ExecNonQuery2("INSERT INTO ENV_MONTO_LIQ VALUES (?,?,?,?,?)", Array As Object(ET_Add_Monto.Text, a.GetString("ID_ALMACEN"), f.GetString("RUTAA"), u, fecha3 & " " & hora(0)))
'		f.Close
'		a.Close
'	
'		c = Starter.skmt.ExecQuery("SELECT * FROM ENV_MONTO_LIQ")
'		If c.RowCount > 0 Then
'			c.Position = 0
'			Dim cmd As DBCommand
'			cmd.Initialize
'			cmd.Name = "select_MontoCuenta_MAZAPArep"
'			cmd.Parameters = Array As Object(c.GetString("EML_USUARIO"), c.GetString("EML_ALMACEN"), c.GetString("EML_RUTA"),c.GetString("EML_FECHA_PED"))
'			reqManager.ExecuteQuery(cmd , 0, "SelectMontoLiq")
'		End If
'		c.Close
'	Else
'		Starter.skmt.ExecNonQuery2("UPDATE ENV_MONTO_LIQ SET EML_MONTO = ? WHERE EML_ALMACEN = ? AND EML_RUTA = ? AND EML_USUARIO = ?", Array As String (ET_Add_Monto.Text ,a.GetString("ID_ALMACEN"), f.GetString("RUTAA"), cI.GetString("USUARIO")))
'		f.Close
'		a.Close
'	
'		c = Starter.skmt.ExecQuery("SELECT * FROM ENV_MONTO_LIQ")
'		If c.RowCount > 0 Then
'			c.Position = 0
'			Dim cmd As DBCommand
'			cmd.Initialize
'			cmd.Name = "select_MontoCuenta_MAZAPArep"
'			cmd.Parameters = Array As Object(c.GetString("EML_USUARIO"), c.GetString("EML_ALMACEN"), c.GetString("EML_RUTA"),c.GetString("EML_FECHA_PED"))
'			reqManager.ExecuteQuery(cmd , 0, "SelectMontoLiq")
'		End If
'		c.Close
'	End If

	p_add_monto.Visible = False
	
End Sub

Private Sub B_Can_Monto_Click
	p_add_monto.Visible = False
End Sub

Private Sub b_arqueocieego_Click
	c = Starter.skmt.ExecQuery("SELECT *  FROM CAT_GUNAPROD3")
	If c.RowCount > 0 Then
		Subs.panelVisible(p_validacion,0,0)
	Else
		MsgboxAsync("No hay ruta cargada, favor de cargar día","Atención")
	End If
End Sub

Private Sub et_buspc_TextChanged (Old As String, New As String)
	If New = "" Then
		CLV_PICK_CIEGO.Clear
	Else If New.Length >= 3 Then
		CLV_PICK_CIEGO.Clear
	
		q_buscar = "%" & et_buspc.Text & "%"
		Log(q_buscar)
		c=Starter.skmt.ExecQuery2($"select CAT_GP_NOMBRE, CAT_GP_ID , ifnull(PC_CANT,0) AS PC_CANT FROM CAT_GUNAPROD3 INNER JOIN PICK_CIEGO ON PC_ID_PROD = CAT_GP_ID AND PC_NOM_PROD = CAT_GP_NOMBRE WHERE (CAT_GP_NOMBRE LIKE ? OR  CAT_GP_ID  LIKE ? ) and CAT_GP_CLASIF <> 'PROMOS'"$, Array As String(q_buscar,q_buscar))
		If c.RowCount > 0 Then

		
			For i = 0 To c.RowCount - 1
				c.Position = i
				CLV_PICK_CIEGO.Add(CreateListItem(c.GetString("CAT_GP_ID"), c.GetString("CAT_GP_NOMBRE"), c.GetString("PC_CANT")),i)
'				Log(c.GetString("CAT_GP_ID") & ", " & c.GetString("CAT_GP_NOMBRE") & " ," & c.GetString("PC_CANT"))
			Next
			c.Close
		
			d=Starter.skmt.ExecQuery2($"select CAT_GP_NOMBRE, CAT_GP_ID FROM CAT_GUNAPROD3 WHERE (CAT_GP_NOMBRE LIKE ? OR  CAT_GP_ID  LIKE ? ) and CAT_GP_CLASIF <> 'PROMOS'AND CAT_GP_ID NOT IN (SELECT PC_ID_PROD FROM PICK_CIEGO)"$, Array As String(q_buscar,q_buscar))
		
			For i = 0 To d.RowCount - 1
				d.Position = i
				CLV_PICK_CIEGO.Add(CreateListItem2(d.GetString("CAT_GP_ID"), d.GetString("CAT_GP_NOMBRE")),i)
'				Log(d.GetString("CAT_GP_ID") & ", " & d.GetString("CAT_GP_NOMBRE"))
			Next
			d.Close
		
		Else If c.RowCount = 0 Then
			d=Starter.skmt.ExecQuery2($"select CAT_GP_NOMBRE, CAT_GP_ID FROM CAT_GUNAPROD3 WHERE (CAT_GP_NOMBRE LIKE ? OR  CAT_GP_ID  LIKE ? ) and CAT_GP_CLASIF <> 'PROMOS'"$, Array As String(q_buscar,q_buscar))
		
			For i = 0 To d.RowCount - 1
				d.Position = i
				CLV_PICK_CIEGO.Add(CreateListItem2(d.GetString("CAT_GP_ID"), d.GetString("CAT_GP_NOMBRE")),i)
'				Log(d.GetString("CAT_GP_ID") & ", " & d.GetString("CAT_GP_NOMBRE"))
			Next
			d.Close
		End If
	End If
End Sub

Private Sub B_PC_ENV_Click
	Dim sDate, sTime As String
	DateTime.DateFormat = "dd/MM/yyyy"
	DateTime.TimeFormat = "HH:mm:ss"
	sDate = DateTime.Date(DateTime.Now)
	sTime = DateTime.Time(DateTime.Now)
	
	
	For i = 0 To CLV_PICK_CIEGO.Size - 1
		' Retrieve the panel and child views for the current item
		Dim itemPanel As B4XView = CLV_PICK_CIEGO.GetPanel(i)
		Dim innerPanel As B4XView = itemPanel.GetView(0)
		Dim editText As B4XView = innerPanel.GetView(1)
		Dim inputText As String = editText.As(EditText).Text

		' Check if the input text matches the regex pattern for zeros or if it's empty
		If Regex.IsMatch("^[0]+$", inputText) Or inputText = "" Then
			inputText = "0"
		End If

		' Retrieve and process the ID label
		Dim idLabel As B4XView = innerPanel.GetView(0)
		Dim idText As String = idLabel.As(Label).Text
		Dim idParts() As String = Regex.Split(CRLF, idText)
'		Log(idParts(1))
		f=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
		f.Position=0
		Log(f.GetString("RUTAA"))
		a=Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
		If a.RowCount>0 Then
			a.Position=0
		End If
		Dim k As Cursor = Starter.skmt.ExecQuery("SELECT HVD_FECHA FROM HIST_VENTAS")
		k.Position = 0
		Dim fechatabulador() As String = Regex.Split(" ", k.GetString("HVD_FECHA"))
		Dim fechatabulador2() As String = Regex.Split("-", fechatabulador(0))
		Dim fechatabulador3 As String = fechatabulador2(2)&"/"&fechatabulador2(1)&"/"&fechatabulador2(0)
		k.Close
		If inputText <> "" Then
			c = Starter.skmt.ExecQuery2("SELECT * FROM PICK_CIEGO where PC_ID_PROD = ?", Array As String (idParts(0)))
			If c.RowCount = 0 Then
				' Insert data into the database
				Log(f.GetString("RUTAA"))
				Starter.skmt.ExecNonQuery2("INSERT INTO PICK_CIEGO(PC_ID_PROD, PC_NOM_PROD, PC_CANT, PC_ALMACEN, PC_RUTA, PC_FECHA) VALUES(?,?,?,?,?,?)", Array As String(idParts(0), idParts(1), inputText, a.GetString("ID_ALMACEN"), f.GetString("RUTAA"), fechatabulador3&" "&sTime))
			
			Else
				Log(f.GetString("RUTAA"))
				Starter.skmt.ExecNonQuery2("Update PICK_CIEGO set PC_CANT = ?  WHERE PC_ID_PROD = ?" , Array As String(inputText ,idParts(0)))
			End If

		End If
		f.Close
		a.Close
		Log("Processed item " & i)
	Next
	et_buspc.Text = ""
	CLV_PICK_CIEGO.Clear
End Sub

Private Sub b_terpc_Click
	Msgbox2Async("Una vez enviada la información no podras hacer modificaciones","Atención","SI","", "",LoadBitmap(File.DirAssets,"alert2.png"), False)
	Wait For Msgbox_Result (resultado As Int)
	If resultado = DialogResponse.POSITIVE Then
		Msgbox2Async("Estas seguro de enviar la información?","Atención","SI","", "NO",LoadBitmap(File.DirAssets,"alert2.png"), False)
		Wait For Msgbox_Result (resultado As Int)
		If resultado = DialogResponse.POSITIVE Then
		
			Dim sDate, sTime As String
			DateTime.DateFormat = "dd/MM/yyyy"
			DateTime.TimeFormat = "HH:mm:ss"
			sDate = DateTime.Date(DateTime.Now)
			sTime = DateTime.Time(DateTime.Now)
	
			For i = 0 To CLV_PICK_CIEGO.Size - 1
				' Retrieve the panel and child views for the current item
				Dim itemPanel As B4XView = CLV_PICK_CIEGO.GetPanel(i)
				Dim innerPanel As B4XView = itemPanel.GetView(0)
				Dim editText As B4XView = innerPanel.GetView(1)
				Dim inputText As String = editText.As(EditText).Text
	
				' Check if the input text matches the regex pattern for zeros or if it's empty
				If Regex.IsMatch("^[0]+$", inputText) Or inputText = "" Then
					inputText = "0"
				End If
	
				' Retrieve and process the ID label
				Dim idLabel As B4XView = innerPanel.GetView(0)
				Dim idText As String = idLabel.As(Label).Text
				Dim idParts() As String = Regex.Split(CRLF, idText)
'				Log(idParts(1))
				f=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
				f.Position=0
				Log(f.GetString("RUTAA"))

				a=Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
				If a.RowCount>0 Then
					a.Position=0
				End If
				Log(a.GetString("ID_ALMACEN"))
				
				Dim k As Cursor = Starter.skmt.ExecQuery("SELECT HVD_FECHA FROM HIST_VENTAS")
				k.Position = 0
				Dim fechatabulador() As String = Regex.Split(" ", k.GetString("HVD_FECHA"))
				Dim fechatabulador2() As String = Regex.Split("-", fechatabulador(0))
				Dim fechatabulador3 As String = fechatabulador2(2)&"/"&fechatabulador2(1)&"/"&fechatabulador2(0)
				k.Close
				If inputText <> "" Then
					c = Starter.skmt.ExecQuery2("SELECT * FROM PICK_CIEGO where PC_ID_PROD = ?", Array As String (idParts(0)))
					If c.RowCount = 0 Then
						' Insert data into the database
						Starter.skmt.ExecNonQuery2("INSERT INTO PICK_CIEGO(PC_ID_PROD, PC_NOM_PROD, PC_CANT, PC_ALMACEN, PC_RUTA, PC_FECHA) VALUES(?,?,?,?,?,?)", Array As String(idParts(0), idParts(1), inputText, a.GetString("ID_ALMACEN"), f.GetString("RUTAA"), fechatabulador3&" "&sTime))
					Else
						Starter.skmt.ExecNonQuery2("Update PICK_CIEGO set PC_CANT = ?  WHERE PC_ID_PROD = ?" , Array As String(inputText ,idParts(0)))
					End If
				End If
				f.Close
				a.Close
				Log("Processed item " & i)
			Next
			Log("Finished processing all items")
			P_CIEGO.Visible = False
			et_buspc.Text = ""
			CLV_PICK_CIEGO.Clear
			c = Starter.skmt.ExecQuery("SELECT PC_ID_PROD, PC_ALMACEN, PC_RUTA, PC_FECHA FROM PICK_CIEGO")
'			If c.RowCount > 0 Then
'				For i = 0 To c.RowCount - 1
'					c.Position = i
'					Dim cmd As DBCommand
'					cmd.Initialize
'					cmd.Name = "select_HIST_PICKCIEGO_MAZAPA" '
'					cmd.Parameters = Array As Object(c.GetString("PC_ID_PROD"), c.GetString("PC_ALMACEN"), c.GetString("PC_RUTA"), c.GetString("PC_FECHA"),"REPARTO")
'					reqManager.ExecuteQuery(cmd , 0, $"PICK_C_${c.GetString("PC_ID_PROD")}"$)
'				Next
'			End If
			c.close
		Else
		
		End If
	End If
End Sub

Private Sub P_CIEGO_Click
	
End Sub

Private Sub b_aceptar_Click
	Private f As Cursor=Starter.skmt.ExecQuery("select RUTAA from RUTAA")
	f.Position=0
	Private a As Cursor =Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
	a.Position = 0
'	Dim cmd As DBCommand
'	cmd.Initialize
'	cmd.Name = "select_estatus_MAZAPA"
'	cmd.Parameters = Array As Object(a.GetString("ID_ALMACEN"),f.GetString("RUTAA"))
'	reqManager.ExecuteQuery(cmd , 0, "estatus2")
	f.Close
	a.Close
'	p_validacion.Visible = False
'	et_codigo.Text = ""
'						
'	Subs.panelVisible(P_CIEGO,0,0)
End Sub

Sub passaquci
	f=Starter.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info")
	f.Position=0

	a=Starter.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
	If a.RowCount>0 Then
		a.Position=0
	End If
	Log(a.GetString("ID_ALMACEN"))
	Log(f.GetString("CAT_CL_RUTA"))
	
'	If et_codigo.Text = "KMTS1" Then
'		p_validacion.Visible = False
'		et_codigo.Text = ""
'		Subs.panelVisible(P_CIEGO,0,0)
'	Else
'		Dim cmd As DBCommand
'		cmd.Initialize
'		cmd.Name = "select_CAT_PASS_ARQUEO_MAZAPA"
'		cmd.Parameters = Array As Object(f.GetString("CAT_CL_RUTA"),a.GetString("ID_ALMACEN"),"REPARTO")
'		reqManager.ExecuteQuery(cmd , 0, "contrasena")
'		f.Close
'		a.Close
'	End If
End Sub

Private Sub b_cancelarcodigo_Click
	p_validacion.Visible = False
End Sub

Private Sub p_validacion_Click
	
End Sub

Sub CreateListItem(Id_prod As String, Prod As String,cant As String) As Panel
	Dim pa As B4XView = xui.CreatePanel("")
	pa.SetLayoutAnimated(0, 0, 0, 1, 10)
	pa.LoadLayout("PANEL_PICK_CIEGO")
	pa.Height = 55dip
	pa.Width = 298dip
	'pa.Width = clv_orden.GetBase.Width
	L_PICK_CIEGO.Text = Id_prod &  CRLF & Prod
	L_PICK_CIEGO.TextSize = 12
	L_PICK_CIEGO.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
	ET_PICK_CIEGO.Text = cant
	'cxc.Id_prod = mostrar3
	'Log(pa.Width)
	Return pa
End Sub

Sub CreateListItem2(Id_prod As String, Prod As String) As Panel
	Dim pa As B4XView = xui.CreatePanel("")
	pa.SetLayoutAnimated(0, 0, 0, 1, 10)
	pa.LoadLayout("PANEL_PICK_CIEGO")
	pa.Height = 55dip
	pa.Width = 298dip
	'pa.Width = clv_orden.GetBase.Width
	L_PICK_CIEGO.Text = Id_prod &  CRLF & Prod
	L_PICK_CIEGO.TextSize = 12
	L_PICK_CIEGO.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
	'cxc.Id_prod = mostrar3
	'Log(pa.Width)
	Return pa
End Sub

Private Sub ImageView1_LongClick

End Sub

Private Sub p_appUpdate_Click
	
End Sub

Private Sub cb_importarBDWA_CheckedChange(Checked As Boolean)
'	LogColor($"cb_importarBDWA_CheckedChange = ${Checked}"$, Colors.Red)
	Starter.skmt.ExecNonQuery("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'")
	Starter.skmt.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('IMPORTAR_BD_WA', '${Checked}')"$)
End Sub