Пример #1
0
        public void ShowReport(DebtType type, int month, int year)
        {
            var reportParam = new Report1ParamForm(type, month, year);

            if (reportParam.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            type  = reportParam.DebtProperties.DebtType;
            month = reportParam.DebtProperties.Month;
            year  = reportParam.DebtProperties.Year;

            string reportCaption = string.Format("Отчет по {0} задолженности за {1} месяц {2} года", (type == DebtType.Кредиторская ? "кредиторской" : "дебиторской"), DebtUtil.GetMonthName(month).ToLower(), year);
            string reportName    = (reportParam.GroupBySubjects ? reportName = "CI.Debt.Reports.Report1.rdlc" : "CI.Debt.Reports.Report2.rdlc");

            var reportForm = new ReportForm();

            reportForm.Text = reportCaption;
            reportForm.reportViewer.LocalReport.ReportEmbeddedResource = reportName;
            reportForm.reportViewer.LocalReport.DisplayName            = reportCaption;
            reportForm.reportViewer.LocalReport.SetParameters(new[] { new ReportParameter("pCaption", reportCaption) });

            reportForm.Show();


            IList <DebtRow> rows = null;

            if (reportParam.GroupBySubjects && 0 < reportParam.comboBoxBudgetName.SelectedIndex)
            {
                rows = DebtDAO.GetDebtRows(type, month, year, (string)reportParam.comboBoxBudgetName.SelectedItem);
            }
            else
            {
                rows = DebtDAO.GetDebtRows(type, month, year);
            }
            var reportRows = new List <Report1Row>();

            foreach (var row in rows)
            {
                reportRows.Add(new Report1Row(row));
            }

            reportForm.reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Report1Row", reportRows));
            reportForm.reportViewer.RefreshReport();

            reportForm.reportViewer.SetDisplayMode(DisplayMode.PrintLayout);
            reportForm.reportViewer.ZoomMode    = ZoomMode.Percent;
            reportForm.reportViewer.ZoomPercent = 100;
        }
Пример #2
0
        private void buttonExport_Click(object sender, EventArgs e)
        {
            if (exportFolderBrowser.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try {
                string fileName = Path.Combine(
                    exportFolderBrowser.SelectedPath,
                    string.Format("{0}_{1}_{2}.xml", debtDocProperties.DebtType.ToString(), DebtUtil.GetMonthName(debtDocProperties.Month), debtDocProperties.Year)
                    );
                XmlDebtRowsSerializer.Serialize(DebtDAO.GetDebtRows(debtDocProperties.DebtType, debtDocProperties.Month, debtDocProperties.Year), fileName);
                MessageBox.Show(string.Format("Экспорт успешно завершен.\r\nФайл экспорта: {0}", fileName), Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex) {
                MessageBox.Show("При экспорте возникло програмное исключение. Экспорт не выполнен.\r\nТекст ошибки: " + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }