From 4a467c050039ae5d7c88bcf8719608e396725dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=90=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 24 Apr 2023 15:29:03 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81?= =?UTF-8?q?=204=D0=BE=D0=B9=20=D0=BB=D0=B0=D0=B1=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ReportLogic.cs | 16 ++++----- .../OfficePackage/AbstractSaveToExcel.cs | 6 ++-- .../OfficePackage/AbstractSaveToWord.cs | 5 +-- .../OfficePackage/HelperModels/WordInfo.cs | 2 +- .../ReportPastryComponentViewModel.cs | 4 +-- .../Implements/OrderStorage.cs | 34 +++---------------- .../FormReportPastryComponents.Designer.cs | 18 +++++----- .../FormReportPastryComponents.cs | 4 +-- .../FormReportPastryComponents.resx | 9 ----- 9 files changed, 33 insertions(+), 65 deletions(-) diff --git a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs index 54366ca..c637a77 100644 --- a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs @@ -42,19 +42,19 @@ namespace ConfectioneryBusinessLogic.BusinessLogics var components = _componentStorage.GetFullList(); var pastries = _pastryStorage.GetFullList(); var list = new List(); - foreach (var component in components) + foreach (var pastry in pastries) { var record = new ReportPastryComponentViewModel { - ComponentName = component.ComponentName, - Pastries = new List<(string, int)>(), + PastryName = pastry.PastryName, + Components = new List<(string Component, int Count)>(), TotalCount = 0 }; - foreach (var pastry in pastries) + foreach (var component in components) { if (pastry.PastryComponents.ContainsKey(component.Id)) { - record.Pastries.Add(new (pastry.PastryName, pastry.PastryComponents[component.Id].Item2)); + record.Components.Add(new (component.ComponentName, pastry.PastryComponents[component.Id].Item2)); record.TotalCount += pastry.PastryComponents[component.Id].Item2; } } @@ -95,8 +95,8 @@ namespace ConfectioneryBusinessLogic.BusinessLogics _saveToWord.CreateDoc(new WordInfo { FileName = model.FileName, - Title = "Список компонент", - Components = _componentStorage.GetFullList() + Title = "Список изделий", + Pastries = _pastryStorage.GetFullList() }); } /// @@ -108,7 +108,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics _saveToExcel.CreateReport(new ExcelInfo { FileName = model.FileName, - Title = "Список компонент", + Title = "Список изделий", PastryComponents = GetPastryComponent() }); } diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 77973de..cec2c86 100644 --- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -33,17 +33,17 @@ namespace ConfectioneryBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = pc.ComponentName, + Text = pc.PastryName, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var (Pastry, Count) in pc.Pastries) + foreach (var (Component, Count) in pc.Components) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = Pastry, + Text = Component, StyleInfo = ExcelStyleInfoType.TextWithBroder }); diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 8151374..23dd666 100644 --- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -22,11 +22,12 @@ namespace ConfectioneryBusinessLogic.OfficePackage JustificationType = WordJustificationType.Center } }); - foreach (var component in info.Components) + foreach (var pastry in info.Pastries) { CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> { (component.ComponentName, new WordTextProperties { Size = "24", }) }, + Texts = new List<(string, WordTextProperties)> { (pastry.PastryName + " - ", new WordTextProperties { Size = "24", Bold = true}), + (pastry.Price.ToString(), new WordTextProperties { Size = "24"})}, TextProperties = new WordTextProperties { Size = "24", diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index 7778a4d..25e00e4 100644 --- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -13,6 +13,6 @@ namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; - public List Components { get; set; } = new(); + public List Pastries { get; set; } = new(); } } diff --git a/Confectionery/ConfectioneryContracts/ViewModels/ReportPastryComponentViewModel.cs b/Confectionery/ConfectioneryContracts/ViewModels/ReportPastryComponentViewModel.cs index fd405a4..71927e6 100644 --- a/Confectionery/ConfectioneryContracts/ViewModels/ReportPastryComponentViewModel.cs +++ b/Confectionery/ConfectioneryContracts/ViewModels/ReportPastryComponentViewModel.cs @@ -8,8 +8,8 @@ namespace ConfectioneryContracts.ViewModels { public class ReportPastryComponentViewModel { - public string ComponentName { get; set; } = string.Empty; + public string PastryName { get; set; } = string.Empty; public int TotalCount { get; set; } - public List<(string Pastry, int Count)> Pastries { get; set; } = new(); + public List<(string Component, int Count)> Components { get; set; } = new(); } } diff --git a/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs b/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs index 7447cd9..290141c 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs @@ -50,38 +50,14 @@ namespace ConfectioneryDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { - using var context = new ConfectioneryDatabase(); - if (model.Id.HasValue) - { - return context.Orders - .Include(x => x.Pastry) - .Include(x => x.Client) - .Where(x => x.Id == model.Id) - .Select(x => x.GetViewModel) - .ToList(); - } - else if (model.DateFrom != null && model.DateTo != null) - { - return context.Orders - .Include(x => x.Pastry) - .Include(x => x.Client) - .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) - .Select(x => x.GetViewModel) - .ToList(); - } - else if (model.ClientId.HasValue) - { - return context.Orders - .Include(x => x.Pastry) - .Include(x => x.Client) - .Where(x => x.ClientId == model.ClientId) - .Select(x => x.GetViewModel) - .ToList(); - } - else + if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) { return new(); } + using var context = new ConfectioneryDatabase(); + + return context.Orders.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo) + .Select(x => GetViewModel(x)).ToList(); } public List GetFullList() diff --git a/Confectionery/ConfectioneryView/FormReportPastryComponents.Designer.cs b/Confectionery/ConfectioneryView/FormReportPastryComponents.Designer.cs index d4510a7..c6ebde5 100644 --- a/Confectionery/ConfectioneryView/FormReportPastryComponents.Designer.cs +++ b/Confectionery/ConfectioneryView/FormReportPastryComponents.Designer.cs @@ -30,8 +30,8 @@ { this.buttonSaveToExcel = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView(); - this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnPastry = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -53,8 +53,8 @@ this.dataGridView.AllowUserToOrderColumns = true; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.ColumnComponent, this.ColumnPastry, + this.ColumnComponent, this.ColumnCount}); this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom; this.dataGridView.Location = new System.Drawing.Point(0, 53); @@ -64,18 +64,18 @@ this.dataGridView.Size = new System.Drawing.Size(800, 397); this.dataGridView.TabIndex = 1; // - // ColumnComponent - // - this.ColumnComponent.HeaderText = "Компонент"; - this.ColumnComponent.Name = "ColumnComponent"; - this.ColumnComponent.ReadOnly = true; - // // ColumnPastry // this.ColumnPastry.HeaderText = "Изделие"; this.ColumnPastry.Name = "ColumnPastry"; this.ColumnPastry.ReadOnly = true; // + // ColumnComponent + // + this.ColumnComponent.HeaderText = "Компонент"; + this.ColumnComponent.Name = "ColumnComponent"; + this.ColumnComponent.ReadOnly = true; + // // ColumnCount // this.ColumnCount.HeaderText = "Количество"; @@ -101,8 +101,8 @@ private Button buttonSaveToExcel; private DataGridView dataGridView; - private DataGridViewTextBoxColumn ColumnComponent; private DataGridViewTextBoxColumn ColumnPastry; + private DataGridViewTextBoxColumn ColumnComponent; private DataGridViewTextBoxColumn ColumnCount; } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormReportPastryComponents.cs b/Confectionery/ConfectioneryView/FormReportPastryComponents.cs index 4f1c718..50110cb 100644 --- a/Confectionery/ConfectioneryView/FormReportPastryComponents.cs +++ b/Confectionery/ConfectioneryView/FormReportPastryComponents.cs @@ -34,8 +34,8 @@ namespace ConfectioneryView dataGridView.Rows.Clear(); foreach (var elem in dict) { - dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" }); - foreach (var listElem in elem.Pastries) + dataGridView.Rows.Add(new object[] { elem.PastryName, "", "" }); + foreach (var listElem in elem.Components) { dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); } diff --git a/Confectionery/ConfectioneryView/FormReportPastryComponents.resx b/Confectionery/ConfectioneryView/FormReportPastryComponents.resx index 524e341..48d432a 100644 --- a/Confectionery/ConfectioneryView/FormReportPastryComponents.resx +++ b/Confectionery/ConfectioneryView/FormReportPastryComponents.resx @@ -57,21 +57,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - True - - True - True - - True - True