Display Multiple rdlc files using one Report Viewer Control using vb.net

Good Morning! Sorry it has been so long. What have I been up to? Well work is crazy right now. Lots of long weekends, nights and such. I installed Windows 7 after recovering from my  hard drive crash, along with SQL 2008 and am learning my way around that. Positive results so far.

Anyway, I needed to display multiple rdlc files using one report viewer control. No sense in creating 50 of the controls right? So here it is. Make it a great day!


Join me on Facebook

Public Sub PrintOrder(ByVal orderToPrint As Dal.Model.Order)   
        Try
            Using rvf As New ReportViewForm()
                With rvf.TheReportViewer
                    rvf.FormCaption = "Order Report Viewer"
                    rvf.ReportDisplayName = String.Format("{0}-Order-{1}", Dal.MiscInterface.GetSalesmanNumber, orderToPrint.ID)
                    .ProcessingMode = ProcessingMode.Local
                    .LocalReport.ReportEmbeddedResource = "OE.OrderReportRegular.rdlc"
                    orderToPrint.LoadLineItems(Nothing)
                    Dim ol As New List(Of Dal.Model.Order)
                    ol.Add(orderToPrint)
                    .LocalReport.DataSources.Add(New ReportDataSource("Dal_Model_Order", ol))
                    .LocalReport.DataSources.Add(New ReportDataSource("Dal_Model_OrderLineItem", orderToPrint.LineItemList))
                    Dim parms() As ReportParameter = New ReportParameter(17) {}
                    parms(0) = New ReportParameter("BTCustomerName", orderToPrint.CustomerName)
                    parms(1) = New ReportParameter("BTCustomerFullAddr", orderToPrint.CustomerFullAddress)
                    parms(2) = New ReportParameter("STCustomerName", orderToPrint.ShipToName)
                    parms(3) = New ReportParameter("STCustomerFullAddr", orderToPrint.FullShipToAddress)
                    parms(4) = New ReportParameter("OrderId", orderToPrint.ID.ToString)
                    parms(5) = New ReportParameter("CombinedId", orderToPrint.CombinedId.ToString)
                    parms(6) = New ReportParameter("EntryDate", orderToPrint.OrderDate.ToShortDateString)
                    parms(7) = New ReportParameter("CustomerId", orderToPrint.CustomerNumber)
                    parms(8) = New ReportParameter("OrderType", orderToPrint.OrderTypeDescription)
                    parms(9) = New ReportParameter("DiscountPercentage", orderToPrint.CustomerDiscountPercentage.ToString)
                    parms(10) = New ReportParameter("SubTotal", orderToPrint.TotalDollars.ToString)
                    parms(11) = New ReportParameter("DiscountAmount", orderToPrint.CustomerDiscountAmount.ToString)
                    parms(12) = New ReportParameter("GrandTotal", orderToPrint.TotalDollarsLessCustDiscount.ToString)
                    parms(13) = New ReportParameter("ShipMethod", orderToPrint.ShipMethod.ToString)
                    parms(14) = New ReportParameter("CreditTerms", orderToPrint.CreditTermsDescription.ToString)
                    parms(15) = New ReportParameter("Status", orderToPrint.OrderStatusDesc.ToString)
                    parms(16) = New ReportParameter("DSCNumber", Dal.MiscInterface.GetSalesmanNumber)
                    parms(17) = New ReportParameter("CustomerNotes", orderToPrint.CustomerNotes(-1))
                    .LocalReport.SetParameters(parms)
                End With
                rvf.ToolBar.Items("uxEMail").Visible = True
                rvf.ToolBar.Items("uxExit").Visible = True
                frmWait.Hide()
                rvf.ShowDialog()
            End Using
        Catch ex As Exception
            ErrorHandler.DisplayAndLog(ex, "Problem while printing order.", True)
        End Try
    End Sub


Join me on Facebook

Technorati Tags: ,,,,,,,,,,,,,,

,,,,,,,

,,,,,,,,,

,,,

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: