diff --git a/AbstractShopBusinessLogic/BusinessLogics/ComponentLogic.cs b/AbstractShopBusinessLogic/BusinessLogics/ComponentLogic.cs new file mode 100644 index 0000000..50408a2 --- /dev/null +++ b/AbstractShopBusinessLogic/BusinessLogics/ComponentLogic.cs @@ -0,0 +1,108 @@ +using DinerContracts.BindingModels; +using DinerContracts.BusinessLogicsContracts; +using DinerContracts.SearchModels; +using DinerContracts.StoragesContracts; +using DinerContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace DinerBusinessLogic.BusinessLogics +{ + public class ComponentLogic : IComponentLogic + { + private readonly ILogger _logger; + private readonly IComponentStorage _componentStorage; + public ComponentLogic(ILogger logger, IComponentStorage componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + public List? ReadList(ComponentSearchModel? model) + { + _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{ Id}", model?.ComponentName, model?.Id); + var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ComponentViewModel? ReadElement(ComponentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{ Id}", model.ComponentName, model.Id); + var element = _componentStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ComponentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ComponentBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ComponentName)) + { + throw new ArgumentNullException("Нет названия компонента", + nameof(model.ComponentName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); + } + _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel{ + ComponentName = model.ComponentName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + + } +} diff --git a/AbstractShopBusinessLogic/BusinessLogics/OrderLogic.cs b/AbstractShopBusinessLogic/BusinessLogics/OrderLogic.cs new file mode 100644 index 0000000..1466f90 --- /dev/null +++ b/AbstractShopBusinessLogic/BusinessLogics/OrderLogic.cs @@ -0,0 +1,122 @@ +using DinerContracts.BindingModels; +using DinerContracts.BusinessLogicsContracts; +using DinerContracts.SearchModels; +using DinerContracts.StoragesContracts; +using DinerContracts.ViewModels; +using DinerDataModels.Enum; +using Microsoft.Extensions.Logging; + +namespace DinerBusinessLogic.BusinessLogics +{ + 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); + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (model.Status != OrderStatus.Неизвестен) return false; + model.Status = OrderStatus.Принят; + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool TakeOrderInWork(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выполняется); + } + public bool FinishOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Готов); + } + public bool DeliveryOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выдан); + } + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.SnackId < 0) + { + throw new ArgumentNullException("Неверный идентификатор компонента", nameof(model.SnackId)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество компонентов должно быть больше 0", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); + } + _logger.LogInformation("Order. ProductId: {ProductId}. Count: {Count}. Sum: {Sum}. Id: {Id}", model.SnackId, model.Count, model.Sum, model.Id); + var element = _orderStorage.GetElement(new OrderSearchModel + { + Id = model.Id + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Изделие с таким идентификатором уже есть"); + } + } + private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) + { + CheckModel(model, false); + var element = _orderStorage.GetElement(new OrderSearchModel() + { + Id = model.Id + }); + if (element == null) + { + throw new ArgumentNullException(nameof(element)); + } + model.DateCreate = element.DateCreate; + model.SnackId = element.SnackId; + model.DateImplement = element.DateImplement; + model.Status = element.Status; + model.Count = element.Count; + model.Sum = element.Sum; + if (requiredStatus - model.Status == 1) + { + model.Status = requiredStatus; + if (model.Status == OrderStatus.Выдан) + model.DateImplement = DateTime.Now; + if (_orderStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + _logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus); + throw new ArgumentException($"Невозможно приствоить статус {requiredStatus} заказу с текущим статусом {model.Status}"); + } + } +} + diff --git a/AbstractShopBusinessLogic/BusinessLogics/SnackLogic.cs b/AbstractShopBusinessLogic/BusinessLogics/SnackLogic.cs new file mode 100644 index 0000000..ca4bb60 --- /dev/null +++ b/AbstractShopBusinessLogic/BusinessLogics/SnackLogic.cs @@ -0,0 +1,108 @@ +using DinerContracts.BindingModels; +using DinerContracts.BusinessLogicsContracts; +using DinerContracts.SearchModels; +using DinerContracts.StoragesContracts; +using DinerContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace DinerBusinessLogic.BusinessLogics +{ + public class SnackLogic : ISnackLogic + { + private readonly ILogger _logger; + private readonly ISnackStorage _snackStorage; + public SnackLogic(ILogger logger, ISnackStorage snackStorage) + { + _logger = logger; + _snackStorage = snackStorage; + } + public List? ReadList(SnackSearchModel? model) + { + _logger.LogInformation("ReadList. BouquetName:{BouquetName}.Id:{ Id}", model?.SnackName, model?.Id); + var list = model == null ? _snackStorage.GetFullList() : _snackStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public SnackViewModel? ReadElement(SnackSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. BouquetName:{BouquetName}.Id:{ Id}", model.SnackName, model.Id); + var element = _snackStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(SnackBindingModel model) + { + CheckModel(model); + if (_snackStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(SnackBindingModel model) + { + CheckModel(model); + if (_snackStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(SnackBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_snackStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(SnackBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.SnackName)) + { + throw new ArgumentNullException("Нет названия изделия", + nameof(model.SnackName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Product. BouquetName:{BouquetName}.Cost:{ Cost}. Id: { Id}", model.SnackName, model.Price, model.Id); + var element = _snackStorage.GetElement(new SnackSearchModel + { + SnackName = model.SnackName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Изделие с таким названием уже есть"); + } + } + } +} diff --git a/AbstractShopBusinessLogic/DinerBusinessLogic.csproj b/AbstractShopBusinessLogic/DinerBusinessLogic.csproj new file mode 100644 index 0000000..6c7b98e --- /dev/null +++ b/AbstractShopBusinessLogic/DinerBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/AbstractShopContracts/BindingModels/ComponentBindingModel.cs b/AbstractShopContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..70418a9 --- /dev/null +++ b/AbstractShopContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,12 @@ +using DinerDataModels.Models; + +namespace DinerContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + } + +} diff --git a/AbstractShopContracts/BindingModels/OrderBindingModel.cs b/AbstractShopContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..01b7870 --- /dev/null +++ b/AbstractShopContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,18 @@ +using DinerDataModels.Enum; +using DinerDataModels.Models; + + +namespace DinerContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int SnackId { get; set; } + public string SnackName { get; set; } + public int Count { get; set; } + public double Sum { get; set; } + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime? DateImplement { get; set;} + } +} diff --git a/AbstractShopContracts/BindingModels/SnackBindingModel.cs b/AbstractShopContracts/BindingModels/SnackBindingModel.cs new file mode 100644 index 0000000..fa2d081 --- /dev/null +++ b/AbstractShopContracts/BindingModels/SnackBindingModel.cs @@ -0,0 +1,14 @@ +using DinerDataModels.Models; + + +namespace DinerContracts.BindingModels +{ + public class SnackBindingModel : ISnackModel + { + public int Id { get; set; } + public string SnackName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary SnackComponents { get; set; } = new(); + } + +} diff --git a/AbstractShopContracts/BusinessLogicsContracts/IComponentLogic.cs b/AbstractShopContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..7db2048 --- /dev/null +++ b/AbstractShopContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,16 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.ViewModels; + + +namespace DinerContracts.BusinessLogicsContracts +{ + public interface IComponentLogic + { + List? ReadList(ComponentSearchModel? model); + ComponentViewModel? ReadElement(ComponentSearchModel model); + bool Create(ComponentBindingModel model); + bool Update(ComponentBindingModel model); + bool Delete(ComponentBindingModel model); + } +} diff --git a/AbstractShopContracts/BusinessLogicsContracts/IOrderLogic.cs b/AbstractShopContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..18813a3 --- /dev/null +++ b/AbstractShopContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,15 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.ViewModels; + +namespace DinerContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); + } +} diff --git a/AbstractShopContracts/BusinessLogicsContracts/ISnackLogic.cs b/AbstractShopContracts/BusinessLogicsContracts/ISnackLogic.cs new file mode 100644 index 0000000..d5ca9a7 --- /dev/null +++ b/AbstractShopContracts/BusinessLogicsContracts/ISnackLogic.cs @@ -0,0 +1,15 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.ViewModels; + +namespace DinerContracts.BusinessLogicsContracts +{ + public interface ISnackLogic + { + List? ReadList(SnackSearchModel? model); + SnackViewModel? ReadElement(SnackSearchModel model); + bool Create(SnackBindingModel model); + bool Update(SnackBindingModel model); + bool Delete(SnackBindingModel model); + } +} diff --git a/AbstractShopContracts/DinerContracts.csproj b/AbstractShopContracts/DinerContracts.csproj new file mode 100644 index 0000000..bdec9f1 --- /dev/null +++ b/AbstractShopContracts/DinerContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/AbstractShopContracts/SearchModels/ComponentSearchModel.cs b/AbstractShopContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..54b9abf --- /dev/null +++ b/AbstractShopContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,8 @@ +namespace DinerContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/AbstractShopContracts/SearchModels/OrderSearchModel.cs b/AbstractShopContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..f4f8ca6 --- /dev/null +++ b/AbstractShopContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,7 @@ +namespace DinerContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/AbstractShopContracts/SearchModels/SnackSearchModel.cs b/AbstractShopContracts/SearchModels/SnackSearchModel.cs new file mode 100644 index 0000000..768594a --- /dev/null +++ b/AbstractShopContracts/SearchModels/SnackSearchModel.cs @@ -0,0 +1,8 @@ +namespace DinerContracts.SearchModels +{ + public class SnackSearchModel + { + public int? Id { get; set; } + public string? SnackName { get; set; } + } +} diff --git a/AbstractShopContracts/StoragesContracts/IComponentStorage.cs b/AbstractShopContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..c6a5cf2 --- /dev/null +++ b/AbstractShopContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,16 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.ViewModels; + +namespace DinerContracts.StoragesContracts +{ + public interface IComponentStorage + { + List GetFullList(); + List GetFilteredList(ComponentSearchModel model); + ComponentViewModel? GetElement(ComponentSearchModel model); + ComponentViewModel? Insert(ComponentBindingModel model); + ComponentViewModel? Update(ComponentBindingModel model); + ComponentViewModel? Delete(ComponentBindingModel model); + } +} diff --git a/AbstractShopContracts/StoragesContracts/IOrderStorage.cs b/AbstractShopContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..c463057 --- /dev/null +++ b/AbstractShopContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,17 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.ViewModels; + +namespace DinerContracts.StoragesContracts +{ + public interface IOrderStorage + { + List GetFullList(); + List GetFilteredList(OrderSearchModel model); + OrderViewModel? GetElement(OrderSearchModel model); + OrderViewModel? Insert(OrderBindingModel model); + OrderViewModel? Update(OrderBindingModel model); + OrderViewModel? Delete(OrderBindingModel model); + + } +} diff --git a/AbstractShopContracts/StoragesContracts/ISnackStorage.cs b/AbstractShopContracts/StoragesContracts/ISnackStorage.cs new file mode 100644 index 0000000..3b8acff --- /dev/null +++ b/AbstractShopContracts/StoragesContracts/ISnackStorage.cs @@ -0,0 +1,17 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.ViewModels; + +namespace DinerContracts.StoragesContracts +{ + public interface ISnackStorage + { + List GetFullList(); + List GetFilteredList(SnackSearchModel model); + SnackViewModel? GetElement(SnackSearchModel model); + SnackViewModel? Insert(SnackBindingModel model); + SnackViewModel? Update(SnackBindingModel model); + SnackViewModel? Delete(SnackBindingModel model); + + } +} diff --git a/AbstractShopContracts/ViewModels/ComponentViewModel.cs b/AbstractShopContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..12ac568 --- /dev/null +++ b/AbstractShopContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,14 @@ +using System.ComponentModel; +using DinerDataModels.Models; + +namespace DinerContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + [DisplayName("Название компонента")] + public string ComponentName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Cost { get; set; } + } +} diff --git a/AbstractShopContracts/ViewModels/OrderViewModel.cs b/AbstractShopContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..3d75413 --- /dev/null +++ b/AbstractShopContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,25 @@ +using System.ComponentModel; +using DinerDataModels.Models; +using DinerDataModels.Enum; + +namespace DinerContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int SnackId { get; set; } + [DisplayName("Изделие")] + public string SnackName { get; set; } = string.Empty; + [DisplayName("Количество")] + public int Count { get; set; } + [DisplayName("Сумма")] + public double Sum { get; set; } + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/AbstractShopContracts/ViewModels/SnackViewModel.cs b/AbstractShopContracts/ViewModels/SnackViewModel.cs new file mode 100644 index 0000000..0e43889 --- /dev/null +++ b/AbstractShopContracts/ViewModels/SnackViewModel.cs @@ -0,0 +1,16 @@ +using DinerDataModels.Models; +using System.ComponentModel; + +namespace DinerContracts.ViewModels +{ + public class SnackViewModel : ISnackModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string SnackName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary SnackComponents { get; set; } = new(); + } + +} diff --git a/AbstractShopDataModels/DinerDataModels.csproj b/AbstractShopDataModels/DinerDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/AbstractShopDataModels/DinerDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/AbstractShopDataModels/Enum/OrderStatus.cs b/AbstractShopDataModels/Enum/OrderStatus.cs new file mode 100644 index 0000000..cb7f002 --- /dev/null +++ b/AbstractShopDataModels/Enum/OrderStatus.cs @@ -0,0 +1,11 @@ +namespace DinerDataModels.Enum +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} diff --git a/AbstractShopDataModels/IId.cs b/AbstractShopDataModels/IId.cs new file mode 100644 index 0000000..0ab5841 --- /dev/null +++ b/AbstractShopDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace DinerDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/AbstractShopDataModels/Models/IComponentModel.cs b/AbstractShopDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..f279110 --- /dev/null +++ b/AbstractShopDataModels/Models/IComponentModel.cs @@ -0,0 +1,8 @@ +namespace DinerDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/AbstractShopDataModels/Models/IOrderModel.cs b/AbstractShopDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..5e9a7b7 --- /dev/null +++ b/AbstractShopDataModels/Models/IOrderModel.cs @@ -0,0 +1,14 @@ +using DinerDataModels.Enum; + +namespace DinerDataModels.Models +{ + public interface IOrderModel : IId + { + int Id { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get;} + } +} diff --git a/AbstractShopDataModels/Models/ISnackModel.cs b/AbstractShopDataModels/Models/ISnackModel.cs new file mode 100644 index 0000000..e08959e --- /dev/null +++ b/AbstractShopDataModels/Models/ISnackModel.cs @@ -0,0 +1,9 @@ +namespace DinerDataModels.Models +{ + public interface ISnackModel : IId + { + string SnackName { get; } + double Price { get; } + Dictionary SnackComponents { get; } + } +} diff --git a/Diner/AbstractShopListImplement/DataListSingleton.cs b/Diner/AbstractShopListImplement/DataListSingleton.cs new file mode 100644 index 0000000..2d1d2d3 --- /dev/null +++ b/Diner/AbstractShopListImplement/DataListSingleton.cs @@ -0,0 +1,31 @@ +using DinerListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DinerListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Products { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Products = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} diff --git a/Diner/AbstractShopListImplement/DinerListImplement.csproj b/Diner/AbstractShopListImplement/DinerListImplement.csproj new file mode 100644 index 0000000..51f4155 --- /dev/null +++ b/Diner/AbstractShopListImplement/DinerListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/Diner/AbstractShopListImplement/Implements/ComponentStorage.cs b/Diner/AbstractShopListImplement/Implements/ComponentStorage.cs new file mode 100644 index 0000000..3173dcf --- /dev/null +++ b/Diner/AbstractShopListImplement/Implements/ComponentStorage.cs @@ -0,0 +1,102 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.StoragesContracts; +using DinerContracts.ViewModels; +using DinerListImplement.Models; + +namespace DinerListImplement.Implements +{ + public class ComponentStorage : IComponentStorage + { + private readonly DataListSingleton _source; + public ComponentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var component in _source.Components) + { + result.Add(component.GetViewModel); + } + return result; + } + public List GetFilteredList(ComponentSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ComponentName)) + { + return result; + } + foreach (var component in _source.Components) + { + if (component.ComponentName.Contains(model.ComponentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Components) + { + if ((!string.IsNullOrEmpty(model.ComponentName) && + component.ComponentName == model.ComponentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + _source.Components.Add(newComponent); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + foreach (var component in _source.Components) + { + if (component.Id == model.Id) + { + component.Update(model); + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + for (int i = 0; i < _source.Components.Count; ++i) + { + if (_source.Components[i].Id == model.Id) + { + var element = _source.Components[i]; + _source.Components.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } + } diff --git a/Diner/AbstractShopListImplement/Implements/OrderStorage.cs b/Diner/AbstractShopListImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..536b993 --- /dev/null +++ b/Diner/AbstractShopListImplement/Implements/OrderStorage.cs @@ -0,0 +1,115 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.StoragesContracts; +using DinerContracts.ViewModels; +using DinerListImplement.Models; +using DinerListImplement; + +namespace DinerListImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataListSingleton _source; + public OrderStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var order in _source.Orders) + { + result.Add(AttachDinerName(order.GetViewModel)); + } + return result; + } + public List GetFilteredList(OrderSearchModel model) + { + var result = new List(); + if (model == null || !model.Id.HasValue) + { + return result; + } + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + result.Add(AttachDinerName(order.GetViewModel)); + } + } + return result; + + } + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + foreach (var order in _source.Orders) + { + if (model.Id.HasValue && order.Id == model.Id) + { + return AttachDinerName(order.GetViewModel); + } + } + return null; + + } + public OrderViewModel? Insert(OrderBindingModel model) + { + model.Id = 1; + foreach (var order in _source.Orders) + { + if (model.Id <= order.Id) + { + model.Id = order.Id + 1; + } + } + var newOrder = Order.Create(model); + if (newOrder == null) + { + return null; + } + _source.Orders.Add(newOrder); + return AttachDinerName(newOrder.GetViewModel); + } + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + order.Update(model); + return AttachDinerName(order.GetViewModel); + } + } + return null; + } + public OrderViewModel? Delete(OrderBindingModel model) + { + for (int i = 0; i < _source.Orders.Count; ++i) + { + if (_source.Orders[i].Id == model.Id) + { + var element = _source.Orders[i]; + _source.Orders.RemoveAt(i); + return AttachDinerName(element.GetViewModel); + } + } + return null; + } + private OrderViewModel AttachDinerName(OrderViewModel model) + { + foreach (var snack in _source.Products) + { + if (snack.Id == model.SnackId) + { + model.SnackName = snack.SnackName; + return model; + } + } + return model; + } + } +} diff --git a/Diner/AbstractShopListImplement/Implements/SnackStorage.cs b/Diner/AbstractShopListImplement/Implements/SnackStorage.cs new file mode 100644 index 0000000..a51977a --- /dev/null +++ b/Diner/AbstractShopListImplement/Implements/SnackStorage.cs @@ -0,0 +1,104 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.StoragesContracts; +using DinerContracts.ViewModels; +using DinerListImplement.Models; + +namespace DinerListImplement.Implements +{ + public class SnackStorage : ISnackStorage + { + private readonly DataListSingleton _source; + public SnackStorage() + { + _source = DataListSingleton.GetInstance(); + } + public SnackViewModel? Delete(SnackBindingModel model) + { + for (int i = 0; i < _source.Products.Count; ++i) + { + if (_source.Products[i].Id == model.Id) + { + var element = _source.Products[i]; + _source.Products.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + public SnackViewModel? GetElement(SnackSearchModel model) + { + if (string.IsNullOrEmpty(model.SnackName) && !model.Id.HasValue) + { + return null; + } + foreach (var product in _source.Products) + { + if ((!string.IsNullOrEmpty(model.SnackName) && product.SnackName == model.SnackName) || (model.Id.HasValue && product.Id == model.Id)) + { + return product.GetViewModel; + } + } + return null; + } + + public List GetFilteredList(SnackSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.SnackName)) + { + return result; + } + foreach (var product in _source.Products) + { + if (product.SnackName.Contains(model.SnackName)) + { + result.Add(product.GetViewModel); + } + } + return result; + } + + public List GetFullList() + { + var result = new List(); + foreach (var product in _source.Products) + { + result.Add(product.GetViewModel); + } + return result; + } + + public SnackViewModel? Insert(SnackBindingModel model) + { + model.Id = 1; + foreach (var product in _source.Products) + { + if (model.Id <= product.Id) + { + model.Id = product.Id + 1; + } + } + var newProduct = Snack.Create(model); + if (newProduct == null) + { + return null; + } + _source.Products.Add(newProduct); + return newProduct.GetViewModel; + } + + public SnackViewModel? Update(SnackBindingModel model) + { + foreach (var product in _source.Products) + { + if (product.Id == model.Id) + { + product.Update(model); + return product.GetViewModel; + } + } + return null; + } + } +} diff --git a/Diner/AbstractShopListImplement/Models/Component.cs b/Diner/AbstractShopListImplement/Models/Component.cs new file mode 100644 index 0000000..e2c0c2a --- /dev/null +++ b/Diner/AbstractShopListImplement/Models/Component.cs @@ -0,0 +1,41 @@ +using DinerContracts.BindingModels; +using DinerContracts.ViewModels; +using DinerDataModels.Models; + +namespace DinerListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } +} diff --git a/Diner/AbstractShopListImplement/Models/Order.cs b/Diner/AbstractShopListImplement/Models/Order.cs new file mode 100644 index 0000000..2423aaf --- /dev/null +++ b/Diner/AbstractShopListImplement/Models/Order.cs @@ -0,0 +1,63 @@ +using DinerContracts.BindingModels; +using DinerContracts.ViewModels; +using DinerDataModels.Enum; +using DinerDataModels.Models; + +namespace DinerListImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + public string SnackName { get; private set; } + public int SnackID { get; private set; } + public int Count { get; private set; } + public double Sum { get; private set; } + public OrderStatus Status { get; private set; } + public DateTime DateCreate { get; private set; } + public DateTime? DateImplement { get; private set; } + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + SnackName = model.SnackName, + SnackID = model.SnackId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement + }; + } + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + Id = model.Id; + SnackID = model.SnackId; + SnackName = model.SnackName; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + DateImplement = model.DateImplement; + } + public OrderViewModel GetViewModel => new() + { + Id = Id, + SnackId = SnackID, + SnackName = SnackName, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement + }; + } +} diff --git a/Diner/AbstractShopListImplement/Models/Snack.cs b/Diner/AbstractShopListImplement/Models/Snack.cs new file mode 100644 index 0000000..626a9d3 --- /dev/null +++ b/Diner/AbstractShopListImplement/Models/Snack.cs @@ -0,0 +1,49 @@ +using DinerContracts.BindingModels; +using DinerContracts.ViewModels; +using DinerDataModels.Models; + +namespace DinerListImplement.Models +{ + public class Snack : ISnackModel + { + public int Id { get; private set; } + public string SnackName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary SnackComponents + { + get; + private set; + } = new Dictionary(); + public static Snack? Create(SnackBindingModel? model) + { + if (model == null) + { + return null; + } + return new Snack() + { + Id = model.Id, + SnackName = model.SnackName, + Price = model.Price, + SnackComponents = model.SnackComponents + }; + } + public void Update(SnackBindingModel? model) + { + if (model == null) + { + return; + } + SnackName = model.SnackName; + Price = model.Price; + SnackComponents = model.SnackComponents; + } + public SnackViewModel GetViewModel => new() + { + Id = Id, + SnackName = SnackName, + Price = Price, + SnackComponents = SnackComponents + }; + } +} diff --git a/Diner/Diner.csproj b/Diner/Diner.csproj deleted file mode 100644 index b57c89e..0000000 --- a/Diner/Diner.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - WinExe - net6.0-windows - enable - true - enable - - - \ No newline at end of file diff --git a/Diner/Diner.sln b/Diner/Diner.sln index 8dbffe7..be21916 100644 --- a/Diner/Diner.sln +++ b/Diner/Diner.sln @@ -1,9 +1,17 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.3.32825.248 +VisualStudioVersion = 17.3.32819.101 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Diner", "Diner.csproj", "{23C9B122-7EEF-4651-88E0-1A0C4A5D342A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerView", "Diner\DinerView.csproj", "{65DDF152-0786-40A2-8CAD-091C19000D84}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerDataModels", "..\AbstractShopDataModels\DinerDataModels.csproj", "{1AA0331A-FF61-4CA9-8273-51DF0A9ABBEC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerContracts", "..\AbstractShopContracts\DinerContracts.csproj", "{86956F83-EF92-432E-B2DA-7E719873AC98}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerBusinessLogic", "..\AbstractShopBusinessLogic\DinerBusinessLogic.csproj", "{DDA6A507-23B7-4CB2-B5CF-3FBBB687D43C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerListImplement", "AbstractShopListImplement\DinerListImplement.csproj", "{A24E7474-4B43-4E81-A6BF-2B7323D5C26A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +19,31 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {23C9B122-7EEF-4651-88E0-1A0C4A5D342A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {23C9B122-7EEF-4651-88E0-1A0C4A5D342A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {23C9B122-7EEF-4651-88E0-1A0C4A5D342A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {23C9B122-7EEF-4651-88E0-1A0C4A5D342A}.Release|Any CPU.Build.0 = Release|Any CPU + {65DDF152-0786-40A2-8CAD-091C19000D84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {65DDF152-0786-40A2-8CAD-091C19000D84}.Debug|Any CPU.Build.0 = Debug|Any CPU + {65DDF152-0786-40A2-8CAD-091C19000D84}.Release|Any CPU.ActiveCfg = Release|Any CPU + {65DDF152-0786-40A2-8CAD-091C19000D84}.Release|Any CPU.Build.0 = Release|Any CPU + {1AA0331A-FF61-4CA9-8273-51DF0A9ABBEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1AA0331A-FF61-4CA9-8273-51DF0A9ABBEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1AA0331A-FF61-4CA9-8273-51DF0A9ABBEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1AA0331A-FF61-4CA9-8273-51DF0A9ABBEC}.Release|Any CPU.Build.0 = Release|Any CPU + {86956F83-EF92-432E-B2DA-7E719873AC98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86956F83-EF92-432E-B2DA-7E719873AC98}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86956F83-EF92-432E-B2DA-7E719873AC98}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86956F83-EF92-432E-B2DA-7E719873AC98}.Release|Any CPU.Build.0 = Release|Any CPU + {DDA6A507-23B7-4CB2-B5CF-3FBBB687D43C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDA6A507-23B7-4CB2-B5CF-3FBBB687D43C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDA6A507-23B7-4CB2-B5CF-3FBBB687D43C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDA6A507-23B7-4CB2-B5CF-3FBBB687D43C}.Release|Any CPU.Build.0 = Release|Any CPU + {A24E7474-4B43-4E81-A6BF-2B7323D5C26A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A24E7474-4B43-4E81-A6BF-2B7323D5C26A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A24E7474-4B43-4E81-A6BF-2B7323D5C26A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A24E7474-4B43-4E81-A6BF-2B7323D5C26A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {5ED0C012-8FB3-4A50-B469-47606ADB8FC8} + SolutionGuid = {78CA589A-698F-4822-A1DB-E616926BB9B3} EndGlobalSection EndGlobal diff --git a/Diner/Diner/DinerView.csproj b/Diner/Diner/DinerView.csproj new file mode 100644 index 0000000..1df4deb --- /dev/null +++ b/Diner/Diner/DinerView.csproj @@ -0,0 +1,20 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + + + + + + \ No newline at end of file diff --git a/Diner/Diner/FormComponent.Designer.cs b/Diner/Diner/FormComponent.Designer.cs new file mode 100644 index 0000000..5f472c4 --- /dev/null +++ b/Diner/Diner/FormComponent.Designer.cs @@ -0,0 +1,119 @@ +namespace Diner +{ + partial class FormComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelName = new System.Windows.Forms.Label(); + this.labelPrice = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(27, 26); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(80, 20); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название:"; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(27, 64); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(48, 20); + this.labelPrice.TabIndex = 1; + this.labelPrice.Text = "Цена:"; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(113, 23); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(317, 27); + this.textBoxName.TabIndex = 2; + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(113, 61); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(172, 27); + this.textBoxPrice.TabIndex = 3; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(224, 105); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(94, 29); + this.buttonSave.TabIndex = 4; + this.buttonSave.Text = "Создать"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(336, 105); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(94, 29); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(470, 162); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.labelName); + this.Name = "FormComponent"; + this.Text = "Компонент"; + this.Load += new System.EventHandler(this.FormComponent_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelName; + private Label labelPrice; + private TextBox textBoxName; + private TextBox textBoxPrice; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/Diner/Diner/FormComponent.cs b/Diner/Diner/FormComponent.cs new file mode 100644 index 0000000..cf2724b --- /dev/null +++ b/Diner/Diner/FormComponent.cs @@ -0,0 +1,88 @@ +using DinerContracts.BindingModels; +using DinerContracts.BusinessLogicsContracts; +using DinerContracts.SearchModels; +using Microsoft.Extensions.Logging; +using Microsoft.VisualBasic.Logging; + +namespace Diner +{ + public partial class FormComponent : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + public FormComponent(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormComponent_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation(" "); + var view = _logic.ReadElement(new ComponentSearchModel + { + Id = + _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ComponentName; + textBoxPrice.Text = view.Cost.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show(" ", "", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation(" "); + try + { + var model = new ComponentBindingModel + { + Id = _id ?? 0, + ComponentName = textBoxName.Text, + Cost = Convert.ToDouble(textBoxPrice.Text) + }; + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); + 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(); + } + } +} \ No newline at end of file diff --git a/Diner/Diner/FormComponent.resx b/Diner/Diner/FormComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Diner/Diner/FormComponent.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Diner/Diner/FormComponents.Designer.cs b/Diner/Diner/FormComponents.Designer.cs new file mode 100644 index 0000000..b393bf4 --- /dev/null +++ b/Diner/Diner/FormComponents.Designer.cs @@ -0,0 +1,116 @@ +namespace Diner +{ + partial class FormComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(559, 31); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(94, 29); + this.buttonAdd.TabIndex = 0; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(559, 84); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(94, 29); + this.buttonUpd.TabIndex = 1; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(559, 138); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(94, 29); + this.buttonDel.TabIndex = 2; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(559, 189); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(94, 29); + this.buttonRef.TabIndex = 3; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(0, 1); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(529, 442); + this.dataGridView.TabIndex = 4; + // + // FormComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(680, 450); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Name = "FormComponents"; + this.Text = "Компоненты"; + this.Load += new System.EventHandler(this.FormComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private Button buttonRef; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/Diner/Diner/FormComponents.cs b/Diner/Diner/FormComponents.cs new file mode 100644 index 0000000..87ff62a --- /dev/null +++ b/Diner/Diner/FormComponents.cs @@ -0,0 +1,103 @@ +using DinerContracts.BindingModels; +using DinerContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace Diner +{ + public partial class FormComponents : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormComponents_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка компонентов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + form.Id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_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("Удаление компонента"); + try + { + if (!_logic.Delete(new ComponentBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления компонента"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/Diner/Diner/FormComponents.resx b/Diner/Diner/FormComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Diner/Diner/FormComponents.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Diner/Diner/FormCreateOrder.Designer.cs b/Diner/Diner/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..f5260ca --- /dev/null +++ b/Diner/Diner/FormCreateOrder.Designer.cs @@ -0,0 +1,144 @@ +namespace Diner +{ + 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); + } + + #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() + { + this.labelProduct = new System.Windows.Forms.Label(); + this.labelCount = new System.Windows.Forms.Label(); + this.labelPrice = new System.Windows.Forms.Label(); + this.comboBoxProduct = new System.Windows.Forms.ComboBox(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.textBoxSum = new System.Windows.Forms.TextBox(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelProduct + // + this.labelProduct.AutoSize = true; + this.labelProduct.Location = new System.Drawing.Point(47, 21); + this.labelProduct.Name = "labelProduct"; + this.labelProduct.Size = new System.Drawing.Size(71, 20); + this.labelProduct.TabIndex = 0; + this.labelProduct.Text = "Изделие:"; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(47, 62); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(93, 20); + this.labelCount.TabIndex = 1; + this.labelCount.Text = "Количество:"; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(47, 104); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(58, 20); + this.labelPrice.TabIndex = 2; + this.labelPrice.Text = "Сумма:"; + // + // comboBoxProduct + // + this.comboBoxProduct.FormattingEnabled = true; + this.comboBoxProduct.Location = new System.Drawing.Point(149, 18); + this.comboBoxProduct.Name = "comboBoxProduct"; + this.comboBoxProduct.Size = new System.Drawing.Size(246, 28); + this.comboBoxProduct.TabIndex = 3; + this.comboBoxProduct.SelectedIndexChanged += new System.EventHandler(this.ComboBoxProduct_SelectedIndexChanged); + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(149, 59); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(246, 27); + this.textBoxCount.TabIndex = 4; + this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); + // + // textBoxSum + // + this.textBoxSum.Location = new System.Drawing.Point(149, 101); + this.textBoxSum.Name = "textBoxSum"; + this.textBoxSum.Size = new System.Drawing.Size(246, 27); + this.textBoxSum.TabIndex = 5; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(178, 153); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(94, 29); + 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(301, 153); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(94, 29); + this.buttonCancel.TabIndex = 7; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormCreateOrder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(420, 205); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxSum); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxProduct); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.labelProduct); + this.Name = "FormCreateOrder"; + this.Text = "Заказ"; + this.Load += new System.EventHandler(this.FormCreateOrder_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelProduct; + private Label labelCount; + private Label labelPrice; + private ComboBox comboBoxProduct; + private TextBox textBoxCount; + private TextBox textBoxSum; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/Diner/Diner/FormCreateOrder.cs b/Diner/Diner/FormCreateOrder.cs new file mode 100644 index 0000000..754c5f3 --- /dev/null +++ b/Diner/Diner/FormCreateOrder.cs @@ -0,0 +1,119 @@ +using DinerContracts.BindingModels; +using DinerContracts.BusinessLogicsContracts; +using DinerContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System.Data; + +namespace Diner +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly ISnackLogic _logicP; + private readonly IOrderLogic _logicO; + public FormCreateOrder(ILogger logger, ISnackLogic logicP, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicO = logicO; + } + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка изделий для заказа"); + try + { + var list = _logicP.ReadList(null); + if (list != null) + { + comboBoxProduct.DisplayMember = "Snack"; + comboBoxProduct.ValueMember = "Id"; + comboBoxProduct.DataSource = list.Select(c => c.SnackName).ToList(); + comboBoxProduct.SelectedItem = null; + } + + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка изделий"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void CalcSum() + { + if (comboBoxProduct.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxProduct.SelectedIndex + 1); + var product = _logicP.ReadElement(new SnackSearchModel + { + Id = id + }); + int count = Convert.ToInt32(textBoxCount.Text); + textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString(); + _logger.LogInformation("Расчет суммы заказа"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка расчета суммы заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void TextBoxCount_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + private void ComboBoxProduct_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxProduct.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание заказа"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + SnackId = Convert.ToInt32(comboBoxProduct.SelectedIndex + 1), + SnackName = comboBoxProduct.SelectedValue.ToString(), + 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/Diner/Diner/FormCreateOrder.resx b/Diner/Diner/FormCreateOrder.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Diner/Diner/FormCreateOrder.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Diner/Diner/FormMain.Designer.cs b/Diner/Diner/FormMain.Designer.cs new file mode 100644 index 0000000..802160c --- /dev/null +++ b/Diner/Diner/FormMain.Designer.cs @@ -0,0 +1,176 @@ +namespace Diner +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.buttonCreateOrder = new System.Windows.Forms.Button(); + this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); + this.buttonOrderReady = new System.Windows.Forms.Button(); + this.buttonIssuedOrder = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.toolStripLabel1 = new System.Windows.Forms.ToolStripDropDownButton(); + this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.snacksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.toolStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(0, 27); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(986, 421); + this.dataGridView.TabIndex = 0; + // + // buttonCreateOrder + // + this.buttonCreateOrder.Location = new System.Drawing.Point(1040, 88); + this.buttonCreateOrder.Name = "buttonCreateOrder"; + this.buttonCreateOrder.Size = new System.Drawing.Size(202, 29); + 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(1040, 136); + this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + this.buttonTakeOrderInWork.Size = new System.Drawing.Size(202, 29); + this.buttonTakeOrderInWork.TabIndex = 2; + this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; + this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; + this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + // + // buttonOrderReady + // + this.buttonOrderReady.Location = new System.Drawing.Point(1040, 184); + this.buttonOrderReady.Name = "buttonOrderReady"; + this.buttonOrderReady.Size = new System.Drawing.Size(202, 29); + this.buttonOrderReady.TabIndex = 3; + this.buttonOrderReady.Text = "Заказ готов"; + this.buttonOrderReady.UseVisualStyleBackColor = true; + this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); + // + // buttonIssuedOrder + // + this.buttonIssuedOrder.Location = new System.Drawing.Point(1040, 237); + this.buttonIssuedOrder.Name = "buttonIssuedOrder"; + this.buttonIssuedOrder.Size = new System.Drawing.Size(202, 29); + this.buttonIssuedOrder.TabIndex = 4; + this.buttonIssuedOrder.Text = "Заказ выдан"; + this.buttonIssuedOrder.UseVisualStyleBackColor = true; + this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(1040, 287); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(202, 29); + this.buttonRef.TabIndex = 5; + this.buttonRef.Text = "Обновить список"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // toolStrip1 + // + this.toolStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripLabel1}); + this.toolStrip1.Location = new System.Drawing.Point(0, 0); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.Size = new System.Drawing.Size(1280, 27); + this.toolStrip1.TabIndex = 6; + this.toolStrip1.Text = "toolStrip1"; + // + // toolStripLabel1 + // + this.toolStripLabel1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.componentsToolStripMenuItem, + this.snacksToolStripMenuItem}); + this.toolStripLabel1.Name = "toolStripLabel1"; + this.toolStripLabel1.Size = new System.Drawing.Size(117, 24); + this.toolStripLabel1.Text = "Справочники"; + // + // componentsToolStripMenuItem + // + this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; + this.componentsToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.componentsToolStripMenuItem.Text = "Компоненты"; + this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentToolStripMenuItem_Click); + // + // snacksToolStripMenuItem + // + this.snacksToolStripMenuItem.Name = "snacksToolStripMenuItem"; + this.snacksToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.snacksToolStripMenuItem.Text = "Закуски"; + this.snacksToolStripMenuItem.Click += new System.EventHandler(this.ProductToolStripMenuItem_Click); + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1280, 450); + this.Controls.Add(this.toolStrip1); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonIssuedOrder); + this.Controls.Add(this.buttonOrderReady); + this.Controls.Add(this.buttonTakeOrderInWork); + this.Controls.Add(this.buttonCreateOrder); + this.Controls.Add(this.dataGridView); + this.Name = "FormMain"; + this.Text = "Закусочная"; + this.Load += new System.EventHandler(this.FormMain_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; + private Button buttonRef; + private ToolStrip toolStrip1; + private ToolStripDropDownButton toolStripLabel1; + private ToolStripMenuItem componentsToolStripMenuItem; + private ToolStripMenuItem snacksToolStripMenuItem; + } +} \ No newline at end of file diff --git a/Diner/Diner/FormMain.cs b/Diner/Diner/FormMain.cs new file mode 100644 index 0000000..31f1058 --- /dev/null +++ b/Diner/Diner/FormMain.cs @@ -0,0 +1,165 @@ +using DinerContracts.BindingModels; +using DinerContracts.BusinessLogicsContracts; +using DinerDataModels.Enum; +using Microsoft.Extensions.Logging; + +namespace Diner +{ + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + // прописать логику + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ComponentToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void ProductToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSnacks)); + if (service is FormSnacks form) + { + form.ShowDialog(); + } + } + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel + { + Id = id, + SnackId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value), + SnackName = dataGridView.SelectedRows[0].Cells["SnackName"].Value.ToString(), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel + { + Id = id, + SnackId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value), + SnackName = dataGridView.SelectedRows[0].Cells["SnackName"].Value.ToString(), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = id, + SnackId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value), + SnackName = dataGridView.SelectedRows[0].Cells["SnackName"].Value.ToString(), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/Diner/Diner/FormMain.resx b/Diner/Diner/FormMain.resx new file mode 100644 index 0000000..37e571f --- /dev/null +++ b/Diner/Diner/FormMain.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Diner/Diner/FormSnack.Designer.cs b/Diner/Diner/FormSnack.Designer.cs new file mode 100644 index 0000000..a21e5a9 --- /dev/null +++ b/Diner/Diner/FormSnack.Designer.cs @@ -0,0 +1,236 @@ +namespace Diner +{ + partial class FormSnack + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelName = new System.Windows.Forms.Label(); + this.labelPrice = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.groupBoxComponents = new System.Windows.Forms.GroupBox(); + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxComponents.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(41, 20); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(80, 20); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название:"; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(41, 52); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(86, 20); + this.labelPrice.TabIndex = 1; + this.labelPrice.Text = "Стоимость:"; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(140, 17); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(267, 27); + this.textBoxName.TabIndex = 2; + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(140, 52); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(144, 27); + this.textBoxPrice.TabIndex = 3; + // + // groupBoxComponents + // + this.groupBoxComponents.Controls.Add(this.buttonRef); + this.groupBoxComponents.Controls.Add(this.buttonDel); + this.groupBoxComponents.Controls.Add(this.buttonUpd); + this.groupBoxComponents.Controls.Add(this.buttonAdd); + this.groupBoxComponents.Controls.Add(this.dataGridView); + this.groupBoxComponents.Location = new System.Drawing.Point(41, 95); + this.groupBoxComponents.Name = "groupBoxComponents"; + this.groupBoxComponents.Size = new System.Drawing.Size(587, 291); + this.groupBoxComponents.TabIndex = 4; + this.groupBoxComponents.TabStop = false; + this.groupBoxComponents.Text = "Компоненты"; + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(464, 195); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(94, 29); + this.buttonRef.TabIndex = 9; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(464, 146); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(94, 29); + this.buttonDel.TabIndex = 8; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(464, 102); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(94, 29); + this.buttonUpd.TabIndex = 7; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(464, 55); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(94, 29); + this.buttonAdd.TabIndex = 6; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ID, + this.Component, + this.Count}); + this.dataGridView.GridColor = System.Drawing.SystemColors.ControlDarkDark; + this.dataGridView.Location = new System.Drawing.Point(6, 26); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(428, 259); + this.dataGridView.TabIndex = 5; + // + // ID + // + this.ID.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ID.HeaderText = ""; + this.ID.MinimumWidth = 6; + this.ID.Name = "ID"; + this.ID.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.ID.Visible = false; + // + // Component + // + this.Component.HeaderText = "Компонент"; + this.Component.MinimumWidth = 6; + this.Component.Name = "Component"; + this.Component.Width = 125; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + this.Count.Width = 125; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(381, 392); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(94, 29); + this.buttonSave.TabIndex = 10; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(505, 392); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(94, 29); + this.buttonCancel.TabIndex = 11; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormSnack + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(660, 450); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBoxComponents); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.labelName); + this.Name = "FormSnack"; + this.Text = "Закуска"; + this.Load += new System.EventHandler(this.FormProduct_Load); + this.groupBoxComponents.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelName; + private Label labelPrice; + private TextBox textBoxName; + private TextBox textBoxPrice; + private GroupBox groupBoxComponents; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ID; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Count; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/Diner/Diner/FormSnack.cs b/Diner/Diner/FormSnack.cs new file mode 100644 index 0000000..d5b4db6 --- /dev/null +++ b/Diner/Diner/FormSnack.cs @@ -0,0 +1,209 @@ +using DinerContracts.BindingModels; +using DinerContracts.BusinessLogicsContracts; +using DinerContracts.SearchModels; +using DinerDataModels.Models; +using Microsoft.Extensions.Logging; + +namespace Diner +{ + public partial class FormSnack : Form + { + private readonly ILogger _logger; + private readonly ISnackLogic _logic; + private int? _id; + private Dictionary _productComponents; + public int Id { set { _id = value; } } + public FormSnack(ILogger logger, ISnackLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _productComponents = new Dictionary(); + } + private void FormProduct_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка изделия"); + try + { + var view = _logic.ReadElement(new SnackSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.SnackName; + textBoxPrice.Text = view.Price.ToString(); + _productComponents = view.SnackComponents ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка компонент изделия"); + try + { + if (_productComponents != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _productComponents) + { + dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); + } + textBoxPrice.Text = CalcPrice().ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонент изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormSnackComponent)); + if (service is FormSnackComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); + if (_productComponents.ContainsKey(form.Id)) + { + _productComponents[form.Id] = (form.ComponentModel, + form.Count); + } + else + { + _productComponents.Add(form.Id, (form.ComponentModel, + form.Count)); + } + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormSnackComponent)); + if (service is FormSnackComponent form) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _productComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); + _productComponents[form.Id] = (form.ComponentModel, form.Count); + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); + _productComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxPrice.Text)) + { + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + return; + } + if (_productComponents == null || _productComponents.Count == 0) + { + MessageBox.Show("Заполните компоненты", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение изделия"); + try + { + var model = new SnackBindingModel + { + Id = _id ?? 0, + SnackName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + SnackComponents = _productComponents + }; + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); + 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(); + } + private double CalcPrice() + { + double price = 0; + foreach (var elem in _productComponents) + { + price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); + } + } +} diff --git a/Diner/Diner/FormSnack.resx b/Diner/Diner/FormSnack.resx new file mode 100644 index 0000000..58a78b5 --- /dev/null +++ b/Diner/Diner/FormSnack.resx @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/Diner/Diner/FormSnackComponent.Designer.cs b/Diner/Diner/FormSnackComponent.Designer.cs new file mode 100644 index 0000000..703560c --- /dev/null +++ b/Diner/Diner/FormSnackComponent.Designer.cs @@ -0,0 +1,119 @@ +namespace Diner +{ + partial class FormSnackComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.labelNumber = new System.Windows.Forms.Label(); + this.labelComponent = new System.Windows.Forms.Label(); + this.comboBoxComponent = new System.Windows.Forms.ComboBox(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(164, 88); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(243, 27); + this.textBoxCount.TabIndex = 0; + // + // labelNumber + // + this.labelNumber.AutoSize = true; + this.labelNumber.Location = new System.Drawing.Point(40, 88); + this.labelNumber.Name = "labelNumber"; + this.labelNumber.Size = new System.Drawing.Size(93, 20); + this.labelNumber.TabIndex = 1; + this.labelNumber.Text = "Количество:"; + // + // labelComponent + // + this.labelComponent.AutoSize = true; + this.labelComponent.Location = new System.Drawing.Point(40, 44); + this.labelComponent.Name = "labelComponent"; + this.labelComponent.Size = new System.Drawing.Size(91, 20); + this.labelComponent.TabIndex = 2; + this.labelComponent.Text = "Компонент:"; + // + // comboBoxComponent + // + this.comboBoxComponent.FormattingEnabled = true; + this.comboBoxComponent.Location = new System.Drawing.Point(164, 44); + this.comboBoxComponent.Name = "comboBoxComponent"; + this.comboBoxComponent.Size = new System.Drawing.Size(243, 28); + this.comboBoxComponent.TabIndex = 3; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(194, 141); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(94, 29); + this.buttonSave.TabIndex = 4; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(313, 141); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(94, 29); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отменить"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormSnackComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(438, 199); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.comboBoxComponent); + this.Controls.Add(this.labelComponent); + this.Controls.Add(this.labelNumber); + this.Controls.Add(this.textBoxCount); + this.Name = "FormSnackComponent"; + this.Text = "Добавление компонента"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxCount; + private Label labelNumber; + private Label labelComponent; + private ComboBox comboBoxComponent; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/Diner/Diner/FormSnackComponent.cs b/Diner/Diner/FormSnackComponent.cs new file mode 100644 index 0000000..3f86e85 --- /dev/null +++ b/Diner/Diner/FormSnackComponent.cs @@ -0,0 +1,80 @@ +using DinerContracts.BusinessLogicsContracts; +using DinerContracts.ViewModels; +using DinerDataModels.Models; + +namespace Diner +{ + public partial class FormSnackComponent : Form + { + private readonly List? _list; + public int Id + { + get + { + return Convert.ToInt32(comboBoxComponent.SelectedValue); + } + set + { + comboBoxComponent.SelectedValue = value; + } + } + public IComponentModel? ComponentModel + { + get + { + if (_list == null) + { + return null; + } + foreach (var elem in _list) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + public int Count + { + get { return Convert.ToInt32(textBoxCount.Text); } + set + { textBoxCount.Text = value.ToString(); } + } + public FormSnackComponent(IComponentLogic logic) + { + InitializeComponent(); + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxComponent.DisplayMember = "ComponentName"; + comboBoxComponent.ValueMember = "Id"; + comboBoxComponent.DataSource = _list; + comboBoxComponent.SelectedItem = null; + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxComponent.SelectedValue == null) + { + MessageBox.Show("Выберите компонент", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + DialogResult = DialogResult.OK; + Close(); + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/Diner/Diner/FormSnackComponent.resx b/Diner/Diner/FormSnackComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Diner/Diner/FormSnackComponent.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Diner/Diner/FormSnacks.Designer.cs b/Diner/Diner/FormSnacks.Designer.cs new file mode 100644 index 0000000..272ee78 --- /dev/null +++ b/Diner/Diner/FormSnacks.Designer.cs @@ -0,0 +1,123 @@ +namespace Diner +{ + partial class FormSnacks + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonChange = new System.Windows.Forms.Button(); + this.buttonDelete = new System.Windows.Forms.Button(); + this.buttonUpdate = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Margin = new System.Windows.Forms.Padding(2); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 62; + this.dataGridView.RowTemplate.Height = 33; + this.dataGridView.Size = new System.Drawing.Size(514, 390); + this.dataGridView.TabIndex = 0; + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(545, 27); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(2); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(90, 27); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // buttonChange + // + this.buttonChange.Location = new System.Drawing.Point(546, 69); + this.buttonChange.Margin = new System.Windows.Forms.Padding(2); + this.buttonChange.Name = "buttonChange"; + this.buttonChange.Size = new System.Drawing.Size(90, 27); + this.buttonChange.TabIndex = 2; + this.buttonChange.Text = "Изменить"; + this.buttonChange.UseVisualStyleBackColor = true; + this.buttonChange.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonDelete + // + this.buttonDelete.Location = new System.Drawing.Point(545, 113); + this.buttonDelete.Margin = new System.Windows.Forms.Padding(2); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(90, 27); + this.buttonDelete.TabIndex = 3; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(546, 153); + this.buttonUpdate.Margin = new System.Windows.Forms.Padding(2); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(90, 27); + this.buttonUpdate.TabIndex = 4; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); + // + // FormSnacks + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(661, 390); + this.Controls.Add(this.buttonUpdate); + this.Controls.Add(this.buttonDelete); + this.Controls.Add(this.buttonChange); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.dataGridView); + this.Margin = new System.Windows.Forms.Padding(2); + this.Name = "FormSnacks"; + this.Text = "Закуски"; + this.Load += new System.EventHandler(this.FormProducts_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonChange; + private Button buttonDelete; + private Button buttonUpdate; + } +} \ No newline at end of file diff --git a/Diner/Diner/FormSnacks.cs b/Diner/Diner/FormSnacks.cs new file mode 100644 index 0000000..4956cc8 --- /dev/null +++ b/Diner/Diner/FormSnacks.cs @@ -0,0 +1,109 @@ +using DinerContracts.BindingModels; +using DinerContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace Diner +{ + public partial class FormSnacks : Form + { + private readonly ILogger _logger; + private readonly ISnackLogic _logic; + + public FormSnacks(ILogger logger, ISnackLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["SnackName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["SnackComponents"].Visible = false; + } + + _logger.LogInformation("Загрузка компонентов"); + + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSnack)); + + if (service is FormSnack form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSnack)); + + if (service is FormSnack form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_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("Удаление компонента"); + + try + { + if (!_logic.Delete(new SnackBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + + 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 FormProducts_Load(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/Diner/Diner/FormSnacks.resx b/Diner/Diner/FormSnacks.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Diner/Diner/FormSnacks.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Diner/Diner/Program.cs b/Diner/Diner/Program.cs new file mode 100644 index 0000000..8684190 --- /dev/null +++ b/Diner/Diner/Program.cs @@ -0,0 +1,51 @@ +using DinerContracts.BusinessLogicsContracts; +using DinerContracts.StoragesContracts; +using DinerListImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; +using DinerBusinessLogic.BusinessLogics; + +namespace Diner +{ + internal static class Program + { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } + } +} \ No newline at end of file diff --git a/Diner/Diner/Properties/DataSources/DinerListImplement.DataListSingleton.datasource b/Diner/Diner/Properties/DataSources/DinerListImplement.DataListSingleton.datasource new file mode 100644 index 0000000..8ecc489 --- /dev/null +++ b/Diner/Diner/Properties/DataSources/DinerListImplement.DataListSingleton.datasource @@ -0,0 +1,10 @@ + + + + DinerListImplement.DataListSingleton, DinerListImplement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Diner/Diner/Properties/DataSources/DinerListImplement.Implements.ComponentStorage.datasource b/Diner/Diner/Properties/DataSources/DinerListImplement.Implements.ComponentStorage.datasource new file mode 100644 index 0000000..1287086 --- /dev/null +++ b/Diner/Diner/Properties/DataSources/DinerListImplement.Implements.ComponentStorage.datasource @@ -0,0 +1,10 @@ + + + + DinerListImplement.Implements.ComponentStorage, DinerListImplement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Diner/Diner/nlog.config b/Diner/Diner/nlog.config new file mode 100644 index 0000000..c18a0df --- /dev/null +++ b/Diner/Diner/nlog.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/Diner/Form1.Designer.cs b/Diner/Form1.Designer.cs deleted file mode 100644 index 1f2675b..0000000 --- a/Diner/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Diner -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/Diner/Form1.cs b/Diner/Form1.cs deleted file mode 100644 index 0a2874a..0000000 --- a/Diner/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Diner -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/Diner/Form1.resx b/Diner/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/Diner/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Diner/Program.cs b/Diner/Program.cs deleted file mode 100644 index b36bc8f..0000000 --- a/Diner/Program.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Diner -{ - internal static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); - } - } -} \ No newline at end of file