From 5f93587d9720da4723f7e756c3d6f725d00b26dd Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 6 Jul 2025 11:05:16 +0200 Subject: [PATCH] Nueva rutina en tsXtraReports ImprimeInforme --- Utilidades/tsXtraReports.vb | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Utilidades/tsXtraReports.vb b/Utilidades/tsXtraReports.vb index f317b46..c37d4a4 100644 --- a/Utilidades/tsXtraReports.vb +++ b/Utilidades/tsXtraReports.vb @@ -1,4 +1,8 @@ Imports System.IO +Imports DevExpress.Xpf.Core +Imports DevExpress.Xpf.Grid.Printing +Imports DevExpress.XtraPrinting +Imports DevExpress.XtraReports.UI Public Class tsXtraReport Public Shared Sub ExportarAPDF(Plantilla() As Byte, Datos As Object, FicheroPDF As String) @@ -106,4 +110,38 @@ Public Class tsXtraReport xr.ExportToPdf(ms) Return ms End Function + Private Shared NumeroCopias As Integer + Friend Shared Sub ImprimeInforme(xr As XtraReport, ImpresoraPredeterminada As Boolean, Copias As Integer, Fecha As Date, Datos As Object) + Try + For Each pr In xr.Parameters + pr.Visible = False + If pr.Name = "Fecha" Then + pr.Value = Fecha + End If + Next + xr.DataSource = Datos + xr.CreateDocument(True) + If ImpresoraPredeterminada Then + If Copias < 2 Then + NumeroCopias = 1 + xr.Print() + Else + NumeroCopias = Copias + AddHandler xr.PrintingSystem.StartPrint, AddressOf xr_StartPring + xr.Print() + End If + Else + PrintHelper.Print(xr) + 'xr.PrintDialog() + End If + Catch ex As Exception + DXMessageBox.Show(ex.Message, "Error") + End Try + End Sub + + Private Shared Sub xr_StartPring(sender As Object, e As PrintDocumentEventArgs) + e.PrintDocument.PrinterSettings.Copies = NumeroCopias + End Sub + + End Class \ No newline at end of file