Example #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (!rdbIn.Checked && !rdbFrom.Checked)
            {
                lblPrintStatus.Text = "  Please choose date.";
            }
            else
            {
                lblPrintStatus.Text = string.Empty;

                //string exeFolder = Application.StartupPath;
                //string reportPath = Path.Combine(exeFolder, @"Reports\ExamineeCodeReport.rdlc");

                IList <ExamineeCodeReport> codeReports;
                ReportParameter[]          reportParameters = new ReportParameter[1];

                FrmReport frmReport = new FrmReport();

                if (rdbIn.Checked)
                {
                    //reportParameters[0] = new ReportParameter("ExamCodeDate", "Exam codes issued in " + dtpIn.Value.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture));
                    reportParameters[0] = new ReportParameter("ExamCodeDate", "Exam codes issued in " + dtpIn.Value.ToShortDateString());
                    codeReports         = _examineeTakeBLL.GetExamineeCodeReport(dtpIn.Value, null);

                    frmReport.LoadReport("ExamineeCodeReport", codeReports, "PresentationLayer.Reports.ExamineeCodeReport.rdlc", reportParameters);
                    frmReport.ShowDialog(this);
                }
                else
                {
                    if (dtpFrom.Value.Date >= dtpTo.Value.Date)
                    {
                        lblPrintStatus.Text = "  Invalid start date/end date.";
                    }
                    else
                    {
                        //reportParameters[0] =  new ReportParameter("ExamCodeDate", "Exam codes issued in " + dtpFrom.Value.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture) + " to " + dtpTo.Value.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture));
                        reportParameters[0] = new ReportParameter("ExamCodeDate", "Exam codes issued from " + dtpFrom.Value.ToShortDateString() + " to " + dtpTo.Value.Date.ToShortDateString());
                        codeReports         = _examineeTakeBLL.GetExamineeCodeReport(dtpFrom.Value, dtpTo.Value);

                        frmReport.LoadReport("ExamineeCodeReport", codeReports, "PresentationLayer.Reports.ExamineeCodeReport.rdlc", reportParameters);
                        frmReport.ShowDialog(this);
                    }
                }
            }
        }