PIbd-22_Gerimovich.I.M._Furniture_Assembly_LabWork5base #8
@ -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<ClientLogic> 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("Аккаунт с таким логином уже есть");
|
||||
|
@ -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<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
|
||||
// Вывод отфильтрованного списка компонентов
|
||||
public List<OrderViewModel>? 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--;
|
||||
|
||||
|
@ -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<ReportFurnitureWorkPieceViewModel> GetFurnitureWorkPiece()
|
||||
{
|
||||
var furnitures = _furnitureStorage.GetFullList();
|
||||
@ -65,6 +67,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||
return list;
|
||||
}
|
||||
|
||||
// Получение списка заказов за определённый период
|
||||
public List<ReportOrdersViewModel> 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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<string> 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<string> columns);
|
||||
|
||||
/// Создание и заполнение строки
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
|
||||
/// Сохранение файла
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,16 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
// Вспомогательное перечисление для оформления excel
|
||||
public enum ExcelStyleInfoType
|
||||
{
|
||||
// Заголовок
|
||||
Title,
|
||||
|
||||
// Просто текст
|
||||
Text,
|
||||
|
||||
// Текст в рамке
|
||||
TextWithBorder
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,16 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
// Вспомогательное перечисление для оформления pdf документа
|
||||
public enum PdfParagraphAlignmentType
|
||||
{
|
||||
// Либо по центру
|
||||
Center,
|
||||
|
||||
// Либо с левого края
|
||||
Left,
|
||||
|
||||
// Либо с правого края
|
||||
Right
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
// Вспомогательное перечисление для настройки формата word документа
|
||||
public enum WordJustificationType
|
||||
{
|
||||
// Выравниваем либо по центру
|
||||
Center,
|
||||
|
||||
// Либо на всю ширину
|
||||
Both
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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<ReportFurnitureWorkPieceViewModel> FurnitureWorkPieces { get; set; } = new();
|
||||
|
||||
// Заголовок
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
// Список заготовок по изделиям
|
||||
public List<ReportFurnitureWorkPieceViewModel> FurnitureWorkPieces { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
// Информация для объединения ячеек
|
||||
public class ExcelMergeParameters
|
||||
{
|
||||
public string CellFromName { get; set; } = string.Empty;
|
||||
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
// Общая информация по pdf файлу
|
||||
public class PdfInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
{
|
||||
// Набор текстов
|
||||
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
// Общая информация по документу
|
||||
public class WordInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
// Модель свойств текста, которые нам нужны в Word документе
|
||||
public class WordTextProperties
|
||||
{
|
||||
// Размер текста
|
||||
|
@ -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;
|
||||
|
@ -11,6 +11,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
// Реализация абстрактного класса создания Pdf документа
|
||||
public class SaveToPdf : AbstractSaveToPdf
|
||||
{
|
||||
private Document? _document;
|
||||
|
@ -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();
|
||||
|
@ -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<List<OrderViewModel>>($"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)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
@model List<OrderViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
|
@ -46,7 +46,7 @@
|
||||
</div>
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - Сборка Мебели - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||
© 2024 - СборкаМебели - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
// Реализация сущности "Отчёт"
|
||||
public class ReportBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
@ -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<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||
ClientViewModel? ReadElement(ClientSearchModel model);
|
||||
List<ClientViewModel> ReadList(ClientSearchModel? model);
|
||||
|
||||
ClientViewModel? ReadElement(ClientSearchModel? model);
|
||||
|
||||
bool Create(ClientBindingModel model);
|
||||
|
||||
bool Update(ClientBindingModel model);
|
||||
|
||||
bool Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -10,15 +10,19 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
// Получение списка заготовок с указанием, в каких изделиях используются
|
||||
List<ReportFurnitureWorkPieceViewModel> GetFurnitureWorkPiece();
|
||||
|
||||
// Получение списка заказов за определённый период
|
||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||
|
||||
// Сохранение изделий в файл-Word
|
||||
void SaveFurnituresToWordFile(ReportBindingModel model);
|
||||
|
||||
// Сохранение заготовок с указанием изделий в файл-Excel
|
||||
void SaveFurnitureWorkPieceToExcelFile(ReportBindingModel model);
|
||||
|
||||
// Сохранение заказов в файл-Pdf
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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;}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
// Класс для хранилища клиентов
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
// Класс для хранилища заказов
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -6,10 +6,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
// Интерфейс, отвечающий за клиента
|
||||
public interface IClientModel : IId
|
||||
{
|
||||
string ClientFIO { get; }
|
||||
|
||||
string Email { get; }
|
||||
|
||||
string Password { get; }
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||
column: x => x.FurnitureId,
|
||||
principalTable: "Furnitures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
onDelete: ReferentialAction.NoAction);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
|
@ -28,7 +28,7 @@ namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
onDelete: ReferentialAction.NoAction);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -67,7 +67,7 @@ namespace FurnitureAssemblyFileImplement
|
||||
|
||||
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName, Func<T, XElement> selectFunction)
|
||||
{
|
||||
if (data != null)
|
||||
if(data != null)
|
||||
{
|
||||
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<FurnitureViewModel> 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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -11,6 +11,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyFileImplement.Implements
|
||||
{
|
||||
// Реализация интерфейса хранилища заготовок
|
||||
public class WorkPieceStorage : IWorkPieceStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
@ -10,6 +10,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace FurnitureAssemblyFileImplement.Models
|
||||
{
|
||||
// Класс, реализующий интерфейс модели изделия
|
||||
public class Furniture : IFurnitureModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -10,6 +10,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace FurnitureAssemblyFileImplement.Models
|
||||
{
|
||||
// Класс, реализующий интерфейс модели заготовки
|
||||
public class WorkPiece : IWorkPieceModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
@ -7,15 +7,21 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyListImplement
|
||||
{
|
||||
// Класс для списков, в которых будет храниться информация при работе приложения
|
||||
public class DataListSingleton
|
||||
{
|
||||
private static DataListSingleton? _instance;
|
||||
|
||||
// Список для хранения заготовок
|
||||
public List<WorkPiece> WorkPiece { get; set; }
|
||||
|
||||
// Список для хранения изделий
|
||||
public List<Furniture> Furnitures { get; set; }
|
||||
|
||||
// Список для хранения заказов
|
||||
public List<Order> Orders { get; set; }
|
||||
|
||||
// Список для хранения клиентов
|
||||
public List<Client> Clients { get; set; }
|
||||
|
||||
public DataListSingleton()
|
||||
@ -28,7 +34,7 @@ namespace FurnitureAssemblyListImplement
|
||||
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
if(_instance == null)
|
||||
{
|
||||
_instance = new DataListSingleton();
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
// Поле для работы со списком клиентов
|
||||
private readonly DataListSingleton _source;
|
||||
|
||||
public ClientStorage()
|
||||
|
@ -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<OrderViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
|
||||
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<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
|
||||
|
||||
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++)
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class Клиенты
|
||||
partial class FormClients
|
||||
{
|
||||
/// <summary>
|
||||
/// 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);
|
||||
|
||||
|
@ -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<FormClients> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,33 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormCreateOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
partial class FormCreateOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
@ -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<FormCreateOrder> logger, IFurnitureLogic logicFurniture, IOrderLogic logicOrder, IClientLogic logicClient)
|
||||
{
|
||||
InitializeComponent();
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<FormMain> 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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -42,11 +43,13 @@ namespace FurnitureAssemblyView
|
||||
services.AddTransient<IWorkPieceStorage, WorkPieceStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IFurnitureStorage, FurnitureStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
|
||||
services.AddTransient<IWorkPieceLogic, WorkPieceLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IFurnitureLogic, FurnitureLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
@ -58,9 +61,10 @@ namespace FurnitureAssemblyView
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormFurniture>();
|
||||
services.AddTransient<FormFurnitures>();
|
||||
services.AddTransient<FormFurnitureWorkPiece>();
|
||||
services.AddTransient<FormFurnitureWorkPiece>();
|
||||
services.AddTransient<FormReportFurnitureWorkPieces>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormClients>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user