From e317e0d21a0fd86767201bead098e8677712a8b8 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 29 Jan 2023 18:05:49 +0400 Subject: [PATCH 01/16] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B5=D0=BA=D1=82=20?= =?UTF-8?q?=D1=81=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D1=8F=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enums/OrderStatus.cs | 17 +++++++++++++++++ .../FurnitureAssemblyDataModels.csproj | 15 +++++++++++++++ .../FurnitureAssemblyDataModels/IId.cs | 13 +++++++++++++ .../Models/IComponentModel.cs | 14 ++++++++++++++ .../Models/IFurnitureModel.cs | 15 +++++++++++++++ .../Models/IOrderModel.cs | 19 +++++++++++++++++++ 6 files changed, 93 insertions(+) create mode 100644 FurnitureAssembly/FurnitureAssemblyDataModels/Enums/OrderStatus.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj create mode 100644 FurnitureAssembly/FurnitureAssemblyDataModels/IId.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyDataModels/Models/IComponentModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyDataModels/Models/IFurnitureModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyDataModels/Models/IOrderModel.cs diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/Enums/OrderStatus.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/Enums/OrderStatus.cs new file mode 100644 index 0000000..0f80752 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyDataModels/Enums/OrderStatus.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj b/FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj new file mode 100644 index 0000000..17fe669 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj @@ -0,0 +1,15 @@ + + + + net6.0 + enable + enable + + + + + + + + + diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/IId.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/IId.cs new file mode 100644 index 0000000..07be087 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyDataModels/IId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IComponentModel.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..6ade160 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IComponentModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IFurnitureModel.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IFurnitureModel.cs new file mode 100644 index 0000000..217f579 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IFurnitureModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyDataModels.Models +{ + public interface IFurnitureModel : IId + { + string FurnitureName { get; } + double Price { get; } + Dictionary FurnitureComponents { get; } + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IOrderModel.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..6334ef8 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IOrderModel.cs @@ -0,0 +1,19 @@ +using FurnitureAssemblyDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyDataModels.Models +{ + public interface IOrderModel : IId + { + int FurnitureId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} -- 2.25.1 From 961a7645e6ff93dcac0e7212e6900830cf8a5c62 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 29 Jan 2023 18:06:26 +0400 Subject: [PATCH 02/16] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B5=D0=BA=D1=82=20?= =?UTF-8?q?=D1=81=20=D0=BA=D0=BE=D0=BD=D1=82=D1=80=D0=B0=D0=BA=D1=82=D0=B0?= =?UTF-8?q?=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/ComponentBindingModel.cs | 15 ++++++++++ .../BindingModels/FurnitureBindingModel.cs | 17 +++++++++++ .../BindingModels/OrderBindingModel.cs | 21 +++++++++++++ .../IComponentLogic.cs | 20 +++++++++++++ .../IFurnitureLogic.cs | 20 +++++++++++++ .../BusinessLogicsContarcts/IOrderLogic.cs | 21 +++++++++++++ .../FurnitureAssemblyContracts.csproj | 19 ++++++++++++ .../SearchModels/ComponentSearchModel.cs | 14 +++++++++ .../SearchModels/FurnitureSearchModel.cs | 14 +++++++++ .../SearchModels/OrderSearchModel.cs | 13 ++++++++ .../StoragesContracts/IComponentStorage.cs | 21 +++++++++++++ .../StoragesContracts/IFurnitureStorage.cs | 21 +++++++++++++ .../StoragesContracts/IOrderStorage.cs | 21 +++++++++++++ .../ViewModels/ComponentViewModel.cs | 19 ++++++++++++ .../ViewModels/FurnitureViewModel.cs | 20 +++++++++++++ .../ViewModels/OrderViewModel.cs | 30 +++++++++++++++++++ 16 files changed, 306 insertions(+) create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ComponentBindingModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/FurnitureBindingModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IComponentLogic.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IFurnitureLogic.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IOrderLogic.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ComponentSearchModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/FurnitureSearchModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IComponentStorage.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IFurnitureStorage.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ComponentBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..d0041df --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FurnitureAssemblyDataModels.Models; +namespace FurnitureAssemblyContracts.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/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/FurnitureBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/FurnitureBindingModel.cs new file mode 100644 index 0000000..b29f35d --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/FurnitureBindingModel.cs @@ -0,0 +1,17 @@ +using FurnitureAssemblyDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.BindingModels +{ + public class FurnitureBindingModel : IFurnitureModel + { + public int Id { get; set; } + public string FurnitureName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary FurnitureComponents{ get; set; } = new(); + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..280e941 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,21 @@ +using FurnitureAssemblyDataModels.Enums; +using FurnitureAssemblyDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int FurnitureId { 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/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IComponentLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IComponentLogic.cs new file mode 100644 index 0000000..d2465d6 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IComponentLogic.cs @@ -0,0 +1,20 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.BusinessLogicsContarcts +{ + 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/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IFurnitureLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IFurnitureLogic.cs new file mode 100644 index 0000000..b4ec4f9 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IFurnitureLogic.cs @@ -0,0 +1,20 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.BusinessLogicsContarcts +{ + public interface IFurnitureLogic + { + List? ReadList(FurnitureSearchModel? model); + FurnitureViewModel? ReadElement(FurnitureSearchModel model); + bool Create(FurnitureBindingModel model); + bool Update(FurnitureBindingModel model); + bool Delete(FurnitureBindingModel model); + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IOrderLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IOrderLogic.cs new file mode 100644 index 0000000..0619a27 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IOrderLogic.cs @@ -0,0 +1,21 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.BusinessLogicsContarcts +{ + 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/FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj b/FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj new file mode 100644 index 0000000..57b3533 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ComponentSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..d6cad61 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/FurnitureSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/FurnitureSearchModel.cs new file mode 100644 index 0000000..827fe8f --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/FurnitureSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.SearchModels +{ + public class FurnitureSearchModel + { + public int? Id { get; set; } + public string? FurnitureName { get; set; } + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..25dba07 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IComponentStorage.cs b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..22a17d8 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,21 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.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/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IFurnitureStorage.cs b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IFurnitureStorage.cs new file mode 100644 index 0000000..b6bd179 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IFurnitureStorage.cs @@ -0,0 +1,21 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.StoragesContracts +{ + public interface IFurnitureStorage + { + List GetFullList(); + List GetFilteredList(FurnitureSearchModel model); + FurnitureViewModel? GetElement(FurnitureSearchModel model); + FurnitureViewModel? Insert(FurnitureBindingModel model); + FurnitureViewModel? Update(FurnitureBindingModel model); + FurnitureViewModel? Delete(FurnitureBindingModel model); + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..fd843e7 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,21 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.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/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..516ff28 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,19 @@ +using FurnitureAssemblyDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.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/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs new file mode 100644 index 0000000..ea144c1 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs @@ -0,0 +1,20 @@ +using FurnitureAssemblyDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.ViewModels +{ + public class FurnitureViewModel : IFurnitureModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string FurnitureName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary FurnitureComponents{ get; set; } = new(); + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..da11b84 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,30 @@ +using FurnitureAssemblyDataModels.Enums; +using FurnitureAssemblyDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int FurnitureId { get; set; } + [DisplayName("Изделие")] + public string FurnitureName { 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; } + } +} -- 2.25.1 From 43b22a7d6c4649700af1f5639c311bf35928fbba Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 29 Jan 2023 18:09:59 +0400 Subject: [PATCH 03/16] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B5=D0=BA=D1=82=20?= =?UTF-8?q?=D1=81=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B5=D0=B9=20=D0=B1=D0=B8=D0=B7=D0=BD=D0=B5=D1=81-=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComponentLogic.cs | 113 +++++++++++++++++ .../FurnitureAssemblyBusinessLogic.csproj | 19 +++ .../FurnitureLogic.cs | 115 ++++++++++++++++++ .../OrderLogic.cs | 108 ++++++++++++++++ 4 files changed, 355 insertions(+) create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/ComponentLogic.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureLogic.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ComponentLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..b6a8da5 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ComponentLogic.cs @@ -0,0 +1,113 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.StoragesContracts; +using FurnitureAssemblyContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; + +namespace FurnitureAssemblyBusinessLogic +{ + 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/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj new file mode 100644 index 0000000..0a4e5c8 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureLogic.cs new file mode 100644 index 0000000..0326d00 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureLogic.cs @@ -0,0 +1,115 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.StoragesContracts; +using FurnitureAssemblyContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyBusinessLogic +{ + public class FurnitureLogic : IFurnitureLogic + { + private readonly ILogger _logger; + private readonly IFurnitureStorage _furnitureStorage; + public FurnitureLogic(ILogger logger, IFurnitureStorage furnitureStorage) + { + _logger = logger; + _furnitureStorage = furnitureStorage; + } + public bool Create(FurnitureBindingModel model) + { + CheckModel(model); + if (_furnitureStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Delete(FurnitureBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_furnitureStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public FurnitureViewModel? ReadElement(FurnitureSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. FurnitureName:{FurnitureName}. Id:{ Id}", model.FurnitureName, model.Id); + var element = _furnitureStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + + public List? ReadList(FurnitureSearchModel? model) + { + _logger.LogInformation("ReadList. FurnitureName:{FurnitureName}. Id:{ Id}", model?.FurnitureName, model?.Id); + var list = model == null ? _furnitureStorage.GetFullList() : _furnitureStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public bool Update(FurnitureBindingModel model) + { + CheckModel(model); + if (_furnitureStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(FurnitureBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.FurnitureName)) + { + throw new ArgumentNullException("Нет названия изделия", + nameof(model.FurnitureName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Furniture. FurnitureName:{FurnitureName}. Price:{ Price}. Id: { Id}", model.FurnitureName, model.Price, model.Id); + var element = _furnitureStorage.GetElement(new FurnitureSearchModel { FurnitureName = model.FurnitureName }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Изделие с таким названием уже есть"); + } + } + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..3396e12 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs @@ -0,0 +1,108 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.StoragesContracts; +using FurnitureAssemblyContracts.ViewModels; +using FurnitureAssemblyDataModels.Enums; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyBusinessLogic +{ + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + model.Status = OrderStatus.Принят; + return true; + } + + public bool DeliveryOrder(OrderBindingModel model) + { + if (model.Status.Equals(OrderStatus.Готов)) + { + model.Status = OrderStatus.Выдан; + model.DateImplement = DateTime.Now; + return true; + } + return false; + } + + public bool FinishOrder(OrderBindingModel model) + { + if (model.Status.Equals(OrderStatus.Выполняется)) + { + model.Status = OrderStatus.Готов; + return true; + } + return false; + } + + 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 TakeOrderInWork(OrderBindingModel model) + { + if (model.Status.Equals(OrderStatus.Принят)) + { + model.Status = OrderStatus.Выполняется; + return true; + } + return false; + } + + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.FurnitureId <= 0) + { + throw new ArgumentNullException("Идентификатор изделия должен быть больше 0", nameof(model.FurnitureId)); + } + 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. FurnitureId:{FurnitureId}. Count:{ Count}. Sum:{ Sum}. OrderStatus: {OrderStatus} DateCreate: {DateCreate}. Id: { Id}", model.FurnitureId, model.Count, model.Sum, model.Status, model.DateCreate, model.Id); + } + } +} -- 2.25.1 From 9c4b3ea23d05564060842c13e73c77d8fee8a0b6 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 29 Jan 2023 18:10:27 +0400 Subject: [PATCH 04/16] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B5=D0=BA=D1=82=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5?= =?UTF-8?q?=D0=B9=D1=81=D0=BE=D0=B2=20=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataListSingleton.cs | 32 +++++ .../FurnitureAssemblyListImplement.csproj | 14 +++ .../Implements/ComponentStorage.cs | 110 +++++++++++++++++ .../Implements/FurnitureStorage.cs | 114 ++++++++++++++++++ .../Implements/OrderStorage.cs | 108 +++++++++++++++++ .../Models/Component.cs | 49 ++++++++ .../Models/Furniture.cs | 56 +++++++++ .../Models/Order.cs | 75 ++++++++++++ 8 files changed, 558 insertions(+) create mode 100644 FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj create mode 100644 FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ComponentStorage.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyListImplement/Implements/FurnitureStorage.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyListImplement/Models/Component.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyListImplement/Models/Furniture.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs new file mode 100644 index 0000000..d3d6d9d --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs @@ -0,0 +1,32 @@ +using FurnitureAssemblyListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Furnitures { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Furnitures = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj b/FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj new file mode 100644 index 0000000..c0fa55b --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ComponentStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ComponentStorage.cs new file mode 100644 index 0000000..6becfba --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ComponentStorage.cs @@ -0,0 +1,110 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.StoragesContracts; +using FurnitureAssemblyContracts.ViewModels; +using FurnitureAssemblyListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyListImplement.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/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/FurnitureStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/FurnitureStorage.cs new file mode 100644 index 0000000..d2cd6fc --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/FurnitureStorage.cs @@ -0,0 +1,114 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.StoragesContracts; +using FurnitureAssemblyContracts.ViewModels; +using FurnitureAssemblyListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyListImplement.Implements +{ + public class FurnitureStorage : IFurnitureStorage + { + private readonly DataListSingleton _source; + public FurnitureStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public FurnitureViewModel? Delete(FurnitureBindingModel model) + { + for (int i = 0; i < _source.Furnitures.Count; ++i) + { + if (_source.Furnitures[i].Id == model.Id) + { + var element = _source.Furnitures[i]; + _source.Furnitures.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + + public FurnitureViewModel? GetElement(FurnitureSearchModel model) + { + if (string.IsNullOrEmpty(model.FurnitureName) && !model.Id.HasValue) + { + return null; + } + + foreach (var furniture in _source.Furnitures) + { + if ((!string.IsNullOrEmpty(model.FurnitureName) && + furniture.FurnitureName == model.FurnitureName) || + (model.Id.HasValue && furniture.Id == model.Id)) + { + return furniture.GetViewModel; + } + } + return null; + } + + public List GetFilteredList(FurnitureSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.FurnitureName)) + { + return result; + } + foreach (var furniture in _source.Furnitures) + { + if (furniture.FurnitureName.Contains(model.FurnitureName)) + { + result.Add(furniture.GetViewModel); + } + } + return result; + } + + public List GetFullList() + { + var result = new List(); + foreach (var furniture in _source.Furnitures) + { + result.Add(furniture.GetViewModel); + } + return result; + } + + public FurnitureViewModel? Insert(FurnitureBindingModel model) + { + model.Id = 1; + foreach (var furniture in _source.Furnitures) + { + if (model.Id <= furniture.Id) + { + model.Id = furniture.Id + 1; + } + } + var newFurniture = Furniture.Create(model); + if (newFurniture == null) + { + return null; + } + _source.Furnitures.Add(newFurniture); + return newFurniture.GetViewModel; + } + + public FurnitureViewModel? Update(FurnitureBindingModel model) + { + foreach (var furniture in _source.Furnitures) + { + if (furniture.Id == model.Id) + { + furniture.Update(model); + return furniture.GetViewModel; + } + } + return null; + } + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..eeb359d --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs @@ -0,0 +1,108 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyContracts.StoragesContracts; +using FurnitureAssemblyContracts.ViewModels; +using FurnitureAssemblyListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyListImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataListSingleton _source; + public OrderStorage() + { + _source = DataListSingleton.GetInstance(); + } + 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 element.GetViewModel; + } + } + return null; + } + + 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 order.GetViewModel; + } + } + return null; + } + + public List GetFilteredList(OrderSearchModel model) + { + var result = new List(); + + foreach (var order in _source.Orders) + { + if (order.Id.Equals(model.Id)) + { + result.Add(order.GetViewModel); + } + } + return result; + } + + public List GetFullList() + { + var result = new List(); + foreach (var order in _source.Orders) + { + result.Add(order.GetViewModel); + } + return result; + } + + 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 newOrder.GetViewModel; + } + + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + order.Update(model); + return order.GetViewModel; + } + } + return null; + } + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Component.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Component.cs new file mode 100644 index 0000000..3c70f80 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Component.cs @@ -0,0 +1,49 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.ViewModels; +using FurnitureAssemblyDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyListImplement.Models +{ + public class Component : IComponentModel + { + public string ComponentName { get; private set; } = string.Empty; + + public double Cost { get; set; } + + public int Id { get; private 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/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Furniture.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Furniture.cs new file mode 100644 index 0000000..9202cb4 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Furniture.cs @@ -0,0 +1,56 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.ViewModels; +using FurnitureAssemblyDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyListImplement.Models +{ + public class Furniture : IFurnitureModel + { + public string FurnitureName { get; private set; } = string.Empty; + + public double Price { get; private set; } + + public Dictionary FurnitureComponents { get; private set; } = new Dictionary(); + + public int Id { get; private set; } + + public static Furniture? Create(FurnitureBindingModel? model) + { + if (model == null) + { + return null; + } + return new Furniture() { + Id = model.Id, + FurnitureName = model.FurnitureName, + Price = model.Price, + FurnitureComponents = model.FurnitureComponents + }; + } + + public void Update(FurnitureBindingModel? model) + { + if (model == null) + { + return; + } + FurnitureName = model.FurnitureName; + Price = model.Price; + FurnitureComponents = model.FurnitureComponents; + } + public FurnitureViewModel GetViewModel => new() + { + Id = Id, + FurnitureName = FurnitureName, + Price = Price, + FurnitureComponents = FurnitureComponents + }; + + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs new file mode 100644 index 0000000..eac8c7f --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs @@ -0,0 +1,75 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.ViewModels; +using FurnitureAssemblyDataModels.Enums; +using FurnitureAssemblyDataModels.Models; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyListImplement.Models +{ + public class Order : IOrderModel + { + public int FurnitureId { get; private set; } + + public int Count { get; private set; } + + public double Sum { get; private set; } + + public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; + + public DateTime DateCreate { get; private set; } = DateTime.Now; + + public DateTime? DateImplement { get; private set; } + + public int Id { get; private set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + FurnitureId = model.FurnitureId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement + }; + } + + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + FurnitureId = model.FurnitureId; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + DateImplement = model.DateImplement; + } + + public OrderViewModel GetViewModel => new() + { + Id = Id, + FurnitureId = FurnitureId, + /*FurnitureName = Furn*/ + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement + }; + } +} -- 2.25.1 From 7e2d3985cc15e19bdf77cf0697c9a1e875efe583 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Mon, 30 Jan 2023 00:32:36 +0400 Subject: [PATCH 05/16] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B5=D0=BA=D1=82=20?= =?UTF-8?q?=D1=81=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FurnitureAssembly/FurnitureAssembly.sln | 26 +- .../FormComponent.Designer.cs | 119 +++++++++ .../FurnitureAssembly/FormComponent.cs | 99 ++++++++ .../FurnitureAssembly/FormComponent.resx | 60 +++++ .../FormComponents.Designer.cs | 114 +++++++++ .../FurnitureAssembly/FormComponents.cs | 121 +++++++++ .../FurnitureAssembly/FormComponents.resx | 60 +++++ .../FormCreateOrder.Designer.cs | 142 +++++++++++ .../FurnitureAssembly/FormCreateOrder.cs | 134 ++++++++++ .../FurnitureAssembly/FormCreateOrder.resx | 63 +++++ .../FormFurniture.Designer.cs | 219 +++++++++++++++++ .../FurnitureAssembly/FormFurniture.cs | 230 ++++++++++++++++++ .../FurnitureAssembly/FormFurniture.resx | 69 ++++++ .../FormFurnitureComponent.Designer.cs | 119 +++++++++ .../FormFurnitureComponent.cs | 94 +++++++ .../FormFurnitureComponent.resx | 60 +++++ .../FormFurnitures.Designer.cs | 124 ++++++++++ .../FurnitureAssembly/FormFurnitures.cs | 122 ++++++++++ .../FurnitureAssembly/FormFurnitures.resx | 60 +++++ .../FurnitureAssembly/FormMain.Designer.cs | 176 ++++++++++++++ .../FurnitureAssembly/FormMain.cs | 142 +++++++++++ .../FurnitureAssembly/FormMain.resx | 73 ++++++ .../FurnitureAssembly.csproj | 12 + .../FurnitureAssembly/Program.cs | 38 ++- .../FurnitureAssemblyBusinessLogic.csproj | 1 + .../FurnitureAssemblyContracts.csproj | 1 + .../FurnitureAssemblyDataModels.csproj | 1 + .../FurnitureAssemblyListImplement.csproj | 4 + 28 files changed, 2481 insertions(+), 2 deletions(-) create mode 100644 FurnitureAssembly/FurnitureAssembly/FormComponent.Designer.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormComponent.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormComponent.resx create mode 100644 FurnitureAssembly/FurnitureAssembly/FormComponents.Designer.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormComponents.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormComponents.resx create mode 100644 FurnitureAssembly/FurnitureAssembly/FormCreateOrder.Designer.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormCreateOrder.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormCreateOrder.resx create mode 100644 FurnitureAssembly/FurnitureAssembly/FormFurniture.Designer.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormFurniture.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormFurniture.resx create mode 100644 FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.Designer.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.resx create mode 100644 FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormFurnitures.resx create mode 100644 FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormMain.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormMain.resx diff --git a/FurnitureAssembly/FurnitureAssembly.sln b/FurnitureAssembly/FurnitureAssembly.sln index 0220e7c..da3aa5d 100644 --- a/FurnitureAssembly/FurnitureAssembly.sln +++ b/FurnitureAssembly/FurnitureAssembly.sln @@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32901.215 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssembly", "FurnitureAssembly\FurnitureAssembly.csproj", "{356DBB82-0345-4F3C-BD31-2B05E6DA369A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssembly", "FurnitureAssembly\FurnitureAssembly.csproj", "{356DBB82-0345-4F3C-BD31-2B05E6DA369A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyDataModels", "FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj", "{179446B0-AC44-43BD-88EE-C3DF7CC4061E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyContracts", "FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj", "{6ACF0A8B-8F7C-4511-ABB1-7E688F1F3E8A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyBusinessLogic", "FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj", "{B51952FD-5EB4-4A80-8598-7B1EC39CD34C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyListImplement", "FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj", "{6662252C-A676-4376-AA01-0ACC6AE5B217}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +23,22 @@ Global {356DBB82-0345-4F3C-BD31-2B05E6DA369A}.Debug|Any CPU.Build.0 = Debug|Any CPU {356DBB82-0345-4F3C-BD31-2B05E6DA369A}.Release|Any CPU.ActiveCfg = Release|Any CPU {356DBB82-0345-4F3C-BD31-2B05E6DA369A}.Release|Any CPU.Build.0 = Release|Any CPU + {179446B0-AC44-43BD-88EE-C3DF7CC4061E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {179446B0-AC44-43BD-88EE-C3DF7CC4061E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {179446B0-AC44-43BD-88EE-C3DF7CC4061E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {179446B0-AC44-43BD-88EE-C3DF7CC4061E}.Release|Any CPU.Build.0 = Release|Any CPU + {6ACF0A8B-8F7C-4511-ABB1-7E688F1F3E8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6ACF0A8B-8F7C-4511-ABB1-7E688F1F3E8A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6ACF0A8B-8F7C-4511-ABB1-7E688F1F3E8A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6ACF0A8B-8F7C-4511-ABB1-7E688F1F3E8A}.Release|Any CPU.Build.0 = Release|Any CPU + {B51952FD-5EB4-4A80-8598-7B1EC39CD34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B51952FD-5EB4-4A80-8598-7B1EC39CD34C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B51952FD-5EB4-4A80-8598-7B1EC39CD34C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B51952FD-5EB4-4A80-8598-7B1EC39CD34C}.Release|Any CPU.Build.0 = Release|Any CPU + {6662252C-A676-4376-AA01-0ACC6AE5B217}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6662252C-A676-4376-AA01-0ACC6AE5B217}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6662252C-A676-4376-AA01-0ACC6AE5B217}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6662252C-A676-4376-AA01-0ACC6AE5B217}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FurnitureAssembly/FurnitureAssembly/FormComponent.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormComponent.Designer.cs new file mode 100644 index 0000000..802d0af --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormComponent.Designer.cs @@ -0,0 +1,119 @@ +namespace FurnitureAssembly +{ + 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.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxCost = new System.Windows.Forms.TextBox(); + this.labelName = new System.Windows.Forms.Label(); + this.labelCost = new System.Windows.Forms.Label(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(138, 22); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(281, 23); + this.textBoxName.TabIndex = 0; + // + // textBoxCost + // + this.textBoxCost.Location = new System.Drawing.Point(138, 62); + this.textBoxCost.Name = "textBoxCost"; + this.textBoxCost.Size = new System.Drawing.Size(145, 23); + this.textBoxCost.TabIndex = 1; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(35, 27); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(59, 15); + this.labelName.TabIndex = 2; + this.labelName.Text = "Название"; + // + // labelCost + // + this.labelCost.AutoSize = true; + this.labelCost.Location = new System.Drawing.Point(35, 65); + this.labelCost.Name = "labelCost"; + this.labelCost.Size = new System.Drawing.Size(35, 15); + this.labelCost.TabIndex = 3; + this.labelCost.Text = "Цена"; + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(240, 93); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(75, 23); + 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(344, 93); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(75, 23); + 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(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(459, 130); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.labelCost); + this.Controls.Add(this.labelName); + this.Controls.Add(this.textBoxCost); + this.Controls.Add(this.textBoxName); + this.Name = "FormComponent"; + this.Text = "Компонент"; + this.Load += new System.EventHandler(this.FormComponent_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxName; + private TextBox textBoxCost; + private Label labelName; + private Label labelCost; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormComponent.cs b/FurnitureAssembly/FurnitureAssembly/FormComponent.cs new file mode 100644 index 0000000..4a9cadd --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormComponent.cs @@ -0,0 +1,99 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace FurnitureAssembly +{ + 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; + textBoxCost.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(textBoxCost.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(); + } + } +} diff --git a/FurnitureAssembly/FurnitureAssembly/FormComponent.resx b/FurnitureAssembly/FurnitureAssembly/FormComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/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/FurnitureAssembly/FurnitureAssembly/FormComponents.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormComponents.Designer.cs new file mode 100644 index 0000000..7e0de59 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormComponents.Designer.cs @@ -0,0 +1,114 @@ +namespace FurnitureAssembly +{ + 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.dataGridView = new System.Windows.Forms.DataGridView(); + 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(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(-2, 0); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(559, 453); + this.dataGridView.TabIndex = 0; + // + // ButtonAdd + // + this.ButtonAdd.Location = new System.Drawing.Point(586, 59); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(105, 29); + this.ButtonAdd.TabIndex = 1; + this.ButtonAdd.Text = "Добавить"; + this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // ButtonUpd + // + this.ButtonUpd.Location = new System.Drawing.Point(586, 115); + this.ButtonUpd.Name = "ButtonUpd"; + this.ButtonUpd.Size = new System.Drawing.Size(105, 29); + this.ButtonUpd.TabIndex = 2; + this.ButtonUpd.Text = "Изменить"; + this.ButtonUpd.UseVisualStyleBackColor = true; + this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // ButtonDel + // + this.ButtonDel.Location = new System.Drawing.Point(586, 172); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(105, 29); + this.ButtonDel.TabIndex = 3; + this.ButtonDel.Text = "Удалить"; + this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // ButtonRef + // + this.ButtonRef.Location = new System.Drawing.Point(586, 230); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(105, 29); + this.ButtonRef.TabIndex = 4; + this.ButtonRef.Text = "Обновить"; + this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // FormComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(718, 450); + this.Controls.Add(this.ButtonRef); + this.Controls.Add(this.ButtonDel); + this.Controls.Add(this.ButtonUpd); + this.Controls.Add(this.ButtonAdd); + this.Controls.Add(this.dataGridView); + this.Name = "FormComponents"; + this.Text = "FormComponents"; + this.Load += new System.EventHandler(this.FormComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button ButtonAdd; + private Button ButtonUpd; + private Button ButtonDel; + private Button ButtonRef; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormComponents.cs b/FurnitureAssembly/FurnitureAssembly/FormComponents.cs new file mode 100644 index 0000000..ea435f5 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormComponents.cs @@ -0,0 +1,121 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace FurnitureAssembly +{ + 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/FurnitureAssembly/FurnitureAssembly/FormComponents.resx b/FurnitureAssembly/FurnitureAssembly/FormComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/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/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..726c504 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.Designer.cs @@ -0,0 +1,142 @@ +namespace FurnitureAssembly +{ + 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.labelFurniture = new System.Windows.Forms.Label(); + this.labelCount = new System.Windows.Forms.Label(); + this.labelSum = new System.Windows.Forms.Label(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.comboBoxProduct = new System.Windows.Forms.ComboBox(); + this.textBoxSum = new System.Windows.Forms.TextBox(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelFurniture + // + this.labelFurniture.AutoSize = true; + this.labelFurniture.Location = new System.Drawing.Point(29, 23); + this.labelFurniture.Name = "labelFurniture"; + this.labelFurniture.Size = new System.Drawing.Size(56, 15); + this.labelFurniture.TabIndex = 0; + this.labelFurniture.Text = "Изделие:"; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(29, 50); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(75, 15); + this.labelCount.TabIndex = 1; + this.labelCount.Text = "Количество:"; + // + // labelSum + // + this.labelSum.AutoSize = true; + this.labelSum.Location = new System.Drawing.Point(29, 77); + this.labelSum.Name = "labelSum"; + this.labelSum.Size = new System.Drawing.Size(45, 15); + this.labelSum.TabIndex = 2; + this.labelSum.Text = "Сумма"; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(125, 44); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(297, 23); + this.textBoxCount.TabIndex = 3; + // + // comboBoxProduct + // + this.comboBoxProduct.FormattingEnabled = true; + this.comboBoxProduct.Location = new System.Drawing.Point(125, 15); + this.comboBoxProduct.Name = "comboBoxProduct"; + this.comboBoxProduct.Size = new System.Drawing.Size(297, 23); + this.comboBoxProduct.TabIndex = 4; + // + // textBoxSum + // + this.textBoxSum.Location = new System.Drawing.Point(125, 77); + this.textBoxSum.Name = "textBoxSum"; + this.textBoxSum.Size = new System.Drawing.Size(297, 23); + this.textBoxSum.TabIndex = 5; + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(188, 104); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(105, 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(317, 104); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(105, 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(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(453, 137); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.textBoxSum); + this.Controls.Add(this.comboBoxProduct); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.labelSum); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.labelFurniture); + this.Name = "FormCreateOrder"; + this.Text = "FormCreateOrder"; + this.Load += new System.EventHandler(this.FormCreateOrder_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelFurniture; + private Label labelCount; + private Label labelSum; + private TextBox textBoxCount; + private ComboBox comboBoxProduct; + private TextBox textBoxSum; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.cs b/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.cs new file mode 100644 index 0000000..027cfbc --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.cs @@ -0,0 +1,134 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyContracts.SearchModels; +using Microsoft.Extensions.Logging; +using Microsoft.VisualBasic.Logging; +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace FurnitureAssembly +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly IFurnitureLogic _logicF; + private readonly IOrderLogic _logicO; + public FormCreateOrder(ILogger logger, IFurnitureLogic logicF, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicF = logicF; + _logicO = logicO; + } + + 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 + { + FurnitureId = Convert.ToInt32(comboBoxProduct.SelectedValue), + Count = Convert.ToInt32(textBoxCount.Text), + Sum = Convert.ToDouble(textBoxSum.Text) + }); + if (!operationResult) + { + throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка изделий для заказа"); + // прописать логику + LoadData(); + } + private void LoadData() + { + var _list = _logicF.ReadList(null); + if (_list != null) + { + comboBoxProduct.DisplayMember = "FurnitureName"; + comboBoxProduct.ValueMember = "Id"; + comboBoxProduct.DataSource = _list; + comboBoxProduct.SelectedItem = null; + } + } + + + private void CalcSum() + { + if (comboBoxProduct.SelectedValue != null && + !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxProduct.SelectedValue); + var product = _logicF.ReadElement(new FurnitureSearchModel + { + 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 ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.resx b/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.resx new file mode 100644 index 0000000..c3d80ca --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.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 + + + True + + \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurniture.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormFurniture.Designer.cs new file mode 100644 index 0000000..f1e7240 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormFurniture.Designer.cs @@ -0,0 +1,219 @@ +namespace FurnitureAssembly +{ + partial class FormFurniture + { + /// + /// 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.dataGridViewFurn = new System.Windows.Forms.DataGridView(); + this.FurnitureId = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.FurnitureName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + 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.ButtonCancel = new System.Windows.Forms.Button(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.groupBoxComponents.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewFurn)).BeginInit(); + this.SuspendLayout(); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(45, 39); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(62, 15); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название:"; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(45, 76); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(70, 15); + this.labelPrice.TabIndex = 1; + this.labelPrice.Text = "Стоимость:"; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(160, 36); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(233, 23); + this.textBoxName.TabIndex = 2; + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(160, 73); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(151, 23); + this.textBoxPrice.TabIndex = 3; + // + // groupBoxComponents + // + this.groupBoxComponents.Controls.Add(this.dataGridViewFurn); + 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.Location = new System.Drawing.Point(12, 122); + this.groupBoxComponents.Name = "groupBoxComponents"; + this.groupBoxComponents.Size = new System.Drawing.Size(764, 300); + this.groupBoxComponents.TabIndex = 4; + this.groupBoxComponents.TabStop = false; + this.groupBoxComponents.Text = "Компоненты"; + // + // dataGridViewFurn + // + this.dataGridViewFurn.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewFurn.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.FurnitureId, + this.FurnitureName, + this.Count}); + this.dataGridViewFurn.Location = new System.Drawing.Point(0, 22); + this.dataGridViewFurn.Name = "dataGridViewFurn"; + this.dataGridViewFurn.RowTemplate.Height = 25; + this.dataGridViewFurn.Size = new System.Drawing.Size(628, 278); + this.dataGridViewFurn.TabIndex = 9; + // + // FurnitureId + // + this.FurnitureId.HeaderText = "Id"; + this.FurnitureId.Name = "FurnitureId"; + this.FurnitureId.Visible = false; + // + // FurnitureName + // + this.FurnitureName.HeaderText = "Название"; + this.FurnitureName.Name = "FurnitureName"; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.Name = "Count"; + // + // ButtonRef + // + this.ButtonRef.Location = new System.Drawing.Point(643, 219); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(105, 29); + this.ButtonRef.TabIndex = 8; + this.ButtonRef.Text = "Обновить"; + this.ButtonRef.UseVisualStyleBackColor = true; + // + // ButtonDel + // + this.ButtonDel.Location = new System.Drawing.Point(643, 161); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(105, 29); + this.ButtonDel.TabIndex = 7; + this.ButtonDel.Text = "Удалить"; + this.ButtonDel.UseVisualStyleBackColor = true; + // + // ButtonUpd + // + this.ButtonUpd.Location = new System.Drawing.Point(643, 104); + this.ButtonUpd.Name = "ButtonUpd"; + this.ButtonUpd.Size = new System.Drawing.Size(105, 29); + this.ButtonUpd.TabIndex = 6; + this.ButtonUpd.Text = "Изменить"; + this.ButtonUpd.UseVisualStyleBackColor = true; + // + // ButtonAdd + // + this.ButtonAdd.Location = new System.Drawing.Point(643, 48); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(105, 29); + this.ButtonAdd.TabIndex = 5; + this.ButtonAdd.Text = "Добавить"; + this.ButtonAdd.UseVisualStyleBackColor = true; + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(669, 440); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(105, 29); + this.ButtonCancel.TabIndex = 9; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(535, 440); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(105, 29); + this.ButtonSave.TabIndex = 8; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + // + // FormFurniture + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(799, 475); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + 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 = "FormFurniture"; + this.Text = "Изделие"; + this.Load += new System.EventHandler(this.FormFurniture_Load); + this.groupBoxComponents.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewFurn)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelName; + private Label labelPrice; + private TextBox textBoxName; + private TextBox textBoxPrice; + private GroupBox groupBoxComponents; + private Button ButtonCancel; + private Button ButtonSave; + private Button ButtonRef; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonAdd; + private DataGridView dataGridViewFurn; + private DataGridViewTextBoxColumn FurnitureId; + private DataGridViewTextBoxColumn FurnitureName; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurniture.cs b/FurnitureAssembly/FurnitureAssembly/FormFurniture.cs new file mode 100644 index 0000000..a089a15 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormFurniture.cs @@ -0,0 +1,230 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyDataModels.Models; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace FurnitureAssembly +{ + public partial class FormFurniture : Form + { + private readonly ILogger _logger; + private readonly IFurnitureLogic _logic; + private int? _id; + private Dictionary _productComponents; + public int Id { set { _id = value; } } + + public FormFurniture(ILogger logger, IFurnitureLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _productComponents = new Dictionary(); + } + + private void FormFurniture_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка изделия"); + try + { + var view = _logic.ReadElement(new FurnitureSearchModel + { + Id = + _id.Value + }); + if (view != null) + { + textBoxName.Text = view.FurnitureName; + textBoxPrice.Text = view.Price.ToString(); + _productComponents = view.FurnitureComponents ?? 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) + { + dataGridViewFurn.Rows.Clear(); + foreach (var pc in _productComponents) + { + dataGridViewFurn.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(FormFurnitureComponent)); + if (service is FormFurnitureComponent 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 (dataGridViewFurn.SelectedRows.Count == 1) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormFurnitureComponent)); + if (service is FormFurnitureComponent form) + { + int id = + Convert.ToInt32(dataGridViewFurn.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 (dataGridViewFurn.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridViewFurn.SelectedRows[0].Cells[1].Value); + _productComponents?.Remove(Convert.ToInt32(dataGridViewFurn.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 FurnitureBindingModel + { + Id = _id ?? 0, + FurnitureName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + FurnitureComponents = _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/FurnitureAssembly/FurnitureAssembly/FormFurniture.resx b/FurnitureAssembly/FurnitureAssembly/FormFurniture.resx new file mode 100644 index 0000000..565a3a5 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormFurniture.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/FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.Designer.cs new file mode 100644 index 0000000..9a36165 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.Designer.cs @@ -0,0 +1,119 @@ +namespace FurnitureAssembly +{ + partial class FormFurnitureComponent + { + /// + /// 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.ButtonCancel = new System.Windows.Forms.Button(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.comboBoxComponent = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(293, 109); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(75, 23); + this.ButtonCancel.TabIndex = 7; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(189, 109); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(75, 23); + this.ButtonSave.TabIndex = 6; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // comboBoxComponent + // + this.comboBoxComponent.FormattingEnabled = true; + this.comboBoxComponent.Location = new System.Drawing.Point(116, 18); + this.comboBoxComponent.Name = "comboBoxComponent"; + this.comboBoxComponent.Size = new System.Drawing.Size(252, 23); + this.comboBoxComponent.TabIndex = 8; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(30, 21); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(72, 15); + this.label1.TabIndex = 9; + this.label1.Text = "Компонент:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(30, 62); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(75, 15); + this.label2.TabIndex = 10; + this.label2.Text = "Количество:"; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(116, 59); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(252, 23); + this.textBoxCount.TabIndex = 11; + // + // FormFurnitureComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(407, 146); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.comboBoxComponent); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Name = "FormFurnitureComponent"; + this.Text = "Компонент изделия"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button ButtonCancel; + private Button ButtonSave; + private ComboBox comboBoxComponent; + private Label label1; + private Label label2; + private TextBox textBoxCount; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.cs b/FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.cs new file mode 100644 index 0000000..5ef9cbf --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.cs @@ -0,0 +1,94 @@ +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyContracts.ViewModels; +using FurnitureAssemblyDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace FurnitureAssembly +{ + public partial class FormFurnitureComponent : 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 FormFurnitureComponent(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/FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.resx b/FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitureComponent.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/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs new file mode 100644 index 0000000..a2a775f --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs @@ -0,0 +1,124 @@ +namespace FurnitureAssembly +{ + partial class FormFurnitures + { + /// + /// 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.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.ButtonAdd = new System.Windows.Forms.Button(); + this.ButtonDel = new System.Windows.Forms.Button(); + this.ButtonUpd = new System.Windows.Forms.Button(); + this.ButtonRef = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(-2, 0); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(559, 453); + this.dataGridView.TabIndex = 0; + // + // dataGridView1 + // + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Location = new System.Drawing.Point(-1, 1); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowTemplate.Height = 25; + this.dataGridView1.Size = new System.Drawing.Size(559, 453); + this.dataGridView1.TabIndex = 5; + // + // ButtonAdd + // + this.ButtonAdd.Location = new System.Drawing.Point(583, 52); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(105, 29); + this.ButtonAdd.TabIndex = 6; + this.ButtonAdd.Text = "Добавить"; + this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // ButtonDel + // + this.ButtonDel.Location = new System.Drawing.Point(583, 106); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(105, 29); + this.ButtonDel.TabIndex = 7; + this.ButtonDel.Text = "Удалить"; + this.ButtonDel.UseVisualStyleBackColor = true; + // + // ButtonUpd + // + this.ButtonUpd.Location = new System.Drawing.Point(583, 161); + this.ButtonUpd.Name = "ButtonUpd"; + this.ButtonUpd.Size = new System.Drawing.Size(105, 29); + this.ButtonUpd.TabIndex = 8; + this.ButtonUpd.Text = "Изменить"; + this.ButtonUpd.UseVisualStyleBackColor = true; + // + // ButtonRef + // + this.ButtonRef.Location = new System.Drawing.Point(583, 216); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(105, 29); + this.ButtonRef.TabIndex = 9; + this.ButtonRef.Text = "Обновить"; + this.ButtonRef.UseVisualStyleBackColor = true; + // + // FormFurnitures + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(712, 453); + this.Controls.Add(this.ButtonRef); + this.Controls.Add(this.ButtonUpd); + this.Controls.Add(this.ButtonDel); + this.Controls.Add(this.ButtonAdd); + this.Controls.Add(this.dataGridView1); + this.Name = "FormFurnitures"; + this.Text = "FormFurnitures"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + + private DataGridView dataGridView1; + private Button ButtonAdd; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonRef; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs new file mode 100644 index 0000000..29ea07d --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs @@ -0,0 +1,122 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace FurnitureAssembly +{ + public partial class FormFurnitures : Form + { + private readonly ILogger _logger; + private readonly IFurnitureLogic _logic; + public FormFurnitures(ILogger logger, IFurnitureLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormFurnitures_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["FurnitureName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["FurnitureCount"].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(FormFurniture)); + if (service is FormFurniture 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(FormFurniture)); + if (service is FormFurniture 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 FurnitureBindingModel + { + 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/FurnitureAssembly/FurnitureAssembly/FormFurnitures.resx b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.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/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs new file mode 100644 index 0000000..c3560c5 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs @@ -0,0 +1,176 @@ +namespace FurnitureAssembly +{ + 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); + 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.toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton(); + this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.toolStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(2, 25); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(859, 425); + this.dataGridView.TabIndex = 0; + // + // ButtonCreateOrder + // + this.ButtonCreateOrder.Location = new System.Drawing.Point(902, 72); + this.ButtonCreateOrder.Name = "ButtonCreateOrder"; + this.ButtonCreateOrder.Size = new System.Drawing.Size(150, 25); + 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(902, 122); + this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork"; + this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(150, 25); + 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(902, 173); + this.ButtonOrderReady.Name = "ButtonOrderReady"; + this.ButtonOrderReady.Size = new System.Drawing.Size(150, 25); + 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(902, 223); + this.ButtonIssuedOrder.Name = "ButtonIssuedOrder"; + this.ButtonIssuedOrder.Size = new System.Drawing.Size(150, 25); + 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(902, 273); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(150, 25); + this.ButtonRef.TabIndex = 5; + this.ButtonRef.Text = "Обновить список"; + this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // toolStrip1 + // + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripDropDownButton1}); + this.toolStrip1.Location = new System.Drawing.Point(0, 0); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.Size = new System.Drawing.Size(1065, 25); + this.toolStrip1.TabIndex = 6; + this.toolStrip1.Text = "toolStrip1"; + // + // toolStripDropDownButton1 + // + this.toolStripDropDownButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripDropDownButton1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.компонентыToolStripMenuItem, + this.изделияToolStripMenuItem}); + this.toolStripDropDownButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripDropDownButton1.Image"))); + this.toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripDropDownButton1.Name = "toolStripDropDownButton1"; + this.toolStripDropDownButton1.Size = new System.Drawing.Size(29, 22); + this.toolStripDropDownButton1.Text = "Справочники"; + // + // компонентыToolStripMenuItem + // + this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; + this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.компонентыToolStripMenuItem.Text = "Компоненты"; + this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click); + // + // изделияToolStripMenuItem + // + this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; + this.изделияToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.изделияToolStripMenuItem.Text = "Изделия"; + this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click); + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1065, 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 = "Магазин мебели"; + ((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 toolStripDropDownButton1; + private ToolStripMenuItem компонентыToolStripMenuItem; + private ToolStripMenuItem изделияToolStripMenuItem; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.cs new file mode 100644 index 0000000..6027d16 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.cs @@ -0,0 +1,142 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace FurnitureAssembly +{ + 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() + { + _logger.LogInformation("Загрузка заказов"); + // прописать логику + } + private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + + private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e) + { + // прописать логику + } + + 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 }); + 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 }); + 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 }); + 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/FurnitureAssembly/FurnitureAssembly/FormMain.resx b/FurnitureAssembly/FurnitureAssembly/FormMain.resx new file mode 100644 index 0000000..5fdc808 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.resx @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb + J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj + CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN + AAAAAElFTkSuQmCC + + + \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj b/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj index b57c89e..a30f8a8 100644 --- a/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj +++ b/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj @@ -8,4 +8,16 @@ enable + + + + + + + + + + + + \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/Program.cs b/FurnitureAssembly/FurnitureAssembly/Program.cs index 22f2995..2cc7ecb 100644 --- a/FurnitureAssembly/FurnitureAssembly/Program.cs +++ b/FurnitureAssembly/FurnitureAssembly/Program.cs @@ -1,7 +1,18 @@ +using FurnitureAssemblyBusinessLogic; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyContracts.StoragesContracts; +using FurnitureAssemblyListImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; +using System.Drawing; + namespace FurnitureAssembly { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// @@ -11,7 +22,32 @@ namespace FurnitureAssembly // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + 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/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj index 0a4e5c8..544ed82 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj @@ -10,6 +10,7 @@ + diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj b/FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj index 57b3533..f9f8ab4 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj +++ b/FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj @@ -10,6 +10,7 @@ + diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj b/FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj index 17fe669..d730273 100644 --- a/FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj +++ b/FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj @@ -10,6 +10,7 @@ + diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj b/FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj index c0fa55b..5081f9c 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj @@ -6,6 +6,10 @@ enable + + + + -- 2.25.1 From 7bb2c5609764be52c7a64e9d39e33c4d8c220709 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Wed, 1 Feb 2023 11:25:29 +0400 Subject: [PATCH 06/16] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=20OrderLogic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs index 3396e12..f0f4238 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs @@ -18,7 +18,7 @@ namespace FurnitureAssemblyBusinessLogic private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; - public OrderLogic(ILogger logger, IOrderStorage orderStorage) + public OrderLogic(ILogger logger, IOrderStorage orderStorage) { _logger = logger; _orderStorage = orderStorage; -- 2.25.1 From f2a6fb76277ca24e562d69cac15cba8a4b7eaa04 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Wed, 1 Feb 2023 11:26:04 +0400 Subject: [PATCH 07/16] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormCreateOrder.Designer.cs | 2 ++ .../FormFurniture.Designer.cs | 6 +++++ .../FormFurnitures.Designer.cs | 20 +++------------ .../FurnitureAssembly/FormFurnitures.cs | 4 +-- .../FurnitureAssembly/FormMain.cs | 25 ++++++++++++++++--- 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.Designer.cs index 726c504..dde2a1d 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.Designer.cs @@ -71,6 +71,7 @@ this.textBoxCount.Name = "textBoxCount"; this.textBoxCount.Size = new System.Drawing.Size(297, 23); this.textBoxCount.TabIndex = 3; + this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); // // comboBoxProduct // @@ -79,6 +80,7 @@ this.comboBoxProduct.Name = "comboBoxProduct"; this.comboBoxProduct.Size = new System.Drawing.Size(297, 23); this.comboBoxProduct.TabIndex = 4; + this.comboBoxProduct.SelectedIndexChanged += new System.EventHandler(this.ComboBoxProduct_SelectedIndexChanged); // // textBoxSum // diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurniture.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormFurniture.Designer.cs index f1e7240..b39db36 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormFurniture.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormFurniture.Designer.cs @@ -130,6 +130,7 @@ this.ButtonRef.TabIndex = 8; this.ButtonRef.Text = "Обновить"; this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); // // ButtonDel // @@ -139,6 +140,7 @@ this.ButtonDel.TabIndex = 7; this.ButtonDel.Text = "Удалить"; this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); // // ButtonUpd // @@ -148,6 +150,7 @@ this.ButtonUpd.TabIndex = 6; this.ButtonUpd.Text = "Изменить"; this.ButtonUpd.UseVisualStyleBackColor = true; + this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); // // ButtonAdd // @@ -157,6 +160,7 @@ this.ButtonAdd.TabIndex = 5; this.ButtonAdd.Text = "Добавить"; this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); // // ButtonCancel // @@ -166,6 +170,7 @@ this.ButtonCancel.TabIndex = 9; this.ButtonCancel.Text = "Отмена"; this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // ButtonSave // @@ -175,6 +180,7 @@ this.ButtonSave.TabIndex = 8; this.ButtonSave.Text = "Сохранить"; this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); // // FormFurniture // diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs index a2a775f..7e0bc01 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs @@ -29,32 +29,21 @@ private void InitializeComponent() { this.dataGridView = new System.Windows.Forms.DataGridView(); - this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.ButtonAdd = new System.Windows.Forms.Button(); this.ButtonDel = new System.Windows.Forms.Button(); this.ButtonUpd = new System.Windows.Forms.Button(); this.ButtonRef = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // dataGridView // this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(-2, 0); + this.dataGridView.Location = new System.Drawing.Point(-1, 1); this.dataGridView.Name = "dataGridView"; this.dataGridView.RowTemplate.Height = 25; this.dataGridView.Size = new System.Drawing.Size(559, 453); - this.dataGridView.TabIndex = 0; - // - // dataGridView1 - // - this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView1.Location = new System.Drawing.Point(-1, 1); - this.dataGridView1.Name = "dataGridView1"; - this.dataGridView1.RowTemplate.Height = 25; - this.dataGridView1.Size = new System.Drawing.Size(559, 453); - this.dataGridView1.TabIndex = 5; + this.dataGridView.TabIndex = 5; // // ButtonAdd // @@ -102,23 +91,22 @@ this.Controls.Add(this.ButtonUpd); this.Controls.Add(this.ButtonDel); this.Controls.Add(this.ButtonAdd); - this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.dataGridView); this.Name = "FormFurnitures"; this.Text = "FormFurnitures"; ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); } #endregion - private DataGridView dataGridView; private DataGridView dataGridView1; private Button ButtonAdd; private Button ButtonDel; private Button ButtonUpd; private Button ButtonRef; + private DataGridView dataGridView; } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs index 29ea07d..03d08c5 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs @@ -39,9 +39,7 @@ namespace FurnitureAssembly dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["FurnitureName"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["FurnitureCount"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; + DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка изделий"); } diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.cs index 6027d16..2a7ec63 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.cs @@ -29,8 +29,22 @@ namespace FurnitureAssembly } private void LoadData() { - _logger.LogInformation("Загрузка заказов"); - // прописать логику + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["FurnitureId"].Visible = false; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } } private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) { @@ -44,7 +58,12 @@ namespace FurnitureAssembly private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e) { - // прописать логику + var service = + Program.ServiceProvider?.GetService(typeof(FormFurnitures)); + if (service is FormFurnitures form) + { + form.ShowDialog(); + } } private void ButtonCreateOrder_Click(object sender, EventArgs e) -- 2.25.1 From 9aa95be83534eca347e63c4a7b5e470182b24dbb Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Wed, 1 Feb 2023 12:35:26 +0400 Subject: [PATCH 08/16] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5:=20=D0=BE=D1=82=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D0=B0=20=D0=BF=D0=BE=D0=BB=D0=BD=D0=BE=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FurnitureAssembly/FormCreateOrder.cs | 1 + .../FurnitureAssembly/FormMain.Designer.cs | 47 +++++++++---------- .../FurnitureAssembly/FormMain.cs | 2 +- .../FurnitureAssembly/FormMain.resx | 12 +---- .../BindingModels/OrderBindingModel.cs | 1 + .../Models/Order.cs | 6 ++- 6 files changed, 31 insertions(+), 38 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.cs b/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.cs index 027cfbc..f506bb3 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormCreateOrder.cs @@ -49,6 +49,7 @@ namespace FurnitureAssembly var operationResult = _logicO.CreateOrder(new OrderBindingModel { FurnitureId = Convert.ToInt32(comboBoxProduct.SelectedValue), + FurnitureName = comboBoxProduct.Text, Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs index c3560c5..b5cabf0 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs @@ -28,19 +28,18 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); 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.toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.toolStrip1.SuspendLayout(); + this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // // dataGridView @@ -102,27 +101,24 @@ this.ButtonRef.UseVisualStyleBackColor = true; this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); // - // toolStrip1 + // menuStrip1 // - this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripDropDownButton1}); - this.toolStrip1.Location = new System.Drawing.Point(0, 0); - this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(1065, 25); - this.toolStrip1.TabIndex = 6; - this.toolStrip1.Text = "toolStrip1"; + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.справочникиToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(1065, 24); + this.menuStrip1.TabIndex = 6; + this.menuStrip1.Text = "menuStrip1"; // - // toolStripDropDownButton1 + // справочникиToolStripMenuItem // - this.toolStripDropDownButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripDropDownButton1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.компонентыToolStripMenuItem, this.изделияToolStripMenuItem}); - this.toolStripDropDownButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripDropDownButton1.Image"))); - this.toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripDropDownButton1.Name = "toolStripDropDownButton1"; - this.toolStripDropDownButton1.Size = new System.Drawing.Size(29, 22); - this.toolStripDropDownButton1.Text = "Справочники"; + this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); + this.справочникиToolStripMenuItem.Text = "Справочники"; // // компонентыToolStripMenuItem // @@ -143,18 +139,19 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1065, 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.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; this.Name = "FormMain"; this.Text = "Магазин мебели"; ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.toolStrip1.ResumeLayout(false); - this.toolStrip1.PerformLayout(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -168,8 +165,8 @@ private Button ButtonOrderReady; private Button ButtonIssuedOrder; private Button ButtonRef; - private ToolStrip toolStrip1; - private ToolStripDropDownButton toolStripDropDownButton1; + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem изделияToolStripMenuItem; } diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.cs index 2a7ec63..f052f6f 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.cs @@ -81,7 +81,7 @@ namespace FurnitureAssembly { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try + try { var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); if (!operationResult) diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.resx b/FurnitureAssembly/FurnitureAssembly/FormMain.resx index 5fdc808..938108a 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.resx +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.resx @@ -57,17 +57,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb - J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj - CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN - AAAAAElFTkSuQmCC - - \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs index 280e941..ea145e7 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs @@ -12,6 +12,7 @@ namespace FurnitureAssemblyContracts.BindingModels { public int Id { get; set; } public int FurnitureId { get; set; } + public string FurnitureName { get; set; } = string.Empty; public int Count { get; set; } public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs index eac8c7f..04b3752 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs @@ -16,6 +16,8 @@ namespace FurnitureAssemblyListImplement.Models { public int FurnitureId { get; private set; } + public string FurnitureName { get; private set; } = string.Empty; + public int Count { get; private set; } public double Sum { get; private set; } @@ -38,6 +40,7 @@ namespace FurnitureAssemblyListImplement.Models { Id = model.Id, FurnitureId = model.FurnitureId, + FurnitureName = model.FurnitureName, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -53,6 +56,7 @@ namespace FurnitureAssemblyListImplement.Models return; } FurnitureId = model.FurnitureId; + FurnitureName = model.FurnitureName; Count = model.Count; Sum = model.Sum; Status = model.Status; @@ -64,7 +68,7 @@ namespace FurnitureAssemblyListImplement.Models { Id = Id, FurnitureId = FurnitureId, - /*FurnitureName = Furn*/ + FurnitureName = FurnitureName, Count = Count, Sum = Sum, Status = Status, -- 2.25.1 From 9452d830d36c9d4e50fb7814e05d78cdd9b0c306 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Wed, 1 Feb 2023 12:36:05 +0400 Subject: [PATCH 09/16] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=84=D0=B0=D0=B9=D0=BB=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20Nlog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FurnitureAssembly/FurnitureAssembly.csproj | 10 ++++++++++ FurnitureAssembly/FurnitureAssembly/nlog.config | 13 +++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 FurnitureAssembly/FurnitureAssembly/nlog.config diff --git a/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj b/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj index a30f8a8..243cc38 100644 --- a/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj +++ b/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj @@ -8,6 +8,16 @@ enable + + + + + + + Always + + + diff --git a/FurnitureAssembly/FurnitureAssembly/nlog.config b/FurnitureAssembly/FurnitureAssembly/nlog.config new file mode 100644 index 0000000..e515916 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/nlog.config @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file -- 2.25.1 From 19340bfe98c359ef82a7671e380f60d5ac2a25f9 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 11 Feb 2023 09:38:42 +0400 Subject: [PATCH 10/16] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FurnitureAssembly/FormMain.cs | 29 +++++--- .../OrderLogic.cs | 70 +++++++++++++------ 2 files changed, 67 insertions(+), 32 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.cs index f052f6f..75a4e3c 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.cs @@ -1,5 +1,6 @@ using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyDataModels.Enums; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -83,7 +84,7 @@ namespace FurnitureAssembly _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); try { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); + var operationResult = _orderLogic.TakeOrderInWork(GetOrderBindingModel()); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -107,10 +108,8 @@ namespace FurnitureAssembly _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); try - { - var operationResult = _orderLogic.FinishOrder(new - OrderBindingModel - { Id = id }); + { + var operationResult = _orderLogic.FinishOrder(GetOrderBindingModel()); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -134,10 +133,8 @@ namespace FurnitureAssembly _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); try - { - var operationResult = _orderLogic.DeliveryOrder(new - OrderBindingModel - { Id = id }); + { + var operationResult = _orderLogic.DeliveryOrder(GetOrderBindingModel()); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -157,5 +154,19 @@ namespace FurnitureAssembly { LoadData(); } + + private OrderBindingModel GetOrderBindingModel() + { + return new OrderBindingModel + { + Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value), + FurnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value), + FurnitureName = dataGridView.SelectedRows[0].Cells["FurnitureName"].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()) + }; + } } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs index f0f4238..a4bb14f 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs @@ -24,39 +24,70 @@ namespace FurnitureAssemblyBusinessLogic _orderStorage = orderStorage; } + private bool ChangeStatus(OrderBindingModel model, OrderStatus orderStatus) + { + if (model.Status + 1 != orderStatus) + { + return false; + } + model.Status = orderStatus; + return true; + } + public bool CreateOrder(OrderBindingModel model) { CheckModel(model); + + if (!ChangeStatus(model, OrderStatus.Принят)) + { + _logger.LogWarning("Order's status is wrong"); + return false; + } + if (_orderStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; } - model.Status = OrderStatus.Принят; + return true; } - public bool DeliveryOrder(OrderBindingModel model) + public bool TakeOrderInWork(OrderBindingModel model) { - if (model.Status.Equals(OrderStatus.Готов)) + if (!ChangeStatus(model, OrderStatus.Выполняется)) { - model.Status = OrderStatus.Выдан; - model.DateImplement = DateTime.Now; - return true; + _logger.LogWarning("Order's status is wrong"); + return false; } - return false; + _orderStorage.Update(model); + return true; } public bool FinishOrder(OrderBindingModel model) { - if (model.Status.Equals(OrderStatus.Выполняется)) + if (!ChangeStatus(model, OrderStatus.Готов)) { - model.Status = OrderStatus.Готов; - return true; + _logger.LogWarning("Order's status is wrong"); + return false; } - return false; + _orderStorage.Update(model); + return true; } + public bool DeliveryOrder(OrderBindingModel model) + { + if (!ChangeStatus(model, OrderStatus.Выдан)) + { + _logger.LogWarning("Order's status is wrong"); + return false; + } + model.DateImplement = DateTime.Now; + _orderStorage.Update(model); + return true; + } + + public List? ReadList(OrderSearchModel? model) { _logger.LogInformation("ReadList. Id:{ Id}", model?.Id); @@ -70,16 +101,7 @@ namespace FurnitureAssemblyBusinessLogic return list; } - public bool TakeOrderInWork(OrderBindingModel model) - { - if (model.Status.Equals(OrderStatus.Принят)) - { - model.Status = OrderStatus.Выполняется; - return true; - } - return false; - } - + private void CheckModel(OrderBindingModel model, bool withParams = true) { if (model == null) @@ -92,7 +114,7 @@ namespace FurnitureAssemblyBusinessLogic } if (model.FurnitureId <= 0) { - throw new ArgumentNullException("Идентификатор изделия должен быть больше 0", nameof(model.FurnitureId)); + throw new ArgumentNullException("Неверный идентификатор изделия", nameof(model.FurnitureId)); } if (model.Count <= 0) { @@ -102,7 +124,9 @@ namespace FurnitureAssemblyBusinessLogic { throw new ArgumentNullException("Стоимость заказа должна быть больше 0", nameof(model.Sum)); } - _logger.LogInformation("Order. FurnitureId:{FurnitureId}. Count:{ Count}. Sum:{ Sum}. OrderStatus: {OrderStatus} DateCreate: {DateCreate}. Id: { Id}", model.FurnitureId, model.Count, model.Sum, model.Status, model.DateCreate, model.Id); + _logger.LogInformation("Order. OrderId: { Id}. OrderStatus: {OrderStatus} DateCreate: {DateCreate} " + + "FurnitureId:{FurnitureId}. FurnitureName:{FurnitureName}. Count:{ Count}. Sum:{ Sum}. ", + model.Id, model.Status, model.DateCreate, model.FurnitureId, model.FurnitureName, model.Count, model.Sum); } } } -- 2.25.1 From fac924f1cbee2f0323c31288b061ed2ca593aec3 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 11 Feb 2023 10:11:42 +0400 Subject: [PATCH 11/16] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20=D0=B1=D0=B5=D1=81?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=B5=D0=B7=D0=BD=D0=B0=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FurnitureAssembly/Form1.Designer.cs | 39 ------ FurnitureAssembly/FurnitureAssembly/Form1.cs | 10 -- .../FurnitureAssembly/Form1.resx | 120 ------------------ 3 files changed, 169 deletions(-) delete mode 100644 FurnitureAssembly/FurnitureAssembly/Form1.Designer.cs delete mode 100644 FurnitureAssembly/FurnitureAssembly/Form1.cs delete mode 100644 FurnitureAssembly/FurnitureAssembly/Form1.resx diff --git a/FurnitureAssembly/FurnitureAssembly/Form1.Designer.cs b/FurnitureAssembly/FurnitureAssembly/Form1.Designer.cs deleted file mode 100644 index 83ebd63..0000000 --- a/FurnitureAssembly/FurnitureAssembly/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace FurnitureAssembly -{ - 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/FurnitureAssembly/FurnitureAssembly/Form1.cs b/FurnitureAssembly/FurnitureAssembly/Form1.cs deleted file mode 100644 index c186dd4..0000000 --- a/FurnitureAssembly/FurnitureAssembly/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace FurnitureAssembly -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/Form1.resx b/FurnitureAssembly/FurnitureAssembly/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FurnitureAssembly/FurnitureAssembly/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 -- 2.25.1 From 7cc7439f3d6c72f890f5f2ad804dfd4d00c57ac2 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 12 Feb 2023 09:22:32 +0400 Subject: [PATCH 12/16] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FurnitureAssembly/FormFurnitures.Designer.cs | 1 + FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs index 7e0bc01..a1be7d1 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs @@ -94,6 +94,7 @@ this.Controls.Add(this.dataGridView); this.Name = "FormFurnitures"; this.Text = "FormFurnitures"; + this.Load += new System.EventHandler(this.FormFurnitures_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs index b5cabf0..0199789 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs @@ -123,14 +123,14 @@ // компонентыToolStripMenuItem // this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(145, 22); this.компонентыToolStripMenuItem.Text = "Компоненты"; this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click); // // изделияToolStripMenuItem // this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; - this.изделияToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.изделияToolStripMenuItem.Size = new System.Drawing.Size(145, 22); this.изделияToolStripMenuItem.Text = "Изделия"; this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click); // @@ -149,6 +149,7 @@ this.MainMenuStrip = this.menuStrip1; this.Name = "FormMain"; this.Text = "Магазин мебели"; + this.Load += new System.EventHandler(this.FormMain_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); -- 2.25.1 From c3d8dfd646fa5fe66288149ab2c93c833143e7eb Mon Sep 17 00:00:00 2001 From: 111 <0@yandex.ru> Date: Mon, 13 Feb 2023 09:02:44 +0400 Subject: [PATCH 13/16] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FurnitureAssembly/FormMain.cs | 22 +++---------- .../OrderLogic.cs | 33 ++++++++++++++++++- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.cs index 75a4e3c..62e043a 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.cs @@ -84,7 +84,7 @@ namespace FurnitureAssembly _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); try { - var operationResult = _orderLogic.TakeOrderInWork(GetOrderBindingModel()); + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -109,7 +109,7 @@ namespace FurnitureAssembly id); try { - var operationResult = _orderLogic.FinishOrder(GetOrderBindingModel()); + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -134,7 +134,7 @@ namespace FurnitureAssembly id); try { - var operationResult = _orderLogic.DeliveryOrder(GetOrderBindingModel()); + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -153,20 +153,6 @@ namespace FurnitureAssembly private void ButtonRef_Click(object sender, EventArgs e) { LoadData(); - } - - private OrderBindingModel GetOrderBindingModel() - { - return new OrderBindingModel - { - Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value), - FurnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value), - FurnitureName = dataGridView.SelectedRows[0].Cells["FurnitureName"].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()) - }; - } + } } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs index a4bb14f..bbe6d31 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs @@ -37,7 +37,7 @@ namespace FurnitureAssemblyBusinessLogic public bool CreateOrder(OrderBindingModel model) { CheckModel(model); - + if (!ChangeStatus(model, OrderStatus.Принят)) { _logger.LogWarning("Order's status is wrong"); @@ -55,6 +55,11 @@ namespace FurnitureAssemblyBusinessLogic public bool TakeOrderInWork(OrderBindingModel model) { + model = Find(model); + if (model == null) + { + return false; + } if (!ChangeStatus(model, OrderStatus.Выполняется)) { _logger.LogWarning("Order's status is wrong"); @@ -66,6 +71,10 @@ namespace FurnitureAssemblyBusinessLogic public bool FinishOrder(OrderBindingModel model) { + model = Find(model); + if (model == null) { + return false; + } if (!ChangeStatus(model, OrderStatus.Готов)) { _logger.LogWarning("Order's status is wrong"); @@ -77,6 +86,11 @@ namespace FurnitureAssemblyBusinessLogic public bool DeliveryOrder(OrderBindingModel model) { + model = Find(model); + if (model == null) + { + return false; + } if (!ChangeStatus(model, OrderStatus.Выдан)) { _logger.LogWarning("Order's status is wrong"); @@ -128,5 +142,22 @@ namespace FurnitureAssemblyBusinessLogic "FurnitureId:{FurnitureId}. FurnitureName:{FurnitureName}. Count:{ Count}. Sum:{ Sum}. ", model.Id, model.Status, model.DateCreate, model.FurnitureId, model.FurnitureName, model.Count, model.Sum); } + + private OrderBindingModel Find(OrderBindingModel model) + { + var modelView = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); + if (modelView == null) + { + return null; + } + model.FurnitureId = modelView.FurnitureId; + model.DateCreate = modelView.DateCreate; + model.Count = modelView.Count; + model.Sum = modelView.Sum; + model.FurnitureId = model.FurnitureId; + model.FurnitureName = modelView.FurnitureName; + model.Status = modelView.Status; + return model; + } } } -- 2.25.1 From b2681563e16f3da0351bcfa7f7654f97acfdedd5 Mon Sep 17 00:00:00 2001 From: pgirl111 Date: Mon, 13 Feb 2023 09:18:24 +0400 Subject: [PATCH 14/16] =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=84=D0=BE=D1=80=D0=BC=20=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FurnitureAssembly/FurnitureAssembly/FormComponents.Designer.cs | 2 +- FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssembly/FormComponents.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormComponents.Designer.cs index 7e0de59..b93da90 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormComponents.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormComponents.Designer.cs @@ -96,7 +96,7 @@ this.Controls.Add(this.ButtonAdd); this.Controls.Add(this.dataGridView); this.Name = "FormComponents"; - this.Text = "FormComponents"; + this.Text = "Компоненты"; this.Load += new System.EventHandler(this.FormComponents_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs index a1be7d1..8afad3b 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs @@ -93,7 +93,7 @@ this.Controls.Add(this.ButtonAdd); this.Controls.Add(this.dataGridView); this.Name = "FormFurnitures"; - this.Text = "FormFurnitures"; + this.Text = "Изделия"; this.Load += new System.EventHandler(this.FormFurnitures_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); -- 2.25.1 From a3e75e643fd5500d94b70f1f8bf9ada81073a4ad Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 26 Feb 2023 19:05:34 +0400 Subject: [PATCH 15/16] =?UTF-8?q?=D0=98=D0=B7=20=D1=84=D0=BE=D1=80=D0=BC?= =?UTF-8?q?=D1=8B=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD=D1=8B=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BB=D0=BB=D0=B5=D0=BA=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs index 03d08c5..ad82020 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs @@ -39,7 +39,8 @@ namespace FurnitureAssembly dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["FurnitureName"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; + DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["FurnitureComponents"].Visible = false; } _logger.LogInformation("Загрузка изделий"); } -- 2.25.1 From 38a767f64c9f85058c7e8a9a7ca26ad1e10a38b4 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 26 Feb 2023 19:18:48 +0400 Subject: [PATCH 16/16] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=D1=87=D0=B5=D0=BC=D1=83-=D1=82=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs index 8afad3b..abe74ea 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs @@ -63,6 +63,7 @@ this.ButtonDel.TabIndex = 7; this.ButtonDel.Text = "Удалить"; this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); // // ButtonUpd // @@ -72,6 +73,7 @@ this.ButtonUpd.TabIndex = 8; this.ButtonUpd.Text = "Изменить"; this.ButtonUpd.UseVisualStyleBackColor = true; + this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); // // ButtonRef // @@ -81,6 +83,7 @@ this.ButtonRef.TabIndex = 9; this.ButtonRef.Text = "Обновить"; this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); // // FormFurnitures // -- 2.25.1