diff --git a/SushiBar/FormReportOrders.Designer.cs b/SushiBar/FormReportOrders.Designer.cs index 38166b0..5de5bb9 100644 --- a/SushiBar/FormReportOrders.Designer.cs +++ b/SushiBar/FormReportOrders.Designer.cs @@ -118,7 +118,6 @@ } #endregion - private GroupBox groupBox1; private Panel panel; private DateTimePicker dateTimePickerDateTo; private DateTimePicker dateTimePickerDateFrom; diff --git a/SushiBar/FormReportOrders.cs b/SushiBar/FormReportOrders.cs index f13388b..22806f8 100644 --- a/SushiBar/FormReportOrders.cs +++ b/SushiBar/FormReportOrders.cs @@ -2,15 +2,6 @@ using Microsoft.Reporting.WinForms; using SushiBarContracts.BindingModel; using SushiBarContracts.BusinessLogicsContracts; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; namespace SushiBarView.Reports { @@ -53,9 +44,9 @@ namespace SushiBarView.Reports var source = new ReportDataSource("DataSetOrders", dataSource); reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Add(source); - var parameters = new[] { new ReportParameter("ReportParameterPeriod", - $"c {dateTimePickerDateFrom.Value.ToShortDateString()} по {dateTimePickerDateTo.Value.ToShortDateString()}") - }; + var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c {dateTimePickerDateFrom.Value.ToShortDateString()} по {dateTimePickerDateTo.Value.ToShortDateString()}") }; + + // ЗДЕСЬ ПРОИСХОДИТ ОШИБКА И ВЫБРАСЫВАЕТСЯ ИСКЛЮЧЕНИЕ reportViewer.LocalReport.SetParameters(parameters); reportViewer.RefreshReport(); _logger.LogInformation("Загрузка списка заказов на период {From}-{To}", @@ -82,6 +73,7 @@ namespace SushiBarView.Reports { try { + // ВОТ ЗДЕСЬ ТОЖЕ СРАЗУ ИСКЛЮЧЕНИЕ _logic.SaveOrdersToPdfFile(new ReportBindingModel { FileName = dialog.FileName, diff --git a/SushiBar/SushiBarView.csproj b/SushiBar/SushiBarView.csproj index 7fd8747..5a8e31d 100644 --- a/SushiBar/SushiBarView.csproj +++ b/SushiBar/SushiBarView.csproj @@ -9,7 +9,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs index 634e453..e9a7d3f 100644 --- a/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs +++ b/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -11,8 +11,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements private Document? _document; private Section? _section; private Table? _table; - private static ParagraphAlignment - GetParagraphAlignment(PdfParagraphAlignmentType type) + private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type) { return type switch { @@ -88,12 +87,28 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements } protected override void SavePdf(PdfInfo info) { - var renderer = new PdfDocumentRenderer(true) + if (_document != null) { - Document = _document - }; - renderer.RenderDocument(); - renderer.PdfDocument.Save(info.FileName); + var renderer = new PdfDocumentRenderer(true) + { + + Document = _document + }; + if (renderer.PdfDocument != null) + { + renderer.RenderDocument(); + renderer.PdfDocument.Save(info.FileName); + } + else + { + throw new NullReferenceException("renderer.RenderDocument is null"); + } + } + else + { + throw new NullReferenceException("_document is null"); + } + } } } diff --git a/SushiBarBusinessLogic/Reportlogic.cs b/SushiBarBusinessLogic/Reportlogic.cs index 55f9eca..8be5323 100644 --- a/SushiBarBusinessLogic/Reportlogic.cs +++ b/SushiBarBusinessLogic/Reportlogic.cs @@ -41,14 +41,14 @@ namespace SushiBarBusinessLogic var record = new ReportSushisComponentViewModel { ComponentName = component.ComponentName, - Sushis = new List<(string, int)>(), + Sushis = new List>(), TotalCount = 0 }; foreach (var sushi in sushis) { if (sushi.SushiComponents.ContainsKey(component.Id)) { - record.Sushis.Add(new (sushi.SushiName, sushi.SushiComponents[component.Id].Item2)); + record.Sushis.Add(new Tuple(sushi.SushiName, sushi.SushiComponents[component.Id].Item2)); record.TotalCount += sushi.SushiComponents[component.Id].Item2; } } diff --git a/SushiBarContracts/ViewModels/ReportSushiComponentViewModel.cs b/SushiBarContracts/ViewModels/ReportSushiComponentViewModel.cs index 3df6329..b43a7b3 100644 --- a/SushiBarContracts/ViewModels/ReportSushiComponentViewModel.cs +++ b/SushiBarContracts/ViewModels/ReportSushiComponentViewModel.cs @@ -4,7 +4,7 @@ { public string ComponentName { get; set; } = string.Empty; public int TotalCount { get; set; } - public List<(string Sushi, int Count)> Sushis { get; set; } = new(); + public List> Sushis { get; set; } = new(); } }