самый стандартный пдф документ который работает
This commit is contained in:
parent
c716bda901
commit
489be1deb8
@ -16,6 +16,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" />
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -3,6 +3,7 @@ using BusinessLogic.OfficePackage.HelperModels;
|
|||||||
using MigraDoc.DocumentObjectModel;
|
using MigraDoc.DocumentObjectModel;
|
||||||
using MigraDoc.DocumentObjectModel.Tables;
|
using MigraDoc.DocumentObjectModel.Tables;
|
||||||
using MigraDoc.Rendering;
|
using MigraDoc.Rendering;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace BusinessLogic.OfficePackage.Implements
|
namespace BusinessLogic.OfficePackage.Implements
|
||||||
{
|
{
|
||||||
|
13
WinFormsApp/FormMain.Designer.cs
generated
13
WinFormsApp/FormMain.Designer.cs
generated
@ -35,6 +35,7 @@
|
|||||||
поставщикиToolStripMenuItem = new ToolStripMenuItem();
|
поставщикиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
buttonSupplyStatusArriving = new Button();
|
buttonSupplyStatusArriving = new Button();
|
||||||
buttonSupplyStatusCompleted = new Button();
|
buttonSupplyStatusCompleted = new Button();
|
||||||
|
buttonCreateReport = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -101,11 +102,22 @@
|
|||||||
buttonSupplyStatusCompleted.UseVisualStyleBackColor = true;
|
buttonSupplyStatusCompleted.UseVisualStyleBackColor = true;
|
||||||
buttonSupplyStatusCompleted.Click += buttonSupplyStatusCompleted_Click;
|
buttonSupplyStatusCompleted.Click += buttonSupplyStatusCompleted_Click;
|
||||||
//
|
//
|
||||||
|
// buttonCreateReport
|
||||||
|
//
|
||||||
|
buttonCreateReport.Location = new Point(707, 190);
|
||||||
|
buttonCreateReport.Name = "buttonCreateReport";
|
||||||
|
buttonCreateReport.Size = new Size(154, 44);
|
||||||
|
buttonCreateReport.TabIndex = 5;
|
||||||
|
buttonCreateReport.Text = "Сформировать отчет о поставке";
|
||||||
|
buttonCreateReport.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateReport.Click += buttonCreateReport_Click;
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(901, 384);
|
ClientSize = new Size(901, 384);
|
||||||
|
Controls.Add(buttonCreateReport);
|
||||||
Controls.Add(buttonSupplyStatusCompleted);
|
Controls.Add(buttonSupplyStatusCompleted);
|
||||||
Controls.Add(buttonSupplyStatusArriving);
|
Controls.Add(buttonSupplyStatusArriving);
|
||||||
Controls.Add(buttonCreateSupply);
|
Controls.Add(buttonCreateSupply);
|
||||||
@ -131,5 +143,6 @@
|
|||||||
private ToolStripMenuItem поставщикиToolStripMenuItem;
|
private ToolStripMenuItem поставщикиToolStripMenuItem;
|
||||||
private Button buttonSupplyStatusArriving;
|
private Button buttonSupplyStatusArriving;
|
||||||
private Button buttonSupplyStatusCompleted;
|
private Button buttonSupplyStatusCompleted;
|
||||||
|
private Button buttonCreateReport;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,13 +22,15 @@ namespace WinFormsApp
|
|||||||
private readonly ISupplyLogic _supplyLogic;
|
private readonly ISupplyLogic _supplyLogic;
|
||||||
private readonly IProductLogic _productLogic;
|
private readonly IProductLogic _productLogic;
|
||||||
private readonly ISupplierLogic _supplierLogic;
|
private readonly ISupplierLogic _supplierLogic;
|
||||||
public FormMain(ILogger<FormMain> logger, ISupplierLogic supplierLogic, ISupplyLogic supplyLogic, IProductLogic productLogic)
|
private readonly IReportLogic _reportLogic;
|
||||||
|
public FormMain(ILogger<FormMain> logger, ISupplierLogic supplierLogic, ISupplyLogic supplyLogic, IProductLogic productLogic, IReportLogic reportLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_supplierLogic = supplierLogic;
|
_supplierLogic = supplierLogic;
|
||||||
_supplyLogic = supplyLogic;
|
_supplyLogic = supplyLogic;
|
||||||
_productLogic = productLogic;
|
_productLogic = productLogic;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_reportLogic = reportLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
@ -136,5 +138,34 @@ namespace WinFormsApp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonCreateReport_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count != 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите одну поставку для формирования отчета", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportLogic.SaveSuppliesToPdfFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = dialog.FileName,
|
||||||
|
Date = (DateTime)dataGridView.SelectedRows[0].Cells["Date"].Value,
|
||||||
|
SupplyId = (Guid)dataGridView.SelectedRows[0].Cells["Id"].Value
|
||||||
|
});
|
||||||
|
_logger.LogInformation("Сохранение отчета о поставке");
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения отчета о поставке");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ using Contracts.BusinessLogicContracts;
|
|||||||
using BusinessLogic.BusinessLogic;
|
using BusinessLogic.BusinessLogic;
|
||||||
using BusinessLogic.OfficePackage.Implements;
|
using BusinessLogic.OfficePackage.Implements;
|
||||||
using BusinessLogic.OfficePackage;
|
using BusinessLogic.OfficePackage;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace WinFormsApp
|
namespace WinFormsApp
|
||||||
{
|
{
|
||||||
@ -21,6 +22,8 @@ namespace WinFormsApp
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
@ -46,6 +49,7 @@ namespace WinFormsApp
|
|||||||
services.AddTransient<ISupplierLogic, SupplierLogic>();
|
services.AddTransient<ISupplierLogic, SupplierLogic>();
|
||||||
services.AddTransient<IProductLogic, ProductLogic>();
|
services.AddTransient<IProductLogic, ProductLogic>();
|
||||||
services.AddTransient<IMediaFileLogic, MediaFileLogic>();
|
services.AddTransient<IMediaFileLogic, MediaFileLogic>();
|
||||||
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user