Esempio n. 1
0
        /// <summary>
        /// Init report from type
        /// </summary>
        /// <returns></returns>
        private XtraReport InitReport(int reportId)
        {
            // get report from database
            var report = ReportDynamicController.GetById(reportId);

            // check result
            if (report != null)
            {
                // init XtraReport
                XtraReport xReport;

                switch (report.Template)
                {
                case ReportTemplate.EnterprisePayroll:
                    // return payroll
                    xReport = InitPayrollReport(report);
                    break;

                default:
                    // invalid report template
                    return(null);
                }

                // set window filter props
                txtReportTitle.Text         = report.Title;
                txtSelectedDepartments.Text = hdfSelectedDepartmentNames.Text;
                dfReportDate.SelectedDate   = report.ReportDate;
                dfStartDate.SelectedDate    = report.StartDate;
                dfEndDate.SelectedDate      = report.EndDate;
                if (string.IsNullOrEmpty(txtCreatedByTitle.Text))
                {
                    txtCreatedByTitle.Text = report.CreatedByTitle;
                }
                if (string.IsNullOrEmpty(txtCreatedByNote.Text))
                {
                    txtCreatedByNote.Text = report.CreatedByNote;
                }
                if (string.IsNullOrEmpty(txtCreatedByName.Text))
                {
                    txtCreatedByName.Text = report.CreatedByName;
                }
                if (string.IsNullOrEmpty(txtReviewedByTitle.Text))
                {
                    txtReviewedByTitle.Text = report.ReviewedByTitle;
                }
                if (string.IsNullOrEmpty(txtReviewedByNote.Text))
                {
                    txtReviewedByNote.Text = report.ReviewedByNote;
                }
                if (string.IsNullOrEmpty(txtReviewedByName.Text))
                {
                    txtReviewedByName.Text = report.ReviewedByName;
                }
                if (string.IsNullOrEmpty(txtSignedByTitle.Text))
                {
                    txtSignedByTitle.Text = report.SignedByTitle;
                }
                if (string.IsNullOrEmpty(txtSignedByNote.Text))
                {
                    txtSignedByNote.Text = report.SignedByNote;
                }
                if (string.IsNullOrEmpty(txtSignedByName.Text))
                {
                    txtSignedByName.Text = report.SignedByName;
                }

                // return
                return(xReport);
            }

            // invalid report id
            return(null);
        }