Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
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
Posted
Comments
Suvendu Shekhar Giri 28-Nov-15 0:19am    
Have you debugged?
What are your findings after debug?
ZurdoDev 28-Nov-15 15:57pm    
What does "the 2nd is not working" mean? Are there errors? Does it now show at all? Does it show but something is wrong?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900