починить пдфку

This commit is contained in:
dex_moth 2024-04-10 19:04:19 +04:00
parent f235faaa0c
commit c3d9757ad1
19 changed files with 244 additions and 234 deletions

View File

@ -14,8 +14,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Reporting.WinForms.v11" Version="1.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.19" />
</ItemGroup>
<ItemGroup>
@ -41,4 +41,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="ReportOrders.rdlc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -33,16 +33,16 @@
toolStripDropDownButton1 = new ToolStripDropDownButton();
компонентыToolStripMenuItem = new ToolStripMenuItem();
консервыToolStripMenuItem = new ToolStripMenuItem();
toolStripDropDownButton2 = new ToolStripDropDownButton();
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
компонентыПоКонсервамToolStripMenuItem = new ToolStripMenuItem();
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
buttonCreateOrder = new Button();
buttonTakeOrderInWork = new Button();
buttonOrderReady = new Button();
buttonIssuedOrder = new Button();
buttonRef = new Button();
dataGridView = new DataGridView();
toolStripDropDownButton2 = new ToolStripDropDownButton();
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem();
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
toolStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
@ -53,7 +53,7 @@
toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, toolStripDropDownButton2 });
toolStrip1.Location = new Point(0, 0);
toolStrip1.Name = "toolStrip1";
toolStrip1.Size = new Size(969, 25);
toolStrip1.Size = new Size(1107, 27);
toolStrip1.TabIndex = 0;
toolStrip1.Text = "toolStrip1";
//
@ -64,28 +64,61 @@
toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image");
toolStripDropDownButton1.ImageTransparentColor = Color.Magenta;
toolStripDropDownButton1.Name = "toolStripDropDownButton1";
toolStripDropDownButton1.Size = new Size(88, 22);
toolStripDropDownButton1.Size = new Size(108, 24);
toolStripDropDownButton1.Text = "Справочник";
//
// компонентыToolStripMenuItem
//
компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem";
компонентыToolStripMenuItem.Size = new Size(145, 22);
компонентыToolStripMenuItem.Size = new Size(182, 26);
компонентыToolStripMenuItem.Text = "Компоненты";
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
//
// консервыToolStripMenuItem
//
консервыToolStripMenuItem.Name = онсервыToolStripMenuItem";
консервыToolStripMenuItem.Size = new Size(145, 22);
консервыToolStripMenuItem.Size = new Size(182, 26);
консервыToolStripMenuItem.Text = "Консервы";
консервыToolStripMenuItem.Click += консервыToolStripMenuItem_Click;
//
// toolStripDropDownButton2
//
toolStripDropDownButton2.DisplayStyle = ToolStripItemDisplayStyle.Text;
toolStripDropDownButton2.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоКонсервамToolStripMenuItem, списокЗаказовToolStripMenuItem });
toolStripDropDownButton2.Image = (Image)resources.GetObject("toolStripDropDownButton2.Image");
toolStripDropDownButton2.ImageTransparentColor = Color.Magenta;
toolStripDropDownButton2.Name = "toolStripDropDownButton2";
toolStripDropDownButton2.Size = new Size(73, 24);
toolStripDropDownButton2.Text = "Отчёты";
//
// списокКомпонентовToolStripMenuItem
//
списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
списокКомпонентовToolStripMenuItem.Size = new Size(284, 26);
списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click;
//
// компонентыПоКонсервамToolStripMenuItem
//
компонентыПоКонсервамToolStripMenuItem.Name = омпонентыПоКонсервамToolStripMenuItem";
компонентыПоКонсервамToolStripMenuItem.Size = new Size(284, 26);
компонентыПоКонсервамToolStripMenuItem.Text = "Компоненты по консервам";
компонентыПоКонсервамToolStripMenuItem.Click += компонентыПоИзделиямToolStripMenuItem_Click;
//
// списокЗаказовToolStripMenuItem
//
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
списокЗаказовToolStripMenuItem.Size = new Size(284, 26);
списокЗаказовToolStripMenuItem.Text = "Список заказов";
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
//
// buttonCreateOrder
//
buttonCreateOrder.Location = new Point(800, 56);
buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonCreateOrder.Location = new Point(914, 75);
buttonCreateOrder.Margin = new Padding(3, 4, 3, 4);
buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.Size = new Size(141, 24);
buttonCreateOrder.Size = new Size(161, 32);
buttonCreateOrder.TabIndex = 1;
buttonCreateOrder.Text = "Создать заказ";
buttonCreateOrder.UseVisualStyleBackColor = true;
@ -93,9 +126,11 @@
//
// buttonTakeOrderInWork
//
buttonTakeOrderInWork.Location = new Point(800, 100);
buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonTakeOrderInWork.Location = new Point(914, 133);
buttonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4);
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonTakeOrderInWork.Size = new Size(141, 24);
buttonTakeOrderInWork.Size = new Size(161, 32);
buttonTakeOrderInWork.TabIndex = 2;
buttonTakeOrderInWork.Text = "Отдать на выполнение";
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
@ -103,9 +138,11 @@
//
// buttonOrderReady
//
buttonOrderReady.Location = new Point(800, 142);
buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonOrderReady.Location = new Point(914, 189);
buttonOrderReady.Margin = new Padding(3, 4, 3, 4);
buttonOrderReady.Name = "buttonOrderReady";
buttonOrderReady.Size = new Size(141, 24);
buttonOrderReady.Size = new Size(161, 32);
buttonOrderReady.TabIndex = 3;
buttonOrderReady.Text = "Заказ готов";
buttonOrderReady.UseVisualStyleBackColor = true;
@ -113,9 +150,11 @@
//
// buttonIssuedOrder
//
buttonIssuedOrder.Location = new Point(800, 181);
buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonIssuedOrder.Location = new Point(914, 241);
buttonIssuedOrder.Margin = new Padding(3, 4, 3, 4);
buttonIssuedOrder.Name = "buttonIssuedOrder";
buttonIssuedOrder.Size = new Size(141, 24);
buttonIssuedOrder.Size = new Size(161, 32);
buttonIssuedOrder.TabIndex = 4;
buttonIssuedOrder.Text = "Заказ выдан";
buttonIssuedOrder.UseVisualStyleBackColor = true;
@ -123,9 +162,11 @@
//
// buttonRef
//
buttonRef.Location = new Point(800, 222);
buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonRef.Location = new Point(914, 296);
buttonRef.Margin = new Padding(3, 4, 3, 4);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(141, 24);
buttonRef.Size = new Size(161, 32);
buttonRef.TabIndex = 5;
buttonRef.Text = "Обновить список";
buttonRef.UseVisualStyleBackColor = true;
@ -134,51 +175,21 @@
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(0, 26);
dataGridView.Location = new Point(0, 27);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 24;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(763, 435);
dataGridView.Size = new Size(872, 588);
dataGridView.TabIndex = 6;
//
// toolStripDropDownButton2
//
toolStripDropDownButton2.DisplayStyle = ToolStripItemDisplayStyle.Text;
toolStripDropDownButton2.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem });
toolStripDropDownButton2.Image = (Image)resources.GetObject("toolStripDropDownButton2.Image");
toolStripDropDownButton2.ImageTransparentColor = Color.Magenta;
toolStripDropDownButton2.Name = "toolStripDropDownButton2";
toolStripDropDownButton2.Size = new Size(61, 22);
toolStripDropDownButton2.Text = "Отчёты";
//
// списокКомпонентовToolStripMenuItem
//
списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
списокКомпонентовToolStripMenuItem.Size = new Size(225, 22);
списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click;
//
// компонентыПоИзделиямToolStripMenuItem
//
компонентыПоИзделиямToolStripMenuItem.Name = омпонентыПоИзделиямToolStripMenuItem";
компонентыПоИзделиямToolStripMenuItem.Size = new Size(225, 22);
компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по консервам";
компонентыПоИзделиямToolStripMenuItem.Click += компонентыПоИзделиямToolStripMenuItem_Click;
//
// списокЗаказовToolStripMenuItem
//
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
списокЗаказовToolStripMenuItem.Size = new Size(225, 22);
списокЗаказовToolStripMenuItem.Text = "Список заказов";
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(969, 461);
ClientSize = new Size(1107, 615);
Controls.Add(dataGridView);
Controls.Add(buttonRef);
Controls.Add(buttonIssuedOrder);
@ -186,6 +197,7 @@
Controls.Add(buttonTakeOrderInWork);
Controls.Add(buttonCreateOrder);
Controls.Add(toolStrip1);
Margin = new Padding(3, 4, 3, 4);
Name = "FormMain";
Text = "Рыбный завод";
Load += FormMain_Load;
@ -210,7 +222,7 @@
private ToolStripMenuItem консервыToolStripMenuItem;
private ToolStripDropDownButton toolStripDropDownButton2;
private ToolStripMenuItem списокКомпонентовToolStripMenuItem;
private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem;
private ToolStripMenuItem компонентыПоКонсервамToolStripMenuItem;
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
}
}

View File

@ -10,11 +10,12 @@ namespace FishFactory.Forms
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_reportLogic = reportLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
@ -150,7 +151,7 @@ namespace FishFactory.Forms
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel
_reportLogic.SaveCannedsToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});

View File

@ -124,7 +124,7 @@
<data name="toolStripDropDownButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
@ -139,12 +139,12 @@
<data name="toolStripDropDownButton2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEISURBVEhL3ZErDsJAGIR7DlA47oArV8CDR9RiSDAQPBcA
Qx1BgUMQBEk1ooJAKE0I4Wlqf5gmu1n6oqW7hiZfthkx33aqeZ5HKvEFpmmSYRhSQScXINB1XSroDAke
96cUpAmupyPZsx7Z8x4drAnPpQmsgU7LdoHDJNIEYjnAlyBXJ3jPhVyaYLca8nLMhX+CPJXAOT+ouTj5
p5in4asApdWpS8XRwT+zShIFG/fOyxlZJbGC9f5G5bHzUf6LJFJQqTViyxlxEmRiHhLUW10qDbeRpUGC
ErwjE/OQoG9dIsviYGWsXMwxc24BYLcO5pgZc+cWJIG5MbsyAUDnHwlUAkFHJZraR9NeMVq3zi+WF/0A
AAAASUVORK5CYII=
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAEKSURBVEhL3ZG9DsFQHMXvczDZvIOtXsHObuhqkViI3Quw
6CYmNoMYJJ0NBiFFIoIytOuf0+TeXP3yde+iyS+3OcP53Z4y3/dJJ4HAsiwyTVMp6BQCBIZhKAWdEcHV
vSlBmeB82NFy1KLluEWOPRC5MoHdMWhazwi4RJlALgf4EuT6BI+5kCsTrGddUY658E+QvyXYHq9UnRyC
U87f4aUApcXhnrI9Jzg/laQKFntXlHM+lSQK5psL5fvbp/JvJLGCQqmSWM5JkiCT84igXGtSrruKLQ0T
luAdmZxHBG37FFuWBC/j5XKOmX8WAH7rcI6ZMffPgjQwN2bXJgDo/COBTpjneQ2dML0PY3cISreGe8HM
qgAAAABJRU5ErkJggg==
</value>
</data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -30,17 +30,18 @@
{
buttonSaveToExcel = new Button();
dataGridView = new DataGridView();
Component = new DataGridViewTextBoxColumn();
Canned = new DataGridViewTextBoxColumn();
Count = new DataGridViewTextBoxColumn();
Canned = new DataGridViewTextBoxColumn();
Component = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonSaveToExcel
//
buttonSaveToExcel.Location = new Point(27, 15);
buttonSaveToExcel.Location = new Point(31, 19);
buttonSaveToExcel.Margin = new Padding(3, 4, 3, 4);
buttonSaveToExcel.Name = "buttonSaveToExcel";
buttonSaveToExcel.Size = new Size(160, 23);
buttonSaveToExcel.Size = new Size(183, 29);
buttonSaveToExcel.TabIndex = 0;
buttonSaveToExcel.Text = "Сохранить в Excel";
buttonSaveToExcel.UseVisualStyleBackColor = true;
@ -51,39 +52,45 @@
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Component, Canned, Count });
dataGridView.Location = new Point(0, 47);
dataGridView.Location = new Point(0, 60);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(799, 438);
dataGridView.Size = new Size(913, 555);
dataGridView.TabIndex = 1;
//
// Component
//
Component.HeaderText = "Компонент";
Component.Name = "Component";
Component.ReadOnly = true;
//
// Canned
//
Canned.HeaderText = "Консервы";
Canned.Name = "Canned";
//
// Count
//
Count.HeaderText = "Количество";
Count.MinimumWidth = 6;
Count.Name = "Count";
Count.ReadOnly = true;
//
// Canned
//
Canned.HeaderText = "Консервы";
Canned.MinimumWidth = 6;
Canned.Name = "Canned";
//
// Component
//
Component.HeaderText = "Компонент";
Component.MinimumWidth = 6;
Component.Name = "Component";
Component.ReadOnly = true;
//
// FormReportCannedComponents
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 19F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(801, 484);
ClientSize = new Size(915, 613);
Controls.Add(dataGridView);
Controls.Add(buttonSaveToExcel);
Margin = new Padding(3, 4, 3, 4);
Name = "FormReportCannedComponents";
Text = "Компоненты по консервам";
Load += FormReportCannedComponents_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}

View File

@ -18,14 +18,14 @@ namespace FishFactory.Forms
{
try
{
var dict = _logic.GetCannedComponent();
var dict = _logic.GetCannedComponents();
if (dict != null)
{
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
foreach (var listElem in elem.Canneds)
dataGridView.Rows.Add(new object[] { elem.CannedName, "", "" });
foreach (var listElem in elem.Components)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}
@ -33,11 +33,11 @@ namespace FishFactory.Forms
dataGridView.Rows.Add(Array.Empty<object>());
}
}
_logger.LogInformation("Загрузка списка изделий по компонентам");
_logger.LogInformation("Загрузка списка консерв по компонентам");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
_logger.LogError(ex, "Ошибка загрузки списка консерв по компонентам");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
@ -57,13 +57,13 @@ namespace FishFactory.Forms
{
FileName = dialog.FileName
});
_logger.LogInformation("Сохранение списка изделий по компонентам");
_logger.LogInformation("Сохранение списка консерв по компонентам");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
_logger.LogError(ex, "Ошибка сохранения списка консерв по компонентам");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

View File

@ -34,27 +34,32 @@
label1 = new Label();
label2 = new Label();
panel = new Panel();
buttonSaveToPdf = new Button();
panel.SuspendLayout();
SuspendLayout();
//
// dateTimePickerFrom
//
dateTimePickerFrom.Location = new Point(33, 7);
dateTimePickerFrom.Location = new Point(38, 12);
dateTimePickerFrom.Margin = new Padding(3, 4, 3, 4);
dateTimePickerFrom.Name = "dateTimePickerFrom";
dateTimePickerFrom.Size = new Size(149, 23);
dateTimePickerFrom.Size = new Size(170, 27);
dateTimePickerFrom.TabIndex = 0;
//
// dateTimePickerTo
//
dateTimePickerTo.Location = new Point(215, 7);
dateTimePickerTo.Location = new Point(246, 12);
dateTimePickerTo.Margin = new Padding(3, 4, 3, 4);
dateTimePickerTo.Name = "dateTimePickerTo";
dateTimePickerTo.Size = new Size(149, 23);
dateTimePickerTo.Size = new Size(170, 27);
dateTimePickerTo.TabIndex = 1;
//
// buttonMake
//
buttonMake.Location = new Point(570, 7);
buttonMake.Location = new Point(597, 13);
buttonMake.Margin = new Padding(3, 4, 3, 4);
buttonMake.Name = "buttonMake";
buttonMake.Size = new Size(120, 23);
buttonMake.Size = new Size(137, 31);
buttonMake.TabIndex = 2;
buttonMake.Text = "Сформировать";
buttonMake.UseVisualStyleBackColor = true;
@ -63,43 +68,58 @@
// label1
//
label1.AutoSize = true;
label1.Location = new Point(14, 12);
label1.Location = new Point(15, 16);
label1.Name = "label1";
label1.Size = new Size(15, 15);
label1.Size = new Size(18, 20);
label1.TabIndex = 3;
label1.Text = "С";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(192, 11);
label2.Location = new Point(218, 15);
label2.Name = "label2";
label2.Size = new Size(21, 15);
label2.Size = new Size(27, 20);
label2.TabIndex = 4;
label2.Text = "по";
//
// panel
//
panel.Location = new Point(0, 36);
panel.Controls.Add(buttonSaveToPdf);
panel.Controls.Add(dateTimePickerFrom);
panel.Controls.Add(label2);
panel.Controls.Add(dateTimePickerTo);
panel.Controls.Add(label1);
panel.Controls.Add(buttonMake);
panel.Dock = DockStyle.Top;
panel.Location = new Point(0, 0);
panel.Margin = new Padding(3, 3, 3, 4);
panel.Name = "panel";
panel.Size = new Size(802, 418);
panel.Size = new Size(941, 51);
panel.TabIndex = 5;
//
// buttonSaveToPdf
//
buttonSaveToPdf.Location = new Point(749, 13);
buttonSaveToPdf.Name = "buttonSaveToPdf";
buttonSaveToPdf.Size = new Size(140, 31);
buttonSaveToPdf.TabIndex = 6;
buttonSaveToPdf.Text = "Сохранить в pdf";
buttonSaveToPdf.UseVisualStyleBackColor = true;
buttonSaveToPdf.Click += buttonSaveToPdf_Click;
//
// FormReportOrders
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
ClientSize = new Size(941, 723);
Controls.Add(panel);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(buttonMake);
Controls.Add(dateTimePickerTo);
Controls.Add(dateTimePickerFrom);
Margin = new Padding(3, 4, 3, 4);
Name = "FormReportOrders";
Text = "Заказы";
panel.ResumeLayout(false);
panel.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
@ -110,5 +130,6 @@
private Label label1;
private Label label2;
private Panel panel;
private Button buttonSaveToPdf;
}
}

View File

@ -10,8 +10,8 @@ namespace FishFactory.Forms
private readonly ReportViewer reportViewer;
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public FormReportOrders(ILogger<FormReportOrders> logger, IReportLogic
logic)
public FormReportOrders(ILogger<FormReportOrders> logger, IReportLogic logic)
{
InitializeComponent();
_logger = logger;
@ -20,8 +20,7 @@ namespace FishFactory.Forms
{
Dock = DockStyle.Fill
};
reportViewer.LocalReport.LoadReportDefinition(new
FileStream("ReportOrders.rdlc", FileMode.Open));
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open));
Controls.Clear();
Controls.Add(reportViewer);
Controls.Add(panel);
@ -43,10 +42,10 @@ namespace FishFactory.Forms
var source = new ReportDataSource("DataSetOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source);
var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c" +
$"{dateTimePickerFrom.Value.ToShortDateString()} по" +
$"{dateTimePickerTo.Value.ToShortDateString()}") };
var parameters = new[] { new ReportParameter("ReportParameterPeriod",
$"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
reportViewer.LocalReport.SetParameters(parameters);
reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
}
@ -56,7 +55,7 @@ namespace FishFactory.Forms
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonToPdf_Click(object sender, EventArgs e)
private void buttonSaveToPdf_Click(object sender, EventArgs e)
{
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
{
@ -83,7 +82,7 @@ namespace FishFactory.Forms
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

View File

@ -2,10 +2,12 @@ using FishFactory.Forms;
using FishFactoryContracts.BusinessLogicsContracts;
using FishFactoryBusinessLogic.BusinessLogic;
using FishFactoryContracts.StoragesContracts;
using FishFactoryDatabaseImplement.Implements;
using FishFactoryFileImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using FishFactoryBusinessLogic.OfficePackage;
using FishFactoryBusinessLogic.OfficePackage.Implements;
namespace FishFactory
{
@ -42,6 +44,9 @@ namespace FishFactory
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ICannedLogic, CannedLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();

View File

@ -11,59 +11,31 @@ namespace FishFactoryBusinessLogic.BusinessLogic
public class ReportLogic : IReportLogic
{
private readonly IComponentStorage _componentStorage;
private readonly ICannedStorage _CannedStorage;
private readonly ICannedStorage _cannedStorage;
private readonly IOrderStorage _orderStorage;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(ICannedStorage CannedStorage, IComponentStorage
componentStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord,
AbstractSaveToPdf saveToPdf)
public ReportLogic(ICannedStorage CannedStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_CannedStorage = CannedStorage;
_cannedStorage = CannedStorage;
_componentStorage = componentStorage;
_orderStorage = orderStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
}
/// <summary>
/// Получение списка компонент с указанием, в каких изделиях используются
/// </summary>
/// <returns></returns>
public List<ReportCannedComponentViewModel> GetCannedComponent()
public List<ReportCannedComponentViewModel> GetCannedComponents()
{
var components = _componentStorage.GetFullList();
var Canneds = _CannedStorage.GetFullList();
var list = new List<ReportCannedComponentViewModel>();
foreach (var component in components)
return _cannedStorage.GetFullList().Select( x => new ReportCannedComponentViewModel
{
var record = new ReportCannedComponentViewModel
{
ComponentName = component.ComponentName,
Canneds = new List<Tuple<string, int>>(),
TotalCount = 0
};
foreach (var Canned in Canneds)
{
if (Canned.CannedComponents.ContainsKey(component.Id))
{
record.Canneds.Add(new Tuple<string,
int>(Canned.CannedName, Canned.CannedComponents[component.Id].Item2));
record.TotalCount +=
Canned.CannedComponents[component.Id].Item2;
}
}
list.Add(record);
}
return list;
CannedName = x.CannedName,
Components = x.CannedComponents.Select(x => (x.Value.Item1.ComponentName, x.Value.Item2)).ToList(),
TotalCount = x.CannedComponents.Select(x => x.Value.Item2).Sum()
}).ToList();
}
/// <summary>
/// Получение списка заказов за определенный период
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
{
return _orderStorage.GetFilteredList(new OrderSearchModel
@ -76,40 +48,32 @@ namespace FishFactoryBusinessLogic.BusinessLogic
Id = x.Id,
DateCreate = x.DateCreate,
CannedName = x.CannedName,
Sum = x.Sum
Sum = x.Sum,
Status = x.Status.ToString()
})
.ToList();
}
/// <summary>
/// Сохранение компонент в файл-Word
/// </summary>
/// <param name="model"></param>
public void SaveComponentsToWordFile(ReportBindingModel model)
public void SaveCannedsToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список компонент",
Title = "Список консерв",
Components = _componentStorage.GetFullList()
});
}
/// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel
/// </summary>
/// <param name="model"></param>
public void SaveCannedComponentToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Список компонент",
CannedComponents = GetCannedComponent()
Title = "Список консерв",
CannedComponents = GetCannedComponents()
});
}
/// <summary>
/// Сохранение заказов в файл-Pdf
/// </summary>
/// <param name="model"></param>
public void SaveOrdersToPdfFile(ReportBindingModel model)
{
_saveToPdf.CreateDoc(new PdfInfo

View File

@ -5,13 +5,10 @@ namespace FishFactoryBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToExcel
{
/// <summary>
/// Создание отчета
/// </summary>
/// <param name="info"></param>
public void CreateReport(ExcelInfo info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
@ -31,28 +28,27 @@ namespace FishFactoryBusinessLogic.OfficePackage
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.ComponentName,
Text = pc.CannedName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var Canned in pc.Canneds)
foreach (var Component in pc.Components)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = Canned.Item1,
StyleInfo =
ExcelStyleInfoType.TextWithBroder
Text = Component.Item1,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = Canned.Item2.ToString(),
StyleInfo =
ExcelStyleInfoType.TextWithBroder
Text = Component.Item2.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters
@ -73,27 +69,13 @@ namespace FishFactoryBusinessLogic.OfficePackage
}
SaveExcel(info);
}
/// <summary>
/// Создание excel-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreateExcel(ExcelInfo info);
/// <summary>
/// Добавляем новую ячейку в лист
/// </summary>
/// <param name="cellParameters"></param>
protected abstract void InsertCellInWorksheet(ExcelCellParameters
excelParams);
/// <summary>
/// Объединение ячеек
/// </summary>
/// <param name="mergeParameters"></param>
protected abstract void MergeCells(ExcelMergeParameters excelParams);
/// <summary>
/// Сохранение файла
/// </summary>
/// <param name="info"></param>
protected abstract void SaveExcel(ExcelInfo info);
protected abstract void CreateExcel(ExcelInfo info);
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
protected abstract void MergeCells(ExcelMergeParameters excelParams);
protected abstract void SaveExcel(ExcelInfo info);
}
}

View File

@ -16,8 +16,7 @@ namespace FishFactoryBusinessLogic.OfficePackage.Implements
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
private static JustificationValues
GetJustificationValues(WordJustificationType type)
private static JustificationValues GetJustificationValues(WordJustificationType type)
{
return type switch
{
@ -45,8 +44,7 @@ namespace FishFactoryBusinessLogic.OfficePackage.Implements
/// </summary>
/// <param name="paragraphProperties"></param>
/// <returns></returns>
private static ParagraphProperties?
CreateParagraphProperties(WordTextProperties? paragraphProperties)
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
{
if (paragraphProperties == null)
{
@ -62,6 +60,7 @@ namespace FishFactoryBusinessLogic.OfficePackage.Implements
LineRule = LineSpacingRuleValues.Auto
});
properties.AppendChild(new Indentation());
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
if (!string.IsNullOrEmpty(paragraphProperties.Size))
{

View File

@ -9,7 +9,7 @@ namespace FishFactoryContracts.BusinessLogicsContracts
/// Получение списка компонент с указанием, в каких изделиях используются
/// </summary>
/// <returns></returns>
List<ReportCannedComponentViewModel> GetCannedComponent();
List<ReportCannedComponentViewModel> GetCannedComponents();
/// <summary>
/// Получение списка заказов за определенный период
/// </summary>
@ -20,7 +20,7 @@ namespace FishFactoryContracts.BusinessLogicsContracts
/// Сохранение компонент в файл-Word
/// </summary>
/// <param name="model"></param>
void SaveComponentsToWordFile(ReportBindingModel model);
void SaveCannedsToWordFile(ReportBindingModel model);
/// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel
/// </summary>

View File

@ -2,8 +2,8 @@
{
public class ReportCannedComponentViewModel
{
public string ComponentName { get; set; } = string.Empty;
public string CannedName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<Tuple<string, int>> Canneds { get; set; } = new();
public List<(string Component, int Count)> Components { get; set; } = new();
}
}

View File

@ -7,6 +7,6 @@ namespace FishFactoryContracts.ViewModels
public DateTime DateCreate { get; set; }
public string CannedName { get; set; } = string.Empty;
public double Sum { get; set; }
public string Status { get; set; } = string.Empty;
}
}

View File

@ -9,7 +9,7 @@ namespace FishFactoryDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql(@"Host=localhost;Database=FishFactory2;Username=postgres;Password=postgres");
optionsBuilder.UseNpgsql(@"Host=localhost;Database=FishFactory;Username=postgres;Password=postgres");
}
base.OnConfiguring(optionsBuilder);
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);

View File

@ -19,11 +19,21 @@ namespace FishFactoryDatabaseImplement.Implements
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
if (!model.Id.HasValue || !model.DateFrom.HasValue || !model.DateTo.HasValue)
{
return new();
}
using var context = new FishFactoryDatabase();
if (model.DateFrom.HasValue)
{
return context.Orders
.Include(x => x.Canned)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Orders
.Include(x => x.Canned)
.Where(x => x.Id == model.Id)

View File

@ -3,6 +3,7 @@ using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels;
using FishFactoryFileImplement.Models;
using System.Reflection;
using System.Xml.Linq;
namespace FishFactoryFileImplement.Implements
@ -18,15 +19,15 @@ namespace FishFactoryFileImplement.Implements
public List<OrderViewModel> GetFullList()
{
return _source.Orders.Select(x => AttachCannedName(x)).ToList();
return _source.Orders.Select(x => AttachCannedName(x.GetViewModel)).ToList();
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (model == null || !model.Id.HasValue)
if (!model.Id.HasValue || !model.DateFrom.HasValue || !model.DateTo.HasValue)
{
return new();
}
return _source.Orders.Where(x => x.Id == model.Id).Select(x => AttachCannedName(x)).ToList();
return _source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => AttachCannedName(x.GetViewModel)).ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
@ -34,7 +35,7 @@ namespace FishFactoryFileImplement.Implements
{
return null;
}
return AttachCannedName(_source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id));
return AttachCannedName(_source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel);
}
public OrderViewModel? Insert(OrderBindingModel model)
{
@ -46,7 +47,7 @@ namespace FishFactoryFileImplement.Implements
}
_source.Orders.Add(newOrder);
_source.SaveOrders();
return AttachCannedName(newOrder);
return AttachCannedName(newOrder.GetViewModel);
}
public OrderViewModel? Update(OrderBindingModel model)
{
@ -57,7 +58,7 @@ namespace FishFactoryFileImplement.Implements
}
order.Update(model);
_source.SaveOrders();
return AttachCannedName(order);
return AttachCannedName(order.GetViewModel);
}
public OrderViewModel? Delete(OrderBindingModel model)
{
@ -68,17 +69,20 @@ namespace FishFactoryFileImplement.Implements
}
_source.Orders.Remove(order);
_source.SaveOrders();
return AttachCannedName(order);
return AttachCannedName(order.GetViewModel);
}
private OrderViewModel AttachCannedName(Order order)
private OrderViewModel? AttachCannedName(OrderViewModel? model)
{
var viewModel = order.GetViewModel;
var canned = _source.Canneds.FirstOrDefault(x => x.Id == order.CannedId);
if (model == null)
{
return null;
}
var canned = _source.Canneds.FirstOrDefault(x => x.Id == model.CannedId);
if (canned != null)
{
viewModel.CannedName = canned.CannedName;
model.CannedName = canned.CannedName;
}
return viewModel;
return model;
}
}
}

View File

@ -33,13 +33,13 @@ namespace FishFactoryListImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (model == null || !model.Id.HasValue)
if (model == null || !model.Id.HasValue || !model.DateFrom.HasValue || !model.DateFrom.HasValue)
{
return result;
}
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
{
result.Add(AttachCannedName(order.GetViewModel));
}