elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Imprimir report rdlc vs 2010 vb.net , Consulta
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Imprimir report rdlc vs 2010 vb.net , Consulta  (Leído 7,126 veces)
Yaldabaot

Desconectado Desconectado

Mensajes: 186


Ver Perfil
Imprimir report rdlc vs 2010 vb.net , Consulta
« en: 12 Octubre 2015, 23:10 pm »

Buenas, estoy tratando de realizar un POS y pues ya puedo meter los datos en la base de datos y ya tengo mi archivo rdlc con la personalización que necesito, pues como ustedes saben las impresoras POS tienen ciertas medidas, pues tengo el reporte con el formato definido y sus respectivos parámetros.

Necesito agarrar ese reporte e imprimirlo directamente en la impresora sin vista previa, ya he visto varios enlaces como por ejemplo este

https://msdn.microsoft.com/en-us/library/ms252091.aspx

Y pues me parece un poco engorroso ese código y sobretodo no me sirve, sólo errores. También veo en ese código que ellos definen los datos del tamaño y el formato, pues yo ya tengo el reporte hecho el diseñador del VS lo cuál creo que no necesito definirselo ahí.


Necesito pasarle los parámetros al reporte para hacer correctamente la consulta, donde ya tengo mis datasets definidos, entonces sinceramente no se como hacer para llenar ese reporte y poder imprimirlo. Ya que antes simplemente ponía un control de report viewer y el me lanzaba el dialogo para imprimirlo, pero como es para facturas necesito que no se vea.


Código
  1.  
  2. Private Sub imprimir_reporte()
  3.  
  4.        Dim FACT As New ReportParameter("FACT", lbl_Consecutivo.Text)
  5.        Dim deviceInfo As String = "<DeviceInfo><OutputFormat>EMF</OutputFormat><PageWidth>8.5in</PageWidth><PageHeight>11in</PageHeight><MarginTop>0.25in</MarginTop><MarginLeft>0.25in</MarginLeft><MarginRight>0.25in</MarginRight><MarginBottom>0.25in</MarginBottom></DeviceInfo>"
  6.  
  7.        Dim report As New LocalReport()
  8.  
  9.        Try
  10.  
  11.            Me.Tbl_DETAILTableAdapter1.Fill(Me.FacturacionDataSet1.tbl_DETAIL)
  12.            Me.Tbl_HEADERTableAdapter1.Fill(Me.FacturacionDataSet11.tbl_HEADER)
  13.  
  14.            'report.ReportPath = "..\..\Report2.rdlc"
  15.  
  16.            report.DataSources.Add(New ReportDataSource("HEADER", Me.Tbl_HEADERTableAdapter1.Fill(Me.FacturacionDataSet11.tbl_HEADER)))
  17.            report.DataSources.Add(New ReportDataSource("DETAIL", Me.Tbl_HEADERTableAdapter1.Fill(Me.FacturacionDataSet11.tbl_HEADER)))
  18.  
  19.            report.SetParameters((New ReportParameter() {FACT}))
  20.  
  21.            report.ReportEmbeddedResource = "Report2.rdlc"
  22.  
  23.  
  24.  
  25.        Catch ex As Exception
  26.            MessageBox.Show(ex.ToString)
  27.        End Try
  28.    End Sub
  29.  
  30.  
  31.  


Ese es el código que tengo, realmente yo tenía el código para imprimir y que a ese reporte le lleguen los datos del dataset les agradezco pero como les digo se hace realmente engorroso y da errores.

Con respecto a los datos del dataset pues he visto que uno le define el datasource, y le mando por medio de parámetros el adapter, dataset pero en ninguna parte de mi rdlc necesito hacer eso y pues me tiene confundido.

Si uds serían tan amables de darme una guía se los agradezco mucho


GRACIAS POR LEER.


En línea

Nunca me contestan -_-
Yaldabaot

Desconectado Desconectado

Mensajes: 186


Ver Perfil
Re: Imprimir report rdlc vs 2010 vb.net , Consulta
« Respuesta #1 en: 14 Octubre 2015, 01:15 am »

Me rindo, sinceramente no se como pasarle el documento YA CREADO

El control tiene todos los datos necesarios desde su atributos, como carajos los obtengo para pasarselo al P....  reporte!?

Código
  1.  
  2. Me.ReportViewer1.Clear()
  3.  
  4.            Dim FACT As New ReportParameter("FACT", Convert.ToInt32(lbl_Consecutivo.Text))
  5.            Dim Subtotal_Descuento As String = String.Empty
  6.  
  7.  
  8.            Subtotal_Descuento = Convert.ToDouble(lbl_Subtotal.Text - lblDescuento.Text)
  9.  
  10.            Dim Subtotal_con_Descuento As New ReportParameter("Subtotal_Con_Descuento", Subtotal_Descuento)
  11.  
  12.           'Acá lleno los table adapter para el CONTROL del report viewer, donde si se ve!!
  13.  
  14.            Me.tbl_HEADERTableAdapter.Fill(Me.FACTURACIONDataSet1.tbl_HEADER)
  15.            Me.tbl_DETAILTableAdapter.Fill(Me.FACTURACIONDataSet.tbl_DETAIL)
  16.  
  17.  
  18.            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {FACT})
  19.            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Subtotal_con_Descuento})
  20.  
  21.            Me.ReportViewer1.RefreshReport()
  22.  
  23.            imprimir_reporte(Me.ReportViewer1.LocalReport(), 3.92884, 8.9933)
  24.  
  25.  


Acá es donde trato de imprimir

Código
  1.  
  2. ' Export the given report as an EMF (Enhanced Metafile) file.
  3.    Private Sub Exportar(ByVal report As LocalReport)
  4.  
  5.        Dim w As Integer = 0
  6.        Dim h As Integer = 0
  7.  
  8.  
  9.        If printdoc.DefaultPageSettings.Landscape = True Then
  10.            w = printdoc.DefaultPageSettings.PaperSize.Height
  11.            h = printdoc.DefaultPageSettings.PaperSize.Width
  12.        Else
  13.            w = printdoc.DefaultPageSettings.PaperSize.Width
  14.            h = printdoc.DefaultPageSettings.PaperSize.Height
  15.        End If
  16.  
  17.  
  18.        Dim deviceInfo As String = "<DeviceInfo>" & _
  19.            "<OutputFormat>EMF</OutputFormat>" & _
  20.            "<PageWidth>" & w / 100 & "in</PageWidth>" & _
  21.            "<PageHeight>" & h / 100 & "in</PageHeight>" & _
  22.            "<MarginTop>0.0in</MarginTop>" & _
  23.            "<MarginLeft>0.0in</MarginLeft>" & _
  24.            "<MarginRight>0.0in</MarginRight>" & _
  25.            "<MarginBottom>0.0in</MarginBottom>" & _
  26.            "</DeviceInfo>"
  27.  
  28.  
  29.        m_streams = New List(Of Stream)()
  30.        report.Render("Image", deviceInfo, AddressOf CreateStream, warnings)
  31.  
  32.        For Each stream As Stream In m_streams
  33.            stream.Position = 0
  34.        Next
  35.  
  36.    End Sub
  37.  


Código
  1. 'Imprimir
  2.    Private Sub Print()
  3.        If m_streams Is Nothing OrElse m_streams.Count = 0 Then
  4.            Throw New Exception("Error: no stream to print.")
  5.        End If
  6.        AddHandler printdoc.PrintPage, AddressOf ImprimirPagina
  7.        m_currentPageIndex = 0
  8.        printdoc.Print()
  9.    End Sub
  10.  
  11.  


Código
  1.  
  2. 'Imprime el reporte
  3.    Public Sub imprimir_reporte(ByRef report As LocalReport, ByVal page_width As Integer, ByVal page_height As Integer, _
  4.                                      Optional ByVal islandscap As Boolean = False, _
  5.                                      Optional ByVal printer_name As String = Nothing)
  6.  
  7.        printdoc = New PrintDocument()
  8.        If printer_name <> Nothing Then printdoc.PrinterSettings.PrinterName = printer_name 'Obtiene el nombre de la impresora.
  9.  
  10.        If Not printdoc.PrinterSettings.IsValid Then 'Detecta si tiene configuración válida
  11.            Throw New Exception("Cannot find the specified printer")
  12.        Else
  13.  
  14.  
  15.            Dim ps As New PaperSize("Custom", page_width, page_height)
  16.            printdoc.DefaultPageSettings.PaperSize = ps
  17.            printdoc.DefaultPageSettings.Landscape = islandscap
  18.            Exportar(Me.ReportViewer1.LocalReport)
  19.            Print()
  20.  
  21.        End If
  22.    End Sub
  23.  
  24.  

Código
  1.  
  2. Private Sub ImprimirPagina(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
  3.        Dim pageImage As New Metafile(m_streams(m_currentPageIndex))
  4.  
  5.        ' Adjust rectangular area with printer margins.
  6.        Dim adjustedRect As New System.Drawing.Rectangle(ev.PageBounds.Left - CInt(ev.PageSettings.HardMarginX),
  7.                                          ev.PageBounds.Top - CInt(ev.PageSettings.HardMarginY), _
  8.                                          ev.PageBounds.Width, _
  9.                                          ev.PageBounds.Height)
  10.  
  11.        ' Draw a white background for the report
  12.        ev.Graphics.FillRectangle(Brushes.White, adjustedRect)
  13.  
  14.        ' Draw the report content
  15.        ev.Graphics.DrawImage(pageImage, adjustedRect)
  16.  
  17.        ' Prepare for the next page. Make sure we haven't hit the end.
  18.        m_currentPageIndex += 1
  19.        ev.HasMorePages = (m_currentPageIndex < m_streams.Count)
  20.    End Sub
  21.    'Crea un stream
  22.    Private Function CreateStream(ByVal name As String, ByVal fileNameExtension As String, ByVal encoding As System.Text.Encoding, ByVal mimeType As String, ByVal willSeek As Boolean) As Stream
  23.        Dim stream As Stream = New MemoryStream()
  24.        m_streams.Add(stream)
  25.        Return stream
  26.    End Function
  27.  
  28.  




En línea

Nunca me contestan -_-
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
IMPRIMIR o CREAR REPORTE sin Crystal Report.
.NET (C#, VB.NET, ASP)
[Black Vomit] 0 3,634 Último mensaje 25 Diciembre 2011, 20:08 pm
por [Black Vomit]
Imprimir en VB 2010
.NET (C#, VB.NET, ASP)
cneangel 0 1,852 Último mensaje 12 Julio 2012, 16:03 pm
por cneangel
MOSTRAR CONSULTA EN MI DATA REPORT
Programación Visual Basic
MANUEL BURGOS 0 1,787 Último mensaje 8 Julio 2013, 23:53 pm
por MANUEL BURGOS
Imprimir factura en impresora fiscal desde VB 2010
.NET (C#, VB.NET, ASP)
Legnak 1 5,089 Último mensaje 8 Febrero 2014, 22:03 pm
por Maurice_Lupin
imprimir directamente en una impresora un reporte rdlc
.NET (C#, VB.NET, ASP)
djnilo 0 4,354 Último mensaje 6 Diciembre 2016, 01:48 am
por djnilo
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines