Quantcast
Channel: VB2008 - Problema con PrintDocument
Viewing all articles
Browse latest Browse all 2

VB2008 - Problema con PrintDocument

0
0

Estimados,

tengo problemas con esta rutina, al momento de enviar a imprimir me arroja una cantidad de indefinida de copias y solo necesito una.

Llamo al reporte desde la rutina Imprimir.

    Public Sub imprimir()
        Dim printer As PrintDocument = New PrintDocument
        AddHandler printer.PrintPage, AddressOf rptConsumo
        printer.Print()
    End Sub

  Private Sub rptConsumo(ByVal sender As Object, ByVal e As PrintPageEventArgs)
        Dim oTotal As Integer
        Dim img As Image = Image.FromFile("C:\HAPPY.jpg")
        Dim Font9Nor As Font = New Font("Arial", 9)
        Dim Font10Nor As Font = New Font("Arial", 10)
        Dim Font10Neg As Font = New Font("Arial", 10, FontStyle.Bold)
        Dim NLinea As Integer = 205

        oDataBuscar = oCMD.BusquedaComanda(216).Tables("Comanda")

        e.Graphics.DrawString(Space(1) & oDataBuscar2.Rows(0).Item("PAR_ADMEMPRESA"), Font10Nor, Brushes.Black, 1, 0)
        e.Graphics.DrawString(Space(1) & oDataBuscar2.Rows(0).Item("PAR_ADMDIRECCION"), Font10Nor, Brushes.Black, 1, 15)
        e.Graphics.DrawString(Chr(13), Font10Nor, Brushes.Black, 1, 30)
        e.Graphics.DrawString(Chr(13), Font10Nor, Brushes.Black, 1, 45)
        e.Graphics.DrawString(Space(7) & "D E T A L L E   C O N S U M O", Font10Neg, Brushes.Black, 1, 60)
        e.Graphics.DrawString(Space(1) & "------------------------------------------------------------", Font10Nor, Brushes.Black, 1, 75)
        e.Graphics.DrawString(Space(1) & "CUENTA" & Space(2) & ": " & oDataBuscar.Rows(0).Item("FOLIO") & Space(18) & "MESA  : " & oDataBuscar.Rows(0).Item("MS_COD"), Font9Nor, Brushes.Black, 1, 90)
        e.Graphics.DrawString(Space(1) & "FECHA" & Space(5) & ": " & CStr(oDataBuscar.Rows(0).Item("FECHA")).Replace("/", "-") & Space(13) & "HORA  : " & oDataBuscar.Rows(0).Item("HORA"), Font9Nor, Brushes.Black, 1, 105)
        e.Graphics.DrawString(Space(1) & "GARZON" & Space(2) & ": " & oDataBuscar.Rows(0).Item("USUARIO"), Font9Nor, Brushes.Black, 1, 120)
        e.Graphics.DrawString(Space(1) & "------------------------------------------------------------", Font10Nor, Brushes.Black, 1, 135)
        e.Graphics.DrawString(Chr(13), Font10Nor, Brushes.Black, 1, 150)
        e.Graphics.DrawString(Space(2) & "CANT" & Space(8) & "PRODUCTO" & Space(15) & "TOTAL", Font10Nor, Brushes.Black, 1, 175)
        e.Graphics.DrawString(Space(1) & "=================================", Font10Nor, Brushes.Black, 1, 190)

        For Each fila In oDataBuscar.Rows()

            Dim Cant As String = FormatNumber(fila("CANT"), 2)
            Dim Detalle As String = oVAL.RemoveDiacritics(fila("PRODUCTO"))
            Dim Total As String = FormatNumber(fila("TOTAL"), 0)
            Dim ESP1 As Integer = 6 - Len(Cant)
            Dim DETA As Integer = 20 - Len(Detalle)
            Dim ESP2 As Integer = (20 - Len(Detalle)) + (11 - Len(Total))
            oTotal += fila("TOTAL")

            e.Graphics.DrawString(Space(ESP1) & Cant & Space(4) & Detalle & Space(ESP2) & Total.Replace(",", "."), Font9Nor, Brushes.Black, 1, NLinea)
            NLinea += 15
        Next

        Dim ffTotal As String = FormatNumber(oTotal, 0)
        Dim ESP3 As Integer = 16 - Len(ffTotal)

        e.Graphics.DrawString(Space(1) & "=================================", Font10Nor, Brushes.Black, 1, 15 + NLinea)

        e.Graphics.DrawString(Space(25) & "TOTAL $ " & Space(ESP3) & CStr(ffTotal).Replace(",", "."), Font10Nor, Brushes.Black, 1, 30 +

        e.Graphics.DrawImage(img, 1, 90 + NLinea, 300, 150)
        e.HasMorePages = False

        Imprimir()
    End Sub


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images