Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports MySql.Data.MySqlClient
Imports System.Data
Public Class fclsShowReport
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
<code cut>
#End Region
Public conn As New MySqlConnection
Public comm As New MySqlCommand
Public da As New MySqlDataAdapter
Public dtcustomerinfo As New DataTable
Public dtaccountinfo As New DataTable
Public dstransactioninfo As New DataSet
Public rowindexdtcustomerinfo As New Double
Public rowindexdtaccountinfo As New Double
Public rowindexdttransactioninfo As New Double
Dim myReport As New ReportDocument
Public SQL As String
Private Sub fclsShowReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
crViewer.Width = fclsShowReport.ActiveForm.Width - 10
crViewer.Height = fclsShowReport.ActiveForm.Height - 10
SQL = "SELECT AccountNumber,Description,Amount,Date,customerinfo.CustID,TransactionNumber,LastName,FirstName FROM CustomerInfo INNER JOIN Transactions ON CustomerInfo.CustID = Transactions.CustID"
conn.ConnectionString = "server=localhost;user id=root;password=;database=finance_records"
Try
conn.Open()
comm.CommandText = SQL
comm.Connection = conn
da.SelectCommand = comm
da.Fill(dstransactioninfo)
myReport.Load("..\CustomerStatement.rpt")
myReport.SetDataSource(dstransactioninfo)
crViewer.ReportSource = myReport
Catch ex As Exception
MessageBox.Show(ex.Message, "Report could not be created", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub fclsShowReport_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
crViewer.Width = fclsShowReport.ActiveForm.Width - 10
crViewer.Height = fclsShowReport.ActiveForm.Height - 10
End Sub
End Class