From 3b8c95a6eb98e00c8946bf1b35bc564fc6c7a093 Mon Sep 17 00:00:00 2001 From: Yourdax Date: Wed, 20 Mar 2024 11:08:09 +0400 Subject: [PATCH 1/4] =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/ReportBindingModel.cs | 10 ++++++++++ .../ViewModels/ReportCannedComponentViewModel.cs | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 FishFactoryContracts/BindingModels/ReportBindingModel.cs create mode 100644 FishFactoryContracts/ViewModels/ReportCannedComponentViewModel.cs diff --git a/FishFactoryContracts/BindingModels/ReportBindingModel.cs b/FishFactoryContracts/BindingModels/ReportBindingModel.cs new file mode 100644 index 0000000..bdaa762 --- /dev/null +++ b/FishFactoryContracts/BindingModels/ReportBindingModel.cs @@ -0,0 +1,10 @@ +namespace FishFactoryContracts.BindingModels +{ + public class ReportBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + + } +} diff --git a/FishFactoryContracts/ViewModels/ReportCannedComponentViewModel.cs b/FishFactoryContracts/ViewModels/ReportCannedComponentViewModel.cs new file mode 100644 index 0000000..f0e6170 --- /dev/null +++ b/FishFactoryContracts/ViewModels/ReportCannedComponentViewModel.cs @@ -0,0 +1,9 @@ +namespace FishFactoryContracts.ViewModels +{ + public class ReportCannedComponentViewModel + { + public string ComponentName { get; set; } = string.Empty; + public int TotalCount { get; set; } + public List> Canneds { get; set; } = new(); + } +} -- 2.25.1 From f235faaa0c4d97be61f3343acf571dbd58d029f1 Mon Sep 17 00:00:00 2001 From: Yourdax Date: Wed, 3 Apr 2024 11:13:23 +0400 Subject: [PATCH 2/4] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=B1=D0=B0=D0=B7=D0=B0,=20=D0=BE=D1=81=D1=82=D0=B0=D0=BB?= =?UTF-8?q?=D0=BE=D1=81=D1=8C:=20=D0=BE=D1=82=D1=87=D1=91=D1=82=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=B0=D0=BC,=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BA,=20=D1=8D=D0=BA=D1=81=D0=B5=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FishFactory/FishFactory.csproj | 16 + .../{ => Forms}/FormCanned.Designer.cs | 0 FishFactory/{ => Forms}/FormCanned.cs | 28 +- FishFactory/{ => Forms}/FormCanned.resx | 0 .../FormCannedComponent.Designer.cs | 0 .../{ => Forms}/FormCannedComponent.cs | 0 .../{ => Forms}/FormCannedComponent.resx | 0 .../{ => Forms}/FormCanneds.Designer.cs | 0 FishFactory/{ => Forms}/FormCanneds.cs | 0 FishFactory/{ => Forms}/FormCanneds.resx | 0 .../{ => Forms}/FormComponent.Designer.cs | 0 FishFactory/{ => Forms}/FormComponent.cs | 0 FishFactory/{ => Forms}/FormComponent.resx | 0 .../{ => Forms}/FormComponents.Designer.cs | 0 FishFactory/{ => Forms}/FormComponents.cs | 0 FishFactory/{ => Forms}/FormComponents.resx | 0 .../{ => Forms}/FormCreateOrder.Designer.cs | 0 FishFactory/{ => Forms}/FormCreateOrder.cs | 0 FishFactory/{ => Forms}/FormCreateOrder.resx | 0 FishFactory/{ => Forms}/FormMain.Designer.cs | 84 ++- FishFactory/{ => Forms}/FormMain.cs | 46 +- FishFactory/{ => Forms}/FormMain.resx | 13 +- .../FormReportCannedComponents.Designer.cs | 99 +++ .../Forms/FormReportCannedComponents.cs | 73 +++ .../Forms/FormReportCannedComponents.resx | 129 ++++ .../Forms/FormReportOrders.Designer.cs | 114 ++++ FishFactory/Forms/FormReportOrders.cs | 92 +++ FishFactory/Forms/FormReportOrders.resx | 120 ++++ FishFactory/Program.cs | 3 + FishFactory/Properties/Resources.Designer.cs | 63 ++ FishFactory/Properties/Resources.resx | 120 ++++ FishFactory/ReportOrders.rdlc | 599 ++++++++++++++++++ .../BusinessLogic/ReportLogic.cs | 125 ++++ .../FishFactoryBusinessLogic.csproj | 3 +- .../OfficePackage/AbstractSaveToExcel.cs | 99 +++ .../OfficePackage/AbstractSaveToPdf.cs | 75 +++ .../OfficePackage/AbstractSaveToWord.cs | 57 ++ .../HelperEnums/ExcelStyleInfoType.cs | 9 + .../HelperEnums/PdfParagraphAlignmentType.cs | 9 + .../HelperEnums/WordJustificationType.cs | 8 + .../HelperModels/ExcelCellParameters.cs | 13 + .../OfficePackage/HelperModels/ExcelInfo.cs | 16 + .../HelperModels/ExcelMergeParameters.cs | 9 + .../OfficePackage/HelperModels/PdfInfo.cs | 13 + .../HelperModels/PdfParagraph.cs | 11 + .../HelperModels/PdfRowParameters.cs | 11 + .../OfficePackage/HelperModels/WordInfo.cs | 11 + .../HelperModels/WordParagraph.cs | 9 + .../HelperModels/WordTextProperties.cs | 11 + .../OfficePackage/Implements/SaveToExcel.cs | 332 ++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 99 +++ .../OfficePackage/Implements/SaveToWord.cs | 122 ++++ .../BusinessLogicsContracts/IReportLogic.cs | 35 + .../SearchModels/OrderSearchModel.cs | 10 +- .../ViewModels/ReportOrdersViewModel.cs | 12 + .../Implements/CannedStorage.cs | 10 +- .../20240320065127_InitialCreate.Designer.cs | 2 +- .../FishFactoryDatabaseModelSnapshot.cs | 2 +- 58 files changed, 2646 insertions(+), 66 deletions(-) rename FishFactory/{ => Forms}/FormCanned.Designer.cs (100%) rename FishFactory/{ => Forms}/FormCanned.cs (86%) rename FishFactory/{ => Forms}/FormCanned.resx (100%) rename FishFactory/{ => Forms}/FormCannedComponent.Designer.cs (100%) rename FishFactory/{ => Forms}/FormCannedComponent.cs (100%) rename FishFactory/{ => Forms}/FormCannedComponent.resx (100%) rename FishFactory/{ => Forms}/FormCanneds.Designer.cs (100%) rename FishFactory/{ => Forms}/FormCanneds.cs (100%) rename FishFactory/{ => Forms}/FormCanneds.resx (100%) rename FishFactory/{ => Forms}/FormComponent.Designer.cs (100%) rename FishFactory/{ => Forms}/FormComponent.cs (100%) rename FishFactory/{ => Forms}/FormComponent.resx (100%) rename FishFactory/{ => Forms}/FormComponents.Designer.cs (100%) rename FishFactory/{ => Forms}/FormComponents.cs (100%) rename FishFactory/{ => Forms}/FormComponents.resx (100%) rename FishFactory/{ => Forms}/FormCreateOrder.Designer.cs (100%) rename FishFactory/{ => Forms}/FormCreateOrder.cs (100%) rename FishFactory/{ => Forms}/FormCreateOrder.resx (100%) rename FishFactory/{ => Forms}/FormMain.Designer.cs (63%) rename FishFactory/{ => Forms}/FormMain.cs (80%) rename FishFactory/{ => Forms}/FormMain.resx (89%) create mode 100644 FishFactory/Forms/FormReportCannedComponents.Designer.cs create mode 100644 FishFactory/Forms/FormReportCannedComponents.cs create mode 100644 FishFactory/Forms/FormReportCannedComponents.resx create mode 100644 FishFactory/Forms/FormReportOrders.Designer.cs create mode 100644 FishFactory/Forms/FormReportOrders.cs create mode 100644 FishFactory/Forms/FormReportOrders.resx create mode 100644 FishFactory/Properties/Resources.Designer.cs create mode 100644 FishFactory/Properties/Resources.resx create mode 100644 FishFactory/ReportOrders.rdlc create mode 100644 FishFactoryBusinessLogic/BusinessLogic/ReportLogic.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 FishFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 FishFactoryContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 FishFactoryContracts/ViewModels/ReportOrdersViewModel.cs diff --git a/FishFactory/FishFactory.csproj b/FishFactory/FishFactory.csproj index 07508e2..d544413 100644 --- a/FishFactory/FishFactory.csproj +++ b/FishFactory/FishFactory.csproj @@ -14,6 +14,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -25,4 +26,19 @@ + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/FishFactory/FormCanned.Designer.cs b/FishFactory/Forms/FormCanned.Designer.cs similarity index 100% rename from FishFactory/FormCanned.Designer.cs rename to FishFactory/Forms/FormCanned.Designer.cs diff --git a/FishFactory/FormCanned.cs b/FishFactory/Forms/FormCanned.cs similarity index 86% rename from FishFactory/FormCanned.cs rename to FishFactory/Forms/FormCanned.cs index 8b515ea..c6dd870 100644 --- a/FishFactory/FormCanned.cs +++ b/FishFactory/Forms/FormCanned.cs @@ -11,14 +11,14 @@ namespace FishFactory.Forms private readonly ILogger _logger; private readonly ICannedLogic _logic; private int? _id; - private Dictionary _productComponents; + private Dictionary _CannedComponents; public int Id { set { _id = value; } } public FormCanned(ILogger logger, ICannedLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; - _productComponents = new Dictionary(); + _CannedComponents = new Dictionary(); } private void FormCanned_Load(object sender, EventArgs e) { @@ -35,7 +35,7 @@ namespace FishFactory.Forms { textBoxName.Text = view.CannedName; textBoxPrice.Text = view.Price.ToString(); - _productComponents = view.CannedComponents ?? new Dictionary(); + _CannedComponents = view.CannedComponents ?? new Dictionary(); LoadData(); } } @@ -50,10 +50,10 @@ namespace FishFactory.Forms _logger.LogInformation("Загрузка компонент изделия"); try { - if (_productComponents != null) + if (_CannedComponents != null) { dataGridView.Rows.Clear(); - foreach (var pc in _productComponents) + foreach (var pc in _CannedComponents) { dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); } @@ -77,13 +77,13 @@ namespace FishFactory.Forms return; } _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count); - if (_productComponents.ContainsKey(form.Id)) + if (_CannedComponents.ContainsKey(form.Id)) { - _productComponents[form.Id] = (form.ComponentModel, form.Count); + _CannedComponents[form.Id] = (form.ComponentModel, form.Count); } else { - _productComponents.Add(form.Id, (form.ComponentModel, form.Count)); + _CannedComponents.Add(form.Id, (form.ComponentModel, form.Count)); } LoadData(); } @@ -98,7 +98,7 @@ namespace FishFactory.Forms { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; - form.Count = _productComponents[id].Item2; + form.Count = _CannedComponents[id].Item2; if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) @@ -106,7 +106,7 @@ namespace FishFactory.Forms return; } _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); - _productComponents[form.Id] = (form.ComponentModel, form.Count); + _CannedComponents[form.Id] = (form.ComponentModel, form.Count); LoadData(); } } @@ -121,7 +121,7 @@ namespace FishFactory.Forms try { _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); - _productComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _CannedComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { @@ -147,7 +147,7 @@ namespace FishFactory.Forms MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (_productComponents == null || _productComponents.Count == 0) + if (_CannedComponents == null || _CannedComponents.Count == 0) { MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -160,7 +160,7 @@ namespace FishFactory.Forms Id = _id ?? 0, CannedName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - CannedComponents = _productComponents + CannedComponents = _CannedComponents }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) @@ -186,7 +186,7 @@ namespace FishFactory.Forms private double CalcPrice() { double price = 0; - foreach (var elem in _productComponents) + foreach (var elem in _CannedComponents) { price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); } diff --git a/FishFactory/FormCanned.resx b/FishFactory/Forms/FormCanned.resx similarity index 100% rename from FishFactory/FormCanned.resx rename to FishFactory/Forms/FormCanned.resx diff --git a/FishFactory/FormCannedComponent.Designer.cs b/FishFactory/Forms/FormCannedComponent.Designer.cs similarity index 100% rename from FishFactory/FormCannedComponent.Designer.cs rename to FishFactory/Forms/FormCannedComponent.Designer.cs diff --git a/FishFactory/FormCannedComponent.cs b/FishFactory/Forms/FormCannedComponent.cs similarity index 100% rename from FishFactory/FormCannedComponent.cs rename to FishFactory/Forms/FormCannedComponent.cs diff --git a/FishFactory/FormCannedComponent.resx b/FishFactory/Forms/FormCannedComponent.resx similarity index 100% rename from FishFactory/FormCannedComponent.resx rename to FishFactory/Forms/FormCannedComponent.resx diff --git a/FishFactory/FormCanneds.Designer.cs b/FishFactory/Forms/FormCanneds.Designer.cs similarity index 100% rename from FishFactory/FormCanneds.Designer.cs rename to FishFactory/Forms/FormCanneds.Designer.cs diff --git a/FishFactory/FormCanneds.cs b/FishFactory/Forms/FormCanneds.cs similarity index 100% rename from FishFactory/FormCanneds.cs rename to FishFactory/Forms/FormCanneds.cs diff --git a/FishFactory/FormCanneds.resx b/FishFactory/Forms/FormCanneds.resx similarity index 100% rename from FishFactory/FormCanneds.resx rename to FishFactory/Forms/FormCanneds.resx diff --git a/FishFactory/FormComponent.Designer.cs b/FishFactory/Forms/FormComponent.Designer.cs similarity index 100% rename from FishFactory/FormComponent.Designer.cs rename to FishFactory/Forms/FormComponent.Designer.cs diff --git a/FishFactory/FormComponent.cs b/FishFactory/Forms/FormComponent.cs similarity index 100% rename from FishFactory/FormComponent.cs rename to FishFactory/Forms/FormComponent.cs diff --git a/FishFactory/FormComponent.resx b/FishFactory/Forms/FormComponent.resx similarity index 100% rename from FishFactory/FormComponent.resx rename to FishFactory/Forms/FormComponent.resx diff --git a/FishFactory/FormComponents.Designer.cs b/FishFactory/Forms/FormComponents.Designer.cs similarity index 100% rename from FishFactory/FormComponents.Designer.cs rename to FishFactory/Forms/FormComponents.Designer.cs diff --git a/FishFactory/FormComponents.cs b/FishFactory/Forms/FormComponents.cs similarity index 100% rename from FishFactory/FormComponents.cs rename to FishFactory/Forms/FormComponents.cs diff --git a/FishFactory/FormComponents.resx b/FishFactory/Forms/FormComponents.resx similarity index 100% rename from FishFactory/FormComponents.resx rename to FishFactory/Forms/FormComponents.resx diff --git a/FishFactory/FormCreateOrder.Designer.cs b/FishFactory/Forms/FormCreateOrder.Designer.cs similarity index 100% rename from FishFactory/FormCreateOrder.Designer.cs rename to FishFactory/Forms/FormCreateOrder.Designer.cs diff --git a/FishFactory/FormCreateOrder.cs b/FishFactory/Forms/FormCreateOrder.cs similarity index 100% rename from FishFactory/FormCreateOrder.cs rename to FishFactory/Forms/FormCreateOrder.cs diff --git a/FishFactory/FormCreateOrder.resx b/FishFactory/Forms/FormCreateOrder.resx similarity index 100% rename from FishFactory/FormCreateOrder.resx rename to FishFactory/Forms/FormCreateOrder.resx diff --git a/FishFactory/FormMain.Designer.cs b/FishFactory/Forms/FormMain.Designer.cs similarity index 63% rename from FishFactory/FormMain.Designer.cs rename to FishFactory/Forms/FormMain.Designer.cs index 73fef74..4b7e0e5 100644 --- a/FishFactory/FormMain.Designer.cs +++ b/FishFactory/Forms/FormMain.Designer.cs @@ -39,6 +39,10 @@ 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(); @@ -46,10 +50,10 @@ // toolStrip1 // toolStrip1.ImageScalingSize = new Size(20, 20); - toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1 }); + toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, toolStripDropDownButton2 }); toolStrip1.Location = new Point(0, 0); toolStrip1.Name = "toolStrip1"; - toolStrip1.Size = new Size(1107, 27); + toolStrip1.Size = new Size(969, 25); toolStrip1.TabIndex = 0; toolStrip1.Text = "toolStrip1"; // @@ -60,29 +64,28 @@ toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image"); toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; toolStripDropDownButton1.Name = "toolStripDropDownButton1"; - toolStripDropDownButton1.Size = new Size(108, 24); + toolStripDropDownButton1.Size = new Size(88, 22); toolStripDropDownButton1.Text = "Справочник"; // // компонентыToolStripMenuItem // компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(182, 26); + компонентыToolStripMenuItem.Size = new Size(145, 22); компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; // // консервыToolStripMenuItem // консервыToolStripMenuItem.Name = "консервыToolStripMenuItem"; - консервыToolStripMenuItem.Size = new Size(182, 26); + консервыToolStripMenuItem.Size = new Size(145, 22); консервыToolStripMenuItem.Text = "Консервы"; консервыToolStripMenuItem.Click += консервыToolStripMenuItem_Click; // // buttonCreateOrder // - buttonCreateOrder.Location = new Point(914, 75); - buttonCreateOrder.Margin = new Padding(3, 4, 3, 4); + buttonCreateOrder.Location = new Point(800, 56); buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(161, 32); + buttonCreateOrder.Size = new Size(141, 24); buttonCreateOrder.TabIndex = 1; buttonCreateOrder.Text = "Создать заказ"; buttonCreateOrder.UseVisualStyleBackColor = true; @@ -90,10 +93,9 @@ // // buttonTakeOrderInWork // - buttonTakeOrderInWork.Location = new Point(914, 133); - buttonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4); + buttonTakeOrderInWork.Location = new Point(800, 100); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(161, 32); + buttonTakeOrderInWork.Size = new Size(141, 24); buttonTakeOrderInWork.TabIndex = 2; buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonTakeOrderInWork.UseVisualStyleBackColor = true; @@ -101,10 +103,9 @@ // // buttonOrderReady // - buttonOrderReady.Location = new Point(914, 190); - buttonOrderReady.Margin = new Padding(3, 4, 3, 4); + buttonOrderReady.Location = new Point(800, 142); buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(161, 32); + buttonOrderReady.Size = new Size(141, 24); buttonOrderReady.TabIndex = 3; buttonOrderReady.Text = "Заказ готов"; buttonOrderReady.UseVisualStyleBackColor = true; @@ -112,10 +113,9 @@ // // buttonIssuedOrder // - buttonIssuedOrder.Location = new Point(914, 241); - buttonIssuedOrder.Margin = new Padding(3, 4, 3, 4); + buttonIssuedOrder.Location = new Point(800, 181); buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(161, 32); + buttonIssuedOrder.Size = new Size(141, 24); buttonIssuedOrder.TabIndex = 4; buttonIssuedOrder.Text = "Заказ выдан"; buttonIssuedOrder.UseVisualStyleBackColor = true; @@ -123,10 +123,9 @@ // // buttonRef // - buttonRef.Location = new Point(914, 296); - buttonRef.Margin = new Padding(3, 4, 3, 4); + buttonRef.Location = new Point(800, 222); buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(161, 32); + buttonRef.Size = new Size(141, 24); buttonRef.TabIndex = 5; buttonRef.Text = "Обновить список"; buttonRef.UseVisualStyleBackColor = true; @@ -135,21 +134,51 @@ // dataGridView // dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 35); - dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Location = new Point(0, 26); dataGridView.Name = "dataGridView"; dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 24; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(872, 580); + dataGridView.Size = new Size(763, 435); 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(8F, 20F); + AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1107, 615); + ClientSize = new Size(969, 461); Controls.Add(dataGridView); Controls.Add(buttonRef); Controls.Add(buttonIssuedOrder); @@ -157,7 +186,6 @@ Controls.Add(buttonTakeOrderInWork); Controls.Add(buttonCreateOrder); Controls.Add(toolStrip1); - Margin = new Padding(3, 4, 3, 4); Name = "FormMain"; Text = "Рыбный завод"; Load += FormMain_Load; @@ -180,5 +208,9 @@ private ToolStripDropDownButton toolStripDropDownButton1; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem консервыToolStripMenuItem; + private ToolStripDropDownButton toolStripDropDownButton2; + private ToolStripMenuItem списокКомпонентовToolStripMenuItem; + private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/FishFactory/FormMain.cs b/FishFactory/Forms/FormMain.cs similarity index 80% rename from FishFactory/FormMain.cs rename to FishFactory/Forms/FormMain.cs index b8c0b8f..149ea78 100644 --- a/FishFactory/FormMain.cs +++ b/FishFactory/Forms/FormMain.cs @@ -1,15 +1,7 @@ -using FishFactoryContracts.BindingModels; +using FishFactoryBusinessLogic.BusinessLogic; +using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; -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 FishFactory.Forms { @@ -17,6 +9,7 @@ namespace FishFactory.Forms { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; public FormMain(ILogger logger, IOrderLogic orderLogic) { InitializeComponent(); @@ -151,5 +144,38 @@ namespace FishFactory.Forms { LoadData(); } + + private void списокКомпонентовToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveComponentsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + } + + private void компонентыПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportCannedComponents)); + if (service is FormReportCannedComponents form) + { + form.ShowDialog(); + } + + } + + private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/FishFactory/FormMain.resx b/FishFactory/Forms/FormMain.resx similarity index 89% rename from FishFactory/FormMain.resx rename to FishFactory/Forms/FormMain.resx index 672dbc1..a50214e 100644 --- a/FishFactory/FormMain.resx +++ b/FishFactory/Forms/FormMain.resx @@ -124,7 +124,7 @@ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc @@ -134,6 +134,17 @@ mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEISURBVEhL3ZErDsJAGIR7DlA47oArV8CDR9RiSDAQPBcA + Qx1BgUMQBEk1ooJAKE0I4Wlqf5gmu1n6oqW7hiZfthkx33aqeZ5HKvEFpmmSYRhSQScXINB1XSroDAke + 96cUpAmupyPZsx7Z8x4drAnPpQmsgU7LdoHDJNIEYjnAlyBXJ3jPhVyaYLca8nLMhX+CPJXAOT+ouTj5 + p5in4asApdWpS8XRwT+zShIFG/fOyxlZJbGC9f5G5bHzUf6LJFJQqTViyxlxEmRiHhLUW10qDbeRpUGC + ErwjE/OQoG9dIsviYGWsXMwxc24BYLcO5pgZc+cWJIG5MbsyAUDnHwlUAkFHJZraR9NeMVq3zi+WF/0A + AAAASUVORK5CYII= diff --git a/FishFactory/Forms/FormReportCannedComponents.Designer.cs b/FishFactory/Forms/FormReportCannedComponents.Designer.cs new file mode 100644 index 0000000..497ff67 --- /dev/null +++ b/FishFactory/Forms/FormReportCannedComponents.Designer.cs @@ -0,0 +1,99 @@ +namespace FishFactory.Forms +{ + partial class FormReportCannedComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonSaveToExcel = new Button(); + dataGridView = new DataGridView(); + Component = new DataGridViewTextBoxColumn(); + Canned = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(27, 15); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(160, 23); + buttonSaveToExcel.TabIndex = 0; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = true; + buttonSaveToExcel.Click += buttonSaveToExcel_Click; + // + // dataGridView + // + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { Component, Canned, Count }); + dataGridView.Location = new Point(0, 47); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(799, 438); + dataGridView.TabIndex = 1; + // + // Component + // + Component.HeaderText = "Компонент"; + Component.Name = "Component"; + Component.ReadOnly = true; + // + // Canned + // + Canned.HeaderText = "Консервы"; + Canned.Name = "Canned"; + // + // Count + // + Count.HeaderText = "Количество"; + Count.Name = "Count"; + Count.ReadOnly = true; + // + // FormReportCannedComponents + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(801, 484); + Controls.Add(dataGridView); + Controls.Add(buttonSaveToExcel); + Name = "FormReportCannedComponents"; + Text = "Компоненты по консервам"; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Canned; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/FishFactory/Forms/FormReportCannedComponents.cs b/FishFactory/Forms/FormReportCannedComponents.cs new file mode 100644 index 0000000..83129d3 --- /dev/null +++ b/FishFactory/Forms/FormReportCannedComponents.cs @@ -0,0 +1,73 @@ +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace FishFactory.Forms +{ + public partial class FormReportCannedComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportCannedComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormReportCannedComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetCannedComponent(); + 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[] { "", listElem.Item1, listElem.Item2 }); + } + dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount }); + dataGridView.Rows.Add(Array.Empty()); + } + } + _logger.LogInformation("Загрузка списка изделий по компонентам"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void buttonSaveToExcel_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveCannedComponentToExcelFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + _logger.LogInformation("Сохранение списка изделий по компонентам"); + + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/FishFactory/Forms/FormReportCannedComponents.resx b/FishFactory/Forms/FormReportCannedComponents.resx new file mode 100644 index 0000000..cc8c5d0 --- /dev/null +++ b/FishFactory/Forms/FormReportCannedComponents.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/FishFactory/Forms/FormReportOrders.Designer.cs b/FishFactory/Forms/FormReportOrders.Designer.cs new file mode 100644 index 0000000..19810bd --- /dev/null +++ b/FishFactory/Forms/FormReportOrders.Designer.cs @@ -0,0 +1,114 @@ +namespace FishFactory.Forms +{ + partial class FormReportOrders + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dateTimePickerFrom = new DateTimePicker(); + dateTimePickerTo = new DateTimePicker(); + buttonMake = new Button(); + label1 = new Label(); + label2 = new Label(); + panel = new Panel(); + SuspendLayout(); + // + // dateTimePickerFrom + // + dateTimePickerFrom.Location = new Point(33, 7); + dateTimePickerFrom.Name = "dateTimePickerFrom"; + dateTimePickerFrom.Size = new Size(149, 23); + dateTimePickerFrom.TabIndex = 0; + // + // dateTimePickerTo + // + dateTimePickerTo.Location = new Point(215, 7); + dateTimePickerTo.Name = "dateTimePickerTo"; + dateTimePickerTo.Size = new Size(149, 23); + dateTimePickerTo.TabIndex = 1; + // + // buttonMake + // + buttonMake.Location = new Point(570, 7); + buttonMake.Name = "buttonMake"; + buttonMake.Size = new Size(120, 23); + buttonMake.TabIndex = 2; + buttonMake.Text = "Сформировать"; + buttonMake.UseVisualStyleBackColor = true; + buttonMake.Click += buttonMake_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(14, 12); + label1.Name = "label1"; + label1.Size = new Size(15, 15); + label1.TabIndex = 3; + label1.Text = "С"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(192, 11); + label2.Name = "label2"; + label2.Size = new Size(21, 15); + label2.TabIndex = 4; + label2.Text = "по"; + // + // panel + // + panel.Location = new Point(0, 36); + panel.Name = "panel"; + panel.Size = new Size(802, 418); + panel.TabIndex = 5; + // + // FormReportOrders + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(buttonMake); + Controls.Add(dateTimePickerTo); + Controls.Add(dateTimePickerFrom); + Name = "FormReportOrders"; + Text = "Заказы"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private DateTimePicker dateTimePickerFrom; + private DateTimePicker dateTimePickerTo; + private Button buttonMake; + private Label label1; + private Label label2; + private Panel panel; + } +} \ No newline at end of file diff --git a/FishFactory/Forms/FormReportOrders.cs b/FishFactory/Forms/FormReportOrders.cs new file mode 100644 index 0000000..aa45614 --- /dev/null +++ b/FishFactory/Forms/FormReportOrders.cs @@ -0,0 +1,92 @@ +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; + +namespace FishFactory.Forms +{ + public partial class FormReportOrders : Form + { + private readonly ReportViewer reportViewer; + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportOrders(ILogger logger, IReportLogic + logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new + FileStream("ReportOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + private void buttonMake_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + 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()}") }; + reportViewer.LocalReport.SetParameters(parameters); + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonToPdf_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + using var dialog = new SaveFileDialog + { + Filter = "pdf|*.pdf" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveOrdersToPdfFile(new ReportBindingModel + { + FileName = dialog.FileName, + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + _logger.LogInformation("Сохранение списка заказов на период { From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка заказов на период"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/FishFactory/Forms/FormReportOrders.resx b/FishFactory/Forms/FormReportOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FishFactory/Forms/FormReportOrders.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FishFactory/Program.cs b/FishFactory/Program.cs index ba4bc0a..9d315dc 100644 --- a/FishFactory/Program.cs +++ b/FishFactory/Program.cs @@ -41,6 +41,7 @@ namespace FishFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -48,6 +49,8 @@ namespace FishFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/FishFactory/Properties/Resources.Designer.cs b/FishFactory/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c7c7065 --- /dev/null +++ b/FishFactory/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace FishFactory.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FishFactory.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/FishFactory/Properties/Resources.resx b/FishFactory/Properties/Resources.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/FishFactory/Properties/Resources.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FishFactory/ReportOrders.rdlc b/FishFactory/ReportOrders.rdlc new file mode 100644 index 0000000..5317f35 --- /dev/null +++ b/FishFactory/ReportOrders.rdlc @@ -0,0 +1,599 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 47cb53f0-7dde-4717-ba03-866a0bc4f4dd + + + + + + FishFactoryContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + CannedName + System.String + + + Sum + System.Decimal + + + OrderStatus + FishFactoryDataModels.OrderStatus + + + + FishFactoryContracts.ViewModels + ReportOrderViewModel + FishFactoryContracts.ViewModels.ReportOrderViewModel, FishFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 1cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Заказы + + + + + + + 1cm + 21cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.59525cm + + + 3.30963cm + + + 8.32842cm + + + 2.59525cm + + + 2.59525cm + + + + + 0.6cm + + + + + true + true + + + + + Номер + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Дата создания + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Консерва + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Статус Заказа + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DateCreate.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!CannedName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 19.4238cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4.21167cm + 14.97625cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4.21167cm + 17.47625cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm + @@ -120,19 +120,19 @@ - 2.59525cm + 2.5cm - 3.30963cm + 3.21438cm - 8.32842cm + 8.23317cm - 2.59525cm + 2.5cm - 2.59525cm + 2.5cm @@ -244,7 +244,7 @@ - Статус Заказа + Статус @@ -398,21 +398,21 @@ - + true true - =Fields!OrderStatus.Value + =Fields!Status.Value - 4.21167cm - 14.97625cm + 4cm + 12cm 0.6cm 2.5cm 3 @@ -534,6 +534,7 @@ =Sum(Fields!Sum.Value, "DataSetOrders") @@ -542,8 +543,8 @@ - 4.21167cm - 17.47625cm + 4cm + 14.5cm 0.6cm 2.5cm 4 @@ -583,7 +584,7 @@ - 5 + 4 2 @@ -595,5 +596,5 @@ Cm - 1c0c12af-b9e8-41db-8d1f-26d1acbf91cc + 2de0031a-4d17-449d-922d-d9fc54572312 \ No newline at end of file diff --git a/FishFactoryBusinessLogic/BusinessLogic/ReportLogic.cs b/FishFactoryBusinessLogic/BusinessLogic/ReportLogic.cs index c3e7e0d..ab7b3f6 100644 --- a/FishFactoryBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/FishFactoryBusinessLogic/BusinessLogic/ReportLogic.cs @@ -16,8 +16,7 @@ namespace FishFactoryBusinessLogic.BusinessLogic 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; _componentStorage = componentStorage; @@ -26,16 +25,24 @@ namespace FishFactoryBusinessLogic.BusinessLogic _saveToWord = saveToWord; _saveToPdf = saveToPdf; } - public List GetCannedComponents() + /// + /// Получение списка компонент с указанием, в каких изделиях используются + /// + /// + public List GetCannedComponent() { - return _cannedStorage.GetFullList().Select( x => new ReportCannedComponentViewModel + return _cannedStorage.GetFullList().Select(x => new ReportCannedComponentViewModel { 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(); } - + /// + /// Получение списка заказов за определенный период + /// + /// + /// public List GetOrders(ReportBindingModel model) { return _orderStorage.GetFilteredList(new OrderSearchModel @@ -48,8 +55,8 @@ namespace FishFactoryBusinessLogic.BusinessLogic Id = x.Id, DateCreate = x.DateCreate, CannedName = x.CannedName, - Sum = x.Sum, - Status = x.Status.ToString() + Status = x.Status.ToString(), + Sum = x.Sum }) .ToList(); } @@ -60,7 +67,7 @@ namespace FishFactoryBusinessLogic.BusinessLogic { FileName = model.FileName, Title = "Список консерв", - Components = _componentStorage.GetFullList() + Canneds = _cannedStorage.GetFullList() }); } @@ -69,11 +76,14 @@ namespace FishFactoryBusinessLogic.BusinessLogic _saveToExcel.CreateReport(new ExcelInfo { FileName = model.FileName, - Title = "Список консерв", - CannedComponents = GetCannedComponents() + Title = "Список компонент", + CannedComponents = GetCannedComponent() }); } - + /// + /// Сохранение заказов в файл-Pdf + /// + /// public void SaveOrdersToPdfFile(ReportBindingModel model) { _saveToPdf.CreateDoc(new PdfInfo diff --git a/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 1157def..452ece7 100644 --- a/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -5,10 +5,13 @@ namespace FishFactoryBusinessLogic.OfficePackage { public abstract class AbstractSaveToExcel { + /// + /// Создание отчета + /// + /// public void CreateReport(ExcelInfo info) { CreateExcel(info); - InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "A", @@ -32,23 +35,24 @@ namespace FishFactoryBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var Component in pc.Components) + foreach (var Canned in pc.Components) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = Component.Item1, - StyleInfo = ExcelStyleInfoType.TextWithBroder + Text = Canned.Item1, + StyleInfo = + ExcelStyleInfoType.TextWithBroder }); InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "C", RowIndex = rowIndex, - Text = Component.Item2.ToString(), - StyleInfo = ExcelStyleInfoType.TextWithBroder + Text = Canned.Item2.ToString(), + StyleInfo = + ExcelStyleInfoType.TextWithBroder }); - rowIndex++; } InsertCellInWorksheet(new ExcelCellParameters @@ -69,13 +73,27 @@ namespace FishFactoryBusinessLogic.OfficePackage } SaveExcel(info); } - + /// + /// Создание excel-файла + /// + /// protected abstract void CreateExcel(ExcelInfo info); - - protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); - + /// + /// Добавляем новую ячейку в лист + /// + /// + protected abstract void InsertCellInWorksheet(ExcelCellParameters + excelParams); + /// + /// Объединение ячеек + /// + /// protected abstract void MergeCells(ExcelMergeParameters excelParams); - + /// + /// Сохранение файла + /// + /// protected abstract void SaveExcel(ExcelInfo info); + } } diff --git a/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 874cd52..7ebb9b9 100644 --- a/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -19,10 +19,10 @@ namespace FishFactoryBusinessLogic.OfficePackage Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List { "2cm", "3cm", "6cm", "3cm" }); + CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" }); CreateRow(new PdfRowParameters { - Texts = new List { "Номер", "Дата заказа", "Изделие", "Сумма" }, + Texts = new List { "Номер", "Дата заказа", "Изделие", "Статус", "Сумма" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); @@ -30,7 +30,7 @@ namespace FishFactoryBusinessLogic.OfficePackage { CreateRow(new PdfRowParameters { - Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.CannedName, order.Sum.ToString() }, + Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.CannedName, order.Status, order.Sum.ToString() }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); diff --git a/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 88b079a..4a86fd4 100644 --- a/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -8,25 +8,24 @@ namespace FishFactoryBusinessLogic.OfficePackage public void CreateDoc(WordInfo info) { CreateWord(info); + CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> { - (info.Title, - new WordTextProperties { Bold = true, Size = "24", }) - }, + Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); - foreach (var component in info.Components) + + foreach (var canned in info.Canneds) { CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { - (component.ComponentName, - new WordTextProperties { Size = "24", }) + (canned.CannedName + ' ', new WordTextProperties { Size = "24", Bold = true }), + (canned.Price.ToString(), new WordTextProperties { Size = "24" }) }, TextProperties = new WordTextProperties { diff --git a/FishFactoryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/FishFactoryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index bb4c13c..137e2e4 100644 --- a/FishFactoryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/FishFactoryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -6,6 +6,6 @@ namespace FishFactoryBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List Components { get; set; } = new(); + public List Canneds { get; set; } = new(); } } diff --git a/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs index 8b5e8fd..0e2ba25 100644 --- a/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -16,7 +16,8 @@ namespace FishFactoryBusinessLogic.OfficePackage.Implements /// /// /// - private static JustificationValues GetJustificationValues(WordJustificationType type) + private static JustificationValues + GetJustificationValues(WordJustificationType type) { return type switch { @@ -60,7 +61,6 @@ namespace FishFactoryBusinessLogic.OfficePackage.Implements LineRule = LineSpacingRuleValues.Auto }); properties.AppendChild(new Indentation()); - var paragraphMarkRunProperties = new ParagraphMarkRunProperties(); if (!string.IsNullOrEmpty(paragraphProperties.Size)) { diff --git a/FishFactoryContracts/BusinessLogicsContracts/IReportLogic.cs b/FishFactoryContracts/BusinessLogicsContracts/IReportLogic.cs index 0dc2806..6960ffa 100644 --- a/FishFactoryContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/FishFactoryContracts/BusinessLogicsContracts/IReportLogic.cs @@ -9,7 +9,7 @@ namespace FishFactoryContracts.BusinessLogicsContracts /// Получение списка компонент с указанием, в каких изделиях используются /// /// - List GetCannedComponents(); + List GetCannedComponent(); /// /// Получение списка заказов за определенный период /// diff --git a/FishFactoryContracts/ViewModels/ReportOrdersViewModel.cs b/FishFactoryContracts/ViewModels/ReportOrdersViewModel.cs index 63cd422..ce76f07 100644 --- a/FishFactoryContracts/ViewModels/ReportOrdersViewModel.cs +++ b/FishFactoryContracts/ViewModels/ReportOrdersViewModel.cs @@ -6,7 +6,8 @@ namespace FishFactoryContracts.ViewModels public int Id { get; set; } public DateTime DateCreate { get; set; } public string CannedName { get; set; } = string.Empty; - public double Sum { get; set; } public string Status { get; set; } = string.Empty; + public double Sum { get; set; } + } } diff --git a/FishFactoryDatabaseImplement/FishFactoryDatabase.cs b/FishFactoryDatabaseImplement/FishFactoryDatabase.cs index d93d11d..16b5a6e 100644 --- a/FishFactoryDatabaseImplement/FishFactoryDatabase.cs +++ b/FishFactoryDatabaseImplement/FishFactoryDatabase.cs @@ -9,7 +9,7 @@ namespace FishFactoryDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseNpgsql(@"Host=localhost;Database=FishFactory;Username=postgres;Password=postgres"); + optionsBuilder.UseNpgsql(@"Host=localhost;Database=FishFactory2;Username=postgres;Password=postgres"); } base.OnConfiguring(optionsBuilder); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); diff --git a/FishFactoryDatabaseImplement/Implements/OrderStorage.cs b/FishFactoryDatabaseImplement/Implements/OrderStorage.cs index d2e9090..3c38dca 100644 --- a/FishFactoryDatabaseImplement/Implements/OrderStorage.cs +++ b/FishFactoryDatabaseImplement/Implements/OrderStorage.cs @@ -19,21 +19,11 @@ namespace FishFactoryDatabaseImplement.Implements } public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue || !model.DateFrom.HasValue || !model.DateTo.HasValue) + if (!model.Id.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) diff --git a/FishFactoryFileImplement/Implements/OrderStorage.cs b/FishFactoryFileImplement/Implements/OrderStorage.cs index af38185..9a90729 100644 --- a/FishFactoryFileImplement/Implements/OrderStorage.cs +++ b/FishFactoryFileImplement/Implements/OrderStorage.cs @@ -23,7 +23,7 @@ namespace FishFactoryFileImplement.Implements } public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue || !model.DateFrom.HasValue || !model.DateTo.HasValue) + if (!model.DateFrom.HasValue || !model.DateTo.HasValue) { return new(); } diff --git a/FishFactoryListImplement/Implements/OrderStorage.cs b/FishFactoryListImplement/Implements/OrderStorage.cs index 3562783..75896f3 100644 --- a/FishFactoryListImplement/Implements/OrderStorage.cs +++ b/FishFactoryListImplement/Implements/OrderStorage.cs @@ -33,13 +33,13 @@ namespace FishFactoryListImplement.Implements public List GetFilteredList(OrderSearchModel model) { var result = new List(); - if (model == null || !model.Id.HasValue || !model.DateFrom.HasValue || !model.DateFrom.HasValue) + if (model == null || !model.Id.HasValue) { return result; } foreach (var order in _source.Orders) { - if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) + if (order.Id == model.Id) { result.Add(AttachCannedName(order.GetViewModel)); } -- 2.25.1