mirror of
https://github.com/KeymonSoft/Estacionamiento.git
synced 2026-04-17 19:37:01 +00:00
697 lines
23 KiB
QBasic
697 lines
23 KiB
QBasic
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
|
|
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
|
|
'###########################################################################################################
|
|
'###################### PULL #############################################################
|
|
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=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
|
|
Private b_salida As Button
|
|
Private b_entrada As Button
|
|
Private b_cancelar As Button
|
|
Private b_guardar As Button
|
|
Private b_regresar As Button
|
|
Dim c As Cursor
|
|
Dim t As Cursor
|
|
Dim cmd As DBCommand
|
|
Private et_placa As EditText
|
|
Private Root As B4XView
|
|
Dim RES As String
|
|
Dim RES3 As String
|
|
Dim RES5 As String
|
|
Private p_estacionamiento As Panel
|
|
Private p_guarda_info As Panel
|
|
Private p_sal_esta As Panel
|
|
Public Provider As FileProvider
|
|
' Private xui As XUI
|
|
Dim skmt As SQL
|
|
Private lv_Lis_Placa As ListView
|
|
Dim TAMANO As Int
|
|
Dim ESPACIO As Int
|
|
Dim BLANCO As String
|
|
Dim printer As TextWriter
|
|
Dim cmp20 As Serial
|
|
Dim btAdmin As BluetoothAdmin
|
|
Dim Printer1 As EscPosPrinter
|
|
Dim impresoraConectada As Boolean = False
|
|
Dim errorImpresora As Int = 0
|
|
Dim p As Int
|
|
Dim v As Object
|
|
Private LogoEst As ImageView
|
|
Private LogEst_lv As ImageView
|
|
Private LogoEst_placa As ImageView
|
|
Private b_Tarifa As Button
|
|
Private p_tar_f As Panel
|
|
Private et_tar_f As EditText
|
|
Private b_tar_can As Button
|
|
Private b_tar_in As Button
|
|
Private b_resdia As Button
|
|
Private LogEst_res As ImageView
|
|
Private p_res As Panel
|
|
Private l_totales As Label
|
|
Private l_totalsal As Label
|
|
Private l_montoto As Label
|
|
Private b_resacep As Button
|
|
Private b_rescan As Button
|
|
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)
|
|
Provider.Initialize
|
|
skmt.Initialize(File.DirInternal,"kmt.db", True)
|
|
Root = Root1
|
|
Root.LoadLayout("MainPage")
|
|
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_VARIABLES (CAT_VA_DESCRIPCION TEXT, CAT_VA_VALOR TEXT)")
|
|
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS TMP_INFO_EnSal (TMP_PLACA TEXT, TMP_HR_ENTRA TEXT, TMP_HR_SAL TEXT)")
|
|
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS TMP_TARIFA (TMP_TAR_H TEXT)")
|
|
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_PLACAS (PLACA TEXT, ENTRADA TEXT, SALIDA TEXT, MONTO TEXT, FOLIO TEXT)")
|
|
Subs.agregaColumna("TMP_INFO_EnSal", "TMP_DEN_FUE", "INTEGER")
|
|
Subs.agregaColumna("TMP_INFO_EnSal", "TMP_FOLIO", "TEXT")
|
|
|
|
|
|
AjustarInterfaz(Root.Width, Root.Height)
|
|
|
|
btAdmin.Initialize("BlueTeeth")
|
|
cmp20.Initialize("Printer")
|
|
|
|
End Sub
|
|
|
|
Private Sub AjustarInterfaz(Ancho As Int, Alto As Int)
|
|
|
|
p_estacionamiento.SetLayoutAnimated(0, 0, 0, Ancho, Alto)
|
|
p_guarda_info.SetLayoutAnimated(0, 0, 0, Ancho, Alto)
|
|
p_sal_esta.SetLayoutAnimated(0, 0, 0, Ancho, Alto)
|
|
p_res.SetLayoutAnimated(0, 0, 0, Ancho, Alto)
|
|
|
|
|
|
Dim margenVertical As Int = Alto * 0.02
|
|
Dim margenHorizontal As Int = Ancho * 0.05
|
|
Dim botonAncho As Int = (Ancho - (margenHorizontal * 4)) / 3
|
|
Dim botonAlto As Int = Alto * 0.09
|
|
Dim botonesY As Int = Alto - botonAlto - margenVertical
|
|
Dim espacioEntreBotones As Int = margenVertical
|
|
|
|
Dim bAncho As Int = (Ancho - (margenHorizontal * 4))
|
|
|
|
Dim centroX As Int = (Ancho - bAncho) / 2
|
|
Dim centroY As Int = (Alto - (3 * botonAlto + 2 * espacioEntreBotones)) / 2
|
|
|
|
b_entrada.SetLayoutAnimated(0, centroX, centroY, bAncho, botonAlto)
|
|
b_salida.SetLayoutAnimated(0, centroX, b_entrada.Top + botonAlto + espacioEntreBotones, bAncho, botonAlto)
|
|
b_Tarifa.SetLayoutAnimated(0,centroX, b_salida.Top + botonAlto + espacioEntreBotones, bAncho, botonAlto)
|
|
b_resdia.SetLayoutAnimated(0,centroX, b_Tarifa.Top + botonAlto + espacioEntreBotones, bAncho, botonAlto)
|
|
|
|
b_guardar.SetLayoutAnimated(0, margenHorizontal, botonesY, botonAncho, botonAlto)
|
|
b_cancelar.SetLayoutAnimated(0, margenHorizontal + 2 * (botonAncho + margenHorizontal), botonesY, botonAncho, botonAlto)
|
|
b_regresar.SetLayoutAnimated(0, margenHorizontal + 1 * (botonAncho + margenHorizontal), botonesY, botonAncho, botonAlto)
|
|
b_rescan.SetLayoutAnimated(0, margenHorizontal + 1 * (botonAncho + margenHorizontal), botonesY, botonAncho, botonAlto)
|
|
b_resacep.SetLayoutAnimated(0, margenHorizontal + 1 * (botonAncho + margenHorizontal), botonesY, botonAncho, botonAlto)
|
|
|
|
|
|
Dim logoAncho As Int = Ancho * 0.3
|
|
Dim logoAlto As Int = Alto * 0.2
|
|
Dim logoY As Int = margenVertical
|
|
|
|
LogoEst.SetLayoutAnimated(0, margenHorizontal, logoY, logoAncho, logoAlto)
|
|
LogEst_lv.SetLayoutAnimated(0, margenHorizontal, logoY, logoAncho, logoAlto)
|
|
LogoEst_placa.SetLayoutAnimated(0, margenHorizontal, logoY, logoAncho, logoAlto)
|
|
LogEst_res.SetLayoutAnimated(0, margenHorizontal, logoY, logoAncho, logoAlto)
|
|
|
|
lv_Lis_Placa.SetLayoutAnimated(0, margenHorizontal, logoY + logoAlto + margenVertical, Ancho - 2 * margenHorizontal, b_regresar.Top - logoAlto - 2 * margenVertical)
|
|
|
|
p_guarda_info.BringToFront
|
|
End Sub
|
|
|
|
|
|
Private Sub B4XPage_Resize(Width As Int, Height As Int)
|
|
AjustarInterfaz(Width, Height)
|
|
End Sub
|
|
|
|
Private Sub b_entrada_Click
|
|
|
|
Dim t As Cursor = skmt.ExecQuery("SELECT TMP_TAR_H FROM TMP_TARIFA")
|
|
If t.RowCount > 0 Then
|
|
t.Position = 0
|
|
Log(t.GetString("TMP_TAR_H"))
|
|
|
|
et_placa.Text = ""
|
|
|
|
b_entrada.Visible = False
|
|
b_salida.Visible = False
|
|
p_guarda_info.Visible = True
|
|
p_estacionamiento.Visible = False
|
|
et_placa.Visible = True
|
|
p_guarda_info.BringToFront
|
|
|
|
Else If t.RowCount = 0 Then
|
|
|
|
MsgboxAsync("Favor de caprurar la tarifa por hora", "Atención")
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub b_salida_Click
|
|
lv_Lis_Placa.Clear
|
|
b_entrada.Visible = False
|
|
b_salida.Visible = False
|
|
p_guarda_info.Visible = False
|
|
p_estacionamiento.Visible = False
|
|
p_sal_esta.Visible = True
|
|
lv_Lis_Placa.Visible = True
|
|
lv_Lis_Placa.BringToFront
|
|
|
|
Private l1 As Label = lv_Lis_Placa.SingleLineLayout.Label
|
|
l1.TextColor = Colors.Black
|
|
|
|
c = skmt.ExecQuery("SELECT TMP_PLACA, TMP_HR_ENTRA, TMP_HR_SAL, TMP_DEN_FUE FROM TMP_INFO_EnSal")
|
|
|
|
If c.RowCount > 0 Then
|
|
|
|
lv_Lis_Placa.Clear
|
|
For i = 0 To c.RowCount - 1
|
|
c.Position = i
|
|
If c.GetString("TMP_DEN_FUE") <> 1 Then
|
|
lv_Lis_Placa.AddSingleLine(c.GetString("TMP_PLACA"))
|
|
End If
|
|
Next
|
|
End If
|
|
c.Close
|
|
End Sub
|
|
|
|
Private Sub b_salida_LongClick
|
|
RES = Msgbox2("Seguro que desea hacer el cierre todos los datos se borraran?","Cierre", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
|
If RES = DialogResponse.POSITIVE Then
|
|
skmt.ExecNonQuery("DELETE FROM TMP_INFO_EnSal")
|
|
skmt.ExecNonQuery("DELETE FROM HIST_PLACAS")
|
|
skmt.ExecNonQuery("DELETE FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = 'Folio'")
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub lv_Lis_Placa_ItemClick (Position As Int, Value As Object)
|
|
RES = Msgbox2Async("¿Seguro que esta placa va a salir?", "Cierre", "Sí", "", "No", LoadBitmap(File.DirAssets, "alert2.png"), False)
|
|
Wait For Msgbox_Result(RES2 As Int)
|
|
If RES2 = DialogResponse.POSITIVE Then
|
|
|
|
v = Value
|
|
p = Position
|
|
Impresion
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Sub Impresion
|
|
Dim placaSeleccionada As String = v
|
|
c = skmt.ExecQuery2("SELECT TMP_PLACA, TMP_HR_ENTRA, TMP_HR_SAL, TMP_DEN_FUE, TMP_FOLIO FROM TMP_INFO_EnSal WHERE TMP_PLACA = ?", Array As String(placaSeleccionada))
|
|
|
|
If c.RowCount > 0 Then
|
|
c.Position = 0
|
|
|
|
Dim fechaSalida As String = Subs.traeFecha
|
|
Dim fechaEntrada As String = c.GetString("TMP_HR_ENTRA")
|
|
Dim partesFechaEntrada() As String = Regex.Split(" ", fechaEntrada)
|
|
Dim partesFechaSalida() As String = Regex.Split(" ", fechaSalida)
|
|
|
|
If partesFechaEntrada.Length > 1 And partesFechaSalida.Length > 1 Then
|
|
|
|
Dim fechaSalida As String = Subs.traeFecha
|
|
Dim fechaEntrada As String = c.GetString("TMP_HR_ENTRA")
|
|
|
|
Dim partesFechaEntrada() As String = Regex.Split(" ", fechaEntrada)
|
|
Dim partesFechaSalida() As String = Regex.Split(" ", fechaSalida)
|
|
|
|
If partesFechaEntrada.Length > 1 And partesFechaSalida.Length > 1 Then
|
|
Dim horaEntrada As String = partesFechaEntrada(1)
|
|
Dim fechaEntrada As String = partesFechaEntrada(0)
|
|
|
|
Dim horaSalida As String = partesFechaSalida(1)
|
|
Dim fechaSalida As String = partesFechaSalida(0)
|
|
|
|
Dim milisEntrada As Long = DateTime.TimeParse(horaEntrada)
|
|
Dim milisSalida As Long = DateTime.TimeParse(horaSalida)
|
|
|
|
Dim diasEntrada As Long = DateTime.DateParse(fechaEntrada) / DateTime.TicksPerDay
|
|
Dim diasSalida As Long = DateTime.DateParse(fechaSalida) / DateTime.TicksPerDay
|
|
|
|
Dim diferenciaDiasEnMilis As Long = (diasSalida - diasEntrada) * DateTime.TicksPerDay
|
|
Dim diferenciaTotalMilis As Long = (milisSalida + diferenciaDiasEnMilis) - milisEntrada
|
|
|
|
Dim diferenciaTotalSegundos As Long = diferenciaTotalMilis / DateTime.TicksPerSecond
|
|
Dim diferenciaTotalMinutos As Long = diferenciaTotalSegundos / 60
|
|
Dim diferenciaTotalHoras As Long = diferenciaTotalMinutos / 60
|
|
|
|
Dim horasRestantes As Long = diferenciaTotalHoras
|
|
Dim minutosRestantes As Long = diferenciaTotalMinutos Mod 60
|
|
Dim segundosRestantes As Long = diferenciaTotalSegundos Mod 60
|
|
|
|
Log("Horas restantes: " & horasRestantes)
|
|
Log("Minutos restantes: " & minutosRestantes)
|
|
Log("Segundos restantes: " & segundosRestantes)
|
|
End If
|
|
|
|
|
|
' printer.WriteLine("------------------------------")
|
|
' printer.WriteLine("---NO ES UN COMPROBANTE ------")
|
|
' printer.WriteLine("---------FISCAL---------------")
|
|
' printer.WriteLine("---COMPROBANTE DE ENTREGA-----")
|
|
' printer.WriteLine("------------------------------")
|
|
|
|
Else
|
|
Log("Formato de fecha incorrecto en entrada o salida.")
|
|
End If
|
|
|
|
|
|
ProgressDialogShow("Imprimiendo, un momento ...")
|
|
Printer1.DisConnect
|
|
If Not(Printer1.IsConnected) Then
|
|
Log("Conectando a impresora ...")
|
|
Printer1.Connect
|
|
Private cont As Int = 0
|
|
Do While Not(impresoraConectada)
|
|
Sleep(1000)
|
|
Log("++++++ " & cont)
|
|
cont = cont + 1
|
|
If cont = 2 Then Printer1.Connect 'Tratamos de reconectar
|
|
If cont > 3 Then impresoraConectada = True
|
|
Loop
|
|
Sleep(500)
|
|
impresoraConectada = False
|
|
Else
|
|
Log("conectando 2")
|
|
Printer1.Connect
|
|
Private cont As Int = 0
|
|
Do While Not(impresoraConectada) Or Not(Printer1.IsConnected)
|
|
Sleep(1000)
|
|
Log("****** " & cont)
|
|
cont = cont + 1
|
|
If cont = 2 Then Printer1.Connect
|
|
If cont > 3 Then impresoraConectada = True
|
|
Loop
|
|
Sleep(500)
|
|
impresoraConectada = False
|
|
End If
|
|
t = skmt.ExecQuery("SELECT TMP_TAR_H FROM TMP_TARIFA")
|
|
If t.RowCount > 0 Then
|
|
t.Position = 0
|
|
Log(t.GetString("TMP_TAR_H"))
|
|
|
|
|
|
Private sDate As String =DateTime.Date(DateTime.Now)
|
|
Private sTime As String =DateTime.Time(DateTime.Now)
|
|
|
|
Printer1.WriteString(" " & CRLF)
|
|
Printer1.WriteString(" " & CRLF)
|
|
|
|
Printer1.WriteString(" Establecimietno: " & CRLF)
|
|
Printer1.WriteString(" La Antigua, Restaurante - Bar" & CRLF)
|
|
Printer1.WriteString(" Fecha: " & sDate & " " & sTime & " " & CRLF)
|
|
Printer1.WriteString(" Folio: " & c.GetString("TMP_FOLIO") & CRLF)
|
|
Printer1.WriteString(Chr(27) & Chr(69)) ' Código ESC/P para iniciar negritas
|
|
Printer1.WriteString(" Placa: " & c.GetString("TMP_PLACA") & " " & CRLF)
|
|
Printer1.WriteString(Chr(27) & Chr(70)) ' Código ESC/P para finalizar negritas
|
|
Printer1.WriteString("Hora Entrada:" & c.GetString("TMP_HR_ENTRA")& CRLF)
|
|
Printer1.WriteString("Hora Salida: " & Subs.traeFecha& CRLF)
|
|
Printer1.WriteString("Tarifa por Hora: " & t.GetString("TMP_TAR_H") & CRLF)
|
|
Printer1.WriteString("Horas: " & horasRestantes & CRLF)
|
|
Printer1.WriteString("Munutos: " & minutosRestantes & CRLF)
|
|
Printer1.WriteString("Total a pagar: " & Subs.CalcularCosto(diferenciaTotalMinutos, t.GetString("TMP_TAR_H"))& CRLF)
|
|
|
|
Printer1.WriteString(" " & CRLF)
|
|
Printer1.WriteString(" " & CRLF)
|
|
Printer1.WriteString(" " & CRLF)
|
|
Printer1.WriteString(" " & CRLF)
|
|
Sleep(1000)
|
|
Printer1.DisConnect
|
|
|
|
ProgressDialogHide
|
|
|
|
RES3 = Msgbox2Async("¿Deceas volver a imprimir el ticket?", "Cierre", "Sí", "", "No", LoadBitmap(File.DirAssets, "alert2.png"), False)
|
|
Wait For Msgbox_Result(RES4 As Int)
|
|
|
|
If RES4 = DialogResponse.POSITIVE Then
|
|
Impresion
|
|
Else
|
|
skmt.ExecNonQuery2("INSERT INTO HIST_PLACAS(PLACA, ENTRADA, SALIDA, MONTO, FOLIO) values(?,?,?,?,?)", Array As String(c.GetString("TMP_PLACA"),c.GetString("TMP_HR_ENTRA"),Subs.traeFecha,Subs.CalcularCosto(diferenciaTotalMinutos, t.GetString("TMP_TAR_H")),c.GetString("TMP_FOLIO")))
|
|
p_estacionamiento.Visible = True
|
|
b_entrada.Visible = True
|
|
b_salida.Visible = True
|
|
lv_Lis_Placa.Visible = False
|
|
p_sal_esta.Visible = False
|
|
skmt.ExecNonQuery2("DELETE FROM TMP_INFO_EnSal WHERE TMP_PLACA = ? and TMP_FOLIO = ? ", Array As String(c.GetString("TMP_PLACA"), c.GetString("TMP_FOLIO")))
|
|
End If
|
|
|
|
End If
|
|
t.Close
|
|
c.Close
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub b_regresar_Click
|
|
p_estacionamiento.Visible = True
|
|
b_entrada.Visible = True
|
|
b_salida.Visible = True
|
|
lv_Lis_Placa.Visible = False
|
|
p_sal_esta.Visible = False
|
|
End Sub
|
|
|
|
Private Sub b_guardar_Click
|
|
'Verificamos que haya una placa escrita
|
|
If et_placa.Text <> "" Then
|
|
|
|
'Verificamos que haya un folio o no
|
|
Private check As Cursor = skmt.ExecQuery($"SELECT * FROM TMP_INFO_EnSal WHERE TMP_PLACA = '${et_placa.Text}'"$)
|
|
If check.RowCount = 0 Then
|
|
|
|
Private folio As Cursor = skmt.ExecQuery($"SELECT * FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = 'Folio'"$)
|
|
If folio.RowCount = 0 Then
|
|
|
|
skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) values(?,?)", Array As String("Folio", "1"))
|
|
|
|
Private folioasing As Cursor = skmt.ExecQuery($"SELECT * FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = 'Folio'"$)
|
|
folioasing.Position = 0
|
|
|
|
skmt.ExecNonQuery2("INSERT INTO TMP_INFO_EnSal(TMP_PLACA, TMP_HR_ENTRA ,TMP_DEN_FUE ,TMP_FOLIO) values (?,?,?,?)", Array As String(et_placa.Text,Subs.traeFecha,0, folioasing.GetString("CAT_VA_VALOR")))
|
|
|
|
'Vamos a llamar la rutina de impresion
|
|
imprime_Guarda
|
|
|
|
folioasing.Close
|
|
|
|
Else If folio.RowCount > 0 Then
|
|
|
|
skmt.ExecNonQuery($"UPDATE CAT_VARIABLES SET CAT_VA_VALOR = CAT_VA_VALOR + 1 WHERE CAT_VA_DESCRIPCION = 'Folio' "$)
|
|
|
|
Private folioasing As Cursor = skmt.ExecQuery($"SELECT * FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = 'Folio'"$)
|
|
folioasing.Position = 0
|
|
|
|
skmt.ExecNonQuery2("INSERT INTO TMP_INFO_EnSal(TMP_PLACA, TMP_HR_ENTRA ,TMP_DEN_FUE ,TMP_FOLIO) values (?,?,?,?)", Array As String(et_placa.Text,Subs.traeFecha,0, folioasing.GetString("CAT_VA_VALOR")))
|
|
|
|
'Vamos a llamar la rutina de impresion
|
|
imprime_Guarda
|
|
|
|
folioasing.Close
|
|
|
|
End If
|
|
|
|
Else If check.RowCount > 0 Then
|
|
|
|
MsgboxAsync("El vehiculo esta en el estacionamiento","Atención")
|
|
|
|
End If
|
|
|
|
Else
|
|
|
|
MsgboxAsync("Ingrese una placa valida","Atención")
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Sub imprime_Guarda
|
|
|
|
Private check As Cursor = skmt.ExecQuery($"SELECT * FROM TMP_INFO_EnSal WHERE TMP_PLACA = '${et_placa.Text}'"$)
|
|
If check.RowCount > 0 Then
|
|
|
|
check.Position = 0
|
|
|
|
ProgressDialogShow("Imprimiendo, un momento ...")
|
|
Printer1.DisConnect
|
|
If Not(Printer1.IsConnected) Then
|
|
Log("Conectando a impresora ...")
|
|
Printer1.Connect
|
|
Private cont As Int = 0
|
|
Do While Not(impresoraConectada)
|
|
Sleep(1000)
|
|
Log("++++++ " & cont)
|
|
cont = cont + 1
|
|
If cont = 2 Then Printer1.Connect 'Tratamos de reconectar
|
|
If cont > 3 Then impresoraConectada = True
|
|
Loop
|
|
Sleep(500)
|
|
impresoraConectada = False
|
|
Else
|
|
Log("conectando 2")
|
|
Printer1.Connect
|
|
Private cont As Int = 0
|
|
Do While Not(impresoraConectada) Or Not(Printer1.IsConnected)
|
|
Sleep(1000)
|
|
Log("****** " & cont)
|
|
cont = cont + 1
|
|
If cont = 2 Then Printer1.Connect
|
|
If cont > 3 Then impresoraConectada = True
|
|
Loop
|
|
Sleep(500)
|
|
impresoraConectada = False
|
|
End If
|
|
|
|
Private t As Cursor = skmt.ExecQuery("SELECT TMP_TAR_H FROM TMP_TARIFA")
|
|
t.Position = 0
|
|
Dim folio As Cursor = skmt.ExecQuery($"SELECT * FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = 'Folio'"$)
|
|
folio.Position = 0
|
|
|
|
Dim fecha As String = check.GetString("TMP_HR_ENTRA")
|
|
Dim fechaHora() As String = Regex.Split(" ", fecha)
|
|
|
|
|
|
Printer1.WriteString(" " & CRLF)
|
|
Printer1.WriteString(" " & CRLF)
|
|
|
|
Printer1.WriteString("Establecimietno:" & CRLF)
|
|
Printer1.WriteString("La Antigua, Restaurante - Bar" & CRLF)
|
|
Printer1.WriteString("Fecha: " & fechaHora(0) & CRLF)
|
|
Printer1.WriteString("Folio: " & folio.GetString("CAT_VA_VALOR")& CRLF)
|
|
Printer1.WriteString("Placa: " & et_placa.Text & CRLF)
|
|
Printer1.WriteString("Hora Entrada:" & fechaHora(1)& CRLF)
|
|
Printer1.WriteString("Tarifa por Hora: " & t.GetString("TMP_TAR_H") & CRLF)
|
|
|
|
Printer1.WriteString(" " & CRLF)
|
|
Printer1.WriteString(" " & CRLF)
|
|
Sleep(1000)
|
|
Printer1.DisConnect
|
|
ProgressDialogHide
|
|
|
|
folio.Close
|
|
t.Close
|
|
check.Close
|
|
|
|
RES5 = Msgbox2Async("Deseas imprimirlo de nuevo?", "Atencion", "Sí", "", "No", LoadBitmap(File.DirAssets, "alert2.png"), False)
|
|
Wait For Msgbox_Result(RES6 As Int)
|
|
|
|
If RES6 = DialogResponse.POSITIVE Then
|
|
imprime_Guarda
|
|
Else
|
|
MsgboxAsync("Datos Guardados", "AVISO")
|
|
p_guarda_info.Visible = False
|
|
p_estacionamiento.Visible = True
|
|
b_entrada.Visible = True
|
|
b_salida.Visible = True
|
|
b_Tarifa.Visible = True
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub b_cancelar_Click
|
|
b_entrada.Visible = True
|
|
b_salida.Visible = True
|
|
p_guarda_info.Visible = False
|
|
p_estacionamiento.Visible = True
|
|
et_placa.Text = ""
|
|
End Sub
|
|
|
|
Sub Printer_Connected (Success As Boolean)
|
|
If Success Then
|
|
' B_IMP.Enabled = True
|
|
StartPrinter
|
|
Else
|
|
' B_IMP.Enabled = False
|
|
If Msgbox2("", "Printer Error","Reprint","Cancel","",Null) = DialogResponse.POSITIVE Then 'Ignore
|
|
StartPrinter
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Sub StartPrinter
|
|
Dim PairedDevices As Map
|
|
Dim L As List
|
|
Dim resimp As Int
|
|
ToastMessageShow("Printing.....",True)
|
|
PairedDevices.Initialize
|
|
Try
|
|
PairedDevices = cmp20.GetPairedDevices
|
|
Catch
|
|
Msgbox("Getting Paired Devices","Printer Error") 'Ignore
|
|
printer.Close
|
|
cmp20.Disconnect
|
|
End Try
|
|
If PairedDevices.Size = 0 Then
|
|
Msgbox("Error Connecting to Printer - Printer Not Found","") 'Ignore
|
|
Return
|
|
End If
|
|
If PairedDevices.Size = 1 Then
|
|
Try
|
|
cmp20.ConnectInsecure(btAdmin,PairedDevices.Get(PairedDevices.GetKeyAt(0)),1)
|
|
Catch
|
|
Msgbox("Connecting","Printer Error") 'Ignore
|
|
printer.Close
|
|
cmp20.Disconnect
|
|
End Try
|
|
Else
|
|
L.Initialize
|
|
For i = 0 To PairedDevices.Size - 1
|
|
L.Add(PairedDevices.GetKeyAt(i))
|
|
Next
|
|
resimp = InputList(L, "Choose device", -1) 'Ignore
|
|
If resimp <> DialogResponse.CANCEL Then
|
|
cmp20.Connect(PairedDevices.Get(L.Get(resimp)))
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Sub B4XPage_Appear
|
|
c = skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("MACIMP"))
|
|
If c.RowCount > 0 Then
|
|
c.Position = 0
|
|
Starter.MAC_IMPRESORA = c.GetString("CAT_VA_VALOR")
|
|
End If
|
|
If Starter.MAC_IMPRESORA = "" Then Starter.MAC_IMPRESORA = "0"
|
|
' Log("|" & Starter.MAC_IMPRESORA & "|")
|
|
Printer1.Initialize(Me, "Printer1")
|
|
|
|
If Printer1.IsConnected = False Then
|
|
' Printer1.Connect
|
|
' Log("1")
|
|
Else
|
|
Printer1.DisConnect
|
|
Printer1.Connect
|
|
Log("2")
|
|
End If
|
|
End Sub
|
|
|
|
Sub Printer1_Connected (Success As Boolean)
|
|
' If Logger Then Log("Printer1_Connected")
|
|
If Success Then
|
|
ToastMessageShow("Impresora conectada", False)
|
|
skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("MACIMP"))
|
|
skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("MACIMP",Starter.mac_impresora))
|
|
LogColor("Impresora conectada", Colors.Green)
|
|
' B_IMP2.Enabled = True
|
|
impresoraConectada = True
|
|
Else
|
|
' Msgbox(Printer1.ConnectedErrorMsg, "Error connecting.") 'ignore
|
|
' ToastMessageShow("Error conectando la impresora", False)
|
|
LogColor("Error conectando la impresora", Colors.Red)
|
|
errorImpresora = errorImpresora + 1
|
|
If errorImpresora > 1 Then
|
|
Starter.MAC_IMPRESORA = "0"
|
|
errorImpresora = 0
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub b_Tarifa_Click
|
|
p_tar_f.Visible = True
|
|
b_entrada.Visible = False
|
|
b_salida.Visible = False
|
|
b_Tarifa.Visible = False
|
|
b_resdia.Visible = False
|
|
End Sub
|
|
|
|
Private Sub b_tar_can_Click
|
|
p_tar_f.Visible = False
|
|
b_entrada.Visible = True
|
|
b_salida.Visible = True
|
|
b_resdia.Visible = True
|
|
|
|
b_Tarifa.Visible = True
|
|
End Sub
|
|
|
|
Private Sub b_tar_in_Click
|
|
|
|
If et_tar_f.Text <> "" Then
|
|
|
|
c = skmt.ExecQuery("SELECT TMP_TAR_H FROM TMP_TARIFA")
|
|
If c.RowCount = 0 Then
|
|
|
|
skmt.ExecNonQuery2("INSERT INTO TMP_TARIFA (TMP_TAR_H) VALUES (?)", Array As Object(et_tar_f.Text))
|
|
MsgboxAsync("Tarifa guardada", "AVISO")
|
|
p_tar_f.Visible = False
|
|
p_estacionamiento.Visible = True
|
|
b_entrada.Visible = True
|
|
b_salida.Visible = True
|
|
b_Tarifa.Visible = True
|
|
|
|
Else If c.RowCount > 0 Then
|
|
|
|
skmt.ExecNonQuery($"UPDATE TMP_TARIFA SET TMP_TAR_H = '${et_tar_f.Text}' "$)
|
|
MsgboxAsync("Tarifa actualizada", "AVISO")
|
|
p_tar_f.Visible = False
|
|
p_estacionamiento.Visible = True
|
|
b_entrada.Visible = True
|
|
b_salida.Visible = True
|
|
b_Tarifa.Visible = True
|
|
|
|
End If
|
|
Else
|
|
MsgboxAsync("Ingrese la tarifa por hora", "AVISO")
|
|
End If
|
|
c.Close
|
|
End Sub
|
|
|
|
Private Sub b_resdia_Click
|
|
p_res.Visible = True
|
|
p_estacionamiento.Visible = False
|
|
|
|
c = skmt.ExecQuery("SELECT * FROM TMP_INFO_EnSal")
|
|
l_totales.Text = c.RowCount
|
|
|
|
|
|
Dim fecha As String = Subs.traeFecha
|
|
Dim fechaHora() As String = Regex.Split(" ", fecha)
|
|
Log(fechaHora(0))
|
|
Private d1 As Cursor = skmt.ExecQuery($"SELECT * FROM HIST_PLACAS WHERE SALIDA LIKE '%${fechaHora(0)}%'"$)
|
|
l_totalsal.Text = d1.RowCount
|
|
|
|
Private d2 As Cursor = skmt.ExecQuery($"SELECT IFNULL(SUM(MONTO),0) AS MONTO FROM HIST_PLACAS WHERE SALIDA LIKE '%${fechaHora(0)}%'"$)
|
|
d2.Position = 0
|
|
l_montoto.Text = d2.GetString("MONTO")
|
|
d2.Close
|
|
|
|
End Sub
|
|
|
|
Private Sub b_rescan_Click
|
|
p_res.Visible = False
|
|
p_estacionamiento.Visible = True
|
|
End Sub
|
|
|
|
Private Sub b_resacep_Click
|
|
|
|
End Sub |