Imprimir factura Hola,tengo que imprimir una factura ,si imprimo una sola factura se ve bien pero cuando imprimo varias a la vez se superponen es decir estan todas las facturas unas encima de otras,lo que quiero es que me imprima una factura y sus lineas de factura en una pagina y la siguiente factura en otro pagina etc
Private Sub ListadoPrueba_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles listadoprueba.PrintPage
e.PageSettings.Margins.Left = 200
e.PageSettings.Margins.Top = 100
Dim fuentedatos As New Font("Comic sans ms", 12)
e.Graphics.DrawString("Año", fuentedatos, Brushes.Blue, 50, 20)
e.Graphics.DrawString("NºFac", fuentedatos, Brushes.Blue, 100, 20)
e.Graphics.DrawString("Fecha", fuentedatos, Brushes.Blue, 200, 20)
e.Graphics.DrawString("CodCli", fuentedatos, Brushes.Blue, 300, 20)
e.Graphics.DrawString("Nombre cliente", fuentedatos, Brushes.Blue, 400, 20)
' e.Graphics.DrawString("Cod_Forma", fuentedatos, Brushes.Blue, 600, 20)
e.Graphics.DrawString("Cod_Forma", fuentedatos, Brushes.Blue, 600, 20)
e.Graphics.DrawLine(Pens.Red, 20, 50, 800, 50)
e.HasMorePages = False 'Por defecto xa esta a false pero por seas caso
' e.Graphics.PageUnit = GraphicsUnit.Millimeter
' y = 60
'Imprimimos a cabeceira de factura
For Each filaCF In dsFacturC.Tables("facturc").Rows
e.Graphics.DrawString(filaCF("Año").ToString, fuentedatos, Brushes.Black, 50, 60)
e.Graphics.DrawString(filaCF("nfac").ToString, fuentedatos, Brushes.Black, 100, 60)
e.Graphics.DrawString(filaCF("codcli").ToString, fuentedatos, Brushes.Black, 300, 60)
e.Graphics.DrawString(filaCF("codforma").ToString, fuentedatos, Brushes.Black, 600, 60)
'y += 20
'If y > 1000 Then
' y = 60
' e.HasMorePages = True
'End If
e.Graphics.DrawString("Nº Linea", fuentedatos, Brushes.Blue, 40, 100)
e.Graphics.DrawString("Año Albar", fuentedatos, Brushes.Blue, 150, 100)
e.Graphics.DrawString("Nº Albar", fuentedatos, Brushes.Blue, 250, 100)
e.Graphics.DrawString("Cod Producto", fuentedatos, Brushes.Blue, 350, 100)
e.Graphics.DrawString("Descripción", fuentedatos, Brushes.Blue, 480, 100)
e.Graphics.DrawString("Unidades", fuentedatos, Brushes.Blue, 620, 100)
e.Graphics.DrawString("Precio", fuentedatos, Brushes.Blue, 720, 100)
y = 150
For Each filaLF In dsFacturC.Tables("facturl").Rows
'Imprimimos as liñas de factura cando o ano e o codigo da factura sexa igual o da liña de factura
If filaCF("año").ToString = filaLF("año").ToString And filaCF("nfac").ToString = filaLF("nfact").ToString Then
e.Graphics.DrawString(filaLF("nlinea").ToString, fuentedatos, Brushes.Black, 40, y)
e.Graphics.DrawString(filaLF("Añoalb").ToString, fuentedatos, Brushes.Black, 150, y)
e.Graphics.DrawString(filaLF("Nalbaran").ToString, fuentedatos, Brushes.Black, 250, y)
e.Graphics.DrawString(filaLF("facturl.codprod").To String, fuentedatos, Brushes.Black, 350, y)
e.Graphics.DrawString(filaLF("descri").ToString, fuentedatos, Brushes.Black, 480, y)
e.Graphics.DrawString(filaLF("unidades").ToString, fuentedatos, Brushes.Black, 620, y)
e.Graphics.DrawString(filaLF("precio").ToString, fuentedatos, Brushes.Black, 720, y)
y += 20
If y > 1000 Then
y = 150
e.HasMorePages = True
End If
End If
Next
Next
End Sub |