работает

This commit is contained in:
ityurner02@mail.ru 2023-03-20 17:37:50 +04:00
parent d455459ca1
commit fc68f68e9b
4 changed files with 9 additions and 7 deletions

View File

@ -39,8 +39,8 @@ namespace PlumbingRepair
{ {
var dataSource = _logic.GetOrders(new ReportBindingModel var dataSource = _logic.GetOrders(new ReportBindingModel
{ {
DateFrom = dateTimePickerFrom.Value, DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc),
DateTo = dateTimePickerTo.Value DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc)
}); });
var source = new ReportDataSource("DataSetOrders", dataSource); var source = new ReportDataSource("DataSetOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Clear();
@ -61,6 +61,7 @@ namespace PlumbingRepair
private void ButtonToPdf_Click(object sender, EventArgs e) private void ButtonToPdf_Click(object sender, EventArgs e)
{ {
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
{ {
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
@ -74,8 +75,8 @@ namespace PlumbingRepair
_logic.SaveOrdersToPdfFile(new ReportBindingModel _logic.SaveOrdersToPdfFile(new ReportBindingModel
{ {
FileName = dialog.FileName, FileName = dialog.FileName,
DateFrom = dateTimePickerFrom.Value, DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc),
DateTo = dateTimePickerTo.Value DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc)
}); });
_logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); _logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);

View File

@ -15,6 +15,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" /> <PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" /> <PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
<PackageReference Include="System.Text.Encoding" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -95,8 +95,8 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список заказов", Title = "Список заказов",
DateFrom = model.DateFrom!.Value, DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
DateTo = model.DateTo!.Value, DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
Orders = GetOrders(model) Orders = GetOrders(model)
}); });
} }

View File

@ -44,7 +44,7 @@ namespace PlumbingRepairBusinessLogic.OfficePackage
} }
CreateParagraph(new PdfParagraph CreateParagraph(new PdfParagraph
{ {
Text = $"Total: {info.Orders.Sum(x => x.Sum)}\t", Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t",
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Rigth ParagraphAlignment = PdfParagraphAlignmentType.Rigth
}); });