agregado procesos y bd clases
This commit is contained in:
66
guia/informes/Informes.vb
Normal file
66
guia/informes/Informes.vb
Normal file
@@ -0,0 +1,66 @@
|
||||
Imports DevExpress.XtraReports.UI
|
||||
Imports DevExpress.Xpf.Printing
|
||||
Imports System.Data.Objects
|
||||
Imports System.IO
|
||||
|
||||
Public Class Informes
|
||||
Public Shared Sub ImprimeInforme(xr As XtraReport, Datos As Object, ImpresoraPredeterminada As Boolean)
|
||||
For Each pr In xr.Parameters
|
||||
pr.Visible = False
|
||||
Next
|
||||
xr.DataSource = Datos
|
||||
xr.CreateDocument(True)
|
||||
If ImpresoraPredeterminada Then
|
||||
xr.Print()
|
||||
Else
|
||||
xr.PrintDialog()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Shared Function GeneraXLSX(xr As XtraReport, Datos As Object) As IO.MemoryStream
|
||||
Dim ms As New IO.MemoryStream
|
||||
For Each pr In xr.Parameters
|
||||
pr.Visible = False
|
||||
Next
|
||||
xr.DataSource = Datos
|
||||
xr.CreateDocument(True)
|
||||
xr.ExportToXlsx(ms)
|
||||
Return ms
|
||||
End Function
|
||||
|
||||
|
||||
Public Shared Function GeneraPDF(bd As bdGestionAsegasa.gestionasegasaEntities, idPlantilla As Integer, Datasource As Object) As MemoryStream
|
||||
Try
|
||||
If idPlantilla = 0 Then Throw New Exception("Seleccione primero la plantilla a imprimir")
|
||||
Dim xr As New XtraReport
|
||||
|
||||
Dim qr As ObjectQuery(Of plantillas) = bd.plantillas
|
||||
qr.MergeOption = MergeOption.OverwriteChanges
|
||||
|
||||
Dim pl = qr.Where(Function(x) x.idPlantilla = idPlantilla).First
|
||||
Dim s As String = System.Text.Encoding.UTF8.GetString(pl.ficheros.Fichero)
|
||||
Using sw As New StreamWriter(New MemoryStream())
|
||||
sw.Write(s)
|
||||
sw.Flush()
|
||||
xr = XtraReport.FromStream(sw.BaseStream, True)
|
||||
End Using
|
||||
Try
|
||||
Dim pr As DevExpress.XtraReports.Parameters.Parameter = (From p As DevExpress.XtraReports.Parameters.Parameter In xr.Parameters Where p.Name = "Fecha").First
|
||||
pr.Value = bdGestionAsegasa.Utilidades.AhoraMysql(bd)
|
||||
pr.Visible = False
|
||||
Catch
|
||||
End Try
|
||||
xr.DataSource = Datasource
|
||||
xr.CreateDocument(True)
|
||||
Dim ms As New IO.MemoryStream
|
||||
xr.ExportToPdf(ms)
|
||||
Return ms
|
||||
Catch ex As Exception
|
||||
Throw New Exception(ex.Message, ex)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user