Example #1
0
        /// <summary>
        /// Creates and displays a report based on selected report type
        /// </summary>
        /// <param name="reportType">The type of report to create</param>
        private void CreateReport(ReportType reportType)
        {
            // check if start and end dates are valid
            if (!this.DatesWithinValidRange())
            {
                MessageBox.Show("Please ensure the start date is equal or earlier than the end date.");
                return;
            }

            ReportViewerForm reportViewerForm = new ReportViewerForm();
            this.BuildReport(reportType, reportViewerForm, this.SelectedStartDate, this.SelectedEndDate);
            reportViewerForm.Text = Regex.Replace(ReportNameDictionary[reportType], "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ");
            reportViewerForm.Show();
        }
Example #2
0
        /// <summary>
        /// Builds a report by using query results
        /// </summary>
        /// <param name="reportType">The type of report to build</param>
        /// <param name="reportViewerForm">The form used to show the report</param>
        /// <param name="startDate">The start date to get data from</param>
        /// <param name="endDate">The end date to get data till</param>
        private void BuildReport(ReportType reportType, ReportViewerForm reportViewerForm, DateTime startDate, DateTime endDate)
        {
            if (reportViewerForm == null)
            {
                throw new Exception();
            }

            string reportName = ReportNameDictionary[reportType]; // get report name from dicitionary
            reportViewerForm.ReportViewer.LocalReport.ReportPath = "..\\..\\Reporting\\" + reportName + ".rdlc"; // get report template file
            reportViewerForm.ReportViewer.LocalReport.DataSources.Clear();
            reportViewerForm.ReportViewer.LocalReport.DataSources.Add(new ReportDataSource(reportName + "DataSet", this.GetReportDataSource(reportType, startDate, endDate)));
        }