Example #1
0
        private void LoadReport(string id)
        {
            try
            {
                rptViewer.ProcessingMode = ProcessingMode.Local;

                DataTable dt = ter.GetDispatch(id);

                ReportDataSource source1 = new ReportDataSource();
                source1.Name  = "DispatchPrint";
                source1.Value = dt;

                #region Report Parameters
                ReportParameter p1 = new ReportParameter("InvoiceID", this.id);
                rptViewer.LocalReport.SetParameters(p1);
                ReportParameter p2 = new ReportParameter("CustomerName", ter.GetCustomerName(this.id));
                rptViewer.LocalReport.SetParameters(p2);
                ReportParameter p3 = new ReportParameter("Date", System.DateTime.Now.ToShortDateString());
                rptViewer.LocalReport.SetParameters(p3);
                ReportParameter p4 = new ReportParameter("Quantity", ter.GetSumDetails(dt, 2).ToString());
                rptViewer.LocalReport.SetParameters(p4);
                #endregion

                rptViewer.LocalReport.DataSources.Clear();
                rptViewer.LocalReport.DataSources.Add(source1);

                rptViewer.LocalReport.Refresh();
                rptViewer.RefreshReport();
            }
            catch (Exception ee)
            {
                MessageBox.Show(this, ee.Message.ToString(), "Error Loading the Report", MessageBoxButtons.OK);
            }
        }