diff --git a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs index 54366ca..01ab360 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; } } @@ -74,7 +74,8 @@ namespace ConfectioneryBusinessLogic.BusinessLogics DateFrom = model.DateFrom, DateTo = model.DateTo }) - .Select(x => new ReportOrdersViewModel + .Select(x => + new ReportOrdersViewModel { Id = x.Id, DateCreate = x.DateCreate, @@ -95,8 +96,8 @@ namespace ConfectioneryBusinessLogic.BusinessLogics _saveToWord.CreateDoc(new WordInfo { FileName = model.FileName, - Title = "Список компонент", - Components = _componentStorage.GetFullList() + Title = "Список изделий", + Pastries = _pastryStorage.GetFullList() }); } /// @@ -108,7 +109,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 5f9faf1..c831f04 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs @@ -45,27 +45,14 @@ namespace ConfectioneryDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { - using var context = new ConfectioneryDatabase(); - if (model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) { - return context.Orders - .Include(x => x.Pastry) - .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) - .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) - .Select(x => x.GetViewModel) - .ToList(); - } - else - { - return new(); + 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