lo reviso.
Mil gracias.
--
Ramón Zea
01.993.194.14.27
http://www.paginasprodigy.com/zeasoftware/
zeasoftware@prodigy.net.mx
zeasoftware@hotmail.com
ramonzea@yahoo.com
zeasoft.movil@hotmail.com
visita mi "venta de garage"
"José Alfonso Suárez Moreno" <
jasm@tpvsoft.com> escribió en el mensaje
news:[email=
4644e324@ozsrv2.ozlan.local...]
4644e324@ozsrv2.ozlan.local...[/email]
> Ramon,
>
> Adjunto lo que uso yo para imprimir tickets con TCanvas.
>
> En APPDATA llevo estos valores:
>
> cPrnName ---> Nombre de la impresora en Windows
>
> cFontTicketName ---> Nombre del tipo de letra a usar (para las termicas)
> nFontTicketSize ---> Tamaño del tipo de letra a usar (para las termicas)
>
> lPrev ---> Si quiero previsualizar
>
>
> El resto de cosas que tengo en APPDATA son datos a imprimir.
>
> Saludos
>
> Jose A. Suarez
>
------------------------------------------------------------ --------------------
> METHOD ImprTicket( oSender, nTicket ) CLASS TForm15
>
> LOCAL cI
> LOCAL nI
> LOCAL cLinea
> LOCAL nTotal := 0
> LOCAL cQuery
> LOCAL nLin := 0
> LOCAL nPaso
> LOCAL oFont
> LOCAL nIzq
> LOCAL oDet := TQuery():New()
> LOCAL oCab := TQuery():New()
> LOCAL oCli := TQuery():New()
>
> cQuery := "SELECT cabtick.*, fpago.nombre, concat( cliente.nombre, ' ',
> cliente.apellidos ) FROM cabtick " + ;
> "LEFT JOIN fpago ON fpago.id = cabtick.fpago " + ;
> "LEFT JOIN cliente ON cliente.id = cabtick.id_vend " + ;
> "WHERE id_factura = " + Str( nTicket )
> oCab:Query( cQuery )
>
> IF oCab:lError
> MsgInfo( oCab:cError )
> END IF
>
> cQuery := "SELECT dettick.cantidad, dettick.precio,
> dettick.cantidad*dettick.precio, articulo.descrip " + ;
> "FROM dettick " + ;
> "INNER JOIN articulo ON articulo.codigo = dettick.cod_art " +
> ;
> "INNER JOIN cabtick ON cabtick.numero = dettick.numero " + ;
> "WHERE cabtick.id_factura = " + Str( nTicket ) + " " + ;
> "ORDER BY dettick.linea"
>
> oDet:Query( cQuery )
> IF oDet:lError
> MsgInfo( oDet:cError )
> END IF
>
> IF AppData:lDatosCliente
> oCli:Query( "SELECT * FROM cliente WHERE id = " + Str( oCab:aRes[ 1,
> 11 ] ) )
> END IF
>
> IF !Empty( AppData:cPrnName )
>
> IF oDet:nFilas > 0
> oFont := TFont():New()
>
> WITH OBJECT oFont
> :cName := AppData:cFontTicketName
> :nSize := AppData:nFontTicketSize
> :lBold := .F.
> END WITH
>
> Printer:nPrinterIndex := Ascan( Printer:aPrinterNames,
> Appdata:cPrnName )
>
> Printer:lPreview := AppData:lPrev
> Printer:cJobTitle := "Ticket de caja"
> Printer:StartDoc()
> Printer:oCanvas:nMapMode := mmHIMETRICS //Selecciono medidas
> en sistema metrico.
> //Las unidades son
> milímetros * 10
>
> Printer:StartPage()
>
> nLin := Printer:PhysicalOffset()[2]
> nIzq := Printer:PhysicalOffset()[1]
>
> WITH OBJECT Printer:oCanvas
>
> :oFont := oFont
>
> nPaso := ( :TextHeight( "." ) / Printer:Resolution()[2] * 254 )
>
> cLinea := PadC( Alltrim( AppData:cNombre ), 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
>
> cLinea := PadC( Alltrim( AppData:cDomic ), 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
>
> cLinea := PadC( Alltrim( AppData:cLocal ), 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
>
> cLinea := PadC( Alltrim( AppData:cProvin ), 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
>
> cLinea := PadC( "Telefono: " + Alltrim( AppData:cTelef ), 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
>
> cLinea := PadC( "CIF: " + Alltrim( AppData:cCIF ), 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += ( nPaso * 2 )
>
> FOR nI := 1 TO 6
> cI := Alltrim( Str( nI ) )
> IF !Empty( AppData:cCab&cI )
> :nTextAlignment := taLEFT
> :TextOut( nIzq, nLin, PadC( AppData:cCab&cI, 40 ) )
> nLin += nPaso
> END IF
> NEXT
>
> nLin += ( nPaso * 2 )
>
>
> IF AppData:lDatosCliente .AND. oCli:nFilas > 0
> cLinea := "---------- Datos del cliente -----------"
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> cLinea := Left( oCli:aRes[ 1, 2 ], 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> cLinea := Left( oCli:aRes[ 1, 3 ], 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> cLinea := Left( oCli:aRes[ 1, 4 ], 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> cLinea := Left( StrZero( oCli:aRes[ 1, 5 ], 5 ) + " - " +
> oCli:aRes[ 1, 6 ], 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> cLinea := Left( oCli:aRes[ 1, 7 ], 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> cLinea := Left( "CIF/NIF: " + oCli:aRes[ 1, 8 ], 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> cLinea := "----------------------------------------"
> :TextOut( nIzq, nLin, cLinea )
> nLin += ( nPaso * 2 )
> END IF
>
> cLinea := DiaSemana( oCab:aRes[ 1, 2 ] ) + ", " + D2L(
> oCab:aRes[ 1, 2 ] )
> cLinea += " (" + Left( oCab:aRes[ 1, 10 ], 5 ) + ")"
> cLinea := PadC( cLinea, 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += ( nPaso * 2 )
>
> IF oCab:aRes[ 1, 3 ] != 0 .AND. AppData:cTituloBotonMesas ==
> "&Mesa"
> cLinea := PadL( "Mesa N. ..: " + Str( oCab:aRes[ 1, 3 ],
> 10 ), 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> END IF
> cLinea := PadL( "Factura N.: " + Alltrim( Str( nTicket ) ),
> 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += ( nPaso * 3 )
>
> cLinea := "Articulo" + Space( AppData:nLonArticulo - 8 ) + " "
> cLinea += "Can" + Space( AppData:nLonCantidad - 3 ) + " "
> cLinea += "Pre" + Space( AppData:nLonPrecio - 3 ) + " "
> cLinea += "Importe" + Space( AppData:nLonImporte - 7 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
>
> cLinea := Replicate( "-", AppData:nLonArticulo ) + " "
> cLinea += Replicate( "-", AppData:nLonCantidad ) + " "
> cLinea += Replicate( "-", AppData:nLonPrecio ) + " "
> cLinea += Replicate( "-", AppData:nLonImporte )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
>
> FOR nI := 1 TO oDet:nFilas
>
> cLinea := Left( oDet:aRes[ nI, 4 ], AppData:nLonArticulo ) +
> " " + ;
> Transform( oDet:aRes[ nI, 1 ], DimePic(
> AppData:nLonCantidad, AppData:nDecCantidad ) ) + " " + ;
> Transform( oDet:aRes[ nI, 2 ], DimePic(
> AppData:nLonPrecio, AppData:nDecPrecio ) ) + " " + ;
> Transform( oDet:aRes[ nI, 3 ], DimePic(
> AppData:nLonImporte, AppData:nDecImporte ) )
>
> nTotal += oDet:aRes[ nI, 3 ]
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> NEXT
>
> cLinea := " ---------"
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> cLinea := " Total ..... " + Transform(
> nTotal, "@ZE 99,999.99" )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> IF ::oMaskEdit3:Value != 0
> cLinea := " Entregado . " + Transform(
> ::oMaskEdit3:Value, "@ZE 99,999.99" )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> cLinea := " ---------"
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> cLinea := " Cambio .... " + Transform(
> ::oMaskEdit3:Value - nTotal, "@ZE 99,999.99" )
> :TextOut( nIzq, nLin, cLinea )
> nLin += nPaso
> END IF
> cLinea := " ====================="
> :TextOut( nIzq, nLin, cLinea )
> nLin += ( nPaso * 2 )
> cLinea := PadC( "Forma de pago: " + Alltrim( oCab:aRes[ 1,
> 13 ] ), 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += ( nPaso * 2 )
> cLinea := PadC( "Le atendio: " + Alltrim( oCab:aRes[ 1, 14 ] ),
> 40 )
> :TextOut( nIzq, nLin, cLinea )
> nLin += ( nPaso * 2 )
>
> FOR nI := 1 TO 6
> cI := Alltrim( Str( nI ) )
> IF !Empty( AppData:cPie&cI )
> :TextOut( nIzq, nLin, PadC( AppData:cPie&cI, 40 ) )
> nLin += nPaso
> END IF
> NEXT
>
> FOR nI := 1 TO AppData:nLineas
> cI := Alltrim( Str( nI ) )
> :TextOut( nIzq, nLin, Space( 40 ) )
> nLin += nPaso
> NEXT
> END WITH
>
> Printer:EndPage()
> Printer:EndDoc()
> Printer:Preview( smMAXIMIZE, AppData:lPrev, Self )
> oFont:Destroy()
>
> END IF
>
> END IF
>
> CortarTicket()
>
> RETURN Nil
>