Foros del Web » Programación para mayores de 30 ;) » .NET »

Abrir cajon

Estas en el tema de Abrir cajon en el foro de .NET en Foros del Web. HOLA A TODOS...ESPERO ME PUEDAN AYUDAR CONETO.. TENGO UNA CAJON DE DINERO DYNAPOS CON UNA IMPRESORA POS SAMSUNG BIXOLON...MI PREGUNTA ES LA SIGUIENTE...COMO HAGO PARA ...
  #1 (permalink)  
Antiguo 22/08/2008, 09:13
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Exclamación Abrir cajon

HOLA A TODOS...ESPERO ME PUEDAN AYUDAR CONETO..
TENGO UNA CAJON DE DINERO DYNAPOS CON UNA IMPRESORA POS SAMSUNG BIXOLON...MI PREGUNTA ES LA SIGUIENTE...COMO HAGO PARA ABRIR EL CAJON...DIECN QUE ES DESPUES DE MANDAR A IMPRIMIR LA FACTURA...

ALGO ASI

PrintFactura.Print()
Chr(27) + "p" + Chr(0) + Chr(8) + Chr(32) + Chr(27) + Chr(105)

PERO LA VERDAD NO SE COMO HACERLO PORQUE NO ME SALE NADA...
GRACIAS POR SU AYUDA
  #2 (permalink)  
Antiguo 22/08/2008, 09:57
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Respuesta: Abrir cajon

Es codigo vb.net 2005
  #3 (permalink)  
Antiguo 22/08/2008, 11:11
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Respuesta: Abrir cajon

Llevo 6 horas investigando ya nadie da una respuesta....solo necesito el codigo...que va..gracias de antemano por su ayuda
  #4 (permalink)  
Antiguo 22/08/2008, 11:30
Avatar de GeoAvila
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Antigua Guatemala
Mensajes: 4.032
Antigüedad: 20 años, 5 meses
Puntos: 53
Respuesta: Abrir cajon

pues creo que sería algo así

http://groups.google.com/group/micro...707838477607bf

nos vemos.
__________________
* Antes de preguntar lee las FAQ, y por favor no hagas preguntas en las FAQ
Sitio http://www.geoavila.com twitter: @GeoAvila
  #5 (permalink)  
Antiguo 22/08/2008, 11:59
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Respuesta: Abrir cajon

no se como hacerlo...no me funciona
  #6 (permalink)  
Antiguo 22/08/2008, 12:33
Avatar de GeoAvila
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Antigua Guatemala
Mensajes: 4.032
Antigüedad: 20 años, 5 meses
Puntos: 53
Respuesta: Abrir cajon

Cita:
Iniciado por abaylon Ver Mensaje
no se como hacerlo...no me funciona
que no te funciona? el código no corre? o que..

Nos vemos..
__________________
* Antes de preguntar lee las FAQ, y por favor no hagas preguntas en las FAQ
Sitio http://www.geoavila.com twitter: @GeoAvila
  #7 (permalink)  
Antiguo 22/08/2008, 14:19
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Exclamación Respuesta: Abrir cajon

If Not Safe.IsInvalid Then
outFile = New System.IO.FileStream(Safe, IO.FileAccess.Write)
fw = New System.IO.StreamWriter(outFile)
fw.AutoFlush = True
fw.WriteLine(Chr(27) & Chr(112) & 0) 'Genérico Epson
fw.Close()
End If

EN ESTA PARTE..NO EJECUTA LO QUE ESTA DENTRO DEL IF..POSIBLEMENTE ME ESTOY EQUIVOCANDO EN ALGO VERDAD...
  #8 (permalink)  
Antiguo 22/08/2008, 14:19
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Respuesta: Abrir cajon

Public Sub AbrirCajon()
Dim fw As StreamWriter

LPTPORT = "LPT1" 'El puerto que sea.
hPort = CreateFile(LPTPORT, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)
hPortP = New IntPtr(hPort) 'Convierte Integer to IntPtr
Safe = New Microsoft.Win32.SafeHandles.SafeFileHandle(hPortP, True)
If Not Safe.IsInvalid Then
outFile = New System.IO.FileStream(Safe, IO.FileAccess.Write)
fw = New System.IO.StreamWriter(outFile)
fw.AutoFlush = True
fw.WriteLine(Chr(27) & Chr(112) & 0) 'Genérico Epson
fw.Close()
End If
CloseHandle(hPort)
End Sub

ALLI ESTA EL CODIGO COMPLETO
  #9 (permalink)  
Antiguo 24/08/2008, 20:07
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Exclamación Respuesta: Abrir cajon

Aun nadie me puede decir como soluciono esto...gracias
  #10 (permalink)  
Antiguo 25/08/2008, 09:25
Avatar de GeoAvila
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Antigua Guatemala
Mensajes: 4.032
Antigüedad: 20 años, 5 meses
Puntos: 53
Respuesta: Abrir cajon

Cita:
Iniciado por abaylon Ver Mensaje
Aun nadie me puede decir como soluciono esto...gracias
pensé que habías posteado la solución, dame un tiempo y reviso que es lo que el código no hace, corre bien pero no abre la caja ó el código te dá error?

Nos vemos
__________________
* Antes de preguntar lee las FAQ, y por favor no hagas preguntas en las FAQ
Sitio http://www.geoavila.com twitter: @GeoAvila
  #11 (permalink)  
Antiguo 27/08/2008, 21:57
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Exclamación Respuesta: Abrir cajon

EL CODIGO CORRE BIEN PERO NO ABRE EL CAJON......

Public Sub AbrirCajon()
Dim fw As StreamWriter
LPTPORT = "LPT1" 'El puerto que sea.
hPort = CreateFile(LPTPORT, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)
hPortP = New IntPtr(hPort) 'Convierte Integer to IntPtr
Safe = New Microsoft.Win32.SafeHandles.SafeFileHandle(hPortP, True)

If Not Safe.IsInvalid Then
outFile = New System.IO.FileStream(Safe, IO.FileAccess.Write)
fw = New System.IO.StreamWriter(outFile)
fw.AutoFlush = True
fw.WriteLine(Chr(27) & Chr(112) & 0) 'Genérico Epson
fw.Close()
End If


CloseHandle(hPort)
End Sub

MIRA EN ESTE CODIGO LA PARTE QUE ESTA CON NEGRITA..NO SE EJECUTA
OSEA SALTA Y NO EJECUTA EL CODIGO QUE ESTA DENTRO DEL IF
  #12 (permalink)  
Antiguo 28/08/2008, 14:48
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Exclamación Respuesta: Abrir cajon

mira que ya logre que ejecutara el if pero igual no abre el cajon...el puerto es Com3
mi impresora esta conectada a mi equipo por una cable de usb a paralelo...la parte usb va al computador y el paralelo a la impresora..la verdad no se si ese es el puerto correcto..pero alli te envio el codigo completo

Public Structure SECURITY_ATTRIBUTES
Private nLength As Integer
Private lpSecurityDescriptor As Integer
Private bInheritHandle As Integer
End Structure

Dim SA As SECURITY_ATTRIBUTES
Dim outFile As FileStream
Dim Safe As Microsoft.Win32.SafeHandles.SafeFileHandle
Public LPTPORT As String
Public hPort As Integer
Public hPortP As IntPtr
Public retval As Integer
Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_EXISTING = 3
Public Const FILE_SHARE_WRITE = &H2

Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, _
ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByRef lpSecurityAttributes As _
SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Integer, ByVal _
dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer

Public Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Integer) As Integer

Sub Abrir()
LPTPORT = "Com3"
hPort = CreateFile(LPTPORT, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)
hPortP = New IntPtr(hPort) 'Convierte Integer to IntPtr

Safe = New Microsoft.Win32.SafeHandles.SafeFileHandle(hPortP, True)

If Not Safe.IsInvalid Then
outFile = New System.IO.FileStream(Safe, IO.FileAccess.Write)
Dim fw As New StreamWriter(outFile)
fw.AutoFlush = True
'fw.WriteLine(Chr(27) & Chr(112) & 0) 'Genérico Epson
'fw.WriteLine(Chr(27) & Chr(112) & Chr(48) & Chr(55) & Chr(121))
fw.WriteLine(Chr(&H1B) & "p" & Chr(0) & Chr(100) & Chr(250))
fw.Close()
End If

CloseHandle(hPort)
End Sub

LA SUB RUTINA ABRIR LA COLOCO DENTRO DE...

Private Sub PrintFactura_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintFactura.PrintPage

DESPUES DE IMPRIMIR LA FACTURA..LA VERDAD NO SE QUE ESTA MAL...Y YA NO SE QUE HACER...
  #13 (permalink)  
Antiguo 28/08/2008, 15:49
Avatar de GeoAvila
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Antigua Guatemala
Mensajes: 4.032
Antigüedad: 20 años, 5 meses
Puntos: 53
Respuesta: Abrir cajon

Mirá, lo que pasa es que si te das cuenta, el código dice que lo están mandando al LPT1 y tenes conectado el equipo al USB, entonces.. haz probado abrir el cajor con otro programa? poque puede ser que la conversión cables te esté dando problemas, deberías probar con la impresora conectada directamente en la lpt1, o bien le cambiaria la parte donde dice LPT1 en el código por USB1, talvez te lo reconoce..

nos vemos.
__________________
* Antes de preguntar lee las FAQ, y por favor no hagas preguntas en las FAQ
Sitio http://www.geoavila.com twitter: @GeoAvila
  #14 (permalink)  
Antiguo 28/08/2008, 22:32
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Exclamación Respuesta: Abrir cajon

No abre y no lo reconoce con al cambiar com3 por usb1...
  #15 (permalink)  
Antiguo 29/08/2008, 09:39
Avatar de GeoAvila
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Antigua Guatemala
Mensajes: 4.032
Antigüedad: 20 años, 5 meses
Puntos: 53
Respuesta: Abrir cajon

Cita:
Iniciado por abaylon Ver Mensaje
No abre y no lo reconoce con al cambiar com3 por usb1...
bueno entonces tendremos que buscar otro código, en el com3 decis que lo tenés verdad.. bueno busquemos algo

seguimos buscando.. nos vemos..
__________________
* Antes de preguntar lee las FAQ, y por favor no hagas preguntas en las FAQ
Sitio http://www.geoavila.com twitter: @GeoAvila
  #16 (permalink)  
Antiguo 29/08/2008, 09:42
Avatar de GeoAvila
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Antigua Guatemala
Mensajes: 4.032
Antigüedad: 20 años, 5 meses
Puntos: 53
Respuesta: Abrir cajon

ya haz contactado al soporte de de la empresa
http://www.dynapos.com/CD350.htm

para ver si ellos tienen códigos para facilitarte eso ayuda mucho..

Saludos..
__________________
* Antes de preguntar lee las FAQ, y por favor no hagas preguntas en las FAQ
Sitio http://www.geoavila.com twitter: @GeoAvila
  #17 (permalink)  
Antiguo 29/08/2008, 10:06
Usuario no validado
 
Fecha de Ingreso: marzo-2008
Ubicación: Morelia Mich. México
Mensajes: 37
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Abrir cajon

Hola, yo estoy haciendo una aplicacion en la que mando a puerto paralelo estas secuancias de escape de impresora, el detalle es que ya que no he encontrado una manera de que VB se comunique directamente con el puerto paralelo "LPT", ni con puerto USB, asi que lo hago mediante una llamada de shell (consola de windows), esto porque lo hago como si fuera una instruccion directamente desde MS-DOS, te dejo el codigo y pruebalo, en realidad funciona y esto sin instalñar drivers de la impresora, solo la conectas por puerto LPT y listo, estas son las secuencias de escape: (Chr(&H1B) & "@"), intenta con tus secuencias

Código:
Private Sub imprimir()

        Dim file As System.IO.StreamWriter = System.IO.File.CreateText("C:\temp.txt")

        file.Write(Chr(&H1B) & "@")
        file.Write(Chr(&H1B) & "a" & Chr(1)) 'Centra Texto
        file.WriteLine("Texto Centrado")
        file.Write(Chr(&H1B) & "E") 'Bold
        file.WriteLine("Texto Bold")
        file.Write(Chr(&H1B) & "F") 'Elimina Bold
        file.Write(Chr(&H1B) & "a" & Chr(0)) ' Texto a la Izquierda
        file.WriteLine("Panama # 356 y Luis Urdaneta")
        file.WriteLine("TICKET No. :" & "ticket")
        file.Write("nada de nuevo")
        file.Write("nada de nuevo")
        file.WriteLine("nada de nuevo")
        file.Write(Chr(13))
        file.Write(Chr(&H1B) & Chr(&H67)) 'ESC g: Select 15-cpi

        file.WriteLine("Ingreso:" & Format(Now, "dddd, d MMM yyyy") & "/ " & TimeOfDay)

        file.WriteLine("------------------------------")

        file.Write(Chr(&H1B) & "!" & Chr(0)) 'ESC ! 0: Vuelve a lo normal

        file.WriteLine("Neto : USD$:" & "Net0")

        file.WriteLine("I.V.A: " & "IVA")
        file.Write(Chr(&H1B) & "g") 'ESC g: Select 15-cpi
        file.WriteLine("Total: USD$:" & "Total")

        file.WriteLine(Chr(&H1D) & "V" & Chr(0))

        'Drawer Kick (ESC p)

        'file.WriteLine(CHR(&H1B)& CHR(&H70)& CHR(&H0)& CHR(60)& CHR(120)

        file.Close()
        Try
            Shell("print /d:lpt1 C:\temp.txt", AppWinStyle.Hide)
        Catch ax As System.IO.FileNotFoundException
            MsgBox(ax.Message)
        End Try
    End Sub
de antemano te comunico que yo tampoco he logrado comunicarme directamente con el puerto USB, ni LPT, solo con el serial (COMn) en otros proyectos que he echo, lo que se es que si se puede hacer muy bien esta conexion y enviar valores por el puerto serial (COM1, COM2, ... COMn)
  #18 (permalink)  
Antiguo 29/08/2008, 10:09
Usuario no validado
 
Fecha de Ingreso: marzo-2008
Ubicación: Morelia Mich. México
Mensajes: 37
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Abrir cajon

aaaa, y checate en esta parte:
Código:
Shell("print /d:lpt1 C:\temp.txt", AppWinStyle.Hide)
como hacer para enviar la salida por puerto USB, que se debe de poder desde MS-DOS, intenta cambiar /d:lpt1 por: /d:usb1 ó USB001 , dependiendo del caso en el puerto que se encuentre, intenta con varios usbn....

Suerte,, comenta que paso !!!
  #19 (permalink)  
Antiguo 16/09/2008, 19:42
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Exclamación Respuesta: Abrir cajon

ME FUNCIONO DE MIL MARAVILLAS, PERO TENGO UNA DUDA COMO HAGO PARA QUE AL MOMENTO DE IMPRIMIR ME ESCRIBA EN UNA POSICION (X, Y) DETERMINADA
POR EJEMPLO:

file.WriteLine(cantidad) 'QUE ESTO ME LO ESCRIBA EN LA POSICION (0,0)
file.WriteLine(nombre) 'QUE ESTO ME LO ESCRIBA EN LA POSICION (0,30)
file.WriteLine(total) 'QUE ESTO ME LO ESCRIBA EN LA POSICION (0,150)
  #20 (permalink)  
Antiguo 16/09/2008, 19:44
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Respuesta: Abrir cajon

PERDON SERIA ASI:
---------------------------------
ME FUNCIONO DE MIL MARAVILLAS, PERO TENGO UNA DUDA COMO HAGO PARA QUE AL MOMENTO DE IMPRIMIR ME ESCRIBA EN UNA POSICION (X, Y) DETERMINADA
POR EJEMPLO:

file.WriteLine(cantidad) 'QUE ESTO ME LO ESCRIBA EN LA POSICION (0,0)
file.WriteLine(nombre) 'QUE ESTO ME LO ESCRIBA EN LA POSICION (30,0)
file.WriteLine(total) 'QUE ESTO ME LO ESCRIBA EN LA POSICION (150,0)
  #21 (permalink)  
Antiguo 17/09/2008, 09:35
Avatar de GeoAvila
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Antigua Guatemala
Mensajes: 4.032
Antigüedad: 20 años, 5 meses
Puntos: 53
Respuesta: Abrir cajon

con el comando "priter" revisá las opciones que te dá

nos vemos..
__________________
* Antes de preguntar lee las FAQ, y por favor no hagas preguntas en las FAQ
Sitio http://www.geoavila.com twitter: @GeoAvila
  #22 (permalink)  
Antiguo 21/09/2008, 18:59
 
Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años
Puntos: 0
Exclamación Respuesta: Abrir cajon

YA ENCONTRE OTRA SOLUCION:

Public Sub open_cashdrawer()
Dim intFileNo As Integer = FreeFile()
FileOpen(1, "c:\temp.txt", OpenMode.Output)
PrintLine(1, Chr(27) & "p" & Chr(0) & Chr(25) & Chr(250))
FileClose(1)
Shell("print /d:lpt1 c:\temp.txt", vbNormalFocus)
End Sub

PERO AHORA ME FALTA HALLAR EL CODIGO PARA VERIFICAR EL ESTADO DEL CAJON (ABIERTO O CERRADO)
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:23.