' Starter
'
' Parametros de Impresion
Dim ParPrinterName As String ' PRINTER_NAME Nombre de la Impresora PRINTER
Dim ParPrinterAddress As String ' PRINTER_ADDRESS MAC address de la Impresora
Dim ParPrinterSets As String ' PRINTER_SETS Sets al momento de inicializar la Impresora
Dim ParPNRRepCodigo As String ' PNR_REP_CODIGO Codigo del Reporte para imprimir la Boleta 1
Dim ParPNRHead01 As String ' PNR_HEAD_01 PRINTER: Caracter de Control para el encabezado # 1
Dim ParPNRHead02 As String ' PNR_HEAD_02 PRINTER: Caracter de Control para el encabezado # 2
Dim ParPNRHead03 As String ' PNR_HEAD_03 PRINTER: Caracter de Control para el encabezado # 3
Dim ParPNRDet01 As String ' PNR_DET_01 PRINTER: Caracter de Control para el DETALLE
Dim ParPNRTot01 As String ' PNR_TOT_01 PRINTER: Caracter de Control para el TOTAL # 1
Dim ParPNRTot02 As String ' PNR_TOT_02 PRINTER: Caracter de Control para el TOTAL # 2
Dim ParPNRNumLf As Int ' PNR_NUM_LF PRINTER: Numero de Lineas en Blanco al Finalizar de Imprimir la Boleta
'
Dim o_Serial As Serial ' Objeto que contiene la comunicacion con los dispositivos
Dim o_Printer As AsyncStreams ' Objeto que contiene la informacion a imprimir
Dim o_Printer_Conected As Boolean ' Indica si la impresora está conectada
'
' Connect the printer in a Activity
'
Sub Activity_Resume
cietImpresora.Text = Starter.ParPrinterName
cietAddress.Text = Starter.ParPrinterAddress
'
If Starter.o_Printer.IsInitialized = True Then
If Starter.o_Printer_Conected = True Then
cietEstado.Text = "Conectada"
Else
cietEstado.Text = "Desconectada"
End If
Else
cietEstado.Text = "Desconectada"
End If
'
If Starter.o_Serial.IsEnabled = True Then
cibutConectar.Enabled = True
cibutConectar.Visible = True
Else
cibutConectar.Enabled = False
cibutConectar.Visible = False
'
Msgbox("Es necesario HABILITAR el Bluetooth", "ERROR:")
End If
End Sub
'
' A code module that print
'
Sub Verifica_Estado_Impresora As Boolean
Dim lcResultado As Boolean
Dim lcData As String
lcResultado = True
'
'Starter.o_Printer.Initialize(Starter.o_Serial.InputStream, Starter.o_Serial.OutputStream, "Printer")
'
Try
' Se Imprime una linea en blanco
lcData = Chr(10)
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Catch
Log("Verifica_Estado_Impresora")
Log(LastException)
lcResultado = False
End Try
'
Return lcResultado
End Sub
Sub Imprime_Envio
Dim lcData As String
Dim lcSqlComando As String
Dim lcFecha As String
Dim lcHora As String
Dim lcStr As String
Dim lcMoneda As String
Dim lcTasaImpresion As Double
Dim lcLineasEnca() As String
Dim lcLineFeed As String
Dim lcCursorEnvio As Cursor
Dim lcCursorDetalle As Cursor
'
' Se verifica que esté inicializado el objeto de la Printer
If Starter.o_Printer.IsInitialized = False Then
Msgbox("La impresora NO está lista","Impresion de Envio")
Return
End If
'
' Se cargan los cursores
lcSqlComando = "SELECT * FROM work_t_envios"
lcCursorEnvio = Starter.Database.ExecQuery(lcSqlComando)
If lcCursorEnvio.RowCount < 1 Then
Msgbox("NO se encuentra un ENVIO cargado","Impresion de Envio")
Return
End If
'
lcSqlComando = "SELECT * FROM work_t_envios_detalle ORDER BY wsdescripcion"
lcCursorDetalle = Starter.Database.ExecQuery(lcSqlComando)
If lcCursorDetalle.RowCount < 1 Then
Msgbox("EL Envio NO tiene productos cargados","Impresion de Envio")
Return
End If
'
lcCursorEnvio.Position = 0
'
lcSqlComando = ""
lcData = ""
lcFecha = ""
lcHora = ""
lcStr = ""
'
If lcCursorEnvio.GetString("moneda_impresion") = "S" Then
lcMoneda = "$ "
lcTasaImpresion = Starter.ParTasaDolares
Else
lcMoneda = "Q "
lcTasaImpresion = 1.00
End If
'
' Imprime el Envio que está CARGADO en "work_t_envios"
'
lcLineasEnca = Regex.Split(CRLF, Starter.SysDireccionEmpresa)
lcLineFeed = Chr(10)
'
' Se asignan los SETS de la impresora
Starter.o_Printer.Write(Starter.ParPrinterSets.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
' Se imprime el 1er Encabezado
Starter.o_Printer.Write(Starter.ParPNRHead01.GetBytes("UTF8"))
Starter.o_Printer.Write(Str_Format_Center(Starter.SysNombreEmpresa.Trim,48).GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
' Se imprime el 2do Encabezado (direccion de la Empresa)
For i = 0 To lcLineasEnca.Length - 1
Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
lcData = lcLineasEnca(i).Trim
lcData = lcData.Replace(CRLF,"")
Starter.o_Printer.Write(Str_Format_Center(lcData,48).GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
Next
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
' Se imprime el ENCABEZADO del Envio
lcData = ""
Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
lcData = lcData & "ENVIO No: " & NumberFormat2(lcCursorEnvio.GetDouble("numero"),1,0,0,True)
lcStr = "Venta al " & lcCursorEnvio.GetString("tipo").Trim
lcData = lcData & Str_Repeat(" ", 47 - lcData.Length - lcStr.Length)
lcData = lcData & lcStr
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
lcFecha = lcCursorEnvio.GetString("fecha")
lcFecha = Change_Format_Date(lcFecha, "DD-MM-YYYY", "/")
lcHora = lcCursorEnvio.GetString("hora")
'
Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
lcData = "FECHA: " & lcFecha & " HORA: " & lcHora
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
lcData = "CLIENTE: (" & lcCursorEnvio.GetString("fk_cliente") & ") " & lcCursorEnvio.GetString("wsclbnombrecliente").Trim
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
' Se imprime el Detalle del Envio (productos)
Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
Starter.o_Printer.Write(Str_Repeat("-",48).GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
Starter.o_Printer.Write("PRODUCTO METROS MONTO".GetBytes("UTF8"))
' ....+....1....+....2....+....3....+....4....+...
' ....+....1....+....2...... 999,999 9,999,999.99
' ....+.. ....+....1..
' TOTAL :
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
For i = 0 To lcCursorDetalle.RowCount -1
lcCursorDetalle.Position = i
lcData = ""
lcData = lcCursorDetalle.GetString("wsdescripcion").Trim
lcData = lcData & Str_Repeat(" ", 25 - lcData.Length)
lcData = lcData & Str_Format_Right(NumberFormat2(lcCursorDetalle.GetDouble("cantidad"),1,1,1,False),7)
lcData = lcData & Str_Format_Right(lcMoneda & NumberFormat2(lcCursorDetalle.GetDouble("total")/lcTasaImpresion,1,2,2,True),15)
'
Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
Next
'
' Se imprime el total del envio
Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
Starter.o_Printer.Write(Str_Format_Right("-------------",48).GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
lcData = Str_Format_Right("TOTAL :" ,32) & Str_Format_Right(lcMoneda & NumberFormat2(lcCursorEnvio.GetDouble("total")/lcTasaImpresion,1,2,2,True),15)
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
' Se imprime la información adicional del Envio
Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
lcData = "Destino: " & lcCursorEnvio.GetString("destino").Trim
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
lcData = "Piloto: " & lcCursorEnvio.GetString("piloto").Trim
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
lcData = "Placas: " & lcCursorEnvio.GetString("placas").Trim
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
lcData = "Observaciones: " & lcCursorEnvio.GetString("observaciones").Trim
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
If lcCursorEnvio.GetString("tipo") = "Contado" Then
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
lcData = "No Recibo: " & lcCursorEnvio.GetString("recibo_numero").Trim
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
End If
'
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
lcData = "Le atendió: (" & Starter.SysCodigoCobrador & ") " & Starter.SysNombreUsuario.ToUpperCase
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
'
If lcCursorEnvio.GetDouble("total_descuento") > 0 Then
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
Starter.o_Printer.Write(Str_Repeat("-",48).GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
lcData = " Credito a cuenta :" & Str_Format_Right(lcMoneda & NumberFormat2(lcCursorEnvio.GetDouble("total_descuento")/lcTasaImpresion,1,2,2,True),13)
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
lcData = " Saldo del Envio :" & Str_Format_Right(lcMoneda & NumberFormat2(lcCursorEnvio.GetDouble("valor_contable")/lcTasaImpresion,1,2,2,True),13)
Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
Starter.o_Printer.Write(Str_Repeat("-",48).GetBytes("UTF8"))
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
End If
'
' Se imprimen lineas en blanco para el Corte del Papel
For i = 1 To Starter.ParPNRNumLf
Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
Next
'