Hello All
I have designed a dotnet application using VB which basically takes a
selection and passes value to a crystal report which in turn passes the
value to a Stored procedure. After the report gets generated it is PDF'ed -
all this is done thru a single click in my program.
Now the catch here is that through the program all these tasks of generating
the report and PDF'ing 1400 records (about 25 pages) takes 15 minutes.
I executed the SP through analyzer and to generate the 1300 records it takes
about 4 seconds. I executed the information thru Crystal Reports 8.5 and to
generate the report with the parameters it takes less than a minute. To
export to a PDF version from the Drop Down Menu choice, it took about 15
seconds.
It seems to me that when I add the .Net app layer it adds on the extra time.
I am a newbie to dot net. Please advise.. Below is the code that I am using.
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Data.SqlClient
Public Class frmCRReport
Inherits System.Windows.Forms.Form
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterValues As ParameterValues
Dim crParameterValues2 As ParameterValues
Dim crParameterValues3 As ParameterValues
Dim crParameterValues4 As ParameterValues
Dim crConnectionInfo As ConnectionInfo
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim crLogonInfo As TableLogOnInfo
Dim response As Integer
Dim response1 As Integer
Dim msg As Integer
Dim msg1 As Integer
Dim oRpt As ReportDocument
Dim crview As New CRView()
Dim i As Integer
Dim BegDate As Date
Dim DateVal As Date
Dim YTD As String
Dim disptext As String
Dim dtFolder As String
Dim Exportpath As String
Dim exportFilePath As String
Dim ExportFileName As String
Dim dlg As System.IO.DirectoryInfo
Dim dlg1 As New OpenFileDialog()
Dim dlg2 As New SaveFileDialog()
Dim dirpath As String
Dim undwrtr As String
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents CheckedListBox1 As System.Windows.Forms.CheckedListBox
Friend WithEvents cmdEnd As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker
Friend WithEvents DateTimePicker2 As System.Windows.Forms.DateTimePicker
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents cboMonth As System.Windows.Forms.ComboBox
Friend WithEvents lblDirPath As System.Windows.Forms.Label
Friend WithEvents btnDirPath As System.Windows.Forms.Button
Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents btnSavRpt As System.Windows.Forms.Button
Friend WithEvents lblSavPath As System.Windows.Forms.Label
Friend WithEvents CheckedListBox2 As System.Windows.Forms.CheckedListBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents btnRunReports As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.CheckedListBox1 = New System.Windows.Forms.CheckedListBox()
Me.cmdEnd = New System.Windows.Forms.Button()
Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker()
Me.DateTimePicker2 = New System.Windows.Forms.DateTimePicker()
Me.Label3 = New System.Windows.Forms.Label()
Me.cboMonth = New System.Windows.Forms.ComboBox()
Me.lblDirPath = New System.Windows.Forms.Label()
Me.btnDirPath = New System.Windows.Forms.Button()
Me.RichTextBox1 = New System.Windows.Forms.RichTextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.Label8 = New System.Windows.Forms.Label()
Me.btnSavRpt = New System.Windows.Forms.Button()
Me.lblSavPath = New System.Windows.Forms.Label()
Me.CheckedListBox2 = New System.Windows.Forms.CheckedListBox()
Me.Label6 = New System.Windows.Forms.Label()
Me.btnRunReports = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'CheckedListBox1
'
Me.CheckedListBox1.Items.AddRange(New Object() {"1400 - Test"})
Me.CheckedListBox1.Location = New System.Drawing.Point(112, 176)
Me.CheckedListBox1.Name = "CheckedListBox1"
Me.CheckedListBox1.Size = New System.Drawing.Size(272, 229)
Me.CheckedListBox1.Sorted = True
Me.CheckedListBox1.TabIndex = 5
'
'cmdEnd
'
Me.cmdEnd.BackColor = System.Drawing.Color.LightGray
Me.cmdEnd.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.cmdEnd.ForeColor = System.Drawing.Color.Maroon
Me.cmdEnd.Location = New System.Drawing.Point(512, 368)
Me.cmdEnd.Name = "cmdEnd"
Me.cmdEnd.Size = New System.Drawing.Size(168, 32)
Me.cmdEnd.TabIndex = 24
Me.cmdEnd.Text = "End"
'
'DateTimePicker1
'
Me.DateTimePicker1.CustomFormat = "mm/dd/yyyy"
Me.DateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Short
Me.DateTimePicker1.Location = New System.Drawing.Point(392, 312)
Me.DateTimePicker1.Name = "DateTimePicker1"
Me.DateTimePicker1.Size = New System.Drawing.Size(104, 20)
Me.DateTimePicker1.TabIndex = 7
Me.DateTimePicker1.Value = New Date(2003, 4, 16, 0, 0, 0, 0)
'
'DateTimePicker2
'
Me.DateTimePicker2.Format = System.Windows.Forms.DateTimePickerFormat.Short
Me.DateTimePicker2.Location = New System.Drawing.Point(520, 312)
Me.DateTimePicker2.Name = "DateTimePicker2"
Me.DateTimePicker2.Size = New System.Drawing.Size(96, 20)
Me.DateTimePicker2.TabIndex = 9
'
'Label3
'
Me.Label3.BackColor = System.Drawing.Color.DarkGreen
Me.Label3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Label3.Font = New System.Drawing.Font("Arial Black", 26.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label3.ForeColor = System.Drawing.Color.LightGoldenrodYellow
Me.Label3.Location = New System.Drawing.Point(-8, 0)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(936, 72)
Me.Label3.TabIndex = 1
Me.Label3.Text = "REPORTS"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.TopCenter
'
'cboMonth
'
Me.cboMonth.Items.AddRange(New Object() {"January", "February", "March",
"April", "May", "June", "July", "August", "September", "October",
"November", "December"})
Me.cboMonth.Location = New System.Drawing.Point(392, 344)
Me.cboMonth.Name = "cboMonth"
Me.cboMonth.Size = New System.Drawing.Size(112, 21)
Me.cboMonth.TabIndex = 20
Me.cboMonth.Text = "Select a Month"
'
'lblDirPath
'
Me.lblDirPath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.lblDirPath.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.lblDirPath.ForeColor = System.Drawing.Color.DarkBlue
Me.lblDirPath.Location = New System.Drawing.Point(296, 80)
Me.lblDirPath.Name = "lblDirPath"
Me.lblDirPath.Size = New System.Drawing.Size(536, 32)
Me.lblDirPath.TabIndex = 3
Me.lblDirPath.Text = "M:\MIS\Programming\Reports"
'
'btnDirPath
'
Me.btnDirPath.BackColor = System.Drawing.Color.LightGray
Me.btnDirPath.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.btnDirPath.ForeColor = System.Drawing.Color.Maroon
Me.btnDirPath.Location = New System.Drawing.Point(104, 80)
Me.btnDirPath.Name = "btnDirPath"
Me.btnDirPath.Size = New System.Drawing.Size(192, 32)
Me.btnDirPath.TabIndex = 2
Me.btnDirPath.Text = "Set Report Location Path"
'
'RichTextBox1
'
Me.RichTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.RichTextBox1.Location = New System.Drawing.Point(104, 512)
Me.RichTextBox1.Name = "RichTextBox1"
Me.RichTextBox1.Size = New System.Drawing.Size(784, 160)
Me.RichTextBox1.TabIndex = 25
Me.RichTextBox1.Text = ""
'
'Label2
'
Me.Label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label2.ForeColor = System.Drawing.Color.DarkBlue
Me.Label2.Location = New System.Drawing.Point(392, 288)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(72, 16)
Me.Label2.TabIndex = 6
Me.Label2.Text = "Begin Date"
'
'Label4
'
Me.Label4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label4.ForeColor = System.Drawing.Color.DarkBlue
Me.Label4.Location = New System.Drawing.Point(520, 288)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(64, 16)
Me.Label4.TabIndex = 8
Me.Label4.Text = "End Date"
'
'Label5
'
Me.Label5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label5.ForeColor = System.Drawing.Color.DarkBlue
Me.Label5.Location = New System.Drawing.Point(112, 152)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(96, 16)
Me.Label5.TabIndex = 4
Me.Label5.Text = "Select Group(s)"
'
'Label8
'
Me.Label8.BackColor = System.Drawing.Color.DarkGreen
Me.Label8.Location = New System.Drawing.Point(0, 72)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(96, 680)
Me.Label8.TabIndex = 41
'
'btnSavRpt
'
Me.btnSavRpt.BackColor = System.Drawing.Color.LightGray
Me.btnSavRpt.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.btnSavRpt.ForeColor = System.Drawing.Color.Maroon
Me.btnSavRpt.Location = New System.Drawing.Point(104, 112)
Me.btnSavRpt.Name = "btnSavRpt"
Me.btnSavRpt.Size = New System.Drawing.Size(192, 32)
Me.btnSavRpt.TabIndex = 42
Me.btnSavRpt.Text = "Set Report Export Path"
'
'lblSavPath
'
Me.lblSavPath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.lblSavPath.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.lblSavPath.ForeColor = System.Drawing.Color.DarkBlue
Me.lblSavPath.Location = New System.Drawing.Point(296, 112)
Me.lblSavPath.Name = "lblSavPath"
Me.lblSavPath.Size = New System.Drawing.Size(536, 32)
Me.lblSavPath.TabIndex = 43
'
'CheckedListBox2
'
Me.CheckedListBox2.Items.AddRange(New Object() {"Class Statistical Report -
All Funds"})
Me.CheckedListBox2.Location = New System.Drawing.Point(392, 176)
Me.CheckedListBox2.Name = "CheckedListBox2"
Me.CheckedListBox2.Size = New System.Drawing.Size(256, 109)
Me.CheckedListBox2.TabIndex = 44
'
'Label6
'
Me.Label6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label6.ForeColor = System.Drawing.Color.DarkBlue
Me.Label6.Location = New System.Drawing.Point(392, 152)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(144, 16)
Me.Label6.TabIndex = 45
Me.Label6.Text = "Select Report(s) to Run"
'
'btnRunReports
'
Me.btnRunReports.BackColor = System.Drawing.Color.LightGray
Me.btnRunReports.Font = New System.Drawing.Font("Microsoft Sans Serif",
8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.btnRunReports.ForeColor = System.Drawing.Color.Maroon
Me.btnRunReports.Location = New System.Drawing.Point(512, 336)
Me.btnRunReports.Name = "btnRunReports"
Me.btnRunReports.Size = New System.Drawing.Size(168, 32)
Me.btnRunReports.TabIndex = 46
Me.btnRunReports.Text = "Run Selected Reports"
'
'frmCRReport
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.AutoScroll = True
Me.AutoScrollMargin = New System.Drawing.Size(10, 10)
Me.BackColor = System.Drawing.Color.PaleGoldenrod
Me.ClientSize = New System.Drawing.Size(774, 555)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnRunReports,
Me.Label6, Me.CheckedListBox2, Me.lblSavPath, Me.btnSavRpt, Me.Label8,
Me.Label5, Me.Label4, Me.Label2, Me.RichTextBox1, Me.btnDirPath,
Me.lblDirPath, Me.cboMonth, Me.Label3, Me.cmdEnd, Me.CheckedListBox1,
Me.DateTimePicker1, Me.DateTimePicker2})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.Name = "frmCRReport"
Me.Text = "Benesys Eldorado Special Processing Reports"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmCRReport_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim myConnectionString As String
Dim dataset1 As DataSet
CheckedListBox1.CheckOnClick = True
CheckedListBox2.CheckOnClick = True
End Sub
Public Sub connectDB()
crLogonInfo = oRpt.Database.Tables(0).LogOnInfo
crLogonInfo.ConnectionInfo.ServerName = "XXXX"
crLogonInfo.ConnectionInfo.UserID = "XXXXXXXXXXX"
crLogonInfo.ConnectionInfo.Password = "XXXXXXXX"
crLogonInfo.ConnectionInfo.DatabaseName = "XXXXXXXXXXX"
oRpt.Database.Tables(0).ApplyLogOnInfo(crLogonInfo )
End Sub
Public Sub PDFDoc()
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = exportFilePath
crExportOptions = oRpt.ExportOptions
With crExportOptions
..DestinationOptions = crDiskFileDestinationOptions
..ExportDestinationType = ExportDestinationType.DiskFile
..ExportFormatType = ExportFormatType.PortableDocFormat
End With
oRpt.Export()
End Sub
Public Function checkFund()
If CheckedListBox1.CheckedItems.Count = 0 Then
MsgBox("No Group has been selected. You must select atleast one group to run
the report", MsgBoxStyle.OKOnly)
CheckedListBox1.Focus()
checkFund = 1
Exit Function
End If
checkFund = 0
End Function
Public Sub FundBegDates()
YTD = ""
If Mid(CheckedListBox1.CheckedItems(i), 1, 4) = "1400" Then
YTD = "05/01/"
End If
End Sub
Public Sub getParams(ByVal BegDate As Date, ByVal EndDate As Date, ByVal
GroupNum As String)
crParameterFieldDefinitions = oRpt.DataDefinition.ParameterFields
'Access the specified parameter from the collection
crParameterValues =
crParameterFieldDefinitions.Item("@BegDate").Curre ntValues
crParameterValues2 =
crParameterFieldDefinitions.Item("@EndDate").Curre ntValues
crParameterValues3 =
crParameterFieldDefinitions.Item("@GRNUM").Current Values
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = GroupNum
crParameterValues3.Add(crParameterDiscreteValue)
crParameterFieldDefinitions.Item("@GRNUM").ApplyCu rrentValues(crParameterVal
ues3)
'Set the current values for the numeric parameter field
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = BegDate
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinitions.Item("@BegDate").Apply CurrentValues(crParameterV
alues)
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = EndDate
crParameterValues2.Add(crParameterDiscreteValue)
crParameterFieldDefinitions.Item("@EndDate").Apply CurrentValues(crParameterV
alues2)
undwrtr = "001"
End Sub
Public Sub ProcFund()
If msg = MsgBoxResult.Yes Then
disptext = disptext & "Exporting Report " & ExportFileName & " to PDF in " &
exportFilePath & vbCrLf
RichTextBox1.Text = disptext
Call PDFDoc()
disptext = disptext & "Report(s) exported to: '" & exportFilePath & "'" &
vbCrLf
RichTextBox1.Text = disptext
ElseIf msg = MsgBoxResult.No Then
response = MsgBox("Do you want to view " & ExportFileName,
MsgBoxStyle.YesNo)
If response = MsgBoxResult.Yes Then
crview.Show()
crview.CrystalReportViewer1.ReportSource = oRpt
response1 = MsgBox("Do you want to PDF " & ExportFileName,
MsgBoxStyle.YesNo)
If response1 = MsgBoxResult.Yes Then
disptext = disptext & "Exporting Report " & ExportFileName & " to PDF in " &
exportFilePath & vbCrLf
RichTextBox1.Text = disptext
Call PDFDoc()
End If
ElseIf response = MsgBoxResult.No Then
response1 = MsgBox("Do you want to PDF " & ExportFileName,
MsgBoxStyle.YesNo)
If response1 = MsgBoxResult.Yes Then
disptext = disptext & "Exporting Report " & ExportFileName & " to PDF in " &
exportFilePath & vbCrLf
RichTextBox1.Text = disptext
Call PDFDoc()
End If
End If
RichTextBox1.Text = disptext & "Report(s) exported to: '" & exportFilePath &
"'" & vbCrLf
End If
End Sub
Public Sub LoadRpt(ByVal rptname As String)
oRpt = New ReportDocument()
disptext = "" & vbCrLf
oRpt.Load(lblDirPath.Text & "\" & rptname,
OpenReportMethod.OpenReportByTempCopy)
Call connectDB()
End Sub
Public Sub procReports(ByVal Dateval1 As String, ByVal Dateval2 As Date,
ByVal expfname As String, ByVal YTDFlag As Integer)
msg = MsgBox("Do you just want to PDF all selected fund reports or view the
fund reports individually. Yes will PDF all the Funds without displaying and
No will display further options", MsgBoxStyle.YesNoCancel)
For i = 0 To CheckedListBox1.CheckedItems.Count - 1
RichTextBox1.Text = "Processing Group # " & CheckedListBox1.CheckedItems(i)
& ". Please Wait" & vbCrLf
If YTDFlag = 1 Then
Call FundBegDates()
BegDate = YTD & Year(Today)
If Today > BegDate Then
If Month(Today) = Month(BegDate) And Year(Today) = Year(BegDate) Then
Dateval1 = YTD & (Year(Today) - 1)
Else
Dateval1 = BegDate
End If
ElseIf Today < BegDate Then
Dateval1 = YTD & (Year(Today) - 1)
End If
End If
Call getParams(CDate(Dateval1), Dateval2,
Mid(CheckedListBox1.CheckedItems(i), 1, 3))
ExportFileName = Mid(CheckedListBox1.CheckedItems(i), 1, 4) & "_CLASS
STATISTICAL_" & expfname & ".pdf"
dtFolder = DateFunc(Year(LastDayOfMonth(Today)),
Month(LastDayOfMonth(Today)),
Microsoft.VisualBasic.Day(LastDayOfMonth(Today)))
If lblSavPath.Text <> "" Then
Exportpath = lblSavPath.Text
exportFilePath = Exportpath & "\" & ExportFileName
Else
Exportpath = "L:\" & Mid(CheckedListBox1.CheckedItems(i), 1, 4) & "\E2\" &
dtFolder & "\"
Call CheckDir()
End If
Call ProcFund()
Next
RichTextBox1.Text = disptext & "Finished processing All Groups"
End Sub
Public Function FirstDayOfMonth(ByVal CurDate)
FirstDayOfMonth = DateSerial(Year(CurDate), Month(CurDate) - 1, 1)
End Function
Public Function LastDayOfMonth(ByVal CurDate)
LastDayOfMonth = DateSerial(Year(CurDate), Month(CurDate), 0)
End Function
Private Sub btnDirPath_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDirPath.Click
dlg1.Title = "Set Report Folder"
dlg1.Filter = "Crystal Reports (*.rpt)|*.rpt|All Files (*.*)|*.*"
dlg1.InitialDirectory = "M:\MIS\Programming\Reports\"
If dlg1.ShowDialog() = DialogResult.OK Then
lblDirPath.Text = UCase(Path.GetDirectoryName(dlg1.FileName))
End If
End Sub
Private Sub btnSavRpt_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSavRpt.Click
dlg2.Title = "Save Report"
dlg2.Filter = "Adobe Acrobat (*.pdf)|*.pdf|All Files (*.*)|*.*"
dlg2.InitialDirectory = "L:\"
If dlg2.ShowDialog() = DialogResult.OK Then
lblSavPath.Text = UCase(Path.GetDirectoryName(dlg2.FileName))
End If
End Sub
Public Function DateFunc(ByVal YYYY As String, ByVal MM As String, ByVal DD
As String)
If MM < 10 Then
MM = "0" & MM
ElseIf DD < 10 Then
DD = "0" & DD
End If
DateFunc = YYYY & MM & DD
End Function
Public Sub CheckDir()
If Directory.Exists(Exportpath) Then
exportFilePath = Exportpath & ExportFileName
Else
Directory.CreateDirectory(Exportpath)
exportFilePath = Exportpath & ExportFileName
End If
End Sub
Private Sub cmdEnd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEnd.Click
End
End Sub
Public Sub procClassStat()
If checkFund() = 1 Then
Exit Sub
End If
Call LoadRpt("AllProductsMonthlyClassStatisticalReport_ V1.rpt")
Call procReports(FirstDayOfMonth(Today), LastDayOfMonth(Today), _
(Month(LastDayOfMonth(Today)) & "-" &
Microsoft.VisualBasic.Day(LastDayOfMonth(Today)) & "-" &
Year(LastDayOfMonth(Today))), 0)
End Sub
Public Sub procClassStatByDate()
If checkFund() = 1 Then
Exit Sub
End If
Call LoadRpt("AllProductsMonthlyClassStatisticalReport_ V1.rpt")
Call procReports(DateTimePicker1.Value, DateTimePicker2.Value, _
(Month(DateTimePicker1.Value) & "-" &
Microsoft.VisualBasic.Day(DateTimePicker1.Value) _
& "-" & Year(DateTimePicker1.Value) & _
"_TO_" & Month(DateTimePicker2.Value) & "-" &
Microsoft.VisualBasic.Day(DateTimePicker2.Value) & _
"-" & Year(DateTimePicker2.Value)), 0)
End Sub
Public Sub procClassStatYTD()
If checkFund() = 1 Then
Exit Sub
End If
Call LoadRpt("AllProductsMonthlyClassStatisticalReport_ V1.rpt")
Call procReports("", LastDayOfMonth(Today), _
("YTD_" & Month(LastDayOfMonth(Today)) & "-" &
Microsoft.VisualBasic.Day(LastDayOfMonth(Today)) & "-" &
Year(LastDayOfMonth(Today))), 1)
End Sub
Public Sub procPPOAnalysis()
If checkFund() = 1 Then
Exit Sub
End If
Call LoadRpt("PPOReport.rpt")
Call procReports(DateTimePicker1.Value, DateTimePicker2.Value, _
(Month(DateTimePicker1.Value) & "-" &
Microsoft.VisualBasic.Day(DateTimePicker1.Value) _
& "-" & Year(DateTimePicker1.Value) & _
"_TO_" & Month(DateTimePicker2.Value) & "-" & Microsoft.VisualBasic.Day(Date
TimePicker2.Value) & _
"-" & Year(DateTimePicker2.Value)), 0)
End Sub
Private Sub btnRunReports_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnRunReports.Click
If CheckedListBox2.CheckedItems.Count = 0 Then
MsgBox("You must select at least one report to run", MsgBoxStyle.OKOnly, "
Alert")
CheckedListBox2.Focus()
Exit Sub
End If
For i = 0 To CheckedListBox2.CheckedItems.Count - 1
If CheckedListBox2.CheckedItems(i) = "Class Statistical Report - All Funds"
Then
Call procClassStat()
End If
Next
End Sub
End Class