| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- Imports CrystalDecisions.CrystalReports.Engine
- Imports CrystalDecisions.Shared
- Public Class frmImprimir
- Public NombreRPT As String = String.Empty
- Public IdDocumento As String = String.Empty
- Public VistaPrevia As Boolean = True
- Sub New()
- ' Esta llamada es exigida por el diseñador.
- InitializeComponent()
- ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
- End Sub
- Sub New(ByRef NombreRPT As String, ByRef IdDocumento As String, ByRef VistaPrevia As Boolean)
- Me.New
- Me.NombreRPT = NombreRPT
- Me.IdDocumento = IdDocumento
- CargarRPT()
- End Sub
- Private Sub frmImpresion_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- End Sub
- Public Sub CargarRPT()
- Dim crSubDB As Database
- Dim crTables As Tables
- Dim cInfo = New ConnectionInfo()
- Dim oRPT As New ReportDocument
- crViewer.SetProductLocale(Threading.Thread.CurrentThread.CurrentUICulture.LCID)
- cInfo.ServerName = My.Settings.ServidorSQL
- cInfo.UserID = My.Settings.UsuarioSQL
- cInfo.Password = My.Settings.ClaveSQL
- cInfo.DatabaseName = My.Settings.BaseDeDatos
- oRPT.Load(My.Settings("RutaReportes") & NombreRPT)
- oRPT.SetDatabaseLogon(cInfo.UserID, cInfo.Password)
- oRPT.SetParameterValue(0, IdDocumento)
- crSubDB = oRPT.Database
- crTables = crSubDB.Tables
- Dim crTableLogOnInfo As TableLogOnInfo
- For Each crTable In crTables
- crTableLogOnInfo = crTable.LogOnInfo
- crTableLogOnInfo.ConnectionInfo = cInfo
- crTable.ApplyLogOnInfo(crTableLogOnInfo)
- Next
- If VistaPrevia = False Then
- oRPT.PrintToPrinter(IdDocumento, False, 0, 0)
- End If
- crViewer.ReportSource = oRPT
- End Sub
- Private Sub crViewer_Load(sender As Object, e As EventArgs) Handles crViewer.Load
- End Sub
- End Class
|