From de4b7c8c07f6399ad93f63d607d8f061c87c1b68 Mon Sep 17 00:00:00 2001 From: platoff aeeee Date: Wed, 22 May 2024 10:14:48 +0400 Subject: [PATCH] lab5proc --- .../BussinessLogic/ClientLogic.cs | 14 ++ .../BussinessLogic/OrderLogic.cs | 43 +++- .../BussinessLogic/ReportLogic.cs | 21 +- .../OfficePackage/AbstractSaveToExcel.cs | 5 + .../OfficePackage/AbstractSaveToPdf.cs | 27 ++- .../OfficePackage/AbstractSaveToWord.cs | 18 +- .../HelperEnums/ExcelStyleInfoType.cs | 4 + .../HelperEnums/PdfParagraphAlignmentType.cs | 4 + .../HelperEnums/WordJustificationType.cs | 3 + .../HelperModels/ExcelCellParameters.cs | 21 +- .../OfficePackage/HelperModels/ExcelInfo.cs | 9 +- .../HelperModels/ExcelMergeParameters.cs | 1 + .../OfficePackage/HelperModels/PdfInfo.cs | 1 + .../HelperModels/PdfParagraph.cs | 5 +- .../HelperModels/PdfRowParameters.cs | 5 +- .../OfficePackage/HelperModels/WordInfo.cs | 1 + .../HelperModels/WordParagraph.cs | 5 +- .../HelperModels/WordTextProperties.cs | 1 + .../OfficePackage/Implements/SaveToExcel.cs | 13 +- .../OfficePackage/Implements/SaveToPdf.cs | 1 + .../OfficePackage/Implements/SaveToWord.cs | 10 +- .../Controllers/HomeController.cs | 11 + .../Views/Home/Index.cshtml | 2 +- .../Views/Home/_Layout.cshtml | 2 +- .../Views/Shared/_Layout.cshtml.css | 41 ++-- .../BindingModels/ClientBindingModel.cs | 10 +- .../BindingModels/OrderBindingModel.cs | 4 +- .../BindingModels/ReportBindingModel.cs | 1 + .../BusinessLogicsContracts/IClientLogic.cs | 11 +- .../BusinessLogicsContracts/IReportLogic.cs | 6 +- .../SearchModels/ClientSearchModel.cs | 6 +- .../SearchModels/OrderSearchModel.cs | 9 +- .../StoragesContracts/IClientStorage.cs | 1 + .../StoragesContracts/IOrderStorage.cs | 1 + .../ViewModels/ClientViewModel.cs | 8 +- .../ReportFurnitureWorkPieceViewModel.cs | 4 +- .../ViewModels/ReportOrdersViewModel.cs | 2 +- .../Models/IClientModel.cs | 3 + .../FurnitureAssemblyDatabase.cs | 3 +- .../20240327064137_InitialCreate.cs | 2 +- .../Migrations/20240521203342_lab52.cs | 2 +- .../DataFileSingleton.cs | 2 +- .../Implements/ClientStorage.cs | 2 +- .../Implements/FurnitureStorage.cs | 9 +- .../Implements/OrderStorage.cs | 8 +- .../Implements/WorkPieceStorage.cs | 1 + .../Models/Furniture.cs | 1 + .../Models/Order.cs | 3 +- .../Models/WorkPiece.cs | 1 + .../DataListSingleton.cs | 8 +- .../Implements/ClientStorage.cs | 1 + .../Implements/OrderStorage.cs | 14 +- .../Models/Client.cs | 5 + .../Models/Order.cs | 8 +- .../FormClients.Designer.cs | 31 ++- .../FurnitureAssemblyView/FormClients.cs | 122 +++++----- .../FormCreateOrder.Designer.cs | 116 +++++---- .../FurnitureAssemblyView/FormCreateOrder.cs | 222 ++++++++++-------- .../FormMain.Designer.cs | 45 ++-- .../FurnitureAssemblyView/FormMain.cs | 22 +- .../FurnitureAssemblyView/Program.cs | 10 +- 61 files changed, 593 insertions(+), 379 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/ClientLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/ClientLogic.cs index b2c2e3f..272530b 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/ClientLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/ClientLogic.cs @@ -12,12 +12,14 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.BussinessLogic { + // Класс, реализующий логику для клиентов public class ClientLogic : IClientLogic { private readonly ILogger _logger; private readonly IClientStorage _clientStorage; + // Конструктор public ClientLogic(ILogger logger, IClientStorage clientStorage) { _logger = logger; @@ -28,6 +30,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic { _logger.LogInformation("ReadList. Email:{Email}. Id:{Id}", model?.Email, model?.Id); + // list хранит весь список в случае, если model пришло со значением null на вход метода var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model); if (list == null) @@ -108,24 +111,33 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic return true; } + // Проверка входного аргумента для методов Insert, Update и Delete private void CheckModel(ClientBindingModel model, bool withParams = true) { if (model == null) { throw new ArgumentNullException(nameof(model)); } + + // При удалении передаём как параметр false if (!withParams) { return; } + + // Проверка на наличие Фамилии Имени и Отчества if (string.IsNullOrEmpty(model.ClientFIO)) { throw new ArgumentNullException("Отсутствие ФИО в учётной записи", nameof(model.ClientFIO)); } + + // Проверка на наличие эл. почты if (string.IsNullOrEmpty(model.Email)) { throw new ArgumentNullException("Отсутствие эл. почты в учётной записи (логина)", nameof(model.Email)); } + + // Проверка на наличие пароля if (string.IsNullOrEmpty(model.Password)) { throw new ArgumentNullException("Отсутствие пароля в учётной записи", nameof(model.Password)); @@ -133,11 +145,13 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic _logger.LogInformation("Client. ClientFIO:{ClientFIO}. Email:{Email}. Id:{Id} ", model.ClientFIO, model.Email, model.Id); + // Для проверка на наличие такого же аккаунта var element = _clientStorage.GetElement(new ClientSearchModel { Email = model.Email }); + // Если элемент найден и его Id не совпадает с Id переданного объекта if (element != null && element.Id != model.Id) { throw new InvalidOperationException("Аккаунт с таким логином уже есть"); diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/OrderLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/OrderLogic.cs index f0b2635..aeee864 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/OrderLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/OrderLogic.cs @@ -13,25 +13,29 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.BussinessLogic { + // Класс, реализующий логику для заказов public class OrderLogic : IOrderLogic { private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; + // Конструктор public OrderLogic(ILogger logger, IOrderStorage orderStorage) { _logger = logger; _orderStorage = orderStorage; } + // Вывод отфильтрованного списка компонентов public List? ReadList(OrderSearchModel? model) { _logger.LogInformation("ReadList. Id:{Id}", model?.Id); + // list хранит весь список в случае, если model пришло со значением null на вход метода var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); - if (list == null) + if(list == null) { _logger.LogWarning("ReadList return null list"); @@ -43,11 +47,12 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic return list; } + // Создание чека public bool CreateOrder(OrderBindingModel model) { CheckModel(model); - if (model.Status != OrderStatus.Неизвестен) + if(model.Status != OrderStatus.Неизвестен) { _logger.LogWarning("Insert operation failed, incorrect order status"); return false; @@ -55,7 +60,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic model.Status = OrderStatus.Принят; - if (_orderStorage.Insert(model) == null) + if(_orderStorage.Insert(model) == null) { model.Status = OrderStatus.Неизвестен; _logger.LogWarning("Insert operation failed"); @@ -80,6 +85,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic return StatusUpdate(model, OrderStatus.Выдан); } + // Проверка на пустоту входного параметра private void CheckModel(OrderBindingModel model, bool withParams = true) { if (model == null) @@ -87,27 +93,37 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic throw new ArgumentNullException(nameof(model)); } + // При удалении параметру withParams передаём false if (!withParams) { return; } - if (model.Count <= 0) + // Проверка на наличие товаров в заказе + if(model.Count <= 0) { throw new ArgumentNullException("В заказе не может быть 0 изделий", nameof(model.Count)); } - if (model.Sum <= 0) + + // Проверка на наличие нормальной суммарной стоимости чека + if(model.Sum <= 0) { throw new ArgumentNullException("Суммарная стоимость заказа должна быть больше 0", nameof(model.Sum)); } - if (model.FurnitureId < 0) + + // Проверка корректности id у изделий + if(model.FurnitureId < 0) { throw new ArgumentNullException("Некорректный id у изделия", nameof(model.FurnitureId)); } - if (model.DateCreate > model.DateImplement) + + // Проверка корректности дат + if(model.DateCreate > model.DateImplement) { throw new InvalidOperationException("Дата создания должна быть более ранней, нежели дата завершения"); } + + // Проверка на клиента if (model.ClientId < 0) { throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.ClientId)); @@ -116,16 +132,19 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic _logger.LogInformation("Order. OrderId:{Id}. Sum:{Sum}. ClientId:{ClientId}. FurnitureId:{Id}", model.Id, model.Sum, model.ClientId, model.FurnitureId); } + // Обновление статуса заказа public bool StatusUpdate(OrderBindingModel model, OrderStatus newOrderStatus) { var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); - if (viewModel == null) + // Если не смогли найти указанный заказ по его Id + if(viewModel == null) { throw new ArgumentNullException(nameof(model)); } - if (viewModel.Status + 1 != newOrderStatus) + // Проверка на возможность обновления статуса на следующий + if(viewModel.Status + 1 != newOrderStatus) { _logger.LogWarning("Status update operation failed. New status " + newOrderStatus.ToString() + "incorrect"); return false; @@ -133,7 +152,8 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic model.Status = newOrderStatus; - if (model.Status == OrderStatus.Выдан) + // Проверка на выдачу + if(model.Status == OrderStatus.Выдан) { model.DateImplement = DateTime.Now; } @@ -144,7 +164,8 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic CheckModel(model, false); - if (_orderStorage.Update(model) == null) + // Финальная проверка на возможность обновления + if(_orderStorage.Update(model) == null) { model.Status--; diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/ReportLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/ReportLogic.cs index 8e4a2cf..f672ccd 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/ReportLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/ReportLogic.cs @@ -1,10 +1,10 @@ -using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyBusinessLogic.OfficePackage; +using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels; +using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.BusinessLogicsContracts; using FurnitureAssemblyContracts.SearchModels; using FurnitureAssemblyContracts.StoragesContracts; using FurnitureAssemblyContracts.ViewModels; -using FurnitureAssemblyBusinessLogic.OfficePackage; -using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +13,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.BussinessLogic { + // Реализация бизнес-логики отчётов public class ReportLogic : IReportLogic { private readonly IFurnitureStorage _furnitureStorage; @@ -25,9 +26,10 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic private readonly AbstractSaveToPdf _saveToPdf; - public ReportLogic(IFurnitureStorage furnitureStorage, - IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, - AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) + // Инициализируем поля класса через контейнер + public ReportLogic(IFurnitureStorage furnitureStorage, + IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, + AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) { _furnitureStorage = furnitureStorage; _orderStorage = orderStorage; @@ -37,7 +39,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic _saveToPdf = saveToPdf; } - + // Получение списка компонент с указанием, в каких изделиях используются public List GetFurnitureWorkPiece() { var furnitures = _furnitureStorage.GetFullList(); @@ -65,6 +67,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic return list; } + // Получение списка заказов за определённый период public List GetOrders(ReportBindingModel model) { return _orderStorage.GetFilteredList(new OrderSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo }) @@ -78,6 +81,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic }).ToList(); } + // Сохранение мебели в файл-Word public void SaveFurnituresToWordFile(ReportBindingModel model) { _saveToWord.CreateDoc(new WordInfo @@ -87,6 +91,8 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic Furnitures = _furnitureStorage.GetFullList() }); } + + // Сохранение заготовок с указанием изделий в файл_Excel public void SaveFurnitureWorkPieceToExcelFile(ReportBindingModel model) { _saveToExcel.CreateReport(new ExcelInfo @@ -97,6 +103,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic }); } + // Сохранение заказов в файл-Pdf public void SaveOrdersToPdfFile(ReportBindingModel model) { _saveToPdf.CreateDoc(new PdfInfo diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index b3ba79d..6732864 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -10,6 +10,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage { public abstract class AbstractSaveToExcel { + // Создание отчета. Описание методов ниже public void CreateReport(ExcelInfo info) { CreateExcel(info); @@ -85,12 +86,16 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage SaveExcel(info); } + // Создание Excel-файла protected abstract void CreateExcel(ExcelInfo info); + // Добавляем новую ячейку в лист protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); + // Объединение ячеек protected abstract void MergeCells(ExcelMergeParameters excelParams); + // Сохранение файла protected abstract void SaveExcel(ExcelInfo info); } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 11fc9d9..74e7261 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -1,16 +1,16 @@ -using System; +using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; +using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; -using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels; - namespace FurnitureAssemblyBusinessLogic.OfficePackage { public abstract class AbstractSaveToPdf { + // Публичный метод создания документа. Описание методов ниже public void CreateDoc(PdfInfo info) { CreatePdf(info); @@ -57,11 +57,20 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage SavePdf(info); } - protected abstract void CreatePdf(PdfInfo info); - protected abstract void CreateParagraph(PdfParagraph paragraph); - protected abstract void CreateTable(List columns); - protected abstract void CreateRow(PdfRowParameters rowParameters); - protected abstract void SavePdf(PdfInfo info); + /// Создание Pdf-файла + protected abstract void CreatePdf(PdfInfo info); + + /// Создание параграфа с текстом + protected abstract void CreateParagraph(PdfParagraph paragraph); + + /// Создание таблицы + protected abstract void CreateTable(List columns); + + /// Создание и заполнение строки + protected abstract void CreateRow(PdfRowParameters rowParameters); + + /// Сохранение файла + protected abstract void SavePdf(PdfInfo info); } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 0cae3f3..ee2ddf5 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -1,20 +1,21 @@ -using System; +using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; +using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; -using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels; - namespace FurnitureAssemblyBusinessLogic.OfficePackage { public abstract class AbstractSaveToWord { + // Метод создания документа public void CreateDoc(WordInfo info) { CreateWord(info); + // Создание ряда абзацев CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) }, @@ -25,6 +26,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage } }); + // Заполнение абзацев текстом foreach (var furniture in info.Furnitures) { CreateParagraph(new WordParagraph @@ -42,9 +44,13 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage SaveWord(info); } + // Создание Doc-файла protected abstract void CreateWord(WordInfo info); - protected abstract void CreateParagraph(WordParagraph paragraph); - protected abstract void SaveWord(WordInfo info); + // Создание абзаца с текстом + protected abstract void CreateParagraph(WordParagraph paragraph); + + // Сохранение файла + protected abstract void SaveWord(WordInfo info); } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs index ef1ed4b..1b778a9 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs @@ -6,12 +6,16 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums { + // Вспомогательное перечисление для оформления excel public enum ExcelStyleInfoType { + // Заголовок Title, + // Просто текст Text, + // Текст в рамке TextWithBorder } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs index e6294f4..a8fcd28 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs @@ -6,12 +6,16 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums { + // Вспомогательное перечисление для оформления pdf документа public enum PdfParagraphAlignmentType { + // Либо по центру Center, + // Либо с левого края Left, + // Либо с правого края Right } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs index acf9e1b..77fd3b4 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs @@ -6,10 +6,13 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums { + // Вспомогательное перечисление для настройки формата word документа public enum WordJustificationType { + // Выравниваем либо по центру Center, + // Либо на всю ширину Both } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs index 639cea8..9265cb9 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs @@ -1,19 +1,28 @@ -using System; +using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels { + // Информация по ячейке в таблице excel public class ExcelCellParameters { + // Название колонки public string ColumnName { get; set; } = string.Empty; - public uint RowIndex { get; set; } - public string Text { get; set; } = string.Empty; - public string CellReference => $"{ColumnName}{RowIndex}"; - public ExcelStyleInfoType StyleInfo { get; set; } + // Строка + public uint RowIndex { get; set; } + + // Тект в ячейке + public string Text { get; set; } = string.Empty; + + // Геттер для того, чтобы не искать каждый раз + public string CellReference => $"{ColumnName}{RowIndex}"; + + // В каком стиле выводить информацию + public ExcelStyleInfoType StyleInfo { get; set; } } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index 17a32f0..34b71b5 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -7,11 +7,16 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels { + // Информация по excel файлу, который хотим создать public class ExcelInfo { + // Название файла public string FileName { get; set; } = string.Empty; - public string Title { get; set; } = string.Empty; - public List FurnitureWorkPieces { get; set; } = new(); + // Заголовок + public string Title { get; set; } = string.Empty; + + // Список заготовок по изделиям + public List FurnitureWorkPieces { get; set; } = new(); } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs index b0a9321..1b6b6bc 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels { + // Информация для объединения ячеек public class ExcelMergeParameters { public string CellFromName { get; set; } = string.Empty; diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index ee2e1b5..7e9549d 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels { + // Общая информация по pdf файлу public class PdfInfo { public string FileName { get; set; } = string.Empty; diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs index 8f1c340..b39f4b6 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs @@ -1,12 +1,13 @@ -using System; +using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels { + // Информация п параграфу в pdf документе public class PdfParagraph { public string Text { get; set; } = string.Empty; diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs index a9b3d66..4fe4fda 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs @@ -1,12 +1,13 @@ -using System; +using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels { + // Информация по параметрам строк таблицы public class PdfRowParameters { // Набор текстов diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index c5ff534..987a54a 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels { + // Общая информация по документу public class WordInfo { public string FileName { get; set; } = string.Empty; diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs index c775c71..12c062a 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs @@ -6,10 +6,13 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels { + // Модель параграфов, которые есть в тексте public class WordParagraph { + // Набор текстов в абзаце (для случая, если в абзаце текст разных стилей) public List<(string, WordTextProperties)> Texts { get; set; } = new(); - public WordTextProperties? TextProperties { get; set; } + //свойства параграфа, если они есть + public WordTextProperties? TextProperties { get; set; } } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs index fbde3f7..b8ae4ac 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels { + // Модель свойств текста, которые нам нужны в Word документе public class WordTextProperties { // Размер текста diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToExcel.cs index fa00708..68128dc 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToExcel.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToExcel.cs @@ -1,18 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using DocumentFormat.OpenXml.Office2010.Excel; +using DocumentFormat.OpenXml.Office2010.Excel; using DocumentFormat.OpenXml.Office2013.Excel; using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Spreadsheet; using DocumentFormat.OpenXml; using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums; using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements { + // Реализация абстрактного класса создания Excel документа public class SaveToExcel : AbstractSaveToExcel { private SpreadsheetDocument? _spreadsheetDocument; diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToPdf.cs index abed695..fea96bc 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToPdf.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements { + // Реализация абстрактного класса создания Pdf документа public class SaveToPdf : AbstractSaveToPdf { private Document? _document; diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToWord.cs index f3981a5..66e8513 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -8,10 +8,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using DocumentFormat.OpenXml.Vml; namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements { + // Реализация абстрактного класса сохранения в Word документ public class SaveToWord : AbstractSaveToWord { private WordprocessingDocument? _wordDocument; @@ -122,8 +122,6 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements if (run.Item2.Bold) { - // properties.AppendChild(new Italic()); - properties.AppendChild(new Bold()); } @@ -141,7 +139,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements _docBody.AppendChild(docParagraph); } - // сохранение документа + // Метод сохранения документа protected override void SaveWord(WordInfo info) { if (_docBody == null || _wordDocument == null) @@ -149,10 +147,10 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements return; } - // вставляем инфу по секциям (настройка страницы) + // Вставляем информацию по секциям (смотри, что является входным параметром) _docBody.AppendChild(CreateSectionProperties()); - // сохраняем + // Сохраняем документ _wordDocument.MainDocumentPart!.Document.Save(); _wordDocument.Dispose(); diff --git a/FurnitureAssembly/FurnitureAssemblyClientApp/Controllers/HomeController.cs b/FurnitureAssembly/FurnitureAssemblyClientApp/Controllers/HomeController.cs index 33c5199..3037960 100644 --- a/FurnitureAssembly/FurnitureAssemblyClientApp/Controllers/HomeController.cs +++ b/FurnitureAssembly/FurnitureAssemblyClientApp/Controllers/HomeController.cs @@ -15,6 +15,7 @@ namespace FurnitureAssemblyClientApp.Controllers _logger = logger; } + // Через API клиента Get-запросом получается список его собственных заказов public IActionResult Index() { if (APIClient.Client == null) @@ -24,6 +25,7 @@ namespace FurnitureAssemblyClientApp.Controllers return View(APIClient.GetRequest>($"api/main/getorders?clientId={APIClient.Client.Id}")); } + // Получение данных Get-ом [HttpGet] public IActionResult Privacy() { @@ -34,6 +36,7 @@ namespace FurnitureAssemblyClientApp.Controllers return View(APIClient.Client); } + // Изменение данных Post-ом [HttpPost] public void Privacy(string login, string password, string fio) { @@ -71,12 +74,14 @@ namespace FurnitureAssemblyClientApp.Controllers }); } + // Открытие Vieхи [HttpGet] public IActionResult Enter() { return View(); } + // Отправляем указанные данные на проверку [HttpPost] public void Enter(string login, string password) { @@ -95,12 +100,14 @@ namespace FurnitureAssemblyClientApp.Controllers Response.Redirect("Index"); } + // Открытие Vieхи [HttpGet] public IActionResult Register() { return View(); } + // Post-запрос по созданию нового пользователя [HttpPost] public void Register(string login, string password, string fio) { @@ -116,11 +123,13 @@ namespace FurnitureAssemblyClientApp.Controllers Password = password }); + // Переход на вкладку "Enter", чтобы пользователь сразу смог зайти Response.Redirect("Enter"); return; } + // Создание заказа. Получаем и передаём список изделий во View [HttpGet] public IActionResult Create() { @@ -129,6 +138,7 @@ namespace FurnitureAssemblyClientApp.Controllers return View(); } + // Создание заказа Post-запросом [HttpPost] public void Create(int furniture, int count) { @@ -153,6 +163,7 @@ namespace FurnitureAssemblyClientApp.Controllers Response.Redirect("Index"); } + // Подсчёт стоимости заказа [HttpPost] public double Calc(int count, int furniture) { diff --git a/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Home/Index.cshtml b/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Home/Index.cshtml index 82a163d..81bfa08 100644 --- a/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Home/Index.cshtml +++ b/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Home/Index.cshtml @@ -1,4 +1,4 @@ -@using FurnitureAssemblyContracts.ViewModels +@using FurnitureAssemblyContracts.ViewModels @model List @{ ViewData["Title"] = "Home Page"; diff --git a/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Home/_Layout.cshtml b/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Home/_Layout.cshtml index 1bf0d35..04bd1c4 100644 --- a/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Home/_Layout.cshtml +++ b/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Home/_Layout.cshtml @@ -46,7 +46,7 @@ diff --git a/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Shared/_Layout.cshtml.css b/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Shared/_Layout.cshtml.css index 947d5b5..a72cbea 100644 --- a/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Shared/_Layout.cshtml.css +++ b/FurnitureAssembly/FurnitureAssemblyClientApp/Views/Shared/_Layout.cshtml.css @@ -2,48 +2,47 @@ for details on configuring this project to bundle and minify static web assets. */ a.navbar-brand { - white-space: normal; - text-align: center; - word-break: break-all; + white-space: normal; + text-align: center; + word-break: break-all; } a { - color: #0077cc; + color: #0077cc; } .btn-primary { - color: #fff; - background-color: #1b6ec2; - border-color: #1861ac; + color: #fff; + background-color: #1b6ec2; + border-color: #1861ac; } .nav-pills .nav-link.active, .nav-pills .show > .nav-link { - color: #fff; - background-color: #1b6ec2; - border-color: #1861ac; + color: #fff; + background-color: #1b6ec2; + border-color: #1861ac; } .border-top { - border-top: 1px solid #e5e5e5; + border-top: 1px solid #e5e5e5; } - .border-bottom { - border-bottom: 1px solid #e5e5e5; + border-bottom: 1px solid #e5e5e5; } .box-shadow { - box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); + box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); } button.accept-policy { - font-size: 1rem; - line-height: inherit; + font-size: 1rem; + line-height: inherit; } .footer { - position: absolute; - bottom: 0; - width: 100%; - white-space: nowrap; - line-height: 60px; + position: absolute; + bottom: 0; + width: 100%; + white-space: nowrap; + line-height: 60px; } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ClientBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ClientBindingModel.cs index 22bce2c..882d915 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ClientBindingModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ClientBindingModel.cs @@ -1,17 +1,21 @@ -using System; +using FurnitureAssemblyDataModels.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using FurnitureAssemblyDataModels.Models; namespace FurnitureAssemblyContracts.BindingModels { + // Реализация сущности "Клиент" public class ClientBindingModel : IClientModel { public int Id { get; set; } + public string ClientFIO { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; - public string Password { get; set; } = string.Empty; + + public string Password { get; set; } = string.Empty; } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs index 496af93..d1e91f8 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs @@ -12,10 +12,10 @@ namespace FurnitureAssemblyContracts.BindingModels { public int Id { get; set; } - public int FurnitureId { get; set; } - public int ClientId { get; set; } + public int FurnitureId { get; set; } + public int Count { get; set; } public double Sum { get; set; } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ReportBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ReportBindingModel.cs index cbb9af9..3afb378 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ReportBindingModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ReportBindingModel.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyContracts.BindingModels { + // Реализация сущности "Отчёт" public class ReportBindingModel { public string FileName { get; set; } = string.Empty; diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IClientLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IClientLogic.cs index 871a8f4..9e59045 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IClientLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IClientLogic.cs @@ -1,6 +1,6 @@ using FurnitureAssemblyContracts.BindingModels; -using FurnitureAssemblyContracts.ViewModels; using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.ViewModels; using System; using System.Collections.Generic; using System.Linq; @@ -9,12 +9,17 @@ using System.Threading.Tasks; namespace FurnitureAssemblyContracts.BusinessLogicsContracts { + // Бизнес-логика для клиентов public interface IClientLogic { - List? ReadList(ClientSearchModel? model); - ClientViewModel? ReadElement(ClientSearchModel model); + List ReadList(ClientSearchModel? model); + + ClientViewModel? ReadElement(ClientSearchModel? model); + bool Create(ClientBindingModel model); + bool Update(ClientBindingModel model); + bool Delete(ClientBindingModel model); } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IReportLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IReportLogic.cs index 9d23c40..3ab8a6f 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IReportLogic.cs @@ -10,15 +10,19 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts { public interface IReportLogic { + // Получение списка заготовок с указанием, в каких изделиях используются List GetFurnitureWorkPiece(); + // Получение списка заказов за определённый период List GetOrders(ReportBindingModel model); + // Сохранение изделий в файл-Word void SaveFurnituresToWordFile(ReportBindingModel model); + // Сохранение заготовок с указанием изделий в файл-Excel void SaveFurnitureWorkPieceToExcelFile(ReportBindingModel model); + // Сохранение заказов в файл-Pdf void SaveOrdersToPdfFile(ReportBindingModel model); - } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs index 3a802d3..18443ee 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs @@ -6,11 +6,13 @@ using System.Threading.Tasks; namespace FurnitureAssemblyContracts.SearchModels { + // Модель для поиска клиента public class ClientSearchModel { public int? Id { get; set; } - public string? ClientFIO { get; set; } - public string? Email { get; set; } + + public string? Email { get; set; } + public string? Password { get; set; } } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs index b2dd2de..ed7b8af 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs @@ -9,10 +9,15 @@ namespace FurnitureAssemblyContracts.SearchModels // Для поиска сущности "Заказ" public class OrderSearchModel { + // для поиска по идентификатору public int? Id { get; set; } + + // для поиска по клиенту + public int? ClientId { get; set; } + + // Два поля для возможности производить выборку public DateTime? DateFrom { get; set; } - public DateTime? DateTo { get; set; } - public int? ClientId { get; set; } + public DateTime? DateTo { get; set;} } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IClientStorage.cs b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IClientStorage.cs index 7cb85cc..2e0276b 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IClientStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IClientStorage.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyContracts.StoragesContracts { + // Класс для хранилища клиентов public interface IClientStorage { List GetFullList(); diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs index 987004f..c59f526 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyContracts.StoragesContracts { + // Класс для хранилища заказов public interface IOrderStorage { List GetFullList(); diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ClientViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ClientViewModel.cs index cac94f5..68687de 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ClientViewModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ClientViewModel.cs @@ -1,20 +1,24 @@ -using System; +using FurnitureAssemblyDataModels.Models; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; -using FurnitureAssemblyDataModels.Models; namespace FurnitureAssemblyContracts.ViewModels { + // Класс для отображения информации о клиентах public class ClientViewModel : IClientModel { public int Id { get; set; } + [DisplayName("ФИО клиента")] public string ClientFIO { get; set; } = string.Empty; + [DisplayName("Логин (эл. почта)")] public string Email { get; set; } = string.Empty; + [DisplayName("Пароль")] public string Password { get; set; } = string.Empty; } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportFurnitureWorkPieceViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportFurnitureWorkPieceViewModel.cs index 594748d..35f1d89 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportFurnitureWorkPieceViewModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportFurnitureWorkPieceViewModel.cs @@ -8,11 +8,11 @@ namespace FurnitureAssemblyContracts.ViewModels { public class ReportFurnitureWorkPieceViewModel { - public string FurnitureName { get; set; } = string.Empty; public int TotalCount { get; set; } - public List<(string WorkPiece, int Count)> WorkPieces { get; set; } = new(); + // Список кортежей + public List<(string WorkPiece, int Count)> WorkPieces { get; set; } = new(); } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportOrdersViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportOrdersViewModel.cs index eae90d5..6533338 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportOrdersViewModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportOrdersViewModel.cs @@ -10,7 +10,7 @@ namespace FurnitureAssemblyContracts.ViewModels { public int Id { get; set; } - public DateTime DateCreate { get; set; } + public DateTime DateCreate { get; set; } public string FurnitureName { get; set; } = string.Empty; diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IClientModel.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IClientModel.cs index 70c3063..13bb7ee 100644 --- a/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IClientModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IClientModel.cs @@ -6,10 +6,13 @@ using System.Threading.Tasks; namespace FurnitureAssemblyDataModels.Models { + // Интерфейс, отвечающий за клиента public interface IClientModel : IId { string ClientFIO { get; } + string Email { get; } + string Password { get; } } } diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/FurnitureAssemblyDatabase.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/FurnitureAssemblyDatabase.cs index f70b73b..fc7ef0b 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/FurnitureAssemblyDatabase.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/FurnitureAssemblyDatabase.cs @@ -14,7 +14,8 @@ namespace FurnitureAssemblyDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=WIN-N21FHIN3LLR\SQLEXPRESS;Initial Catalog=FurnitureAssemblyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + + optionsBuilder.UseSqlServer(@"Data Source=WIN-N21FHIN3LLR\SQLEXPRESS;Initial Catalog=FurnitureAssemblyDatabase2;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20240327064137_InitialCreate.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20240327064137_InitialCreate.cs index 6413913..e3807aa 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20240327064137_InitialCreate.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20240327064137_InitialCreate.cs @@ -60,7 +60,7 @@ namespace FurnitureAssemblyDatabaseImplement.Migrations column: x => x.FurnitureId, principalTable: "Furnitures", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateTable( diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20240521203342_lab52.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20240521203342_lab52.cs index ad5ec82..7dabcbf 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20240521203342_lab52.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Migrations/20240521203342_lab52.cs @@ -28,7 +28,7 @@ namespace FurnitureAssemblyDatabaseImplement.Migrations column: "ClientId", principalTable: "Clients", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); } /// diff --git a/FurnitureAssembly/FurnitureAssemblyFileImplement/DataFileSingleton.cs b/FurnitureAssembly/FurnitureAssemblyFileImplement/DataFileSingleton.cs index 5152572..5eac740 100644 --- a/FurnitureAssembly/FurnitureAssemblyFileImplement/DataFileSingleton.cs +++ b/FurnitureAssembly/FurnitureAssemblyFileImplement/DataFileSingleton.cs @@ -67,7 +67,7 @@ namespace FurnitureAssemblyFileImplement private static void SaveData(List data, string filename, string xmlNodeName, Func selectFunction) { - if (data != null) + if(data != null) { new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename); } diff --git a/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/ClientStorage.cs b/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/ClientStorage.cs index 9ec8ba7..5c26188 100644 --- a/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/ClientStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/ClientStorage.cs @@ -27,7 +27,7 @@ namespace FurnitureAssemblyFileImplement.Implements return null; } return source.Clients - .FirstOrDefault(x => (!string.IsNullOrEmpty(model.Email) && x.Email == model.Email) + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.Email) && x.Email == model.Email) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } diff --git a/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/FurnitureStorage.cs b/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/FurnitureStorage.cs index bddc925..587bcc0 100644 --- a/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/FurnitureStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/FurnitureStorage.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyFileImplement.Implements { + // Реализация интерфейса хранилища изделий public class FurnitureStorage : IFurnitureStorage { private readonly DataFileSingleton source; @@ -27,7 +28,7 @@ namespace FurnitureAssemblyFileImplement.Implements public List GetFilteredList(FurnitureSearchModel model) { - if (string.IsNullOrEmpty(model.FurnitureName)) + if(string.IsNullOrEmpty(model.FurnitureName)) { return new(); } @@ -37,7 +38,7 @@ namespace FurnitureAssemblyFileImplement.Implements public FurnitureViewModel? GetElement(FurnitureSearchModel model) { - if (string.IsNullOrEmpty(model.FurnitureName) && !model.Id.HasValue) + if(string.IsNullOrEmpty(model.FurnitureName) && !model.Id.HasValue) { return null; } @@ -52,7 +53,7 @@ namespace FurnitureAssemblyFileImplement.Implements var newFurniture = Furniture.Create(model); - if (newFurniture == null) + if(newFurniture == null) { return null; } @@ -67,7 +68,7 @@ namespace FurnitureAssemblyFileImplement.Implements { var furniture = source.Furnitures.FirstOrDefault(x => x.Id == model.Id); - if (furniture == null) + if(furniture == null) { return null; } diff --git a/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/OrderStorage.cs index 9fd475b..48f7198 100644 --- a/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/OrderStorage.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyFileImplement.Implements { + // Реализация интерфейса хранилища заказов public class OrderStorage : IOrderStorage { private readonly DataFileSingleton source; @@ -38,7 +39,7 @@ namespace FurnitureAssemblyFileImplement.Implements { return new(); } - + return source.Orders .Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || x.ClientId == model.ClientId) .Select(x => GetViewModel(x)).ToList(); @@ -49,6 +50,7 @@ namespace FurnitureAssemblyFileImplement.Implements return source.Orders.Select(x => GetViewModel(x)).ToList(); } + // Для загрузки названий изделия в заказе private OrderViewModel GetViewModel(Order order) { var viewModel = order.GetViewModel; @@ -91,7 +93,7 @@ namespace FurnitureAssemblyFileImplement.Implements { var order = source.Orders.FirstOrDefault(x => x.Id == model.Id); - if (order == null) + if(order == null) { return null; } @@ -106,7 +108,7 @@ namespace FurnitureAssemblyFileImplement.Implements { var order = source.Orders.FirstOrDefault(x => x.Id == model.Id); - if (order != null) + if(order != null) { source.Orders.Remove(order); source.SaveOrders(); diff --git a/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/WorkPieceStorage.cs b/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/WorkPieceStorage.cs index 89aec60..c5e2b3a 100644 --- a/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/WorkPieceStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyFileImplement/Implements/WorkPieceStorage.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyFileImplement.Implements { + // Реализация интерфейса хранилища заготовок public class WorkPieceStorage : IWorkPieceStorage { private readonly DataFileSingleton source; diff --git a/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/Furniture.cs b/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/Furniture.cs index 38d6d34..d428d39 100644 --- a/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/Furniture.cs +++ b/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/Furniture.cs @@ -10,6 +10,7 @@ using System.Xml.Linq; namespace FurnitureAssemblyFileImplement.Models { + // Класс, реализующий интерфейс модели изделия public class Furniture : IFurnitureModel { public int Id { get; private set; } diff --git a/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/Order.cs b/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/Order.cs index c1b3fe0..eb9b6c9 100644 --- a/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/Order.cs +++ b/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/Order.cs @@ -11,6 +11,7 @@ using System.Xml.Linq; namespace FurnitureAssemblyFileImplement.Models { + // Класс, реализующий интерфейс модели заказа public class Order : IOrderModel { public int Id { get; private set; } @@ -19,7 +20,7 @@ namespace FurnitureAssemblyFileImplement.Models public int ClientId { get; private set; } - public int Count { get; private set; } + public int Count { get; private set; } public double Sum { get; private set; } diff --git a/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/WorkPiece.cs b/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/WorkPiece.cs index 429c634..125494d 100644 --- a/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/WorkPiece.cs +++ b/FurnitureAssembly/FurnitureAssemblyFileImplement/Models/WorkPiece.cs @@ -10,6 +10,7 @@ using System.Xml.Linq; namespace FurnitureAssemblyFileImplement.Models { + // Класс, реализующий интерфейс модели заготовки public class WorkPiece : IWorkPieceModel { public int Id { get; private set; } diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs index b5679a6..be68b1e 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs @@ -7,15 +7,21 @@ using System.Threading.Tasks; namespace FurnitureAssemblyListImplement { + // Класс для списков, в которых будет храниться информация при работе приложения public class DataListSingleton { private static DataListSingleton? _instance; + + // Список для хранения заготовок public List WorkPiece { get; set; } + // Список для хранения изделий public List Furnitures { get; set; } + // Список для хранения заказов public List Orders { get; set; } + // Список для хранения клиентов public List Clients { get; set; } public DataListSingleton() @@ -28,7 +34,7 @@ namespace FurnitureAssemblyListImplement public static DataListSingleton GetInstance() { - if (_instance == null) + if(_instance == null) { _instance = new DataListSingleton(); } diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ClientStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ClientStorage.cs index e9bd3a7..acd5033 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ClientStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ClientStorage.cs @@ -13,6 +13,7 @@ namespace FurnitureAssemblyListImplement.Implements { public class ClientStorage : IClientStorage { + // Поле для работы со списком клиентов private readonly DataListSingleton _source; public ClientStorage() diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs index 24e3450..af581b7 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs @@ -11,20 +11,24 @@ using System.Threading.Tasks; namespace FurnitureAssemblyListImplement.Implements { + // Класс, реализующий интерфейс хранилища заказов public class OrderStorage : IOrderStorage { + // Поле для работы со списком заказов private readonly DataListSingleton _source; + // Получение в конструкторе объекта DataListSingleton public OrderStorage() { _source = DataListSingleton.GetInstance(); } + // Получение полного списка заготовок public List GetFullList() { var result = new List(); - foreach (var order in _source.Orders) + foreach(var order in _source.Orders) { result.Add(GetViewModel(order)); } @@ -32,10 +36,11 @@ namespace FurnitureAssemblyListImplement.Implements return result; } + // Получение отфильтрованного списка заказов public List GetFilteredList(OrderSearchModel model) { var result = new List(); - + if (!model.Id.HasValue) { return result; @@ -66,6 +71,7 @@ namespace FurnitureAssemblyListImplement.Implements return result; } + // Получение элемента из списка заказов public OrderViewModel? GetElement(OrderSearchModel model) { if (!model.Id.HasValue) @@ -84,6 +90,7 @@ namespace FurnitureAssemblyListImplement.Implements return null; } + // Метод для записи названия изделия на форме с заказами private OrderViewModel GetViewModel(Order order) { var viewModel = order.GetViewModel; @@ -110,6 +117,7 @@ namespace FurnitureAssemblyListImplement.Implements return viewModel; } + // При создании заказа определяем для него новый id: ищем max id и прибавляем к нему 1 public OrderViewModel? Insert(OrderBindingModel model) { model.Id = 1; @@ -134,6 +142,7 @@ namespace FurnitureAssemblyListImplement.Implements return GetViewModel(newOrder); } + // Обновление заказа public OrderViewModel? Update(OrderBindingModel model) { foreach (var order in _source.Orders) @@ -149,6 +158,7 @@ namespace FurnitureAssemblyListImplement.Implements return null; } + // Удаление заказа public OrderViewModel? Delete(OrderBindingModel model) { for (int i = 0; i < _source.Orders.Count; i++) diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Client.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Client.cs index f0b7fc4..440d09c 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Client.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Client.cs @@ -11,6 +11,7 @@ namespace FurnitureAssemblyListImplement.Models { public class Client : IClientModel { + // Методы set делаем приватным, чтобы исключить неразрешённые манипуляции public int Id { get; private set; } public string ClientFIO { get; private set; } = string.Empty; @@ -19,6 +20,7 @@ namespace FurnitureAssemblyListImplement.Models public string Password { get; private set; } = string.Empty; + // Метод для создания объекта от класса-компонента на основе класса-BindingModel public static Client? Create(ClientBindingModel? model) { if (model == null) @@ -35,6 +37,7 @@ namespace FurnitureAssemblyListImplement.Models }; } + // Метод изменения существующего объекта public void Update(ClientBindingModel? model) { if (model == null) @@ -46,6 +49,8 @@ namespace FurnitureAssemblyListImplement.Models Email = model.Email; Password = model.Password; } + + // Метод для создания объекта класса ViewModel на основе данных объекта класса-компонента public ClientViewModel GetViewModel => new() { Id = Id, diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs index c29f1e2..2a0c8a6 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs @@ -11,8 +11,10 @@ using System.Threading.Tasks; namespace FurnitureAssemblyListImplement.Models { + // Класс, реализующий интерфейс модели заказа public class Order : IOrderModel { + // Методы set сделали приватными, чтобы исключить неразрешённые манипуляции public int Id { get; private set; } public int ClientId { get; private set; } @@ -31,7 +33,7 @@ namespace FurnitureAssemblyListImplement.Models public static Order? Create(OrderBindingModel? model) { - if (model == null) + if(model == null) { return null; } @@ -49,9 +51,10 @@ namespace FurnitureAssemblyListImplement.Models }; } + // Метод изменения существующего объекта public void Update(OrderBindingModel? model) { - if (model == null) + if(model == null) { return; } @@ -59,6 +62,7 @@ namespace FurnitureAssemblyListImplement.Models DateImplement = model.DateImplement; } + // Метод для создания объекта класса ViewModel на основе данных объекта класса-компонента public OrderViewModel GetViewModel => new() { Id = Id, diff --git a/FurnitureAssembly/FurnitureAssemblyView/FormClients.Designer.cs b/FurnitureAssembly/FurnitureAssemblyView/FormClients.Designer.cs index a3c3aa0..d7ab7cb 100644 --- a/FurnitureAssembly/FurnitureAssemblyView/FormClients.Designer.cs +++ b/FurnitureAssembly/FurnitureAssemblyView/FormClients.Designer.cs @@ -1,6 +1,6 @@ namespace FurnitureAssemblyView { - partial class Клиенты + partial class FormClients { /// /// Required designer variable. @@ -37,17 +37,20 @@ // dataGridView // this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Location = new System.Drawing.Point(10, 9); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.dataGridView.Name = "dataGridView"; - this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(503, 257); + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(509, 320); this.dataGridView.TabIndex = 0; // // buttonDelete // - this.buttonDelete.Location = new System.Drawing.Point(521, 128); + this.buttonDelete.Location = new System.Drawing.Point(558, 26); + this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonDelete.Name = "buttonDelete"; - this.buttonDelete.Size = new System.Drawing.Size(102, 32); + this.buttonDelete.Size = new System.Drawing.Size(109, 22); this.buttonDelete.TabIndex = 1; this.buttonDelete.Text = "Удалить"; this.buttonDelete.UseVisualStyleBackColor = true; @@ -55,25 +58,27 @@ // // buttonRef // - this.buttonRef.Location = new System.Drawing.Point(521, 44); + this.buttonRef.Location = new System.Drawing.Point(558, 77); + this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(102, 32); + this.buttonRef.Size = new System.Drawing.Size(109, 22); this.buttonRef.TabIndex = 2; this.buttonRef.Text = "Обновить"; this.buttonRef.UseVisualStyleBackColor = true; this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); // - // Клиенты + // FormClients // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(653, 290); + this.ClientSize = new System.Drawing.Size(700, 338); this.Controls.Add(this.buttonRef); this.Controls.Add(this.buttonDelete); this.Controls.Add(this.dataGridView); - this.Name = "Клиенты"; - this.Text = "FormClients"; - this.Load += new System.EventHandler(this.FormClients_Load); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormClients"; + this.Text = "Клиенты"; + this.Click += new System.EventHandler(this.FormClients_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/FurnitureAssembly/FurnitureAssemblyView/FormClients.cs b/FurnitureAssembly/FurnitureAssemblyView/FormClients.cs index 240f9ed..0e0fa8d 100644 --- a/FurnitureAssembly/FurnitureAssemblyView/FormClients.cs +++ b/FurnitureAssembly/FurnitureAssemblyView/FormClients.cs @@ -12,84 +12,84 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; - namespace FurnitureAssemblyView { - public partial class Клиенты : Form + public partial class FormClients : Form { - private readonly ILogger _logger; + private readonly ILogger _logger; - private readonly IClientLogic _clientLogic; + private readonly IClientLogic _clientLogic; - public Клиенты(ILogger<Клиенты> logger, IClientLogic clientLogic) + public FormClients(ILogger logger, IClientLogic clientLogic) { InitializeComponent(); - _logger = logger; - _clientLogic = clientLogic; - } + + _logger = logger; + _clientLogic = clientLogic; + } private void FormClients_Load(object sender, EventArgs e) { - LoadData(); - } + LoadData(); + } - private void LoadData() - { - _logger.LogInformation("Загрузка клиентов"); + private void LoadData() + { + _logger.LogInformation("Загрузка клиентов"); - try - { - var list = _clientLogic.ReadList(null); + try + { + var list = _clientLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } - _logger.LogInformation("Успешная загрузка клиентов"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки клиентов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } + _logger.LogInformation("Успешная загрузка клиентов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки клиентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } - private void ButtonDelete_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + private void ButtonDelete_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Удаление клиента"); + _logger.LogInformation("Удаление клиента"); - try - { - if (!_clientLogic.Delete(new ClientBindingModel - { - Id = id - })) - { - throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); - } + try + { + if (!_clientLogic.Delete(new ClientBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка удаления компонента"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления компонента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } - private void ButtonRef_Click(object sender, EventArgs e) - { - LoadData(); - } - } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } } diff --git a/FurnitureAssembly/FurnitureAssemblyView/FormCreateOrder.Designer.cs b/FurnitureAssembly/FurnitureAssemblyView/FormCreateOrder.Designer.cs index 72855e8..024fc55 100644 --- a/FurnitureAssembly/FurnitureAssemblyView/FormCreateOrder.Designer.cs +++ b/FurnitureAssembly/FurnitureAssemblyView/FormCreateOrder.Designer.cs @@ -1,33 +1,33 @@ namespace FurnitureAssemblyView { - partial class FormCreateOrder - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormCreateOrder + { + /// + /// 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); - } + /// + /// 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 + #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() - { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { this.labelFurniture = new System.Windows.Forms.Label(); this.labelCount = new System.Windows.Forms.Label(); this.labelSum = new System.Windows.Forms.Label(); @@ -36,6 +36,8 @@ this.textBoxSum = new System.Windows.Forms.TextBox(); this.buttonSave = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); + this.labelClient = new System.Windows.Forms.Label(); + this.comboBoxClient = new System.Windows.Forms.ComboBox(); this.SuspendLayout(); // // labelFurniture @@ -50,7 +52,7 @@ // labelCount // this.labelCount.AutoSize = true; - this.labelCount.Location = new System.Drawing.Point(21, 52); + this.labelCount.Location = new System.Drawing.Point(21, 86); this.labelCount.Name = "labelCount"; this.labelCount.Size = new System.Drawing.Size(75, 15); this.labelCount.TabIndex = 1; @@ -59,7 +61,7 @@ // labelSum // this.labelSum.AutoSize = true; - this.labelSum.Location = new System.Drawing.Point(21, 85); + this.labelSum.Location = new System.Drawing.Point(21, 118); this.labelSum.Name = "labelSum"; this.labelSum.Size = new System.Drawing.Size(48, 15); this.labelSum.TabIndex = 2; @@ -68,16 +70,15 @@ // comboBoxFurniture // this.comboBoxFurniture.FormattingEnabled = true; - this.comboBoxFurniture.Location = new System.Drawing.Point(127, 15); + this.comboBoxFurniture.Location = new System.Drawing.Point(145, 16); this.comboBoxFurniture.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.comboBoxFurniture.Name = "comboBoxFurniture"; this.comboBoxFurniture.Size = new System.Drawing.Size(244, 23); this.comboBoxFurniture.TabIndex = 3; - this.comboBoxFurniture.SelectedIndexChanged += new System.EventHandler(this.ComboBoxFurniture_SelectedIndexChanged); // // textBoxCount // - this.textBoxCount.Location = new System.Drawing.Point(127, 49); + this.textBoxCount.Location = new System.Drawing.Point(145, 83); this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBoxCount.Name = "textBoxCount"; this.textBoxCount.Size = new System.Drawing.Size(244, 23); @@ -86,7 +87,7 @@ // // textBoxSum // - this.textBoxSum.Location = new System.Drawing.Point(127, 82); + this.textBoxSum.Location = new System.Drawing.Point(145, 116); this.textBoxSum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBoxSum.Name = "textBoxSum"; this.textBoxSum.Size = new System.Drawing.Size(244, 23); @@ -94,31 +95,49 @@ // // buttonSave // - this.buttonSave.Location = new System.Drawing.Point(186, 116); + this.buttonSave.Location = new System.Drawing.Point(201, 149); this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonSave.Name = "buttonSave"; this.buttonSave.Size = new System.Drawing.Size(82, 22); this.buttonSave.TabIndex = 6; this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(274, 116); + this.buttonCancel.Location = new System.Drawing.Point(298, 149); this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(82, 22); this.buttonCancel.TabIndex = 7; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // labelClient + // + this.labelClient.AutoSize = true; + this.labelClient.Location = new System.Drawing.Point(21, 52); + this.labelClient.Name = "labelClient"; + this.labelClient.Size = new System.Drawing.Size(60, 15); + this.labelClient.TabIndex = 8; + this.labelClient.Text = "Заказчик:"; + // + // comboBoxClient + // + this.comboBoxClient.FormattingEnabled = true; + this.comboBoxClient.Location = new System.Drawing.Point(145, 50); + this.comboBoxClient.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxClient.Name = "comboBoxClient"; + this.comboBoxClient.Size = new System.Drawing.Size(244, 23); + this.comboBoxClient.TabIndex = 9; // // FormCreateOrder // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(384, 157); + this.ClientSize = new System.Drawing.Size(419, 192); + this.Controls.Add(this.comboBoxClient); + this.Controls.Add(this.labelClient); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonSave); this.Controls.Add(this.textBoxSum); @@ -130,21 +149,22 @@ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "FormCreateOrder"; this.Text = "Заказ"; - this.Load += new System.EventHandler(this.FormCreateOrder_Load); this.ResumeLayout(false); this.PerformLayout(); - } + } - #endregion + #endregion - private Label labelFurniture; - private Label labelCount; - private Label labelSum; - private ComboBox comboBoxFurniture; - private TextBox textBoxCount; - private TextBox textBoxSum; - private Button buttonSave; - private Button buttonCancel; - } + private Label labelFurniture; + private Label labelCount; + private Label labelSum; + private ComboBox comboBoxFurniture; + private TextBox textBoxCount; + private TextBox textBoxSum; + private Button buttonSave; + private Button buttonCancel; + private Label labelClient; + private ComboBox comboBoxClient; + } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyView/FormCreateOrder.cs b/FurnitureAssembly/FurnitureAssemblyView/FormCreateOrder.cs index b458fa0..3f05bb4 100644 --- a/FurnitureAssembly/FurnitureAssemblyView/FormCreateOrder.cs +++ b/FurnitureAssembly/FurnitureAssemblyView/FormCreateOrder.cs @@ -1,7 +1,6 @@ using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.BusinessLogicsContracts; using FurnitureAssemblyContracts.SearchModels; -using FurnitureAssemblyDataModels.Models; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -15,134 +14,151 @@ using System.Windows.Forms; namespace FurnitureAssemblyView { - public partial class FormCreateOrder : Form - { - private readonly ILogger _logger; + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; - private readonly IFurnitureLogic _logicFurniture; + private readonly IFurnitureLogic _logicFurniture; - private readonly IOrderLogic _logicOrder; + private readonly IOrderLogic _logicOrder; - private readonly IClientLogic _logicClient; + private readonly IClientLogic _logicClient; - public FormCreateOrder(ILogger logger, IFurnitureLogic logicFurniture, IOrderLogic logicOrder, IClientLogic logicClient) - { - InitializeComponent(); + public FormCreateOrder(ILogger logger, IFurnitureLogic logicFurniture, IOrderLogic logicOrder, IClientLogic logicClient) + { + InitializeComponent(); - _logger = logger; + _logger = logger; _logicFurniture = logicFurniture; _logicOrder = logicOrder; - } + _logicClient = logicClient; + } - private void FormCreateOrder_Load(object sender, EventArgs e) - { - _logger.LogInformation("Загрузка изделий для заказа"); + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка изделий для заказа"); - try - { - var list = _logicFurniture.ReadList(null); - var listClients = _logicClient.ReadList(null); + try + { + var list = _logicFurniture.ReadList(null); + var listClients = _logicClient.ReadList(null); - if (list != null) - { - comboBoxFurniture.DisplayMember = "FurnitureName"; + if (list != null) + { + comboBoxFurniture.DisplayMember = "FurnitureName"; comboBoxFurniture.ValueMember = "Id"; comboBoxFurniture.DataSource = list; comboBoxFurniture.SelectedItem = null; - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки изделий для заказа или списка клиентов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } + } - private void CalcSum() - { - if (comboBoxFurniture.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) - { - try - { - int id = Convert.ToInt32(comboBoxFurniture.SelectedValue); - - var furniture = _logicFurniture.ReadElement(new FurnitureSearchModel - { - Id = id - }); + if(listClients != null) + { + comboBoxClient.DisplayMember = "ClientFIO"; + comboBoxClient.ValueMember = "Id"; + comboBoxClient.DataSource = listClients; + comboBoxClient.SelectedItem = null; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделий для заказа или списка клиентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } - int count = Convert.ToInt32(textBoxCount.Text); + private void CalcSum() + { + if (comboBoxFurniture.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxFurniture.SelectedValue); - textBoxSum.Text = Math.Round(count * (furniture?.Price ?? 0), 2).ToString(); - - _logger.LogInformation("Расчет суммы заказа"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка расчета суммы заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } + var furniture = _logicFurniture.ReadElement(new FurnitureSearchModel + { + Id = id + }); - private void TextBoxCount_TextChanged(object sender, EventArgs e) - { - CalcSum(); - } + int count = Convert.ToInt32(textBoxCount.Text); - private void ComboBoxFurniture_SelectedIndexChanged(object sender, EventArgs e) - { - CalcSum(); - } + textBoxSum.Text = Math.Round(count * (furniture?.Price ?? 0), 2).ToString(); - private void ButtonSave_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(textBoxCount.Text)) - { - MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogInformation("Расчет суммы заказа"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка расчета суммы заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } - return; - } + private void TextBoxCount_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } - if (comboBoxFurniture.SelectedValue == null) - { - MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + private void ComboBoxFurniture_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } - return; - } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - _logger.LogInformation("Создание заказа"); + return; + } - try - { - var operationResult = _logicOrder.CreateOrder(new OrderBindingModel - { - FurnitureId = Convert.ToInt32(comboBoxFurniture.SelectedValue), - Count = Convert.ToInt32(textBoxCount.Text), - Sum = Convert.ToDouble(textBoxSum.Text) - }); + if (comboBoxFurniture.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - if (!operationResult) - { - throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); - } + return; + } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); - DialogResult = DialogResult.OK; + if (comboBoxClient.SelectedValue == null) + { + MessageBox.Show("Выберите заказчика", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - Close(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } + return; + } - private void ButtonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } - } + _logger.LogInformation("Создание заказа"); + + try + { + var operationResult = _logicOrder.CreateOrder(new OrderBindingModel + { + FurnitureId = Convert.ToInt32(comboBoxFurniture.SelectedValue), + ClientId = Convert.ToInt32(comboBoxClient.SelectedValue), + Count = Convert.ToInt32(textBoxCount.Text), + Sum = Convert.ToDouble(textBoxSum.Text) + }); + + if (!operationResult) + { + throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); + } + + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } } diff --git a/FurnitureAssembly/FurnitureAssemblyView/FormMain.Designer.cs b/FurnitureAssembly/FurnitureAssemblyView/FormMain.Designer.cs index 92ca11c..d3f2f6b 100644 --- a/FurnitureAssembly/FurnitureAssemblyView/FormMain.Designer.cs +++ b/FurnitureAssembly/FurnitureAssemblyView/FormMain.Designer.cs @@ -56,26 +56,25 @@ this.dataGridView.Name = "dataGridView"; this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(794, 302); + this.dataGridView.Size = new System.Drawing.Size(820, 302); this.dataGridView.TabIndex = 0; // // buttonCreateOrder // - this.buttonCreateOrder.Location = new System.Drawing.Point(820, 27); + this.buttonCreateOrder.Location = new System.Drawing.Point(887, 50); this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonCreateOrder.Name = "buttonCreateOrder"; - this.buttonCreateOrder.Size = new System.Drawing.Size(178, 34); + this.buttonCreateOrder.Size = new System.Drawing.Size(206, 34); this.buttonCreateOrder.TabIndex = 1; this.buttonCreateOrder.Text = "Создать заказ"; this.buttonCreateOrder.UseVisualStyleBackColor = true; - this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); // // buttonTakeOrderInWork // - this.buttonTakeOrderInWork.Location = new System.Drawing.Point(820, 65); + this.buttonTakeOrderInWork.Location = new System.Drawing.Point(887, 107); this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - this.buttonTakeOrderInWork.Size = new System.Drawing.Size(178, 36); + this.buttonTakeOrderInWork.Size = new System.Drawing.Size(206, 36); this.buttonTakeOrderInWork.TabIndex = 2; this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; @@ -83,10 +82,10 @@ // // buttonOrderReady // - this.buttonOrderReady.Location = new System.Drawing.Point(820, 105); + this.buttonOrderReady.Location = new System.Drawing.Point(887, 165); this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonOrderReady.Name = "buttonOrderReady"; - this.buttonOrderReady.Size = new System.Drawing.Size(178, 31); + this.buttonOrderReady.Size = new System.Drawing.Size(206, 31); this.buttonOrderReady.TabIndex = 3; this.buttonOrderReady.Text = "Заказ готов"; this.buttonOrderReady.UseVisualStyleBackColor = true; @@ -94,10 +93,10 @@ // // buttonIssuedOrder // - this.buttonIssuedOrder.Location = new System.Drawing.Point(820, 140); + this.buttonIssuedOrder.Location = new System.Drawing.Point(887, 217); this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonIssuedOrder.Name = "buttonIssuedOrder"; - this.buttonIssuedOrder.Size = new System.Drawing.Size(178, 33); + this.buttonIssuedOrder.Size = new System.Drawing.Size(206, 33); this.buttonIssuedOrder.TabIndex = 4; this.buttonIssuedOrder.Text = "Заказ выдан"; this.buttonIssuedOrder.UseVisualStyleBackColor = true; @@ -105,10 +104,10 @@ // // buttonRefresh // - this.buttonRefresh.Location = new System.Drawing.Point(820, 177); + this.buttonRefresh.Location = new System.Drawing.Point(887, 269); this.buttonRefresh.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonRefresh.Name = "buttonRefresh"; - this.buttonRefresh.Size = new System.Drawing.Size(178, 29); + this.buttonRefresh.Size = new System.Drawing.Size(206, 29); this.buttonRefresh.TabIndex = 5; this.buttonRefresh.Text = "Обновить"; this.buttonRefresh.UseVisualStyleBackColor = true; @@ -124,7 +123,7 @@ this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; this.menuStrip.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2); - this.menuStrip.Size = new System.Drawing.Size(1015, 24); + this.menuStrip.Size = new System.Drawing.Size(1135, 24); this.menuStrip.TabIndex = 6; this.menuStrip.Text = "menuStrip"; // @@ -140,16 +139,14 @@ // workPieceToolStripMenuItem // this.workPieceToolStripMenuItem.Name = "workPieceToolStripMenuItem"; - this.workPieceToolStripMenuItem.Size = new System.Drawing.Size(130, 22); + this.workPieceToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.workPieceToolStripMenuItem.Text = "Заготовки"; - this.workPieceToolStripMenuItem.Click += new System.EventHandler(this.WorkPieceToolStripMenuItem_Click); // // furnitureToolStripMenuItem // this.furnitureToolStripMenuItem.Name = "furnitureToolStripMenuItem"; - this.furnitureToolStripMenuItem.Size = new System.Drawing.Size(130, 22); + this.furnitureToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.furnitureToolStripMenuItem.Text = "Изделия"; - this.furnitureToolStripMenuItem.Click += new System.EventHandler(this.FurnitureToolStripMenuItem_Click); // // reportsToolStripMenuItem // @@ -159,26 +156,26 @@ this.ordersToolStripMenuItem}); this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; this.reportsToolStripMenuItem.Size = new System.Drawing.Size(60, 20); - this.reportsToolStripMenuItem.Text = "Отчеты"; + this.reportsToolStripMenuItem.Text = "Отчёты"; // // workPiecesToolStripMenuItem // this.workPiecesToolStripMenuItem.Name = "workPiecesToolStripMenuItem"; - this.workPiecesToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.workPiecesToolStripMenuItem.Text = "Список компонентов"; + this.workPiecesToolStripMenuItem.Size = new System.Drawing.Size(203, 22); + this.workPiecesToolStripMenuItem.Text = "Список заготовок"; this.workPiecesToolStripMenuItem.Click += new System.EventHandler(this.WorkPiecesToolStripMenuItem_Click); // // workPieceFurnituresToolStripMenuItem // this.workPieceFurnituresToolStripMenuItem.Name = "workPieceFurnituresToolStripMenuItem"; - this.workPieceFurnituresToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.workPieceFurnituresToolStripMenuItem.Text = "Компоненты по изделиям"; + this.workPieceFurnituresToolStripMenuItem.Size = new System.Drawing.Size(203, 22); + this.workPieceFurnituresToolStripMenuItem.Text = "Заготовки по изделиям"; this.workPieceFurnituresToolStripMenuItem.Click += new System.EventHandler(this.WorkPieceFurnituresToolStripMenuItem_Click); // // ordersToolStripMenuItem // this.ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; - this.ordersToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.ordersToolStripMenuItem.Size = new System.Drawing.Size(203, 22); this.ordersToolStripMenuItem.Text = "Список заказов"; this.ordersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); // @@ -201,7 +198,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1015, 338); + this.ClientSize = new System.Drawing.Size(1135, 338); this.Controls.Add(this.buttonRefresh); this.Controls.Add(this.buttonIssuedOrder); this.Controls.Add(this.buttonOrderReady); diff --git a/FurnitureAssembly/FurnitureAssemblyView/FormMain.cs b/FurnitureAssembly/FurnitureAssemblyView/FormMain.cs index 95c9a17..644fe1c 100644 --- a/FurnitureAssembly/FurnitureAssemblyView/FormMain.cs +++ b/FurnitureAssembly/FurnitureAssemblyView/FormMain.cs @@ -1,5 +1,4 @@ -using FurnitureAssemblyBusinessLogic.BussinessLogic; -using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.BusinessLogicsContracts; using FurnitureAssemblyDataModels.Enums; using Microsoft.Extensions.Logging; @@ -20,6 +19,7 @@ namespace FurnitureAssemblyView private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) @@ -29,7 +29,6 @@ namespace FurnitureAssemblyView _logger = logger; _orderLogic = orderLogic; _reportLogic = reportLogic; - } private void FormMain_Load(object sender, EventArgs e) @@ -49,7 +48,9 @@ namespace FurnitureAssemblyView { dataGridView.DataSource = list; dataGridView.Columns["FurnitureId"].Visible = false; + dataGridView.Columns["ClientId"].Visible = false; dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); @@ -182,11 +183,6 @@ namespace FurnitureAssemblyView } } - private void ButtonRef_Click(object sender, EventArgs e) - { - LoadData(); - } - private void WorkPiecesToolStripMenuItem_Click(object sender, EventArgs e) { using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; @@ -221,11 +217,17 @@ namespace FurnitureAssemblyView form.ShowDialog(); } } + + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(Клиенты)); + var service = Program.ServiceProvider?.GetService(typeof(FormClients)); - if (service is Клиенты form) + if (service is FormClients form) { form.ShowDialog(); } diff --git a/FurnitureAssembly/FurnitureAssemblyView/Program.cs b/FurnitureAssembly/FurnitureAssemblyView/Program.cs index 8d08995..d83fad6 100644 --- a/FurnitureAssembly/FurnitureAssemblyView/Program.cs +++ b/FurnitureAssembly/FurnitureAssemblyView/Program.cs @@ -1,7 +1,6 @@ using FurnitureAssemblyBusinessLogic.BussinessLogic; -using FurnitureAssemblyBusinessLogic.OfficePackage; -using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels; using FurnitureAssemblyBusinessLogic.OfficePackage.Implements; +using FurnitureAssemblyBusinessLogic.OfficePackage; using FurnitureAssemblyContracts.BusinessLogicsContracts; using FurnitureAssemblyContracts.StoragesContracts; using FurnitureAssemblyDatabaseImplement.Implements; @@ -15,7 +14,9 @@ namespace FurnitureAssemblyView internal static class Program { private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; + /// /// The main entry point for the application. /// @@ -42,11 +43,13 @@ namespace FurnitureAssemblyView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -58,9 +61,10 @@ namespace FurnitureAssemblyView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file