Exemplo n.º 1
0
        /// <summary>
        /// Получение/формирование параметров отчёта, DataSource (список сущностей для таблицы), пути файла и заголовка
        /// </summary>
        /// <inheritdoc />
        public void AdditionalInitializeComponent()
        {
            _reportFile = Common.GetReportFilePath(ReportFileName);                      // Путь к файлу отчёта

            // Запрос параметров отчёта в отдельном окне

            const bool   isPeriod         = false;
            const bool   isMounthOrYeath  = true;
            const bool   isWarehouse      = false;
            const bool   isWorkGuild      = false;
            const bool   isDate           = true;
            const bool   isDatePeriod     = false;
            const bool   isMonthYear      = false;
            const bool   isProduct        = true;
            const bool   isCompany        = false;
            const bool   isTypeProduct    = false;
            const bool   isFormaPayment   = false;
            const bool   isAbroad         = false;
            const string message          = "Выберите период выборки и продукт";
            var          parametersWindow = new ReportParametersWindow(isPeriod, isMounthOrYeath, isWarehouse,
                                                                       isWorkGuild, isDate, isDatePeriod, isMonthYear, isProduct, isCompany, isTypeProduct, isFormaPayment,
                                                                       isAbroad, message)
            {
                Owner = Common.GetOwnerWindow()
            };

            parametersWindow.ShowDialog();
            if (!parametersWindow.DialogResult.HasValue || parametersWindow.DialogResult != true)
            {
                return;
            }
            // Получение введённых пользователем параметров
            var monthOrYear          = parametersWindow.SelectedMonthOrYear();
            var nullableLoadDateTime = parametersWindow.SelectedDateTime();

            if (nullableLoadDateTime == null)
            {
                const string           errorMessage = "Дата не указана";
                const MessageBoxButton buttons      = MessageBoxButton.OK;
                const MessageBoxImage  messageType  = MessageBoxImage.Error;
                MessageBox.Show(errorMessage, PageLiterals.HeaderValidation, buttons, messageType);
                return;
            }
            var loadDateTime = (DateTime)nullableLoadDateTime;
            var product      = parametersWindow.SelectedProduct();

            // Формирование одиночных строковых параметров отчёта
            _reportParameters = new[] { new ReportParameter("Date", loadDateTime.ToShortDateString()) };
            try
            {
                var          resultReportList = ShipmentByProductService.GetShipmentByProduct(monthOrYear, loadDateTime, product);
                const string dataSourceName   = "ShipmentByProduct";
                _reportDataSource  = new ReportDataSource(dataSourceName, resultReportList);
                ReportViewer.Load += ReportViewer_Load;                     // Подписка на метод загрузки и отображения отчёта
            }
            catch (StorageException ex)
            {
                Common.ShowDetailExceptionMessage(ex);
            }
        }
        /// <summary>
        /// Получение/формирование параметров отчёта, DataSource (список сущностей для таблицы), пути файла и заголовка
        /// </summary>
        /// <inheritdoc />
        public void AdditionalInitializeComponent()
        {
            _reportFile = Common.GetReportFilePath(ReportFileName);          // Путь к файлу отчёта

            // Запрос параметров отчёта в отдельном окне

            const bool   isPeriod         = false;
            const bool   isMounthOrYeath  = true;
            const bool   isWarehouse      = false;
            const bool   isWorkGuild      = false;
            const bool   isDate           = true;
            const bool   isDatePeriod     = false;
            const bool   isMonthYear      = false;
            const bool   isProduct        = false;
            const bool   isCompany        = false;
            const bool   isTypeProduct    = false;
            const bool   isFormaPayment   = false;
            const bool   isAbroad         = false;
            const string message          = "Выберите период, дату";
            var          parametersWindow = new ReportParametersWindow(isPeriod, isMounthOrYeath, isWarehouse,
                                                                       isWorkGuild, isDate, isDatePeriod, isMonthYear, isProduct, isCompany, isTypeProduct, isFormaPayment,
                                                                       isAbroad, message)
            {
                Owner = Common.GetOwnerWindow()
            };

            parametersWindow.ShowDialog();
            if (!parametersWindow.DialogResult.HasValue || parametersWindow.DialogResult != true)
            {
                return;
            }

            // Получение введённых пользователем параметров
            var monthOrYear          = parametersWindow.SelectedMonthOrYear();
            var nullableLoadDateTime = parametersWindow.SelectedDateTime();

            if (nullableLoadDateTime == null)
            {
                const string           errorMessage = "Дата не указана";
                const MessageBoxButton buttons      = MessageBoxButton.OK;
                const MessageBoxImage  messageType  = MessageBoxImage.Error;
                MessageBox.Show(errorMessage, PageLiterals.HeaderValidation, buttons, messageType);
                return;
            }
            var endDate = (DateTime)nullableLoadDateTime;

            DateTime startDate = new DateTime(endDate.Year, 1, 1);

            // Формирование одиночных строковых параметров отчёта
            _reportParameters = new[]
            {
                new ReportParameter("Date", endDate.ToShortDateString()),
                new ReportParameter("Name", "Оборудование(скл.39)"),
                new ReportParameter("TodayYear", endDate.Year.ToString())
            };
            try
            {
                const string dataSourceName = "ExportAccounting";

                var resultReportList =
                    ExportAccountingService.GetExportAccountingsEquipment(startDate, endDate);

                if (monthOrYear == "m")
                {
                    var mounthNumber      = endDate.AddDays(-1).Month;
                    var resultReportList2 = new List <ExportAccounting>();
                    foreach (var item in resultReportList)
                    {
                        if (item.IdMonth == mounthNumber)
                        {
                            resultReportList2.Add(item);
                        }
                    }
                    _reportDataSource = new ReportDataSource(dataSourceName, resultReportList2);
                }
                else
                {
                    _reportDataSource = new ReportDataSource(dataSourceName, resultReportList);
                }

                ReportViewer.Load += ReportViewer_Load;     // Подписка на метод загрузки и отображения отчёта
            }
            catch (StorageException ex)
            {
                Common.ShowDetailExceptionMessage(ex);
            }
        }
        /// <summary>
        /// Получение/формирование параметров отчёта, DataSource (список сущностей для таблицы), пути файла и заголовка
        /// </summary>
        /// <inheritdoc />
        public void AdditionalInitializeComponent()
        {
            _reportFile = Common.GetReportFilePath(ReportFileName);          // Путь к файлу отчёта

            // Запрос параметров отчёта в отдельном окне

            const bool   isPeriod         = false;
            const bool   isMounthOrYeath  = false;
            const bool   isWarehouse      = false;
            const bool   isWorkGuild      = false;
            const bool   isDate           = true;
            const bool   isDatePeriod     = false;
            const bool   isMonthYear      = false;
            const bool   isProduct        = false;
            const bool   isCompany        = false;
            const bool   isTypeProduct    = false;
            const bool   isFormaPayment   = false;
            const bool   isAbroad         = false;
            const string message          = "Выберите дату";
            var          parametersWindow = new ReportParametersWindow(isPeriod, isMounthOrYeath, isWarehouse,
                                                                       isWorkGuild, isDate, isDatePeriod, isMonthYear, isProduct, isCompany, isTypeProduct, isFormaPayment,
                                                                       isAbroad, message)
            {
                Owner = Common.GetOwnerWindow()
            };

            parametersWindow.ShowDialog();
            if (!parametersWindow.DialogResult.HasValue || parametersWindow.DialogResult != true)
            {
                return;
            }

            // Получение введённых пользователем параметров
            var nullableLoadDateTime = parametersWindow.SelectedDateTime();

            if (nullableLoadDateTime == null)
            {
                const string           errorMessage = "Дата не указана";
                const MessageBoxButton buttons      = MessageBoxButton.OK;
                const MessageBoxImage  messageType  = MessageBoxImage.Error;
                MessageBox.Show(errorMessage, PageLiterals.HeaderValidation, buttons, messageType);
                return;
            }
            var endDate = (DateTime)nullableLoadDateTime;

            var startDate = new DateTime(endDate.AddDays(-1).Year - 1, 1, 1);

            // Формирование одиночных строковых параметров отчёта
            _reportParameters = new[]
            {
                new ReportParameter("Text", "готовой продукции по курсу на дату отгрузки"),
                new ReportParameter("Date", endDate.AddDays(-1).ToShortDateString()),
                new ReportParameter("OldYear", (endDate.AddDays(-1).Year - 1).ToString()),
                new ReportParameter("TodayYear", endDate.AddDays(-1).Year.ToString())
            };
            try
            {
                const string dataSourceName   = "ExportByTerritory";
                var          resultReportList =
                    ExportByTerritoryService.GetExportByTerritoryFinishedProductsByDateShipment(startDate, endDate);

                _reportDataSource  = new ReportDataSource(dataSourceName, resultReportList);
                ReportViewer.Load += ReportViewer_Load; // Подписка на метод загрузки и отображения отчёта
            }
            catch (StorageException ex)
            {
                Common.ShowDetailExceptionMessage(ex);
            }
        }
        /// <summary>
        /// Получение/формирование параметров отчёта, DataSource (список сущностей для таблицы), пути файла и заголовка
        /// </summary>
        /// <inheritdoc />
        public void AdditionalInitializeComponent()
        {
            _reportFile = Common.GetReportFilePath(ReportFileName);                      // Путь к файлу отчёта

            // Запрос параметров отчёта в отдельном окне

            const bool isPeriod        = true;
            const bool isMounthOrYeath = false;
            const bool isWarehouse     = false;
            const bool isWorkGuild     = false;
            const bool isDate          = false;
            const bool isDatePeriod    = false;
            const bool isMonthYear     = false;
            const bool isProduct       = false;
            const bool isCompany       = false;
            const bool isTypeProduct   = false;
            const bool isFormaPayment  = true;
            const bool isAbroad        = false;

            const string message          = "Выберите период, дату и оплату";
            var          parametersWindow = new ReportParametersWindow(isPeriod, isMounthOrYeath, isWarehouse,
                                                                       isWorkGuild, isDate, isDatePeriod, isMonthYear, isProduct, isCompany, isTypeProduct, isFormaPayment,
                                                                       isAbroad, message)
            {
                Owner = Common.GetOwnerWindow()
            };

            parametersWindow.ShowDialog();
            if (!parametersWindow.DialogResult.HasValue || parametersWindow.DialogResult != true)
            {
                return;
            }

            DateTime startDate;
            DateTime endDate;

            var period = parametersWindow.SelectedPeriod();

            if (period != "p")
            {
                // Получение введённых пользователем параметров
                var nullableLoadDateTime = parametersWindow.SelectedDateTime();
                if (nullableLoadDateTime == null)
                {
                    const string           errorMessage = "Дата не указана";
                    const MessageBoxButton buttons      = MessageBoxButton.OK;
                    const MessageBoxImage  messageType  = MessageBoxImage.Error;
                    MessageBox.Show(errorMessage, PageLiterals.HeaderValidation, buttons, messageType);
                    return;
                }

                var loadDateTime = (DateTime)nullableLoadDateTime;

                endDate   = loadDateTime.AddDays(-1);
                startDate = period == "m"
                                        ? Common.GetBeginOfMonthWithOffset(endDate)
                                        : new DateTime(endDate.Year, 1, 1);
            }
            else
            {
                // Получение введённых пользователем параметров
                var nullableStartDateTime = parametersWindow.SelectedDateTimeStart();
                var nullableEndDateTime   = parametersWindow.SelectedDateTimeEnd();
                if (nullableStartDateTime == null || nullableEndDateTime == null)
                {
                    const string           errorMessage = "Дата не указана";
                    const MessageBoxButton buttons      = MessageBoxButton.OK;
                    const MessageBoxImage  messageType  = MessageBoxImage.Error;
                    MessageBox.Show(errorMessage, PageLiterals.HeaderValidation, buttons, messageType);
                    return;
                }

                endDate   = ((DateTime)nullableEndDateTime).AddDays(-1);
                startDate = Common.GetBeginOfMonthWithOffset(endDate);
            }

            var formaPayment = parametersWindow.SelectedFormaPayment();

            // Формирование одиночных строковых параметров отчёта
            _reportParameters = new[]
            {
                new ReportParameter("StartDate", startDate.ToShortDateString()),
                new ReportParameter("EndDate", endDate.ToShortDateString())
            };
            try
            {
                var          resultReportList = ControlDebtsService.GetControlDebts(startDate, endDate, formaPayment);
                const string dataSourceName   = "ControlDebts";
                _reportDataSource  = new ReportDataSource(dataSourceName, resultReportList);
                ReportViewer.Load += ReportViewer_Load;                     // Подписка на метод загрузки и отображения отчёта
            }
            catch (StorageException ex)
            {
                Common.ShowDetailExceptionMessage(ex);
            }
        }
        /// <summary>
        /// Получение/формирование параметров отчёта, DataSource (список сущностей для таблицы), пути файла и заголовка
        /// </summary>
        /// <inheritdoc />
        public void AdditionalInitializeComponent()
        {
            _reportFile = Common.GetReportFilePath(ReportFileName);             // Путь к файлу отчёта

            // Запрос параметров отчёта в отдельном окне

            const bool isPeriod                  = false;
            const bool isMounthOrYeath           = false;
            const bool isDate                    = true;
            const bool isDatePeriod              = false;
            const bool isKoefT                   = true;
            const bool isKoefZ                   = true;
            const bool isWorkGuild               = false;
            const bool isArea                    = false;
            const bool isWorkGuildSpecifiedOrAll = false;
            const bool isProduct                 = false;
            const bool isDetail                  = false;
            const bool isProductSpecifiedOrAll   = false;
            const bool isAssemblyUnit            = false;
            const bool isMonthYear               = false;

            const bool isTimeFund                         = false;
            const bool isProcentageOfLossTime             = false;
            const bool isProcentageOfPerformanceStandarts = false;
            const bool isAreaSpecifiedOrAll               = false;

            const string message          = "Выберите дату";
            var          parametersWindow = new ReportParametersWindow(isPeriod, isMounthOrYeath, isDate, isDatePeriod, isKoefT,
                                                                       isKoefZ, isWorkGuild, isArea, isWorkGuildSpecifiedOrAll, isProduct, isDetail, isProductSpecifiedOrAll,
                                                                       isAssemblyUnit, isMonthYear, isTimeFund,
                                                                       isProcentageOfLossTime, isProcentageOfPerformanceStandarts, isAreaSpecifiedOrAll, message)
            {
                Owner = Common.GetOwnerWindow()
            };

            parametersWindow.ShowDialog();
            if (!parametersWindow.DialogResult.HasValue || parametersWindow.DialogResult != true)
            {
                return;
            }
            // Получение введённых пользователем параметров
            var nullableLoadDateTime = parametersWindow.SelectedDateTime();

            if (nullableLoadDateTime == null)
            {
                const string           errorMessage = "Дата не указана";
                const MessageBoxButton buttons      = MessageBoxButton.OK;
                const MessageBoxImage  messageType  = MessageBoxImage.Error;
                MessageBox.Show(errorMessage, PageLiterals.HeaderValidation, buttons, messageType);
                return;
            }
            var loadDateTime = (DateTime)nullableLoadDateTime;

            var nullableKoeft = parametersWindow.KoefTDecimalUpDown.Value;
            var nullableKoefz = parametersWindow.KoefZDecimalUpDown.Value;

            if (nullableKoeft == null || nullableKoefz == null)
            {
                const string           errorMessage = "Не указаны коэффициенты";
                const MessageBoxButton buttons      = MessageBoxButton.OK;
                const MessageBoxImage  messageType  = MessageBoxImage.Error;
                MessageBox.Show(errorMessage, PageLiterals.HeaderValidation, buttons, messageType);
                return;
            }

            var koefT = nullableKoeft;
            var koefZ = nullableKoefz;

            // Формирование одиночных строковых параметров отчёта
            _reportParameters = new[] { new ReportParameter("Date", loadDateTime.ToShortDateString()),
                                        new ReportParameter("Koeft", koefT.ToString()),
                                        new ReportParameter("Koefz", koefZ.ToString()) };
            try
            {
                var          resultReportList = SummeryOfProductsInContextOfWorkGuildService.GetSummeryOfProductsInContextOfWorkGuild();
                const string dataSourceName   = "SummeryOdProductInContextOfWorkGuild";
                _reportDataSource  = new ReportDataSource(dataSourceName, resultReportList);
                ReportViewer.Load += ReportViewer_Load;                     // Подписка на метод загрузки и отображения отчёта
            }
            catch (StorageException ex)
            {
                Common.ShowDetailExceptionMessage(ex);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Получение/формирование параметров отчёта, DataSource (список сущностей для таблицы), пути файла и заголовка
        /// </summary>
        /// <inheritdoc />
        public void AdditionalInitializeComponent()
        {
            _reportFile = Common.GetReportFilePath(ReportFileName);                      // Путь к файлу отчёта

            // Запрос параметров отчёта в отдельном окне

            const bool   isPeriod         = false;
            const bool   isMounthOrYeath  = true;
            const bool   isWarehouse      = false;
            const bool   isWorkGuild      = false;
            const bool   isDate           = true;
            const bool   isDatePeriod     = false;
            const bool   isMonthYear      = false;
            const bool   isProduct        = false;
            const bool   isCompany        = false;
            const bool   isTypeProduct    = false;
            const bool   isFormaPayment   = false;
            const bool   isAbroad         = false;
            const string message          = "Выберите период выборки";
            var          parametersWindow = new ReportParametersWindow(isPeriod, isMounthOrYeath, isWarehouse,
                                                                       isWorkGuild, isDate, isDatePeriod, isMonthYear, isProduct, isCompany, isTypeProduct, isFormaPayment,
                                                                       isAbroad, message)
            {
                Owner = Common.GetOwnerWindow()
            };

            parametersWindow.ShowDialog();
            if (!parametersWindow.DialogResult.HasValue || parametersWindow.DialogResult != true)
            {
                return;
            }
            // Получение введённых пользователем параметров
            var monthOrYear          = parametersWindow.SelectedMonthOrYear();
            var nullableLoadDateTime = parametersWindow.SelectedDateTime();

            if (nullableLoadDateTime == null)
            {
                const string           errorMessage = "Дата не указана";
                const MessageBoxButton buttons      = MessageBoxButton.OK;
                const MessageBoxImage  messageType  = MessageBoxImage.Error;
                MessageBox.Show(errorMessage, PageLiterals.HeaderValidation, buttons, messageType);
                return;
            }
            var loadDateTime = (DateTime)nullableLoadDateTime;

            var endDate   = loadDateTime.AddDays(-1);
            var startDate = endDate;

            if (monthOrYear == "m")
            {
                startDate = new DateTime(endDate.Year, endDate.Month, 1);
            }
            else if (monthOrYear == "y")
            {
                startDate = new DateTime(endDate.Year, 1, 1);
            }

            // Формирование одиночных строковых параметров отчёта
            var reportParameter = new ReportParameter("Report", "");

            switch (_num)
            {
            case 1:
                reportParameter = new ReportParameter("Report", "по учету");
                break;

            case 2:
                reportParameter = new ReportParameter("Report", "на дату отгрузки");
                break;
            }

            _reportParameters = new[]
            {
                new ReportParameter("StartDate", startDate.ToShortDateString()),
                new ReportParameter("EndDate", endDate.ToShortDateString()),
                reportParameter
            };

            try
            {
                var          resultReportList = ExportByTypeSupplyService.GetExportByTypeSupply(startDate, endDate, _num);
                const string dataSourceName   = "ExportByTypeSupply";
                _reportDataSource  = new ReportDataSource(dataSourceName, resultReportList);
                ReportViewer.Load += ReportViewer_Load;                         // Подписка на метод загрузки и отображения отчёта}
            }
            catch (StorageException ex)
            {
                Common.ShowDetailExceptionMessage(ex);
            }
        }