Ejemplo n.º 1
0
        private void GenerateReport()
        {
            try
            {
                if (dtpFromDate.Value != null && dtpFromDate.Value.Value.Year == 1753)
                {
                    dtpFromDate.Value = null;
                }

                if (dtpTillDate.Value != null && dtpTillDate.Value.Value.Year == 1753)
                {
                    dtpTillDate.Value = null;
                }

                DateTime?fromDate = dtpFromDate.Value.ToDateorNull();
                DateTime?tillDate = dtpTillDate.Value.ToDateorNull();


                var list = General.GetQueryable <Fleet_Driver>(c => c.Id == DriverId).ToList();

                string Driver = list.FirstOrDefault().DriverNo + " - " + list.FirstOrDefault().DriverName;

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    this.stp_DriverRatingResultBindingSource.DataSource = db.stp_DriverRating(fromDate, tillDate, DriverId).ToList().OrderByDescending(c => c.UpdatedOn);
                }

                Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[5];

                string address = AppVars.objSubCompany.Address;
                string telNo   = "Tel No. " + AppVars.objSubCompany.TelephoneNo;

                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Header", AppVars.objSubCompany.CompanyName.ToStr());
                param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);
                param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo);


                string heading = string.Empty;
                if (fromDate != null && tillDate != null)
                {
                    heading = string.Format("{0:dd/MM/yyyy}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy}", tillDate);
                }
                param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Criteria", heading);

                param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Driver", Driver);
                reportViewer1.LocalReport.SetParameters(param);



                this.reportViewer1.ZoomPercent = 100;
                this.reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
            }
        }