From 9986b09119a45f536ee7f27d3bf9ede264f680ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=A7=D1=83=D0=B1?= =?UTF-8?q?=D1=8B=D0=BA=D0=B8=D0=BD=D0=B0?= Date: Sat, 20 Apr 2024 15:51:24 +0400 Subject: [PATCH] =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=20=D0=B3=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=B0=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/ReportOrdersViewModel.cs | 1 + .../ReportPastryComponentViewModel.cs | 4 +- .../BusinessLogics/ReportLogic.cs | 29 +- .../OfficePackage/AbstractSaveToExcel.cs | 4 +- .../OfficePackage/AbstractSaveToPdf.cs | 10 +- .../OfficePackage/AbstractSaveToWord.cs | 6 +- .../OfficePackage/HelperModels/WordInfo.cs | 2 +- .../Implements/OrderStorage.cs | 10 +- .../Implements/OrderStorage.cs | 9 +- .../Implements/OrderStorage.cs | 11 +- .../FormReportOrders.Designer.cs | 2 +- .../ConfectioneryView/FormReportOrders.cs | 1 + .../FormReportPastryComponents.Designer.cs | 22 +- .../FormReportPastryComponents.cs | 4 +- .../FormReportPastryComponents.resx | 9 - .../ConfectioneryView/ReportOrders.rdlc | 547 +++++++++++++++++- 16 files changed, 602 insertions(+), 69 deletions(-) diff --git a/Confectionery/ConfectionaryContracts/ViewModels/ReportOrdersViewModel.cs b/Confectionery/ConfectionaryContracts/ViewModels/ReportOrdersViewModel.cs index 88e4738..4dbf99c 100644 --- a/Confectionery/ConfectionaryContracts/ViewModels/ReportOrdersViewModel.cs +++ b/Confectionery/ConfectionaryContracts/ViewModels/ReportOrdersViewModel.cs @@ -11,6 +11,7 @@ namespace ConfectioneryContracts.ViewModels public int Id { get; set; } public DateTime DateCreate { get; set; } public string PastryName { get; set; } = string.Empty; + public string OrderStatus { get; set; } = string.Empty; public double Sum { get; set; } } } diff --git a/Confectionery/ConfectionaryContracts/ViewModels/ReportPastryComponentViewModel.cs b/Confectionery/ConfectionaryContracts/ViewModels/ReportPastryComponentViewModel.cs index 8cef604..f65c79f 100644 --- a/Confectionery/ConfectionaryContracts/ViewModels/ReportPastryComponentViewModel.cs +++ b/Confectionery/ConfectionaryContracts/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> Pastries { get; set; } = new(); + public List<(string Component, int Count)> Components { get; set; } = new(); } } diff --git a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs index 89efec5..69a8290 100644 --- a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs @@ -40,29 +40,27 @@ namespace ConfectioneryBusinessLogic.BusinessLogics /// public List GetPastryComponent() { - 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>(), - TotalCount = 0 + PastryName = pastry.PastryName, + Components = new List<(string Component, int Count)>(), + TotalCount = 0, }; - foreach (var pastry in pastries) + foreach (var component in pastry.PastryComponents) { - if (pastry.PastryComponents.ContainsKey(component.Id)) - { - record.Pastries.Add(new Tuple(pastry.PastryName, pastry.PastryComponents[component.Id].Item2)); - record.TotalCount += - pastry.PastryComponents[component.Id].Item2; - } + record.Components.Add(new(component.Value.Item1.ComponentName, component.Value.Item2)); + record.TotalCount += component.Value.Item2; } + list.Add(record); } + return list; } /// @@ -82,6 +80,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics Id = x.Id, DateCreate = x.DateCreate, PastryName = x.PastryName, + OrderStatus = x.Status.ToString(), Sum = x.Sum }) .ToList(); @@ -95,8 +94,8 @@ namespace ConfectioneryBusinessLogic.BusinessLogics _saveToWord.CreateDoc(new WordInfo { FileName = model.FileName, - Title = "Список компонент", - Components = _componentStorage.GetFullList() + Title = "Список выпечки", + Pastries = _pastryStorage.GetFullList() }); } /// diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 5ac8dde..d8f5907 100644 --- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -36,11 +36,11 @@ namespace ConfectioneryBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = pc.ComponentName, + Text = pc.PastryName, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var pastry in pc.Pastries) + foreach (var pastry in pc.Components) { InsertCellInWorksheet(new ExcelCellParameters { diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 9ad7aaf..c480569 100644 --- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -26,10 +26,10 @@ namespace ConfectioneryBusinessLogic.OfficePackage = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List { "2cm", "3cm", "6cm", "3cm" }); + CreateTable(new List { "2cm", "3cm", "6cm", "4cm", "3cm" }); CreateRow(new PdfRowParameters { - Texts = new List { "Номер", "Дата заказа", "Изделие", "Сумма" }, + Texts = new List { "Номер", "Дата заказа", "Выпечка", "Статус", "Сумма" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); @@ -37,7 +37,8 @@ namespace ConfectioneryBusinessLogic.OfficePackage { CreateRow(new PdfRowParameters { - Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PastryName, order.Sum.ToString() }, + Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PastryName, + order.OrderStatus, order.Sum.ToString() }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); @@ -46,8 +47,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", - ParagraphAlignment = - PdfParagraphAlignmentType.Rigth + ParagraphAlignment = PdfParagraphAlignmentType.Rigth }); SavePdf(info); } diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 5a68565..a5fa5d5 100644 --- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -23,12 +23,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 b3bfc0b..18165c5 100644 --- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -11,6 +11,6 @@ namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List Components { get; set; } = new(); + public List Pastries { get; set; } = new(); } } diff --git a/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs b/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs index 51b041e..0f76e5b 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Implements/OrderStorage.cs @@ -20,11 +20,19 @@ namespace ConfectioneryDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue) { return new(); } using var context = new ConfectioneryDatabase(); + if (model.DateFrom.HasValue) + { + return context.Orders + .Include(x => x.Pastry) + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } return context.Orders .Include(x => x.Pastry) .Where(x => x.Id == model.Id) diff --git a/Confectionery/ConfectioneryFileImplement/Implements/OrderStorage.cs b/Confectionery/ConfectioneryFileImplement/Implements/OrderStorage.cs index 55fada2..5455bb6 100644 --- a/Confectionery/ConfectioneryFileImplement/Implements/OrderStorage.cs +++ b/Confectionery/ConfectioneryFileImplement/Implements/OrderStorage.cs @@ -29,10 +29,17 @@ namespace ConfectioneryFileImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue) { return new(); } + if (model.DateFrom.HasValue) + { + return source.Orders + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Select(x => AddPastryName(x.GetViewModel)) + .ToList(); + } return source.Orders .Where(x => x.Id == model.Id) .Select(x => AddPastryName(x.GetViewModel)) diff --git a/Confectionery/ConfectioneryListImplement/Implements/OrderStorage.cs b/Confectionery/ConfectioneryListImplement/Implements/OrderStorage.cs index c4c13e2..df15642 100644 --- a/Confectionery/ConfectioneryListImplement/Implements/OrderStorage.cs +++ b/Confectionery/ConfectioneryListImplement/Implements/OrderStorage.cs @@ -33,15 +33,18 @@ namespace ConfectioneryListImplement.Implements public List GetFilteredList(OrderSearchModel model) { var result = new List(); - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue) { return result; } - foreach (var order in _source.Orders) + if (model.DateFrom.HasValue) { - if (order.Id == model.Id) + foreach (var order in _source.Orders) { - result.Add(AddPastryName(order.GetViewModel)); + if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) + { + result.Add(AddPastryName(order.GetViewModel)); + } } } return result; diff --git a/Confectionery/ConfectioneryView/FormReportOrders.Designer.cs b/Confectionery/ConfectioneryView/FormReportOrders.Designer.cs index d887692..474ba6e 100644 --- a/Confectionery/ConfectioneryView/FormReportOrders.Designer.cs +++ b/Confectionery/ConfectioneryView/FormReportOrders.Designer.cs @@ -117,7 +117,7 @@ this.ClientSize = new System.Drawing.Size(1111, 450); this.Controls.Add(this.panel); this.Name = "FormReportOrders"; - this.Text = "FormReportOrders"; + this.Text = "Заказы"; this.panel.ResumeLayout(false); this.panel.PerformLayout(); this.ResumeLayout(false); diff --git a/Confectionery/ConfectioneryView/FormReportOrders.cs b/Confectionery/ConfectioneryView/FormReportOrders.cs index 8573616..27e79ce 100644 --- a/Confectionery/ConfectioneryView/FormReportOrders.cs +++ b/Confectionery/ConfectioneryView/FormReportOrders.cs @@ -28,6 +28,7 @@ namespace ConfectioneryView { Dock = DockStyle.Fill }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("C:\\Users\\Полина\\source\\repos\\2 курс\\рпп\\PIbd-22_Chubykina_P.P._Confectionery\\Confectionery\\ConfectioneryView\\ReportOrders.rdlc", FileMode.Open)); Controls.Clear(); diff --git a/Confectionery/ConfectioneryView/FormReportPastryComponents.Designer.cs b/Confectionery/ConfectioneryView/FormReportPastryComponents.Designer.cs index 11c1642..e602a0c 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(); @@ -50,8 +50,8 @@ // 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.Location = new System.Drawing.Point(13, 64); this.dataGridView.Name = "dataGridView"; @@ -60,13 +60,6 @@ this.dataGridView.Size = new System.Drawing.Size(776, 541); this.dataGridView.TabIndex = 1; // - // ColumnComponent - // - this.ColumnComponent.HeaderText = "Компонент"; - this.ColumnComponent.MinimumWidth = 6; - this.ColumnComponent.Name = "ColumnComponent"; - this.ColumnComponent.Width = 150; - // // ColumnPastry // this.ColumnPastry.HeaderText = "Выпечка"; @@ -74,6 +67,13 @@ this.ColumnPastry.Name = "ColumnPastry"; this.ColumnPastry.Width = 150; // + // ColumnComponent + // + this.ColumnComponent.HeaderText = "Компонент"; + this.ColumnComponent.MinimumWidth = 6; + this.ColumnComponent.Name = "ColumnComponent"; + this.ColumnComponent.Width = 150; + // // ColumnCount // this.ColumnCount.HeaderText = "Количество"; @@ -89,7 +89,7 @@ this.Controls.Add(this.dataGridView); this.Controls.Add(this.buttonSaveToExcel); this.Name = "FormReportPastryComponents"; - this.Text = "FormReportPastryComponents"; + this.Text = "Компоненты по изделиям"; this.Load += new System.EventHandler(this.FormReportPastryComponents_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); @@ -100,8 +100,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 379cc1a..2e329b2 100644 --- a/Confectionery/ConfectioneryView/FormReportPastryComponents.cs +++ b/Confectionery/ConfectioneryView/FormReportPastryComponents.cs @@ -36,8 +36,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 diff --git a/Confectionery/ConfectioneryView/ReportOrders.rdlc b/Confectionery/ConfectioneryView/ReportOrders.rdlc index 0ba0039..237093a 100644 --- a/Confectionery/ConfectioneryView/ReportOrders.rdlc +++ b/Confectionery/ConfectioneryView/ReportOrders.rdlc @@ -1,19 +1,67 @@ + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + ConfectioneryContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + PastryName + System.String + + + OrderStatus + System.String + + + Sum + System.Decimal + + + + ConfectioneryContracts.ViewModels + ReportOrdersViewModel + ConfectioneryContracts.ViewModels.ReportOrdersViewModel, ConfectioneryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + - + true true - Заказы - - Textbox1 - 0.03387cm - 0.0127cm - 1.31233cm - 16.4973cm + ReportParameterPeriod + 1cm + 1cm + 21cm @@ -37,11 +84,487 @@ 2pt + + true + true + + + + + Заказы + + + + + + + 1cm + 21cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.5cm + + + 3.21438cm + + + 8.23317cm + + + 2.5cm + + + 2.5cm + + + + + 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!PastryName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Status.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 18.94755cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 12cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 14.5cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + - 2in + 5.72875cm