переделано в List<Turple>, добавлен обработчик исключения на метод SavePdf
This commit is contained in:
parent
1aa25cc87c
commit
f45e4cfaee
1
SushiBar/FormReportOrders.Designer.cs
generated
1
SushiBar/FormReportOrders.Designer.cs
generated
@ -118,7 +118,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private GroupBox groupBox1;
|
|
||||||
private Panel panel;
|
private Panel panel;
|
||||||
private DateTimePicker dateTimePickerDateTo;
|
private DateTimePicker dateTimePickerDateTo;
|
||||||
private DateTimePicker dateTimePickerDateFrom;
|
private DateTimePicker dateTimePickerDateFrom;
|
||||||
|
@ -2,15 +2,6 @@
|
|||||||
using Microsoft.Reporting.WinForms;
|
using Microsoft.Reporting.WinForms;
|
||||||
using SushiBarContracts.BindingModel;
|
using SushiBarContracts.BindingModel;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
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
|
namespace SushiBarView.Reports
|
||||||
{
|
{
|
||||||
@ -53,9 +44,9 @@ namespace SushiBarView.Reports
|
|||||||
var source = new ReportDataSource("DataSetOrders", dataSource);
|
var source = new ReportDataSource("DataSetOrders", dataSource);
|
||||||
reportViewer.LocalReport.DataSources.Clear();
|
reportViewer.LocalReport.DataSources.Clear();
|
||||||
reportViewer.LocalReport.DataSources.Add(source);
|
reportViewer.LocalReport.DataSources.Add(source);
|
||||||
var parameters = new[] { new ReportParameter("ReportParameterPeriod",
|
var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c {dateTimePickerDateFrom.Value.ToShortDateString()} по {dateTimePickerDateTo.Value.ToShortDateString()}") };
|
||||||
$"c {dateTimePickerDateFrom.Value.ToShortDateString()} по {dateTimePickerDateTo.Value.ToShortDateString()}")
|
|
||||||
};
|
// ЗДЕСЬ ПРОИСХОДИТ ОШИБКА И ВЫБРАСЫВАЕТСЯ ИСКЛЮЧЕНИЕ
|
||||||
reportViewer.LocalReport.SetParameters(parameters);
|
reportViewer.LocalReport.SetParameters(parameters);
|
||||||
reportViewer.RefreshReport();
|
reportViewer.RefreshReport();
|
||||||
_logger.LogInformation("Загрузка списка заказов на период {From}-{To}",
|
_logger.LogInformation("Загрузка списка заказов на период {From}-{To}",
|
||||||
@ -82,6 +73,7 @@ namespace SushiBarView.Reports
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// ВОТ ЗДЕСЬ ТОЖЕ СРАЗУ ИСКЛЮЧЕНИЕ
|
||||||
_logic.SaveOrdersToPdfFile(new ReportBindingModel
|
_logic.SaveOrdersToPdfFile(new ReportBindingModel
|
||||||
{
|
{
|
||||||
FileName = dialog.FileName,
|
FileName = dialog.FileName,
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
@ -11,8 +11,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
private Document? _document;
|
private Document? _document;
|
||||||
private Section? _section;
|
private Section? _section;
|
||||||
private Table? _table;
|
private Table? _table;
|
||||||
private static ParagraphAlignment
|
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||||
GetParagraphAlignment(PdfParagraphAlignmentType type)
|
|
||||||
{
|
{
|
||||||
return type switch
|
return type switch
|
||||||
{
|
{
|
||||||
@ -88,12 +87,28 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
}
|
}
|
||||||
protected override void SavePdf(PdfInfo info)
|
protected override void SavePdf(PdfInfo info)
|
||||||
{
|
{
|
||||||
var renderer = new PdfDocumentRenderer(true)
|
if (_document != null)
|
||||||
{
|
{
|
||||||
Document = _document
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
};
|
{
|
||||||
renderer.RenderDocument();
|
|
||||||
renderer.PdfDocument.Save(info.FileName);
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,14 +41,14 @@ namespace SushiBarBusinessLogic
|
|||||||
var record = new ReportSushisComponentViewModel
|
var record = new ReportSushisComponentViewModel
|
||||||
{
|
{
|
||||||
ComponentName = component.ComponentName,
|
ComponentName = component.ComponentName,
|
||||||
Sushis = new List<(string, int)>(),
|
Sushis = new List<Tuple<string, int>>(),
|
||||||
TotalCount = 0
|
TotalCount = 0
|
||||||
};
|
};
|
||||||
foreach (var sushi in sushis)
|
foreach (var sushi in sushis)
|
||||||
{
|
{
|
||||||
if (sushi.SushiComponents.ContainsKey(component.Id))
|
if (sushi.SushiComponents.ContainsKey(component.Id))
|
||||||
{
|
{
|
||||||
record.Sushis.Add(new (sushi.SushiName, sushi.SushiComponents[component.Id].Item2));
|
record.Sushis.Add(new Tuple<string, int>(sushi.SushiName, sushi.SushiComponents[component.Id].Item2));
|
||||||
record.TotalCount += sushi.SushiComponents[component.Id].Item2;
|
record.TotalCount += sushi.SushiComponents[component.Id].Item2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
public int TotalCount { get; set; }
|
public int TotalCount { get; set; }
|
||||||
public List<(string Sushi, int Count)> Sushis { get; set; } = new();
|
public List<Tuple<string, int>> Sushis { get; set; } = new();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user