|
51
|
Programación / .NET (C#, VB.NET, ASP) / Re: Imprimir report rdlc vs 2010 vb.net , Consulta
|
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!? Me.ReportViewer1.Clear() Dim FACT As New ReportParameter("FACT", Convert.ToInt32(lbl_Consecutivo.Text)) Dim Subtotal_Descuento As String = String.Empty Subtotal_Descuento = Convert.ToDouble(lbl_Subtotal.Text - lblDescuento.Text) Dim Subtotal_con_Descuento As New ReportParameter("Subtotal_Con_Descuento", Subtotal_Descuento) 'Acá lleno los table adapter para el CONTROL del report viewer, donde si se ve!! Me.tbl_HEADERTableAdapter.Fill(Me.FACTURACIONDataSet1.tbl_HEADER) Me.tbl_DETAILTableAdapter.Fill(Me.FACTURACIONDataSet.tbl_DETAIL) Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {FACT}) Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Subtotal_con_Descuento}) Me.ReportViewer1.RefreshReport() imprimir_reporte(Me.ReportViewer1.LocalReport(), 3.92884, 8.9933)
Acá es donde trato de imprimir ' Export the given report as an EMF (Enhanced Metafile) file. Private Sub Exportar(ByVal report As LocalReport) Dim w As Integer = 0 Dim h As Integer = 0 If printdoc.DefaultPageSettings.Landscape = True Then w = printdoc.DefaultPageSettings.PaperSize.Height h = printdoc.DefaultPageSettings.PaperSize.Width Else w = printdoc.DefaultPageSettings.PaperSize.Width h = printdoc.DefaultPageSettings.PaperSize.Height End If Dim deviceInfo As String = "<DeviceInfo>" & _ "<OutputFormat>EMF</OutputFormat>" & _ "<PageWidth>" & w / 100 & "in</PageWidth>" & _ "<PageHeight>" & h / 100 & "in</PageHeight>" & _ "<MarginTop>0.0in</MarginTop>" & _ "<MarginLeft>0.0in</MarginLeft>" & _ "<MarginRight>0.0in</MarginRight>" & _ "<MarginBottom>0.0in</MarginBottom>" & _ "</DeviceInfo>" m_streams = New List(Of Stream)() report.Render("Image", deviceInfo, AddressOf CreateStream, warnings) For Each stream As Stream In m_streams stream.Position = 0 Next End Sub
'Imprimir Private Sub Print() If m_streams Is Nothing OrElse m_streams.Count = 0 Then Throw New Exception("Error: no stream to print.") End If AddHandler printdoc.PrintPage, AddressOf ImprimirPagina m_currentPageIndex = 0 printdoc.Print() End Sub
'Imprime el reporte Public Sub imprimir_reporte(ByRef report As LocalReport, ByVal page_width As Integer, ByVal page_height As Integer, _ Optional ByVal islandscap As Boolean = False, _ Optional ByVal printer_name As String = Nothing) printdoc = New PrintDocument() If printer_name <> Nothing Then printdoc.PrinterSettings.PrinterName = printer_name 'Obtiene el nombre de la impresora. If Not printdoc.PrinterSettings.IsValid Then 'Detecta si tiene configuración válida Throw New Exception("Cannot find the specified printer") Else Dim ps As New PaperSize("Custom", page_width, page_height) printdoc.DefaultPageSettings.PaperSize = ps printdoc.DefaultPageSettings.Landscape = islandscap Exportar(Me.ReportViewer1.LocalReport) Print() End If End Sub
Private Sub ImprimirPagina(ByVal sender As Object, ByVal ev As PrintPageEventArgs) Dim pageImage As New Metafile(m_streams(m_currentPageIndex)) ' Adjust rectangular area with printer margins. Dim adjustedRect As New System.Drawing.Rectangle(ev.PageBounds.Left - CInt(ev.PageSettings.HardMarginX), ev.PageBounds.Top - CInt(ev.PageSettings.HardMarginY), _ ev.PageBounds.Width, _ ev.PageBounds.Height) ' Draw a white background for the report ev.Graphics.FillRectangle(Brushes.White, adjustedRect) ' Draw the report content ev.Graphics.DrawImage(pageImage, adjustedRect) ' Prepare for the next page. Make sure we haven't hit the end. m_currentPageIndex += 1 ev.HasMorePages = (m_currentPageIndex < m_streams.Count) End Sub 'Crea un stream 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 Dim stream As Stream = New MemoryStream() m_streams.Add(stream) Return stream End Function
|
|
|
52
|
Programación / .NET (C#, VB.NET, ASP) / 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.aspxY 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. Private Sub imprimir_reporte() Dim FACT As New ReportParameter("FACT", lbl_Consecutivo.Text) 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>" Dim report As New LocalReport() Try Me.Tbl_DETAILTableAdapter1.Fill(Me.FacturacionDataSet1.tbl_DETAIL) Me.Tbl_HEADERTableAdapter1.Fill(Me.FacturacionDataSet11.tbl_HEADER) 'report.ReportPath = "..\..\Report2.rdlc" report.DataSources.Add(New ReportDataSource("HEADER", Me.Tbl_HEADERTableAdapter1.Fill(Me.FacturacionDataSet11.tbl_HEADER))) report.DataSources.Add(New ReportDataSource("DETAIL", Me.Tbl_HEADERTableAdapter1.Fill(Me.FacturacionDataSet11.tbl_HEADER))) report.SetParameters((New ReportParameter() {FACT})) report.ReportEmbeddedResource = "Report2.rdlc" Catch ex As Exception MessageBox.Show(ex.ToString) End Try End Sub
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.
|
|
|
55
|
Programación / .NET (C#, VB.NET, ASP) / Consulta Escritorio Remoto VB.NET 2010
|
en: 2 Octubre 2015, 00:24 am
|
Buenas, Estoy haciendo una especie de team viewer, aunque sea pequeñito, esto con el fin de conectarme fácilmente, donde estoy usando vs 2010 con vb.net. Estoy usando la librería MSTSCLib y la referencia es AxInterop.MSTSCLib y también agregué esta Interop.MSTSCLib, en resumen agregué la referencia Microsoft Terminal Services Active Client 1.0 Type Library. Pues resulta que he visto el código y pues no he podido echarlo a andar pues no me conecta, el "panel" no hace nada. Try Dim secured As IMsTscNonScriptable Pnl_Remoto.Server = txtServidor.Text Pnl_Remoto.UserName = txt_Usuario.Text secured = CType(Pnl_Remoto.GetOcx(), IMsTscNonScriptable) secured.ClearTextPassword = txtContraseña.Text Pnl_Remoto.Connect() Catch ex As Exception MsgBox("No se pudo conectar" + vbCrLf + "Error:" + vbCrLf + ex.Message.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error) End Try
Saben algo que tenga que agregarle, instalarle que estoy haciendo mal? Saludos, gracias por leer.
|
|
|
58
|
Programación / .NET (C#, VB.NET, ASP) / Consulta traslado de proyecto visual studio 2010 C#
|
en: 8 Agosto 2015, 06:02 am
|
Hola, me da pena consultar esto pero sinceramente no se porque no me funciona.
Hice un proyecto de c# en visual studio .net 2010 y necesito pasarlo a un compañero para que el lo continúe, el proyecto pues es algo muy básico y está hecho en capas, en buena teoría simplemente es pasarle todo el folder del proyecto y que el lo abra y lo continúe pero no se porque cuando el lo abre le aparece vacío y verdaderamente necesito que el lo continúe puesto que yo ya hice mi parte y no deseo seguirlo puesto que lo haría todo ¬¬.
Yo simplemente copio y pego el proyecto de la carpeta projects de visual studio y se lo paso, se supone que el con el visual studio lo abre y listo , no ?
El proyecto no lleva referencias, más que las mismas de las capas, es decir capa presentación, lógica y base de datos. Con respecto a los imports pues son de sql server y sqlserver data, nada que no traiga el visual studio.
Que más debo hacer???
GRACIAS POR LEER.
|
|
|
|
|
|
|