Option Strict Off
Option Explicit On
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Friend Class CRViewer
Inherits System.Windows.Forms.Form
'Private rsMachine As ADODB.Recordset
'Private Const PARAMETER_FIELD_NAME As String = "Machine"
Private Sub ConfigureCrystalReports()
CRViewer1.ReportSource = Nothing
CRViewer1.SelectionFormula = ""
Dim myConnectionInfo As ConnectionInfo
Dim ReportPath As String
Dim mySelectionFormula As String = ""
myConnectionInfo = New ConnectionInfo
With myConnectionInfo
.ServerName = "Primero"
.DatabaseName = "Tooling"
.UserID = "sa"
.Password = myPasswordTechniSQL
End With
Select Case glbReportname
Case "Z:\Tooling\PartialToolList.rpt"
mySelectionFormula = "{MachineTool.Machine} = " & Val(glbreportParam)
ReportPath = Application.StartupPath & "\PartialToolList.rpt"
CRViewer1.SelectionFormula = mySelectionFormula
CRViewer1.ReportSource = ReportPath
SetDBLogonForReport(myConnectionInfo)
Case "Z:\Tooling\Tooling.rpt"
ReportPath = Application.StartupPath & "\Tooling.rpt"
CRViewer1.ReportSource = ReportPath
SetDBLogonForReport(myConnectionInfo)
Case "Z:\Tooling\FullToolList.rpt"
ReportPath = Application.StartupPath & "\FullToolList.rpt"
CRViewer1.ReportSource = ReportPath
SetDBLogonForReport(myConnectionInfo)
Case "Z:\Tooling\Xref.rpt"
ReportPath = Application.StartupPath & "\Xref.rpt"
CRViewer1.ReportSource = ReportPath
SetDBLogonForReport(myConnectionInfo)
Case Else
End Select
End Sub
Private Sub CRViewer_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
On Error GoTo errorhandler
ConfigureCrystalReports()
Exit Sub
errorhandler:
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
MsgBox("An error occurred: [" & Err.Number & "] " & Err.Description & " - Source: " & Err.Source)
End Sub
Private Sub CRViewer_Resize(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Resize
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ClientRectangle.Height
CRViewer1.Width = ClientRectangle.Width
CRViewer1.Zoom(75)
End Sub
Private Sub CRViewer_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
'Me = Nothing
End Sub
Private Sub SetDBLogonForReport(ByVal myConnecionInfo As ConnectionInfo)
Dim myTableLogOnInfos As TableLogOnInfos = CRViewer1.LogOnInfo
For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
myTableLogOnInfo.ConnectionInfo = myConnecionInfo
Next
End Sub
Private Sub SetCurrentValuesForParameterField(ByVal myParameterFields As ParameterFields, ByVal myArrayList As ArrayList)
'Dim cPV As ParameterValues = New ParameterValues()
'For Each submittedValue As Object In myArrayList
' Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
' myParameterDiscreteValue.Value = submittedValue.ToString()
' cPV.Add(myParameterDiscreteValue)
'Next
'Dim myParameterField As ParameterField = myParameterFields(PARAMETER_FIELD_NAME)
'myParameterField.CurrentValues = cPV
End Sub
End Class