1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
Public Sub Export_PDF(ByVal nomEtat As String, ByVal Factures As List(Of cls_Facture), ByVal Out As TypeRender, Optional ByVal DateDebut As String = "", Optional ByVal DateFin As String = "", Optional ByVal GénérerPDF_EnLocal As Boolean = True)
If DateDebut = "" Then DateDebut = Now.ToShortDateString
Dim Form As New System.Windows.Forms.Form
Form.ClientSize = New System.Drawing.Size(1112, 510)
Form.Name = "PrintGridView"
Form.Text = "Compte rendu de l'intégration"
Form.WindowState = FormWindowState.Maximized
If Factures.Count > 0 Then
Dim viewer As New Microsoft.Reporting.WinForms.ReportViewer
viewer.Dock = System.Windows.Forms.DockStyle.Fill
viewer.Location = New System.Drawing.Point(0, 0)
viewer.Name = "chpviewer"
viewer.LocalReport.ReportPath = My.Application.Info.DirectoryPath & "\" & nomEtat
viewer.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("cls_Facture", Factures))
Dim Param As New List(Of Microsoft.Reporting.WinForms.ReportParameter)
Param.Add(New Microsoft.Reporting.WinForms.ReportParameter("DateDebut", DateDebut))
Param.Add(New Microsoft.Reporting.WinForms.ReportParameter("DateFin", DateFin))
viewer.LocalReport.SetParameters(Param)
Form.Controls.Add(viewer)
'Affiche le contenu du rapport
viewer.RefreshReport()
If Out = TypeRender.Ecran Then
Form.ShowDialog()
End If
If GénérerPDF_EnLocal Then
Dim warnings As Microsoft.Reporting.WinForms.Warning() = Nothing
Dim streamids As String() = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = Nothing
Dim extension As String = Nothing
Dim bytes As Byte()
bytes = viewer.LocalReport.Render("PDF", Nothing, mimeType, encoding, extension, streamids, warnings)
Dim fs As New IO.FileStream(_FullNameCompteRenduPDF, IO.FileMode.Create)
fs.Write(bytes, 0, bytes.Length)
fs.Close()
fs.Dispose()
bytes = Nothing
End If
Form.Dispose()
End If
End Sub |