Imports Microsoft.Reporting.WinForms Public Class ReportsMain Public Property strReport As String Dim rptDataSource As ReportDataSource Private Sub Reports_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Try With Me.rptviewer.LocalReport .ReportPath = "GymSystem\ReportX\" & strReport & ".rdlc" .DataSources.Clear() End With Select Case strReport Case "Receipt" Dim ds As New GymSystem.Receipt Dim da As New GymSystem.ReceiptTableAdapters.Tbl_ReceiptTableAdapter AddHandler rptviewer.LocalReport.SubreportProcessing, AddressOf Me.subreportProcessingEventHandler da.Fill(ds.Tbl_Receipt, TextBox1.Text) rptDataSource = New ReportDataSource("Receipt", ds.Tables("Tbl_Receipt")) End Select Me.rptviewer.LocalReport.DataSources.Add(rptDataSource) Me.rptviewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.Normal) Catch ex As Exception MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Public Sub subreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs) Try Dim zrpt = e.ReportPath Select Case zrpt Case "Sales" Dim ds As New GymSystem.Sales Dim da As New GymSystem.SalesTableAdapters.Tbl_SalesTableAdapter da.Fill(ds.Tbl_Sales, TextBox1.Text) e.DataSources.Add(New ReportDataSource("Sales", ds.Tables("Tbl_Sales"))) Case "Equip" Dim ds As New GymSystem.Esales Dim da As New GymSystem.EsalesTableAdapters.Tbl_EsalesTableAdapter da.Fill(ds.Tbl_Esales, TextBox1.Text) rptDataSource = New ReportDataSource("Equip", ds.Tables("Tbl_Esales")) End Select Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)