From 6dc933b7992cacc1a2598b8929400d751acf37e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D0=B5=D0=BC=20=D0=A5=D0=B0=D1=80=D0=BB?= =?UTF-8?q?=D0=B0=D0=BC=D0=BE=D0=B2?= Date: Sun, 16 Apr 2023 21:50:35 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=E2=84=964=20-=20=D0=A4=D0=B8?= =?UTF-8?q?=D0=BA=D1=81=D0=B0=D1=86=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ReportLogic.cs | 25 +- .../OfficePackage/AbstractSaveToExcel.cs | 17 +- .../OfficePackage/AbstractSaveToPdf.cs | 18 +- .../OfficePackage/AbstractSaveToWord.cs | 4 +- .../ExcelStyleInfoType.cs | 2 +- .../PdfParagraphAlignmentType.cs | 2 +- .../HelperModels/ExcelCellParameters.cs | 1 + .../OfficePackage/HelperModels/ExcelInfo.cs | 6 +- .../HelperModels/PdfParagraph.cs | 1 + .../HelperModels/PdfRowParameters.cs | 1 + .../OfficePackage/HelperModels/WordInfo.cs | 2 +- .../OfficePackage/Implements/SaveToExcel.cs | 1 + .../OfficePackage/Implements/SaveToPdf.cs | 3 +- .../ReportDishComponentViewModel.cs | 4 +- .../ViewModels/ReportOrdersViewModel.cs | 2 +- .../Implements/OrderStorage.cs | 23 +- .../Implements/OrderStorage.cs | 22 +- .../Implements/OrderStorage.cs | 5 +- FoodOrders/FoodOrders/FoodOrders.csproj | 7 +- FoodOrders/FoodOrders/FormMain.Designer.cs | 281 +++++----- FoodOrders/FoodOrders/FormMain.cs | 42 +- .../FormReportDishComponents.Designer.cs | 118 ++--- .../FoodOrders/FormReportDishComponents.cs | 6 +- .../FoodOrders/FormReportDishComponents.resx | 4 +- .../FoodOrders/FormReportOrders.Designer.cs | 131 +++++ FoodOrders/FoodOrders/FormReportOrders.cs | 110 ++++ FoodOrders/FoodOrders/FormReportOrders.resx | 60 +++ FoodOrders/FoodOrders/Program.cs | 9 +- ...inessLogicsContracts.IDishLogic.datasource | 10 - ...nessLogicsContracts.IOrderLogic.datasource | 10 - ...agesContracts.IComponentStorage.datasource | 10 - ....StoragesContracts.IDishStorage.datasource | 10 - ...StoragesContracts.IOrderStorage.datasource | 10 - FoodOrders/FoodOrders/ReportOrders.rdlc | 485 +++++++++++++++++- 34 files changed, 1104 insertions(+), 338 deletions(-) rename FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/{HelperModels => HelperEnums}/ExcelStyleInfoType.cs (76%) rename FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/{HelperModels => HelperEnums}/PdfParagraphAlignmentType.cs (76%) create mode 100644 FoodOrders/FoodOrders/FormReportOrders.Designer.cs create mode 100644 FoodOrders/FoodOrders/FormReportOrders.cs create mode 100644 FoodOrders/FoodOrders/FormReportOrders.resx delete mode 100644 FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.BusinessLogicsContracts.IDishLogic.datasource delete mode 100644 FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.BusinessLogicsContracts.IOrderLogic.datasource delete mode 100644 FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IComponentStorage.datasource delete mode 100644 FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IDishStorage.datasource delete mode 100644 FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IOrderStorage.datasource diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/BusinessLogics/ReportLogic.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/BusinessLogics/ReportLogic.cs index 867afdd..7013c0b 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/BusinessLogics/ReportLogic.cs @@ -40,24 +40,22 @@ namespace AbstractFoodOrdersBusinessLogic.BusinessLogics public List GetDishComponent() { var components = _componentStorage.GetFullList(); - var products = _dishStorage.GetFullList(); + var dishes = _dishStorage.GetFullList(); var list = new List(); - foreach (var component in components) + foreach (var dish in dishes) { var record = new ReportDishComponentViewModel { - ComponentName = component.ComponentName, - Dishes = new List>(), + DishName = dish.DishName, + Components = new List<(string, int)>(), TotalCount = 0 }; - foreach (var product in products) + foreach (var component in components) { - if (product.DishComponents.ContainsKey(component.Id)) + if (dish.DishComponents.ContainsKey(component.Id)) { - record.Dishes.Add(new Tuple(product.DishName, product.DishComponents[component.Id].Item2)); - record.TotalCount += - product.DishComponents[component.Id].Item2; + record.Components.Add(new (component.ComponentName, dish.DishComponents[component.Id].Item2)); + record.TotalCount += dish.DishComponents[component.Id].Item2; } } list.Add(record); @@ -82,6 +80,7 @@ namespace AbstractFoodOrdersBusinessLogic.BusinessLogics Id = x.Id, DateCreate = x.DateCreate, DishName = x.DishName, + Status = x.Status.ToString(), Sum = x.Sum }) .ToList(); @@ -95,8 +94,8 @@ namespace AbstractFoodOrdersBusinessLogic.BusinessLogics _saveToWord.CreateDoc(new WordInfo { FileName = model.FileName, - Title = "Список компонент", - Components = _componentStorage.GetFullList() + Title = "Список блюд", + Dishes = _dishStorage.GetFullList() }); } /// @@ -108,7 +107,7 @@ namespace AbstractFoodOrdersBusinessLogic.BusinessLogics _saveToExcel.CreateReport(new ExcelInfo { FileName = model.FileName, - Title = "Список компонент", + Title = "Список блюд", DishComponents = GetDishComponent() }); } diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 6dbe6e1..d7393a9 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -1,4 +1,5 @@ -using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels; +using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperEnums; +using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; @@ -35,27 +36,25 @@ namespace AbstractFoodOrdersBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = pc.ComponentName, + Text = pc.DishName, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var product in pc.Dishes) + foreach (var (Component, Count) in pc.Components) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = product.Item1, - StyleInfo = - ExcelStyleInfoType.TextWithBroder + Text = Component, + StyleInfo = ExcelStyleInfoType.TextWithBroder }); InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "C", RowIndex = rowIndex, - Text = product.Item2.ToString(), - StyleInfo = - ExcelStyleInfoType.TextWithBroder + Text = Count.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder }); rowIndex++; } diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index f78b10d..5f2790c 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -1,4 +1,5 @@ -using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels; +using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperEnums; +using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; @@ -14,21 +15,17 @@ namespace AbstractFoodOrdersBusinessLogic.OfficePackage CreatePdf(info); CreateParagraph(new PdfParagraph { - Text = info.Title, - Style = - "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center + Text = info.Title, Style ="NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { - Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", + Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List { "2cm", "3cm", "6cm", "3cm" }); + CreateTable(new List { "2cm", "4cm", "6cm", "3cm", "3cm" }); CreateRow(new PdfRowParameters { - Texts = new List { "Номер", "Дата заказа", "Изделие", -"Сумма" }, + Texts = new List { "Номер", "Дата заказа", "Блюдо", "Статус", "Сумма" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); @@ -36,8 +33,7 @@ namespace AbstractFoodOrdersBusinessLogic.OfficePackage { CreateRow(new PdfRowParameters { - Texts = new List { order.Id.ToString(), -order.DateCreate.ToShortDateString(), order.DishName, order.Sum.ToString() }, + Texts = new List { order.Id.ToString(),order.DateCreate.ToShortDateString(), order.DishName, order.Status.ToString(), order.Sum.ToString() }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 7c922ec..775e6ef 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -23,12 +23,12 @@ WordTextProperties { Bold = true, Size = "24", }) }, JustificationType = WordJustificationType.Center } }); - foreach (var component in info.Components) + foreach (var dish in info.Dishes) { CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { -(component.ComponentName, new WordTextProperties { Size = "24", }) }, +(dish.DishName, new WordTextProperties {Bold = true, Size = "24", }), (" Стоимость: " + dish.Price.ToString(), new WordTextProperties { Size = "24", }) }, TextProperties = new WordTextProperties { Size = "24", diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelStyleInfoType.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs similarity index 76% rename from FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelStyleInfoType.cs rename to FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs index 1ec9350..448f4b4 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelStyleInfoType.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels +namespace AbstractFoodOrdersBusinessLogic.OfficePackage.HelperEnums { public enum ExcelStyleInfoType { diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfParagraphAlignmentType.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs similarity index 76% rename from FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfParagraphAlignmentType.cs rename to FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs index cab111d..7f06c12 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfParagraphAlignmentType.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels +namespace AbstractFoodOrdersBusinessLogic.OfficePackage.HelperEnums { public enum PdfParagraphAlignmentType { diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs index ec9c302..e5c77f5 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperEnums; namespace AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels { diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index 83d3dbd..45ec9af 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -11,11 +11,7 @@ namespace AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List DishComponents - { - get; - set; - } = new(); + public List DishComponents { get; set; } = new(); } } diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs index ff708f7..7aa2f2f 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperEnums; namespace AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels { diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs index 63762e9..8c96620 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperEnums; namespace AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels { diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index 35f1295..98b1fbb 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -11,6 +11,6 @@ namespace AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List Components { get; set; } = new(); + public List Dishes { get; set; } = new(); } } diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/Implements/SaveToExcel.cs index 4f5a8b2..407431f 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/Implements/SaveToExcel.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/Implements/SaveToExcel.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperEnums; namespace AbstractFoodOrdersBusinessLogic.OfficePackage.Implements { diff --git a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/Implements/SaveToPdf.cs index dbd5ec6..9068e6a 100644 --- a/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/Implements/SaveToPdf.cs +++ b/FoodOrders/AbstractFoodOrdersBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -1,4 +1,5 @@ -using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels; +using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperEnums; +using AbstractFoodOrdersBusinessLogic.OfficePackage.HelperModels; using MigraDoc.DocumentObjectModel; using MigraDoc.DocumentObjectModel.Tables; using MigraDoc.Rendering; diff --git a/FoodOrders/AbstractFoodOrdersContracts/ViewModels/ReportDishComponentViewModel.cs b/FoodOrders/AbstractFoodOrdersContracts/ViewModels/ReportDishComponentViewModel.cs index bacc0f3..5a498e4 100644 --- a/FoodOrders/AbstractFoodOrdersContracts/ViewModels/ReportDishComponentViewModel.cs +++ b/FoodOrders/AbstractFoodOrdersContracts/ViewModels/ReportDishComponentViewModel.cs @@ -8,8 +8,8 @@ namespace AbstractFoodOrdersContracts.ViewModels { public class ReportDishComponentViewModel { - public string ComponentName { get; set; } = string.Empty; + public string DishName { get; set; } = string.Empty; public int TotalCount { get; set; } - public List> Dishes { get; set; } = new(); + public List<(string Component, int Count)> Components { get; set; } = new(); } } diff --git a/FoodOrders/AbstractFoodOrdersContracts/ViewModels/ReportOrdersViewModel.cs b/FoodOrders/AbstractFoodOrdersContracts/ViewModels/ReportOrdersViewModel.cs index 6d8acfe..3cab365 100644 --- a/FoodOrders/AbstractFoodOrdersContracts/ViewModels/ReportOrdersViewModel.cs +++ b/FoodOrders/AbstractFoodOrdersContracts/ViewModels/ReportOrdersViewModel.cs @@ -12,6 +12,6 @@ namespace AbstractFoodOrdersContracts.ViewModels public DateTime DateCreate { get; set; } public string DishName { get; set; } = string.Empty; public double Sum { get; set; } - + public string Status { get; set; } = string.Empty; } } diff --git a/FoodOrders/AbstractFoodOrdersDatabaseImplement/Implements/OrderStorage.cs b/FoodOrders/AbstractFoodOrdersDatabaseImplement/Implements/OrderStorage.cs index d50cfec..085e33a 100644 --- a/FoodOrders/AbstractFoodOrdersDatabaseImplement/Implements/OrderStorage.cs +++ b/FoodOrders/AbstractFoodOrdersDatabaseImplement/Implements/OrderStorage.cs @@ -23,15 +23,26 @@ namespace AbstractFoodOrdersDatabaseImplement.Implements } public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) { return new(); } - using var context = new AbstractFoodOrdersDatabase(); - return context.Orders - .Where(x => x.Id == model.Id) - .Select(x => AccessDishStorage(x.GetViewModel, context)) - .ToList(); + if (!model.DateFrom.HasValue || !model.DateTo.HasValue) + { + using var context = new AbstractFoodOrdersDatabase(); + return context.Orders + .Where(x => x.Id == model.Id) + .Select(x => AccessDishStorage(x.GetViewModel, context)) + .ToList(); + } + else + { + using var context = new AbstractFoodOrdersDatabase(); + return context.Orders + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Select(x => AccessDishStorage(x.GetViewModel, context)) + .ToList(); + } } public OrderViewModel? GetElement(OrderSearchModel model) { diff --git a/FoodOrders/AbstractFoodOrdersListImplement/Implements/OrderStorage.cs b/FoodOrders/AbstractFoodOrdersListImplement/Implements/OrderStorage.cs index db015b8..eadf6f6 100644 --- a/FoodOrders/AbstractFoodOrdersListImplement/Implements/OrderStorage.cs +++ b/FoodOrders/AbstractFoodOrdersListImplement/Implements/OrderStorage.cs @@ -29,17 +29,29 @@ namespace AbstractFoodOrdersListImplement.Implements } public List GetFilteredList(OrderSearchModel model) { - //А, собственно, этт метод не имеет ценности, так как повторяет функционал следующего var result = new List(); - if (model == null || !model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) { return result; } - foreach (var order in _source.Orders) + if (!model.DateFrom.HasValue || !model.DateTo.HasValue) { - if (order.Id == model.Id) + foreach (var order in _source.Orders) { - result.Add(AttachReinforcedName(order.GetViewModel)); + if (order.Id == model.Id) + { + result.Add(AttachReinforcedName(order.GetViewModel)); + } + } + } + else + { + foreach (var order in _source.Orders) + { + if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) + { + result.Add(AttachReinforcedName(order.GetViewModel)); + } } } return result; diff --git a/FoodOrders/AbstractShopFileImplement/Implements/OrderStorage.cs b/FoodOrders/AbstractShopFileImplement/Implements/OrderStorage.cs index 8ac2333..3c57565 100644 --- a/FoodOrders/AbstractShopFileImplement/Implements/OrderStorage.cs +++ b/FoodOrders/AbstractShopFileImplement/Implements/OrderStorage.cs @@ -27,12 +27,11 @@ namespace AbstractFoodOrdersFileImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.DateFrom.HasValue || !model.DateTo.HasValue) { return new(); } - - return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList(); + return source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => GetViewModel(x)).Select(y => { y.DishName = source.Dishes.FirstOrDefault(x => x.Id == y?.DishId)?.DishName; return y; }).ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) diff --git a/FoodOrders/FoodOrders/FoodOrders.csproj b/FoodOrders/FoodOrders/FoodOrders.csproj index 8db2995..20d39e6 100644 --- a/FoodOrders/FoodOrders/FoodOrders.csproj +++ b/FoodOrders/FoodOrders/FoodOrders.csproj @@ -9,12 +9,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -36,7 +37,9 @@ - + + Always + \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormMain.Designer.cs b/FoodOrders/FoodOrders/FormMain.Designer.cs index d3e858f..894f2eb 100644 --- a/FoodOrders/FoodOrders/FormMain.Designer.cs +++ b/FoodOrders/FoodOrders/FormMain.Designer.cs @@ -28,170 +28,165 @@ /// private void InitializeComponent() { - this.menuStrip = new System.Windows.Forms.MenuStrip(); - this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.БлюдаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.dataGridView = new System.Windows.Forms.DataGridView(); - this.ButtonCreateOrder = new System.Windows.Forms.Button(); - this.ButtonTakeOrderInWork = new System.Windows.Forms.Button(); - this.ButtonOrderReady = new System.Windows.Forms.Button(); - this.ButtonIssuedOrder = new System.Windows.Forms.Button(); - this.ButtonRef = new System.Windows.Forms.Button(); - this.отчётыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.списокКомпонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.компонентыПоБлюдамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.menuStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.SuspendLayout(); + menuStrip = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + КомпонентыToolStripMenuItem = new ToolStripMenuItem(); + БлюдаToolStripMenuItem = new ToolStripMenuItem(); + отчётыToolStripMenuItem = new ToolStripMenuItem(); + ComponentToolStripMenuItem = new ToolStripMenuItem(); + ComponentProductsToolStripMenuItem = new ToolStripMenuItem(); + OrdersToolStripMenuItem = new ToolStripMenuItem(); + dataGridView = new DataGridView(); + ButtonCreateOrder = new Button(); + ButtonTakeOrderInWork = new Button(); + ButtonOrderReady = new Button(); + ButtonIssuedOrder = new Button(); + ButtonRef = new Button(); + menuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); // // menuStrip // - this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); - this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem, - this.отчётыToolStripMenuItem}); - this.menuStrip.Location = new System.Drawing.Point(0, 0); - this.menuStrip.Name = "menuStrip"; - this.menuStrip.Size = new System.Drawing.Size(1104, 28); - this.menuStrip.TabIndex = 0; - this.menuStrip.Text = "menuStrip1"; + menuStrip.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(1104, 28); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; // // справочникиToolStripMenuItem // - this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.КомпонентыToolStripMenuItem, - this.БлюдаToolStripMenuItem}); - this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; - this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24); - this.справочникиToolStripMenuItem.Text = "Справочники"; + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыToolStripMenuItem, БлюдаToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(117, 24); + справочникиToolStripMenuItem.Text = "Справочники"; // // КомпонентыToolStripMenuItem // - this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem"; - this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26); - this.КомпонентыToolStripMenuItem.Text = "Компоненты"; - this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click); + КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem"; + КомпонентыToolStripMenuItem.Size = new Size(182, 26); + КомпонентыToolStripMenuItem.Text = "Компоненты"; + КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click; // // БлюдаToolStripMenuItem // - this.БлюдаToolStripMenuItem.Name = "БлюдаToolStripMenuItem"; - this.БлюдаToolStripMenuItem.Size = new System.Drawing.Size(224, 26); - this.БлюдаToolStripMenuItem.Text = "Блюда"; - this.БлюдаToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click); - // - // dataGridView - // - this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(0, 40); - this.dataGridView.Name = "dataGridView"; - this.dataGridView.RowHeadersWidth = 51; - this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(798, 408); - this.dataGridView.TabIndex = 1; - // - // ButtonCreateOrder - // - this.ButtonCreateOrder.Location = new System.Drawing.Point(831, 82); - this.ButtonCreateOrder.Name = "ButtonCreateOrder"; - this.ButtonCreateOrder.Size = new System.Drawing.Size(241, 29); - this.ButtonCreateOrder.TabIndex = 2; - this.ButtonCreateOrder.Text = "Создать заказ"; - this.ButtonCreateOrder.UseVisualStyleBackColor = true; - this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); - // - // ButtonTakeOrderInWork - // - this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(831, 141); - this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork"; - this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(241, 29); - this.ButtonTakeOrderInWork.TabIndex = 3; - this.ButtonTakeOrderInWork.Text = "Отдать заказ на выполнение"; - this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true; - this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); - // - // ButtonOrderReady - // - this.ButtonOrderReady.Location = new System.Drawing.Point(831, 202); - this.ButtonOrderReady.Name = "ButtonOrderReady"; - this.ButtonOrderReady.Size = new System.Drawing.Size(241, 29); - this.ButtonOrderReady.TabIndex = 4; - this.ButtonOrderReady.Text = "Заказ готов"; - this.ButtonOrderReady.UseVisualStyleBackColor = true; - this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); - // - // ButtonIssuedOrder - // - this.ButtonIssuedOrder.Location = new System.Drawing.Point(831, 264); - this.ButtonIssuedOrder.Name = "ButtonIssuedOrder"; - this.ButtonIssuedOrder.Size = new System.Drawing.Size(241, 29); - this.ButtonIssuedOrder.TabIndex = 5; - this.ButtonIssuedOrder.Text = "Заказ выдан"; - this.ButtonIssuedOrder.UseVisualStyleBackColor = true; - this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); - // - // ButtonRef - // - this.ButtonRef.Location = new System.Drawing.Point(831, 331); - this.ButtonRef.Name = "ButtonRef"; - this.ButtonRef.Size = new System.Drawing.Size(241, 29); - this.ButtonRef.TabIndex = 6; - this.ButtonRef.Text = "Обновить список"; - this.ButtonRef.UseVisualStyleBackColor = true; - this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); + БлюдаToolStripMenuItem.Name = "БлюдаToolStripMenuItem"; + БлюдаToolStripMenuItem.Size = new Size(182, 26); + БлюдаToolStripMenuItem.Text = "Блюда"; + БлюдаToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click; // // отчётыToolStripMenuItem // - this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.списокКомпонентовToolStripMenuItem, - this.компонентыПоБлюдамToolStripMenuItem, - this.списокЗаказовToolStripMenuItem}); - this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; - this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(73, 24); - this.отчётыToolStripMenuItem.Text = "Отчёты"; + отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentToolStripMenuItem, ComponentProductsToolStripMenuItem, OrdersToolStripMenuItem }); + отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + отчётыToolStripMenuItem.Size = new Size(73, 24); + отчётыToolStripMenuItem.Text = "Отчёты"; // - // списокКомпонентовToolStripMenuItem + // ComponentToolStripMenuItem // - this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; - this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(264, 26); - this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; + ComponentToolStripMenuItem.Name = "ComponentToolStripMenuItem"; + ComponentToolStripMenuItem.Size = new Size(264, 26); + ComponentToolStripMenuItem.Text = "Список блюд"; + ComponentToolStripMenuItem.Click += ComponentToolStripMenuItem_Click; // - // компонентыПоБлюдамToolStripMenuItem + // ComponentProductsToolStripMenuItem // - this.компонентыПоБлюдамToolStripMenuItem.Name = "компонентыПоБлюдамToolStripMenuItem"; - this.компонентыПоБлюдамToolStripMenuItem.Size = new System.Drawing.Size(264, 26); - this.компонентыПоБлюдамToolStripMenuItem.Text = "Компоненты по блюдам"; + ComponentProductsToolStripMenuItem.Name = "ComponentProductsToolStripMenuItem"; + ComponentProductsToolStripMenuItem.Size = new Size(264, 26); + ComponentProductsToolStripMenuItem.Text = "Компоненты по блюдам"; + ComponentProductsToolStripMenuItem.Click += ComponentProductsToolStripMenuItem_Click; // - // списокЗаказовToolStripMenuItem + // OrdersToolStripMenuItem // - this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(264, 26); - this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; + OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; + OrdersToolStripMenuItem.Size = new Size(264, 26); + OrdersToolStripMenuItem.Text = "Список заказов"; + OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; + // + // dataGridView + // + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(0, 40); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(798, 408); + dataGridView.TabIndex = 1; + // + // ButtonCreateOrder + // + ButtonCreateOrder.Location = new Point(831, 82); + ButtonCreateOrder.Name = "ButtonCreateOrder"; + ButtonCreateOrder.Size = new Size(241, 29); + ButtonCreateOrder.TabIndex = 2; + ButtonCreateOrder.Text = "Создать заказ"; + ButtonCreateOrder.UseVisualStyleBackColor = true; + ButtonCreateOrder.Click += ButtonCreateOrder_Click; + // + // ButtonTakeOrderInWork + // + ButtonTakeOrderInWork.Location = new Point(831, 141); + ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork"; + ButtonTakeOrderInWork.Size = new Size(241, 29); + ButtonTakeOrderInWork.TabIndex = 3; + ButtonTakeOrderInWork.Text = "Отдать заказ на выполнение"; + ButtonTakeOrderInWork.UseVisualStyleBackColor = true; + ButtonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; + // + // ButtonOrderReady + // + ButtonOrderReady.Location = new Point(831, 202); + ButtonOrderReady.Name = "ButtonOrderReady"; + ButtonOrderReady.Size = new Size(241, 29); + ButtonOrderReady.TabIndex = 4; + ButtonOrderReady.Text = "Заказ готов"; + ButtonOrderReady.UseVisualStyleBackColor = true; + ButtonOrderReady.Click += ButtonOrderReady_Click; + // + // ButtonIssuedOrder + // + ButtonIssuedOrder.Location = new Point(831, 264); + ButtonIssuedOrder.Name = "ButtonIssuedOrder"; + ButtonIssuedOrder.Size = new Size(241, 29); + ButtonIssuedOrder.TabIndex = 5; + ButtonIssuedOrder.Text = "Заказ выдан"; + ButtonIssuedOrder.UseVisualStyleBackColor = true; + ButtonIssuedOrder.Click += ButtonIssuedOrder_Click; + // + // ButtonRef + // + ButtonRef.Location = new Point(831, 331); + ButtonRef.Name = "ButtonRef"; + ButtonRef.Size = new Size(241, 29); + ButtonRef.TabIndex = 6; + ButtonRef.Text = "Обновить список"; + ButtonRef.UseVisualStyleBackColor = true; + ButtonRef.Click += ButtonRef_Click; // // FormMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1104, 470); - this.Controls.Add(this.ButtonRef); - this.Controls.Add(this.ButtonIssuedOrder); - this.Controls.Add(this.ButtonOrderReady); - this.Controls.Add(this.ButtonTakeOrderInWork); - this.Controls.Add(this.ButtonCreateOrder); - this.Controls.Add(this.dataGridView); - this.Controls.Add(this.menuStrip); - this.MainMenuStrip = this.menuStrip; - this.Name = "FormMain"; - this.Text = "Доставка еды"; - this.Load += new System.EventHandler(this.FormMain_Load); - this.menuStrip.ResumeLayout(false); - this.menuStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1104, 470); + Controls.Add(ButtonRef); + Controls.Add(ButtonIssuedOrder); + Controls.Add(ButtonOrderReady); + Controls.Add(ButtonTakeOrderInWork); + Controls.Add(ButtonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormMain"; + Text = "Доставка еды"; + Load += FormMain_Load; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); } #endregion @@ -207,8 +202,8 @@ private Button ButtonIssuedOrder; private Button ButtonRef; private ToolStripMenuItem отчётыToolStripMenuItem; - private ToolStripMenuItem списокКомпонентовToolStripMenuItem; - private ToolStripMenuItem компонентыПоБлюдамToolStripMenuItem; - private ToolStripMenuItem списокЗаказовToolStripMenuItem; + private ToolStripMenuItem ComponentToolStripMenuItem; + private ToolStripMenuItem ComponentProductsToolStripMenuItem; + private ToolStripMenuItem OrdersToolStripMenuItem; } } \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormMain.cs b/FoodOrders/FoodOrders/FormMain.cs index e44ffc2..16a8ca7 100644 --- a/FoodOrders/FoodOrders/FormMain.cs +++ b/FoodOrders/FoodOrders/FormMain.cs @@ -1,4 +1,5 @@ -using AbstractFoodOrdersContracts.BindingModels; +using AbstractFoodOrdersBusinessLogic.BusinessLogics; +using AbstractFoodOrdersContracts.BindingModels; using AbstractFoodOrdersContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; using System; @@ -17,11 +18,13 @@ namespace FoodOrders { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + private readonly IReportLogic _reportLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void FormMain_Load(object sender, EventArgs e) { @@ -80,7 +83,7 @@ namespace FoodOrders int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try + try { var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel @@ -157,5 +160,38 @@ namespace FoodOrders { LoadData(); } + + private void ComponentToolStripMenuItem_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 ComponentProductsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportDishComponents)); + if (service is FormReportDishComponents form) + { + form.ShowDialog(); + } + } + + private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + + } } } diff --git a/FoodOrders/FoodOrders/FormReportDishComponents.Designer.cs b/FoodOrders/FoodOrders/FormReportDishComponents.Designer.cs index 5d0ee95..55601f0 100644 --- a/FoodOrders/FoodOrders/FormReportDishComponents.Designer.cs +++ b/FoodOrders/FoodOrders/FormReportDishComponents.Designer.cs @@ -28,81 +28,77 @@ /// private void InitializeComponent() { - this.dataGridView = new System.Windows.Forms.DataGridView(); - this.ComponentColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.DishColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.CountColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ButtonSave = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.SuspendLayout(); + dataGridView = new DataGridView(); + ButtonSave = new Button(); + DishColumn = new DataGridViewTextBoxColumn(); + ComponentColumn = new DataGridViewTextBoxColumn(); + CountColumn = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); // // dataGridView // - this.dataGridView.AllowUserToAddRows = false; - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.ComponentColumn, - this.DishColumn, - this.CountColumn}); - this.dataGridView.Location = new System.Drawing.Point(1, 71); - this.dataGridView.Name = "dataGridView"; - this.dataGridView.RowHeadersWidth = 51; - this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(797, 378); - this.dataGridView.TabIndex = 0; - // - // ComponentColumn - // - this.ComponentColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.ComponentColumn.HeaderText = "Компонент"; - this.ComponentColumn.MinimumWidth = 6; - this.ComponentColumn.Name = "ComponentColumn"; - // - // DishColumn - // - this.DishColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.DishColumn.HeaderText = "Блюдо"; - this.DishColumn.MinimumWidth = 6; - this.DishColumn.Name = "DishColumn"; - // - // CountColumn - // - this.CountColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.CountColumn.HeaderText = "Количество"; - this.CountColumn.MinimumWidth = 6; - this.CountColumn.Name = "CountColumn"; + dataGridView.AllowUserToAddRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { DishColumn, ComponentColumn, CountColumn }); + dataGridView.Location = new Point(1, 71); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(797, 378); + dataGridView.TabIndex = 0; // // ButtonSave // - this.ButtonSave.Location = new System.Drawing.Point(12, 24); - this.ButtonSave.Name = "ButtonSave"; - this.ButtonSave.Size = new System.Drawing.Size(181, 29); - this.ButtonSave.TabIndex = 1; - this.ButtonSave.Text = "Сохранить в Excel"; - this.ButtonSave.UseVisualStyleBackColor = true; - this.ButtonSave.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); + ButtonSave.Location = new Point(12, 24); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(181, 29); + ButtonSave.TabIndex = 1; + ButtonSave.Text = "Сохранить в Excel"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSaveToExcel_Click; + // + // DishColumn + // + DishColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + DishColumn.HeaderText = "Блюдо"; + DishColumn.MinimumWidth = 6; + DishColumn.Name = "DishColumn"; + // + // ComponentColumn + // + ComponentColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + ComponentColumn.HeaderText = "Компонент"; + ComponentColumn.MinimumWidth = 6; + ComponentColumn.Name = "ComponentColumn"; + // + // CountColumn + // + CountColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + CountColumn.HeaderText = "Количество"; + CountColumn.MinimumWidth = 6; + CountColumn.Name = "CountColumn"; // // FormReportDishComponents // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.ButtonSave); - this.Controls.Add(this.dataGridView); - this.Name = "FormReportDishComponents"; - this.Text = "FormReportDishComponents"; - this.Load += new System.EventHandler(this.FormReportDishComponents_Load); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.ResumeLayout(false); - + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(ButtonSave); + Controls.Add(dataGridView); + Name = "FormReportDishComponents"; + Text = "FormReportDishComponents"; + Load += FormReportDishComponents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); } #endregion private DataGridView dataGridView; - private DataGridViewTextBoxColumn ComponentColumn; - private DataGridViewTextBoxColumn DishColumn; - private DataGridViewTextBoxColumn CountColumn; private Button ButtonSave; + private DataGridViewTextBoxColumn DishColumn; + private DataGridViewTextBoxColumn ComponentColumn; + private DataGridViewTextBoxColumn CountColumn; } } \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormReportDishComponents.cs b/FoodOrders/FoodOrders/FormReportDishComponents.cs index 5af50f0..df949bc 100644 --- a/FoodOrders/FoodOrders/FormReportDishComponents.cs +++ b/FoodOrders/FoodOrders/FormReportDishComponents.cs @@ -35,8 +35,8 @@ namespace FoodOrders dataGridView.Rows.Clear(); foreach (var elem in dict) { - dataGridView.Rows.Add(new object[] { elem.ComponentName,"", "" }); - foreach (var listElem in elem.Dishes) + dataGridView.Rows.Add(new object[] { elem.DishName, "", "" }); + foreach (var listElem in elem.Components) { dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); } @@ -49,7 +49,7 @@ namespace FoodOrders catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки списка блюд по компонентам"); - + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } diff --git a/FoodOrders/FoodOrders/FormReportDishComponents.resx b/FoodOrders/FoodOrders/FormReportDishComponents.resx index aec059f..9a23a75 100644 --- a/FoodOrders/FoodOrders/FormReportDishComponents.resx +++ b/FoodOrders/FoodOrders/FormReportDishComponents.resx @@ -57,10 +57,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + True - + True diff --git a/FoodOrders/FoodOrders/FormReportOrders.Designer.cs b/FoodOrders/FoodOrders/FormReportOrders.Designer.cs new file mode 100644 index 0000000..7af1713 --- /dev/null +++ b/FoodOrders/FoodOrders/FormReportOrders.Designer.cs @@ -0,0 +1,131 @@ +namespace FoodOrders +{ + 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() + { + panel = new Panel(); + ButtonToPdf = new Button(); + ButtonMake = new Button(); + label2 = new Label(); + label1 = new Label(); + dateTimePickerTo = new DateTimePicker(); + dateTimePickerFrom = new DateTimePicker(); + panel.SuspendLayout(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(ButtonToPdf); + panel.Controls.Add(ButtonMake); + panel.Controls.Add(label2); + panel.Controls.Add(label1); + panel.Controls.Add(dateTimePickerTo); + panel.Controls.Add(dateTimePickerFrom); + panel.Location = new Point(1, 1); + panel.Name = "panel"; + panel.Size = new Size(900, 51); + panel.TabIndex = 0; + // + // ButtonToPdf + // + ButtonToPdf.Location = new Point(782, 10); + ButtonToPdf.Name = "ButtonToPdf"; + ButtonToPdf.Size = new Size(94, 29); + ButtonToPdf.TabIndex = 5; + ButtonToPdf.Text = "В pdf"; + ButtonToPdf.UseVisualStyleBackColor = true; + ButtonToPdf.Click += ButtonToPdf_Click; + // + // ButtonMake + // + ButtonMake.Location = new Point(628, 9); + ButtonMake.Name = "ButtonMake"; + ButtonMake.Size = new Size(123, 29); + ButtonMake.TabIndex = 4; + ButtonMake.Text = "Сформировать"; + ButtonMake.UseVisualStyleBackColor = true; + ButtonMake.Click += ButtonMake_Click; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(318, 15); + label2.Name = "label2"; + label2.Size = new Size(27, 20); + label2.TabIndex = 3; + label2.Text = "по"; + // + // label1 + // + label1.AutoSize = true; + label1.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + label1.Location = new Point(28, 7); + label1.Name = "label1"; + label1.Size = new Size(24, 28); + label1.TabIndex = 2; + label1.Text = "С"; + // + // dateTimePickerTo + // + dateTimePickerTo.Location = new Point(351, 11); + dateTimePickerTo.Name = "dateTimePickerTo"; + dateTimePickerTo.Size = new Size(250, 27); + dateTimePickerTo.TabIndex = 1; + // + // dateTimePickerFrom + // + dateTimePickerFrom.Location = new Point(62, 11); + dateTimePickerFrom.Name = "dateTimePickerFrom"; + dateTimePickerFrom.Size = new Size(250, 27); + dateTimePickerFrom.TabIndex = 0; + // + // FormReportOrders + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(901, 450); + Controls.Add(panel); + Name = "FormReportOrders"; + Text = "FormReportOrders"; + Load += FormReportOrders_Load; + panel.ResumeLayout(false); + panel.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button ButtonToPdf; + private Button ButtonMake; + private Label label2; + private Label label1; + private DateTimePicker dateTimePickerTo; + private DateTimePicker dateTimePickerFrom; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormReportOrders.cs b/FoodOrders/FoodOrders/FormReportOrders.cs new file mode 100644 index 0000000..a1d8cee --- /dev/null +++ b/FoodOrders/FoodOrders/FormReportOrders.cs @@ -0,0 +1,110 @@ +using AbstractFoodOrdersContracts.BindingModels; +using AbstractFoodOrdersContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +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 FoodOrders +{ + 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(panel); + Controls.Add(reportViewer); + + } + + private void FormReportOrders_Load(object sender, EventArgs e) + { + } + + 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/FoodOrders/FoodOrders/FormReportOrders.resx b/FoodOrders/FoodOrders/FormReportOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FoodOrders/FoodOrders/FormReportOrders.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/FoodOrders/FoodOrders/Program.cs b/FoodOrders/FoodOrders/Program.cs index 4db3cac..b1502d2 100644 --- a/FoodOrders/FoodOrders/Program.cs +++ b/FoodOrders/FoodOrders/Program.cs @@ -1,4 +1,6 @@ using AbstractFoodOrdersBusinessLogic.BusinessLogics; +using AbstractFoodOrdersBusinessLogic.OfficePackage.Implements; +using AbstractFoodOrdersBusinessLogic.OfficePackage; using AbstractFoodOrdersContracts.BusinessLogicsContracts; using AbstractFoodOrdersContracts.StoragesContracts; using AbstractFoodOrdersDatabaseImplement.Implements; @@ -40,6 +42,10 @@ namespace FoodOrders services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -47,7 +53,8 @@ namespace FoodOrders services.AddTransient(); services.AddTransient(); services.AddTransient(); - + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.BusinessLogicsContracts.IDishLogic.datasource b/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.BusinessLogicsContracts.IDishLogic.datasource deleted file mode 100644 index 5964ba2..0000000 --- a/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.BusinessLogicsContracts.IDishLogic.datasource +++ /dev/null @@ -1,10 +0,0 @@ - - - - AbstractFoodOrdersContracts.BusinessLogicsContracts.IDishLogic, AbstractFoodOrdersContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - \ No newline at end of file diff --git a/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.BusinessLogicsContracts.IOrderLogic.datasource b/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.BusinessLogicsContracts.IOrderLogic.datasource deleted file mode 100644 index 3eab5f4..0000000 --- a/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.BusinessLogicsContracts.IOrderLogic.datasource +++ /dev/null @@ -1,10 +0,0 @@ - - - - AbstractFoodOrdersContracts.BusinessLogicsContracts.IOrderLogic, AbstractFoodOrdersContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - \ No newline at end of file diff --git a/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IComponentStorage.datasource b/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IComponentStorage.datasource deleted file mode 100644 index f102677..0000000 --- a/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IComponentStorage.datasource +++ /dev/null @@ -1,10 +0,0 @@ - - - - AbstractFoodOrdersContracts.StoragesContracts.IComponentStorage, AbstractFoodOrdersContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - \ No newline at end of file diff --git a/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IDishStorage.datasource b/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IDishStorage.datasource deleted file mode 100644 index b50378b..0000000 --- a/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IDishStorage.datasource +++ /dev/null @@ -1,10 +0,0 @@ - - - - AbstractFoodOrdersContracts.StoragesContracts.IDishStorage, AbstractFoodOrdersContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - \ No newline at end of file diff --git a/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IOrderStorage.datasource b/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IOrderStorage.datasource deleted file mode 100644 index 36188e2..0000000 --- a/FoodOrders/FoodOrders/Properties/DataSources/AbstractFoodOrdersContracts.StoragesContracts.IOrderStorage.datasource +++ /dev/null @@ -1,10 +0,0 @@ - - - - AbstractFoodOrdersContracts.StoragesContracts.IOrderStorage, AbstractFoodOrdersContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - \ No newline at end of file diff --git a/FoodOrders/FoodOrders/ReportOrders.rdlc b/FoodOrders/FoodOrders/ReportOrders.rdlc index c453aa5..02c94da 100644 --- a/FoodOrders/FoodOrders/ReportOrders.rdlc +++ b/FoodOrders/FoodOrders/ReportOrders.rdlc @@ -1,11 +1,55 @@ 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + AbstractFoodOrdersContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + DishName + System.String + + + Sum + System.Decimal + + + Status + System.String + + + + AbstractFoodOrdersContracts.ViewModels + ReportOrdersViewModel + AbstractFoodOrdersContracts.ViewModels.ReportOrdersViewModel, AbstractFoodOrdersContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + - + true true @@ -13,10 +57,7 @@ Заказы - + - Textbox1 - 0.33867cm - 0.88787cm + 0.6cm 16.51cm + Middle 2pt 2pt 2pt @@ -55,10 +95,431 @@ ReportParameterPeriod - 1.33237cm - 0.77639cm + 0.6cm + 0.6cm 16.51cm 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.60583cm + + + 4.04517cm + + + 4.8495cm + + + 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!DishName.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 + 1.9177cm + 0.79267cm + 1.2cm + 16.5005cm + 2 + + + + + + true + true + + + + + Итого: + + + + 3.46287cm + 11.51cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + @@ -70,10 +531,10 @@ - 2.425in + 2in