diff --git a/SnackBarView/Form1.Designer.cs b/SnackBarView/Form1.Designer.cs
deleted file mode 100644
index 93254d4..0000000
--- a/SnackBarView/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace SnackBarView
-{
- 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
- }
-}
diff --git a/SnackBarView/Form1.cs b/SnackBarView/Form1.cs
deleted file mode 100644
index 9b06831..0000000
--- a/SnackBarView/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace SnackBarView
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/SnackBarView/Program.cs b/SnackBarView/Program.cs
deleted file mode 100644
index d145eb5..0000000
--- a/SnackBarView/Program.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace SnackBarView
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
- ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
- }
- }
-}
\ No newline at end of file
diff --git a/SnackBarView/SnackBarView.csproj b/SnackBarView/SnackBarView.csproj
deleted file mode 100644
index b57c89e..0000000
--- a/SnackBarView/SnackBarView.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- WinExe
- net6.0-windows
- enable
- true
- enable
-
-
-
\ No newline at end of file
diff --git a/SnackBarView/SnackBarView.sln b/SnackBarView/SnackBarView.sln
deleted file mode 100644
index 76aaa65..0000000
--- a/SnackBarView/SnackBarView.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.8.34525.116
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnackBarView", "SnackBarView.csproj", "{F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {90C6C176-8EEF-4A99-B848-F6B7B3FA6549}
- EndGlobalSection
-EndGlobal
diff --git a/TypographyBusinessLogic/ComponentLogic.cs b/TypographyBusinessLogic/ComponentLogic.cs
new file mode 100644
index 0000000..e332560
--- /dev/null
+++ b/TypographyBusinessLogic/ComponentLogic.cs
@@ -0,0 +1,115 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.SearchModels;
+using TypographyContracts.StoragesContracts;
+using TypographyContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+
+
+namespace TypographyBusinessLogic.BusinessLogics
+{
+ public class ComponentLogic : IComponentLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentStorage _componentStorage;
+ public ComponentLogic(ILogger logger, IComponentStorage componentStorage)
+ {
+ _logger = logger;
+ _componentStorage = componentStorage;
+ }
+ public List? ReadList(ComponentSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id);
+ var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public ComponentViewModel? ReadElement(ComponentSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id);
+ var element = _componentStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+ public bool Create(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(ComponentBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_componentStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(ComponentBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ throw new ArgumentNullException("Нет названия компонента",
+ nameof(model.ComponentName));
+ }
+ if (model.Cost <= 0)
+ {
+ throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
+ }
+ _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id);
+ var element = _componentStorage.GetElement(new ComponentSearchModel
+ {
+ ComponentName = model.ComponentName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Компонент с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/TypographyBusinessLogic/OrderLogic.cs b/TypographyBusinessLogic/OrderLogic.cs
new file mode 100644
index 0000000..bcf03a7
--- /dev/null
+++ b/TypographyBusinessLogic/OrderLogic.cs
@@ -0,0 +1,124 @@
+using TypographyContracts.BusinessLogicsContracts;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.StoragesContracts;
+using TypographyContracts.ViewModels;
+using TypographyDataModels.Enums;
+using Microsoft.Extensions.Logging;
+
+namespace TypographyBusinessLogic.BusinessLogics
+{
+ public class OrderLogic : IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
+ var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ public bool CreateOrder(OrderBindingModel model)
+ {
+ CheckModel(model);
+ if (model.Status != OrderStatus.Неизвестен) return false;
+ model.Status = OrderStatus.Принят;
+ if (_orderStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
+ {
+ CheckModel(model, false);
+ var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
+ if (element == null)
+ {
+ _logger.LogWarning("Read operation failed");
+ return false;
+ }
+ if (element.Status != status - 1)
+ {
+ _logger.LogWarning("Status change operation failed");
+ throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
+ }
+ OrderStatus oldStatus = model.Status;
+ model.Status = status;
+ if (model.Status == OrderStatus.Выдан)
+ model.DateImplement = DateTime.Now;
+ if (_orderStorage.Update(model) == null)
+ {
+ model.Status = oldStatus;
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Выполняется);
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Готов);
+ }
+
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Выдан);
+ }
+
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (model.PrintedId < 0)
+ {
+ throw new ArgumentNullException("Некорректный идентификатор закусок", nameof(model.PrintedId));
+ }
+ if (model.Count <= 0)
+ {
+ throw new ArgumentNullException("Количество закусок в заказе должно быть больше 0", nameof(model.Count));
+ }
+ if (model.Sum <= 0)
+ {
+ throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum));
+ }
+ if (model.Count <= 0)
+ {
+ throw new ArgumentNullException("Количество элементов в заказе должно быть больше 0", nameof(model.Count));
+ }
+ _logger.LogInformation("Order. Sum:{ Cost}. Id: { Id}", model.Sum, model.Id);
+ }
+ }
+}
diff --git a/TypographyBusinessLogic/PrintedLogic.cs b/TypographyBusinessLogic/PrintedLogic.cs
new file mode 100644
index 0000000..56b789d
--- /dev/null
+++ b/TypographyBusinessLogic/PrintedLogic.cs
@@ -0,0 +1,114 @@
+using Microsoft.Extensions.Logging;
+using TypographyBusinessLogic.BusinessLogics;
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.SearchModels;
+using TypographyContracts.StoragesContracts;
+using TypographyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TypographyBusinessLogic.BusinessLogics
+{
+ public class PrintedLogic : IPrintedLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IPrintedStorage _snackStorage;
+ public PrintedLogic(ILogger logger, IPrintedStorage snackStorage)
+ {
+ _logger = logger;
+ _snackStorage = snackStorage;
+ }
+ public List? ReadList(PrintedSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. PrintedName:{PrintedName}.Id:{ Id}", model?.PrintedName, model?.Id);
+ var list = model == null ? _snackStorage.GetFullList() : _snackStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public PrintedViewModel? ReadElement(PrintedSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. PrintedName:{PrintedName}.Id:{ Id}", model.PrintedName, model.Id);
+ var element = _snackStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+ public bool Create(PrintedBindingModel model)
+ {
+ CheckModel(model);
+ if (_snackStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(PrintedBindingModel model)
+ {
+ CheckModel(model);
+ if (_snackStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(PrintedBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_snackStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(PrintedBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.PrintedName))
+ {
+ throw new ArgumentNullException("Нет названия закуски",
+ nameof(model.PrintedName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена закуски должна быть больше 0", nameof(model.Price));
+ }
+ _logger.LogInformation("Printed. PrintedName:{PrintedName}.Price:{ Price}. Id: { Id}", model.PrintedName, model.Price, model.Id);
+ var element = _snackStorage.GetElement(new PrintedSearchModel
+ {
+ PrintedName = model.PrintedName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Закуска с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/TypographyBusinessLogic/TypographyBusinessLogic.csproj b/TypographyBusinessLogic/TypographyBusinessLogic.csproj
new file mode 100644
index 0000000..f1dbedd
--- /dev/null
+++ b/TypographyBusinessLogic/TypographyBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TypographyContracts/BindingModels/ComponentBindingModel.cs b/TypographyContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..15f49db
--- /dev/null
+++ b/TypographyContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyDataModels.Models;
+
+namespace TypographyContracts.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/TypographyContracts/BindingModels/OrderBindingModel.cs b/TypographyContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..4708a3d
--- /dev/null
+++ b/TypographyContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyDataModels.Enums;
+using TypographyDataModels.Models;
+
+namespace TypographyContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int PrintedId { 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/TypographyContracts/BindingModels/PrintedBindingModel.cs b/TypographyContracts/BindingModels/PrintedBindingModel.cs
new file mode 100644
index 0000000..faf5644
--- /dev/null
+++ b/TypographyContracts/BindingModels/PrintedBindingModel.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyDataModels.Models;
+
+namespace TypographyContracts.BindingModels
+{
+ public class PrintedBindingModel : IPrintedModel
+ {
+ public int Id { get; set; }
+ public string PrintedName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary PrintedComponents { get; set; } = new();
+ }
+}
diff --git a/TypographyContracts/BusinessLogicsContracts/IComponentLogic.cs b/TypographyContracts/BusinessLogicsContracts/IComponentLogic.cs
new file mode 100644
index 0000000..65d0c04
--- /dev/null
+++ b/TypographyContracts/BusinessLogicsContracts/IComponentLogic.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+
+
+namespace TypographyContracts.BusinessLogicsContracts
+{
+ public interface IComponentLogic
+ {
+ List? ReadList(ComponentSearchModel? model);
+ ComponentViewModel? ReadElement(ComponentSearchModel model);
+ bool Create(ComponentBindingModel model);
+ bool Update(ComponentBindingModel model);
+ bool Delete(ComponentBindingModel model);
+ }
+}
diff --git a/TypographyContracts/BusinessLogicsContracts/IOrderLogic.cs b/TypographyContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..6105b9a
--- /dev/null
+++ b/TypographyContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+
+
+namespace TypographyContracts.BusinessLogicsContracts
+{
+ public interface IOrderLogic
+ {
+ List? ReadList(OrderSearchModel? model);
+ bool CreateOrder(OrderBindingModel model);
+ bool TakeOrderInWork(OrderBindingModel model);
+ bool FinishOrder(OrderBindingModel model);
+ bool DeliveryOrder(OrderBindingModel model);
+ }
+}
diff --git a/TypographyContracts/BusinessLogicsContracts/IPrintedLogic.cs b/TypographyContracts/BusinessLogicsContracts/IPrintedLogic.cs
new file mode 100644
index 0000000..8b7a050
--- /dev/null
+++ b/TypographyContracts/BusinessLogicsContracts/IPrintedLogic.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+
+namespace TypographyContracts.BusinessLogicsContracts
+{
+ public interface IPrintedLogic
+ {
+ List? ReadList(PrintedSearchModel? model);
+ PrintedViewModel? ReadElement(PrintedSearchModel model);
+ bool Create(PrintedBindingModel model);
+ bool Update(PrintedBindingModel model);
+ bool Delete(PrintedBindingModel model);
+ }
+}
diff --git a/TypographyContracts/SearchModels/ComponentSearchModel.cs b/TypographyContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..b23cdcf
--- /dev/null
+++ b/TypographyContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TypographyContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComponentName { get; set; }
+ }
+}
diff --git a/TypographyContracts/SearchModels/OrderSearchModel.cs b/TypographyContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..3f183fb
--- /dev/null
+++ b/TypographyContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TypographyContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/TypographyContracts/SearchModels/PrintedSearchModel.cs b/TypographyContracts/SearchModels/PrintedSearchModel.cs
new file mode 100644
index 0000000..115aa32
--- /dev/null
+++ b/TypographyContracts/SearchModels/PrintedSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TypographyContracts.SearchModels
+{
+ public class PrintedSearchModel
+ {
+ public int? Id { get; set; }
+ public string? PrintedName { get; set; }
+ }
+}
diff --git a/TypographyContracts/StoragesContracts/IComponentStorage.cs b/TypographyContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..65094a8
--- /dev/null
+++ b/TypographyContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,21 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TypographyContracts.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/TypographyContracts/StoragesContracts/IOrderStorage.cs b/TypographyContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..1ea8430
--- /dev/null
+++ b/TypographyContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,21 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TypographyContracts.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/TypographyContracts/StoragesContracts/IPrintedStorage.cs b/TypographyContracts/StoragesContracts/IPrintedStorage.cs
new file mode 100644
index 0000000..794b240
--- /dev/null
+++ b/TypographyContracts/StoragesContracts/IPrintedStorage.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+
+namespace TypographyContracts.StoragesContracts
+{
+ public interface IPrintedStorage
+ {
+ List GetFullList();
+ List GetFilteredList(PrintedSearchModel model);
+ PrintedViewModel? GetElement(PrintedSearchModel model);
+ PrintedViewModel? Insert(PrintedBindingModel model);
+ PrintedViewModel? Update(PrintedBindingModel model);
+ PrintedViewModel? Delete(PrintedBindingModel model);
+ }
+}
diff --git a/TypographyContracts/TypographyContracts.csproj b/TypographyContracts/TypographyContracts.csproj
new file mode 100644
index 0000000..30c2576
--- /dev/null
+++ b/TypographyContracts/TypographyContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/TypographyContracts/ViewModels/ComponentViewModel.cs b/TypographyContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..40a6a67
--- /dev/null
+++ b/TypographyContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyDataModels.Models;
+using System.ComponentModel;
+
+namespace TypographyContracts.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/TypographyContracts/ViewModels/OrderViewModel.cs b/TypographyContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..847ebde
--- /dev/null
+++ b/TypographyContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyDataModels.Enums;
+using TypographyDataModels.Models;
+using System.ComponentModel;
+
+
+namespace TypographyContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+ public int PrintedId { get; set; }
+ [DisplayName("Изделие")]
+ public string PrintedName { get; set; } = string.Empty;
+ [DisplayName("Количество")]
+ public int Count { get; set; }
+ [DisplayName("Сумма")]
+ public double Sum { get; set; }
+ [DisplayName("Статус")]
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+ [DisplayName("Дата создания")]
+ public DateTime DateCreate { get; set; } = DateTime.Now;
+ [DisplayName("Дата выполнения")]
+ public DateTime? DateImplement { get; set; }
+ }
+}
diff --git a/TypographyContracts/ViewModels/PrintedViewModel.cs b/TypographyContracts/ViewModels/PrintedViewModel.cs
new file mode 100644
index 0000000..90bd2f7
--- /dev/null
+++ b/TypographyContracts/ViewModels/PrintedViewModel.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyDataModels.Models;
+using System.ComponentModel;
+
+namespace TypographyContracts.ViewModels
+{
+ public class PrintedViewModel : IPrintedModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название изделия")]
+ public string PrintedName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+ public Dictionary PrintedComponents { get; set; } = new();
+
+ }
+}
diff --git a/TypographyDataModels/IComponentModel.cs b/TypographyDataModels/IComponentModel.cs
new file mode 100644
index 0000000..3225cb6
--- /dev/null
+++ b/TypographyDataModels/IComponentModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TypographyDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+ }
+}
diff --git a/TypographyDataModels/IId.cs b/TypographyDataModels/IId.cs
new file mode 100644
index 0000000..5806a37
--- /dev/null
+++ b/TypographyDataModels/IId.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TypographyDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
diff --git a/TypographyDataModels/IOrderModel.cs b/TypographyDataModels/IOrderModel.cs
new file mode 100644
index 0000000..3358942
--- /dev/null
+++ b/TypographyDataModels/IOrderModel.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TypographyDataModels.Enums
+{
+ public interface IOrderModel : IId
+ {
+ int PrintedId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/TypographyDataModels/IPrintedModel.cs b/TypographyDataModels/IPrintedModel.cs
new file mode 100644
index 0000000..a1efb0c
--- /dev/null
+++ b/TypographyDataModels/IPrintedModel.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TypographyDataModels.Models
+{
+ public interface IPrintedModel : IId
+ {
+ string PrintedName { get; }
+ double Price { get; }
+ Dictionary PrintedComponents { get; }
+
+ }
+}
diff --git a/TypographyDataModels/OrderStatus.cs b/TypographyDataModels/OrderStatus.cs
new file mode 100644
index 0000000..9705761
--- /dev/null
+++ b/TypographyDataModels/OrderStatus.cs
@@ -0,0 +1,11 @@
+namespace TypographyDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
diff --git a/TypographyDataModels/TypographyDataModels.csproj b/TypographyDataModels/TypographyDataModels.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/TypographyDataModels/TypographyDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/TypographyListImplement/Component.cs b/TypographyListImplement/Component.cs
new file mode 100644
index 0000000..9b0cdb3
--- /dev/null
+++ b/TypographyListImplement/Component.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.ViewModels;
+using TypographyDataModels.Models;
+
+namespace TypographyListImplement.Models
+{
+ public class Component : IComponentModel
+ {
+ public int Id { get; private set; }
+ public string ComponentName { get; private set; } = string.Empty;
+ public double Cost { get; set; }
+ public static Component? Create(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Component()
+ {
+ Id = model.Id,
+ ComponentName = model.ComponentName,
+ Cost = model.Cost
+ };
+ }
+ public void Update(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ComponentName = model.ComponentName;
+ Cost = model.Cost;
+ }
+ public ComponentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ComponentName = ComponentName,
+ Cost = Cost
+ };
+
+ }
+}
\ No newline at end of file
diff --git a/TypographyListImplement/ComponentStorage.cs b/TypographyListImplement/ComponentStorage.cs
new file mode 100644
index 0000000..35643dc
--- /dev/null
+++ b/TypographyListImplement/ComponentStorage.cs
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.StoragesContracts;
+using TypographyContracts.ViewModels;
+using TypographyListImplement.Models;
+
+
+namespace TypographyListImplement.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/TypographyListImplement/DataListSingleton.cs b/TypographyListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..dd973c4
--- /dev/null
+++ b/TypographyListImplement/DataListSingleton.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyListImplement.Models;
+
+namespace TypographyListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Components { get; set; }
+ public List Orders { get; set; }
+ public List Printeds { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Printeds = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
diff --git a/TypographyListImplement/Order.cs b/TypographyListImplement/Order.cs
new file mode 100644
index 0000000..da05a97
--- /dev/null
+++ b/TypographyListImplement/Order.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.ViewModels;
+using TypographyDataModels.Enums;
+using TypographyDataModels.Models;
+
+namespace TypographyListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int PrintedId { 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,
+ PrintedId = model.PrintedId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement,
+ };
+ }
+
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Id = model.Id;
+ PrintedId = model.PrintedId;
+ Count = model.Count;
+ Sum = model.Sum;
+ Status = model.Status;
+ DateCreate = model.DateCreate;
+ DateImplement = model.DateImplement;
+ }
+
+ public OrderViewModel GetViewModel => new()
+ {
+ PrintedId = PrintedId,
+ Count = Count,
+ Sum = Sum,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement,
+ Id = Id,
+ Status = Status,
+ };
+ }
+}
diff --git a/TypographyListImplement/OrderStorage.cs b/TypographyListImplement/OrderStorage.cs
new file mode 100644
index 0000000..4876aa0
--- /dev/null
+++ b/TypographyListImplement/OrderStorage.cs
@@ -0,0 +1,122 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.StoragesContracts;
+using TypographyContracts.ViewModels;
+using TypographyListImplement.Models;
+
+namespace TypographyListImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataListSingleton _source;
+
+ public OrderStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var order in _source.Orders)
+ {
+ result.Add(AddPrintedName(order.GetViewModel));
+ }
+ return result;
+ }
+
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ var result = new List();
+ if (!model.Id.HasValue)
+ {
+ return result;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ result.Add(AddPrintedName(order.GetViewModel));
+ }
+ }
+ return result;
+ }
+
+ public OrderViewModel? GetElement(OrderSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ return AddPrintedName(order.GetViewModel);
+ }
+ }
+ return null;
+ }
+
+ public OrderViewModel? Insert(OrderBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id <= order.Id)
+ {
+ model.Id = order.Id + 1;
+ }
+ }
+ var newOrder = Order.Create(model);
+ if (newOrder == null)
+ {
+ return null;
+ }
+ _source.Orders.Add(newOrder);
+ return AddPrintedName(newOrder.GetViewModel);
+ }
+
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ order.Update(model);
+ return AddPrintedName(order.GetViewModel);
+ }
+ }
+ return null;
+ }
+
+ public OrderViewModel? Delete(OrderBindingModel model)
+ {
+ for (int i = 0; i < _source.Orders.Count; ++i)
+ {
+ if (_source.Orders[i].Id == model.Id)
+ {
+ var element = _source.Orders[i];
+ _source.Orders.RemoveAt(i);
+ return AddPrintedName(element.GetViewModel);
+ }
+ }
+ return null;
+ }
+
+ private OrderViewModel AddPrintedName(OrderViewModel model)
+ {
+ var selectedPrinted = _source.Printeds.Find(printed => printed.Id == model.PrintedId);
+ if (selectedPrinted != null)
+ {
+ model.PrintedName = selectedPrinted.PrintedName;
+ }
+ return model;
+ }
+ }
+}
diff --git a/TypographyListImplement/Printed.cs b/TypographyListImplement/Printed.cs
new file mode 100644
index 0000000..f4072b3
--- /dev/null
+++ b/TypographyListImplement/Printed.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.ViewModels;
+using TypographyDataModels.Models;
+
+
+namespace TypographyListImplement.Models
+{
+ public class Printed : IPrintedModel
+ {
+ public int Id { get; private set; }
+ public string PrintedName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary PrintedComponents { get; private set; } = new Dictionary();
+ public static Printed? Create(PrintedBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Printed()
+ {
+ Id = model.Id,
+ PrintedName = model.PrintedName,
+ Price = model.Price,
+ PrintedComponents = model.PrintedComponents
+ };
+ }
+ public void Update(PrintedBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ PrintedName = model.PrintedName;
+ Price = model.Price;
+ PrintedComponents = model.PrintedComponents;
+ }
+ public PrintedViewModel GetViewModel => new()
+ {
+ Id = Id,
+ PrintedName = PrintedName,
+ Price = Price,
+ PrintedComponents = PrintedComponents
+ };
+ }
+}
diff --git a/TypographyListImplement/PrintedStorage.cs b/TypographyListImplement/PrintedStorage.cs
new file mode 100644
index 0000000..c202898
--- /dev/null
+++ b/TypographyListImplement/PrintedStorage.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.ConstrainedExecution;
+using System.Text;
+using System.Threading.Tasks;
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.StoragesContracts;
+using TypographyContracts.ViewModels;
+using TypographyListImplement.Models;
+
+namespace TypographyListImplement.Implements
+{
+ public class PrintedStorage : IPrintedStorage
+ {
+ private readonly DataListSingleton _source;
+
+ public PrintedStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var printed in _source.Printeds)
+ {
+ result.Add(printed.GetViewModel);
+ }
+ return result;
+ }
+
+ public List GetFilteredList(PrintedSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.PrintedName))
+ {
+ return result;
+ }
+ foreach (var printed in _source.Printeds)
+ {
+ if (printed.PrintedName.Contains(model.PrintedName))
+ {
+ result.Add(printed.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public PrintedViewModel? GetElement(PrintedSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.PrintedName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var printed in _source.Printeds)
+ {
+ if ((!string.IsNullOrEmpty(model.PrintedName) && printed.PrintedName == model.PrintedName) || (model.Id.HasValue && printed.Id == model.Id))
+ {
+ return printed.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public PrintedViewModel? Insert(PrintedBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var printed in _source.Printeds)
+ {
+ if (model.Id <= printed.Id)
+ {
+ model.Id = printed.Id + 1;
+ }
+ }
+ var newPrinted = Printed.Create(model);
+ if (newPrinted == null)
+ {
+ return null;
+ }
+ _source.Printeds.Add(newPrinted);
+ return newPrinted.GetViewModel;
+ }
+
+ public PrintedViewModel? Update(PrintedBindingModel model)
+ {
+ foreach (var printed in _source.Printeds)
+ {
+ if (printed.Id == model.Id)
+ {
+ printed.Update(model);
+ return printed.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public PrintedViewModel? Delete(PrintedBindingModel model)
+ {
+ for (int i = 0; i < _source.Printeds.Count; ++i)
+ {
+ if (_source.Printeds[i].Id == model.Id)
+ {
+ var element = _source.Printeds[i];
+ _source.Printeds.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/TypographyListImplement/TypographyListImplement.csproj b/TypographyListImplement/TypographyListImplement.csproj
new file mode 100644
index 0000000..95efe1f
--- /dev/null
+++ b/TypographyListImplement/TypographyListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/TypographyView/FormComponent.Designer.cs b/TypographyView/FormComponent.Designer.cs
new file mode 100644
index 0000000..57b5e98
--- /dev/null
+++ b/TypographyView/FormComponent.Designer.cs
@@ -0,0 +1,118 @@
+namespace TypographyView
+{
+ 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()
+ {
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ labelComponentName = new Label();
+ labelCostComponent = new Label();
+ textBoxName = new TextBox();
+ textBoxCost = new TextBox();
+ SuspendLayout();
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(205, 117);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 29);
+ buttonSave.TabIndex = 0;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(330, 117);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 1;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // labelComponentName
+ //
+ labelComponentName.AutoSize = true;
+ labelComponentName.Location = new Point(12, 30);
+ labelComponentName.Name = "labelComponentName";
+ labelComponentName.Size = new Size(80, 20);
+ labelComponentName.TabIndex = 2;
+ labelComponentName.Text = "Название:";
+ //
+ // labelCostComponent
+ //
+ labelCostComponent.AutoSize = true;
+ labelCostComponent.Location = new Point(12, 70);
+ labelCostComponent.Name = "labelCostComponent";
+ labelCostComponent.Size = new Size(48, 20);
+ labelCostComponent.TabIndex = 3;
+ labelCostComponent.Text = "Цена:";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(109, 27);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(315, 27);
+ textBoxName.TabIndex = 4;
+ //
+ // textBoxCost
+ //
+ textBoxCost.Location = new Point(109, 67);
+ textBoxCost.Name = "textBoxCost";
+ textBoxCost.Size = new Size(125, 27);
+ textBoxCost.TabIndex = 5;
+ //
+ // FormComponent
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(455, 158);
+ Controls.Add(textBoxCost);
+ Controls.Add(textBoxName);
+ Controls.Add(labelCostComponent);
+ Controls.Add(labelComponentName);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Name = "FormComponent";
+ Text = "Компонент";
+ Load += FormComponent_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label labelComponentName;
+ private Label labelCostComponent;
+ private TextBox textBoxName;
+ private TextBox textBoxCost;
+ }
+}
diff --git a/TypographyView/FormComponent.cs b/TypographyView/FormComponent.cs
new file mode 100644
index 0000000..f7925ae
--- /dev/null
+++ b/TypographyView/FormComponent.cs
@@ -0,0 +1,84 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System.Windows.Forms;
+
+
+namespace TypographyView
+{
+ 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/TypographyView/FormComponent.resx b/TypographyView/FormComponent.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/TypographyView/FormComponent.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/TypographyView/FormComponents.Designer.cs b/TypographyView/FormComponents.Designer.cs
new file mode 100644
index 0000000..81e8435
--- /dev/null
+++ b/TypographyView/FormComponents.Designer.cs
@@ -0,0 +1,118 @@
+namespace TypographyView
+{
+ 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()
+ {
+ dataGridView = new DataGridView();
+ buttonEdit = new Button();
+ buttonAdd = new Button();
+ buttonDelete = new Button();
+ buttonRefresh = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(0, -2);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(459, 453);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonEdit
+ //
+ buttonEdit.Location = new Point(522, 78);
+ buttonEdit.Name = "buttonEdit";
+ buttonEdit.Size = new Size(119, 36);
+ buttonEdit.TabIndex = 1;
+ buttonEdit.Text = "Изменить";
+ buttonEdit.UseVisualStyleBackColor = true;
+ buttonEdit.Click += ButtonRef_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(522, 25);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(119, 35);
+ buttonAdd.TabIndex = 2;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(522, 131);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(119, 40);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDel_Click;
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Location = new Point(522, 187);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(119, 40);
+ buttonRefresh.TabIndex = 4;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonUpd_Click;
+ //
+ // FormComponents
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(736, 450);
+ Controls.Add(buttonRefresh);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonAdd);
+ Controls.Add(buttonEdit);
+ Controls.Add(dataGridView);
+ Name = "FormComponents";
+ Text = "Компоненты";
+ Load += FormComponents_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonEdit;
+ private Button buttonAdd;
+ private Button buttonDelete;
+ private Button buttonRefresh;
+ }
+}
\ No newline at end of file
diff --git a/TypographyView/FormComponents.cs b/TypographyView/FormComponents.cs
new file mode 100644
index 0000000..bcc56dc
--- /dev/null
+++ b/TypographyView/FormComponents.cs
@@ -0,0 +1,109 @@
+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;
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+
+namespace TypographyView
+{
+ 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)
+ {
+ }
+ }
+ }
+ }
+ 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/TypographyView/FormComponents.resx b/TypographyView/FormComponents.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/TypographyView/FormComponents.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/TypographyView/FormCreateOrder.Designer.cs b/TypographyView/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..b22e27b
--- /dev/null
+++ b/TypographyView/FormCreateOrder.Designer.cs
@@ -0,0 +1,143 @@
+namespace TypographyView
+{
+ 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()
+ {
+ labelPrinted = new Label();
+ labelCount = new Label();
+ labelSum = new Label();
+ comboBoxPrinted = new ComboBox();
+ textBoxCount = new TextBox();
+ textBoxSum = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelPrinted
+ //
+ labelPrinted.AutoSize = true;
+ labelPrinted.Location = new Point(12, 22);
+ labelPrinted.Name = "labelPrinted";
+ labelPrinted.Size = new Size(71, 20);
+ labelPrinted.TabIndex = 0;
+ labelPrinted.Text = "Изделие:";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(12, 65);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(93, 20);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Количество:";
+ //
+ // labelSum
+ //
+ labelSum.AutoSize = true;
+ labelSum.Location = new Point(12, 103);
+ labelSum.Name = "labelSum";
+ labelSum.Size = new Size(58, 20);
+ labelSum.TabIndex = 2;
+ labelSum.Text = "Сумма:";
+ //
+ // comboBoxPrinted
+ //
+ comboBoxPrinted.FormattingEnabled = true;
+ comboBoxPrinted.Location = new Point(111, 19);
+ comboBoxPrinted.Name = "comboBoxPrinted";
+ comboBoxPrinted.Size = new Size(238, 28);
+ comboBoxPrinted.TabIndex = 3;
+ comboBoxPrinted.SelectedIndexChanged += ComboBoxPrinted_SelectedIndexChanged;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(111, 58);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(238, 27);
+ textBoxCount.TabIndex = 4;
+ textBoxCount.TextChanged += TextBoxCount_TextChanged;
+ //
+ // textBoxSum
+ //
+ textBoxSum.Location = new Point(111, 100);
+ textBoxSum.Name = "textBoxSum";
+ textBoxSum.Size = new Size(238, 27);
+ textBoxSum.TabIndex = 5;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(111, 157);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(117, 43);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(234, 157);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(115, 43);
+ buttonCancel.TabIndex = 7;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormCreateOrder
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(412, 212);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxSum);
+ Controls.Add(textBoxCount);
+ Controls.Add(comboBoxPrinted);
+ Controls.Add(labelSum);
+ Controls.Add(labelCount);
+ Controls.Add(labelPrinted);
+ Name = "FormCreateOrder";
+ Text = "Заказ";
+ Load += FormCreateOrder_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelPrinted;
+ private Label labelCount;
+ private Label labelSum;
+ private ComboBox comboBoxPrinted;
+ private TextBox textBoxCount;
+ private TextBox textBoxSum;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/TypographyView/FormCreateOrder.cs b/TypographyView/FormCreateOrder.cs
new file mode 100644
index 0000000..8491661
--- /dev/null
+++ b/TypographyView/FormCreateOrder.cs
@@ -0,0 +1,120 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using Microsoft.VisualBasic.Logging;
+using System.Windows.Forms;
+
+namespace TypographyView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IPrintedLogic _logicIC;
+
+ private readonly IOrderLogic _logicO;
+
+ public FormCreateOrder(ILogger logger, IPrintedLogic logicIC, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicIC = logicIC;
+ _logicO = logicO;
+ }
+
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Loading printed for order");
+ try
+ {
+ var printedList = _logicIC.ReadList(null);
+ if (printedList != null)
+ {
+ comboBoxPrinted.DisplayMember = "PrintedName";
+ comboBoxPrinted.ValueMember = "Id";
+ comboBoxPrinted.DataSource = printedList;
+ comboBoxPrinted.SelectedItem = null;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during loading printed for order");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void CalcSum()
+ {
+ if (comboBoxPrinted.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxPrinted.SelectedValue);
+ var product = _logicIC.ReadElement(new PrintedSearchModel { Id = id });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
+ _logger.LogInformation("Calculation of order sum");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Calculation of order sum error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void TextBoxCount_TextChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+
+ private void ComboBoxPrinted_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxPrinted.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите закуску", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Order creation");
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ PrintedId = Convert.ToInt32(comboBoxPrinted.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, "Order creation error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/TypographyView/FormCreateOrder.resx b/TypographyView/FormCreateOrder.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/TypographyView/FormCreateOrder.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/TypographyView/FormMain.Designer.cs b/TypographyView/FormMain.Designer.cs
new file mode 100644
index 0000000..dbc094d
--- /dev/null
+++ b/TypographyView/FormMain.Designer.cs
@@ -0,0 +1,174 @@
+namespace TypographyView
+{
+ 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()
+ {
+ menuStrip = new MenuStrip();
+ справочникиToolStripMenuItem = new ToolStripMenuItem();
+ компонентыToolStripMenuItem = new ToolStripMenuItem();
+ изделиеToolStripMenuItem = new ToolStripMenuItem();
+ dataGridView = new DataGridView();
+ buttonCreateOrder = new Button();
+ buttonTakeOrderInWork = new Button();
+ buttonOrderReady = new Button();
+ buttonIssuedOrder = new Button();
+ buttonUpd = new Button();
+ menuStrip.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // menuStrip
+ //
+ menuStrip.ImageScalingSize = new Size(20, 20);
+ menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
+ menuStrip.Location = new Point(0, 0);
+ menuStrip.Name = "menuStrip";
+ menuStrip.Size = new Size(1146, 28);
+ menuStrip.TabIndex = 0;
+ menuStrip.Text = "menuStrip1";
+ //
+ // справочникиToolStripMenuItem
+ //
+ справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem });
+ справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ справочникиToolStripMenuItem.Size = new Size(117, 24);
+ справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // компонентыToolStripMenuItem
+ //
+ компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ компонентыToolStripMenuItem.Size = new Size(224, 26);
+ компонентыToolStripMenuItem.Text = "Компоненты";
+ компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
+ //
+ // изделиеToolStripMenuItem
+ //
+ изделиеToolStripMenuItem.Name = "изделиеToolStripMenuItem";
+ изделиеToolStripMenuItem.Size = new Size(224, 26);
+ изделиеToolStripMenuItem.Text = "Изделие";
+ изделиеToolStripMenuItem.Click += ЗакускаToolStripMenuItem_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 31);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(916, 407);
+ dataGridView.TabIndex = 1;
+ //
+ // buttonCreateOrder
+ //
+ buttonCreateOrder.Location = new Point(934, 58);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(200, 37);
+ buttonCreateOrder.TabIndex = 2;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += ButtonCreateOrder_Click;
+ //
+ // buttonTakeOrderInWork
+ //
+ buttonTakeOrderInWork.Location = new Point(934, 112);
+ buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ buttonTakeOrderInWork.Size = new Size(200, 37);
+ buttonTakeOrderInWork.TabIndex = 3;
+ buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
+ //
+ // buttonOrderReady
+ //
+ buttonOrderReady.Location = new Point(934, 166);
+ buttonOrderReady.Name = "buttonOrderReady";
+ buttonOrderReady.Size = new Size(200, 37);
+ buttonOrderReady.TabIndex = 4;
+ buttonOrderReady.Text = "Заказ готов";
+ buttonOrderReady.UseVisualStyleBackColor = true;
+ buttonOrderReady.Click += ButtonOrderReady_Click;
+ //
+ // buttonIssuedOrder
+ //
+ buttonIssuedOrder.Location = new Point(934, 222);
+ buttonIssuedOrder.Name = "buttonIssuedOrder";
+ buttonIssuedOrder.Size = new Size(200, 37);
+ buttonIssuedOrder.TabIndex = 5;
+ buttonIssuedOrder.Text = "Заказ выдан";
+ buttonIssuedOrder.UseVisualStyleBackColor = true;
+ buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(934, 277);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(200, 37);
+ buttonUpd.TabIndex = 6;
+ buttonUpd.Text = "Обновить список";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += ButtonUpd_Click;
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1146, 450);
+ Controls.Add(buttonUpd);
+ Controls.Add(buttonIssuedOrder);
+ Controls.Add(buttonOrderReady);
+ Controls.Add(buttonTakeOrderInWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip);
+ MainMenuStrip = menuStrip;
+ Name = "FormMain";
+ Text = "Типография";
+ Load += FormMain_Load;
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private DataGridView dataGridView;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonUpd;
+ private ToolStripMenuItem компонентыToolStripMenuItem;
+ private ToolStripMenuItem изделиеToolStripMenuItem;
+ }
+}
\ No newline at end of file
diff --git a/TypographyView/FormMain.cs b/TypographyView/FormMain.cs
new file mode 100644
index 0000000..f60a245
--- /dev/null
+++ b/TypographyView/FormMain.cs
@@ -0,0 +1,170 @@
+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;
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using TypographyDataModels.Enums;
+
+namespace TypographyView
+{
+ public partial class FormMain : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IOrderLogic _orderLogic;
+
+ public FormMain(ILogger logger, IOrderLogic orderLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _orderLogic = orderLogic;
+ }
+
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["PrintedId"].Visible = false;
+ dataGridView.Columns["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Orders loading");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Orders loading error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ 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)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPrinteds));
+ if (service is FormPrinteds form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ButtonCreateOrder_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Order №{id}. Status changes to 'В работе'", id);
+ try
+ {
+ var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id));
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error taking an order to work");
+ 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("Order №{id}. Status changes to 'Готов'", id);
+ try
+ {
+ var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id));
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Order readiness marking error");
+ 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("Order №{id}. Status changes to 'Выдан'", id);
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id));
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ _logger.LogInformation("Order №{id} issued", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Order issue marking error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private OrderBindingModel CreateBindingModel(int id)
+ {
+ return new OrderBindingModel
+ {
+ Id = id,
+ PrintedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["PrintedId"].Value),
+ 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 = (System.DateTime)dataGridView.SelectedRows[0].Cells["DateCreate"].Value,
+ };
+ }
+ }
+}
diff --git a/TypographyView/FormMain.resx b/TypographyView/FormMain.resx
new file mode 100644
index 0000000..6c82d08
--- /dev/null
+++ b/TypographyView/FormMain.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/TypographyView/FormPrinted.Designer.cs b/TypographyView/FormPrinted.Designer.cs
new file mode 100644
index 0000000..d53c6ff
--- /dev/null
+++ b/TypographyView/FormPrinted.Designer.cs
@@ -0,0 +1,234 @@
+namespace TypographyView
+{
+ partial class FormPrinted
+ {
+ ///
+ /// 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()
+ {
+ labelName = new Label();
+ labelPrice = new Label();
+ textBoxName = new TextBox();
+ textBoxPrice = new TextBox();
+ groupBoxComponents = new GroupBox();
+ buttonUpd = new Button();
+ buttonDel = new Button();
+ buttonEdit = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ Columnid = new DataGridViewTextBoxColumn();
+ ColumnName = new DataGridViewTextBoxColumn();
+ ColumnCount = new DataGridViewTextBoxColumn();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ groupBoxComponents.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(11, 9);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(80, 20);
+ labelName.TabIndex = 0;
+ labelName.Text = "Название:";
+ //
+ // labelPrice
+ //
+ labelPrice.AutoSize = true;
+ labelPrice.Location = new Point(11, 56);
+ labelPrice.Name = "labelPrice";
+ labelPrice.Size = new Size(86, 20);
+ labelPrice.TabIndex = 1;
+ labelPrice.Text = "Стоимость:";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(98, 5);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(298, 27);
+ textBoxName.TabIndex = 2;
+ //
+ // textBoxPrice
+ //
+ textBoxPrice.Location = new Point(98, 53);
+ textBoxPrice.Name = "textBoxPrice";
+ textBoxPrice.Size = new Size(190, 27);
+ textBoxPrice.TabIndex = 3;
+ //
+ // groupBoxComponents
+ //
+ groupBoxComponents.Controls.Add(buttonUpd);
+ groupBoxComponents.Controls.Add(buttonDel);
+ groupBoxComponents.Controls.Add(buttonEdit);
+ groupBoxComponents.Controls.Add(buttonAdd);
+ groupBoxComponents.Controls.Add(dataGridView);
+ groupBoxComponents.Location = new Point(11, 85);
+ groupBoxComponents.Name = "groupBoxComponents";
+ groupBoxComponents.Size = new Size(776, 351);
+ groupBoxComponents.TabIndex = 4;
+ groupBoxComponents.TabStop = false;
+ groupBoxComponents.Text = "Компоненты";
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(622, 205);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(118, 36);
+ buttonUpd.TabIndex = 4;
+ buttonUpd.Text = "Обновить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += ButtonUpd_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(622, 151);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(118, 36);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += ButtonDel_Click;
+ //
+ // buttonEdit
+ //
+ buttonEdit.Location = new Point(622, 99);
+ buttonEdit.Name = "buttonEdit";
+ buttonEdit.Size = new Size(118, 36);
+ buttonEdit.TabIndex = 2;
+ buttonEdit.Text = "Изменить";
+ buttonEdit.UseVisualStyleBackColor = true;
+ buttonEdit.Click += ButtonEdit_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(622, 41);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(118, 36);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { Columnid, ColumnName, ColumnCount });
+ dataGridView.Location = new Point(6, 27);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(568, 319);
+ dataGridView.TabIndex = 0;
+ //
+ // Columnid
+ //
+ Columnid.HeaderText = "id";
+ Columnid.MinimumWidth = 6;
+ Columnid.Name = "Columnid";
+ Columnid.ReadOnly = true;
+ Columnid.Width = 125;
+ //
+ // ColumnName
+ //
+ ColumnName.HeaderText = "Компонент";
+ ColumnName.MinimumWidth = 6;
+ ColumnName.Name = "ColumnName";
+ ColumnName.ReadOnly = true;
+ ColumnName.Width = 280;
+ //
+ // ColumnCount
+ //
+ ColumnCount.HeaderText = "Количество";
+ ColumnCount.MinimumWidth = 6;
+ ColumnCount.Name = "ColumnCount";
+ ColumnCount.ReadOnly = true;
+ ColumnCount.Width = 125;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(546, 443);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(118, 36);
+ buttonSave.TabIndex = 5;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(670, 443);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(118, 36);
+ buttonCancel.TabIndex = 6;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormPrinted
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 491);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(groupBoxComponents);
+ Controls.Add(textBoxPrice);
+ Controls.Add(textBoxName);
+ Controls.Add(labelPrice);
+ Controls.Add(labelName);
+ Name = "FormPrinted";
+ Text = "Изделия";
+ Load += FormPrinted_Load;
+ groupBoxComponents.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelName;
+ private Label labelPrice;
+ private TextBox textBoxName;
+ private TextBox textBoxPrice;
+ private GroupBox groupBoxComponents;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn Columnid;
+ private DataGridViewTextBoxColumn ColumnName;
+ private DataGridViewTextBoxColumn ColumnCount;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonEdit;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/TypographyView/FormPrinted.cs b/TypographyView/FormPrinted.cs
new file mode 100644
index 0000000..b41844f
--- /dev/null
+++ b/TypographyView/FormPrinted.cs
@@ -0,0 +1,220 @@
+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;
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.SearchModels;
+using TypographyDataModels.Models;
+using Microsoft.Extensions.Logging;
+using Microsoft.VisualBasic.Logging;
+using NLog.Extensions.Logging;
+
+namespace TypographyView
+{
+ public partial class FormPrinted : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IPrintedLogic _logic;
+
+ private int? _id;
+
+ private Dictionary _printedComponents;
+
+ public int Id { set { _id = value; } }
+
+ public FormPrinted(ILogger logger, IPrintedLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _printedComponents = new Dictionary();
+ }
+
+ private void FormPrinted_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Printed loading");
+ try
+ {
+ var view = _logic.ReadElement(new PrintedSearchModel { Id = _id.Value });
+ if (view != null)
+ {
+ textBoxName.Text = view.PrintedName;
+ textBoxPrice.Text = view.Price.ToString();
+ _printedComponents = view.PrintedComponents ?? new Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Printed loading error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void LoadData()
+ {
+ _logger.LogInformation("Printed components loading");
+ try
+ {
+ if (_printedComponents != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var printedC in _printedComponents)
+ {
+ dataGridView.Rows.Add(new object[] { printedC.Key, printedC.Value.Item1.ComponentName, printedC.Value.Item2 });
+ }
+ textBoxPrice.Text = CalcPrice().ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Scank components loading error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPrintedComponent));
+ if (service is FormPrintedComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Adding new component: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
+ if (_printedComponents.ContainsKey(form.Id))
+ {
+ _printedComponents[form.Id] = (form.ComponentModel, form.Count);
+ }
+ else
+ {
+ _printedComponents.Add(form.Id, (form.ComponentModel, form.Count));
+ }
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonEdit_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPrintedComponent));
+ if (service is FormPrintedComponent form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _printedComponents[id].Item2;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Component editing: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
+ _printedComponents[form.Id] = (form.ComponentModel, form.Count);
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ try
+ {
+ _logger.LogInformation("Deletion of component: {ComponentName} - {Count}", dataGridView.SelectedRows[0].Cells[1].Value,
+ dataGridView.SelectedRows[0].Cells[2].Value);
+ _printedComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonUpd_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 (_printedComponents == null || _printedComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Printed saving");
+ try
+ {
+ var model = new PrintedBindingModel
+ {
+ Id = _id ?? 0,
+ PrintedName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ PrintedComponents = _printedComponents
+ };
+ 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, "Printed saving error");
+ 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 _printedComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/TypographyView/FormPrinted.resx b/TypographyView/FormPrinted.resx
new file mode 100644
index 0000000..f2ab3bf
--- /dev/null
+++ b/TypographyView/FormPrinted.resx
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/TypographyView/FormPrintedComponent.Designer.cs b/TypographyView/FormPrintedComponent.Designer.cs
new file mode 100644
index 0000000..e9b2dc0
--- /dev/null
+++ b/TypographyView/FormPrintedComponent.Designer.cs
@@ -0,0 +1,118 @@
+namespace TypographyView
+{
+ partial class FormPrintedComponent
+ {
+ ///
+ /// 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()
+ {
+ labelComponent = new Label();
+ labelCount = new Label();
+ comboBoxComponent = new ComboBox();
+ textBoxCount = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelComponent
+ //
+ labelComponent.AutoSize = true;
+ labelComponent.Location = new Point(29, 30);
+ labelComponent.Name = "labelComponent";
+ labelComponent.Size = new Size(91, 20);
+ labelComponent.TabIndex = 0;
+ labelComponent.Text = "Компонент:";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(29, 91);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(93, 20);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Количество:";
+ //
+ // comboBoxComponent
+ //
+ comboBoxComponent.FormattingEnabled = true;
+ comboBoxComponent.Location = new Point(147, 27);
+ comboBoxComponent.Name = "comboBoxComponent";
+ comboBoxComponent.Size = new Size(218, 28);
+ comboBoxComponent.TabIndex = 2;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(147, 88);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(218, 27);
+ textBoxCount.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(147, 155);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(106, 29);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(259, 155);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(106, 29);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormPrintedComponent
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(438, 214);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxCount);
+ Controls.Add(comboBoxComponent);
+ Controls.Add(labelCount);
+ Controls.Add(labelComponent);
+ Name = "FormPrintedComponent";
+ Text = "Компонент изделия";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelComponent;
+ private Label labelCount;
+ private ComboBox comboBoxComponent;
+ private TextBox textBoxCount;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/TypographyView/FormPrintedComponent.cs b/TypographyView/FormPrintedComponent.cs
new file mode 100644
index 0000000..f59e1a3
--- /dev/null
+++ b/TypographyView/FormPrintedComponent.cs
@@ -0,0 +1,87 @@
+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;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.ViewModels;
+using TypographyDataModels.Models;
+
+namespace TypographyView
+{
+ public partial class FormPrintedComponent : 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 FormPrintedComponent(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/TypographyView/FormPrintedComponent.resx b/TypographyView/FormPrintedComponent.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/TypographyView/FormPrintedComponent.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/TypographyView/FormPrinteds.Designer.cs b/TypographyView/FormPrinteds.Designer.cs
new file mode 100644
index 0000000..aef392b
--- /dev/null
+++ b/TypographyView/FormPrinteds.Designer.cs
@@ -0,0 +1,115 @@
+namespace TypographyView
+{
+ partial class FormPrinteds
+ {
+ ///
+ /// 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()
+ {
+ dataGridView = new DataGridView();
+ buttonAdd = new Button();
+ buttonEdit = new Button();
+ buttonDel = new Button();
+ buttonUpd = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(-1, 1);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(544, 448);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(579, 34);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(155, 55);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // buttonEdit
+ //
+ buttonEdit.Location = new Point(579, 114);
+ buttonEdit.Name = "buttonEdit";
+ buttonEdit.Size = new Size(155, 55);
+ buttonEdit.TabIndex = 2;
+ buttonEdit.Text = "Изменить";
+ buttonEdit.UseVisualStyleBackColor = true;
+ buttonEdit.Click += ButtonEdit_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(579, 196);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(155, 55);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += ButtonDel_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(579, 279);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(155, 55);
+ buttonUpd.TabIndex = 4;
+ buttonUpd.Text = "Обновить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += ButtonUpd_Click;
+ //
+ // FormPrinteds
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(771, 450);
+ Controls.Add(buttonUpd);
+ Controls.Add(buttonDel);
+ Controls.Add(buttonEdit);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Name = "FormPrinteds";
+ Text = "Изделия";
+ Load += FormPrinteds_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonEdit;
+ private Button buttonDel;
+ private Button buttonUpd;
+ }
+}
\ No newline at end of file
diff --git a/TypographyView/FormPrinteds.cs b/TypographyView/FormPrinteds.cs
new file mode 100644
index 0000000..2a5a2d6
--- /dev/null
+++ b/TypographyView/FormPrinteds.cs
@@ -0,0 +1,113 @@
+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;
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace TypographyView
+{
+ public partial class FormPrinteds : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IPrintedLogic _logic;
+
+ public FormPrinteds(ILogger logger, IPrintedLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormPrinteds_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["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["PrintedComponents"].Visible = false;
+ }
+ _logger.LogInformation("Ice creams loading");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ice creams loading error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPrinted));
+ if (service is FormPrinted form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonEdit_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPrinted));
+ if (service is FormPrinted 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("Deletion of ice cream");
+ try
+ {
+ if (!_logic.Delete(new PrintedBindingModel { Id = id }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ice cream deletion error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/TypographyView/FormPrinteds.resx b/TypographyView/FormPrinteds.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/TypographyView/FormPrinteds.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/TypographyView/Program.cs b/TypographyView/Program.cs
new file mode 100644
index 0000000..c3b8cca
--- /dev/null
+++ b/TypographyView/Program.cs
@@ -0,0 +1,53 @@
+using TypographyBusinessLogic.BusinessLogics;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.StoragesContracts;
+using TypographyListImplement.Implements;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+
+namespace TypographyView
+{
+ internal static class Program
+ {
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddLogging(option =>
+ {
+ option.SetMinimumLevel(LogLevel.Information);
+ option.AddNLog("nlog.config");
+ });
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ }
+ }
+}
\ No newline at end of file
diff --git a/TypographyView/Properties/Resources.Designer.cs b/TypographyView/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..de83124
--- /dev/null
+++ b/TypographyView/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace TypographyView.Properties {
+ using System;
+
+
+ ///
+ /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
+ ///
+ // Этот класс создан автоматически классом StronglyTypedResourceBuilder
+ // с помощью такого средства, как ResGen или Visual Studio.
+ // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
+ // с параметром /str или перестройте свой проект VS.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TypographyView.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Перезаписывает свойство CurrentUICulture текущего потока для всех
+ /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/SnackBarView/Form1.resx b/TypographyView/Properties/Resources.resx
similarity index 100%
rename from SnackBarView/Form1.resx
rename to TypographyView/Properties/Resources.resx
diff --git a/TypographyView/TypographyView.csproj b/TypographyView/TypographyView.csproj
new file mode 100644
index 0000000..443c7f0
--- /dev/null
+++ b/TypographyView/TypographyView.csproj
@@ -0,0 +1,28 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Always
+
+
+
+
\ No newline at end of file
diff --git a/TypographyView/TypographyView.sln b/TypographyView/TypographyView.sln
new file mode 100644
index 0000000..71b5d33
--- /dev/null
+++ b/TypographyView/TypographyView.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34525.116
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyView", "TypographyView.csproj", "{F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyListImplement", "..\TypographyListImplement\TypographyListImplement.csproj", "{9D223B95-71A3-4914-9532-A4D8B31288FD}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyDataModels", "..\TypographyDataModels\TypographyDataModels.csproj", "{11F46ADA-6833-42AD-BF19-78A7826BC741}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyContracts", "..\TypographyContracts\TypographyContracts.csproj", "{E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyBusinessLogic", "..\TypographyBusinessLogic\TypographyBusinessLogic.csproj", "{1057A33D-538D-4E7F-862B-1FF8E9E021A0}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9D223B95-71A3-4914-9532-A4D8B31288FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9D223B95-71A3-4914-9532-A4D8B31288FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9D223B95-71A3-4914-9532-A4D8B31288FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9D223B95-71A3-4914-9532-A4D8B31288FD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {11F46ADA-6833-42AD-BF19-78A7826BC741}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {11F46ADA-6833-42AD-BF19-78A7826BC741}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {11F46ADA-6833-42AD-BF19-78A7826BC741}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {11F46ADA-6833-42AD-BF19-78A7826BC741}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1057A33D-538D-4E7F-862B-1FF8E9E021A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1057A33D-538D-4E7F-862B-1FF8E9E021A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1057A33D-538D-4E7F-862B-1FF8E9E021A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1057A33D-538D-4E7F-862B-1FF8E9E021A0}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {90C6C176-8EEF-4A99-B848-F6B7B3FA6549}
+ EndGlobalSection
+EndGlobal
diff --git a/TypographyView/nlog.config b/TypographyView/nlog.config
new file mode 100644
index 0000000..6463869
--- /dev/null
+++ b/TypographyView/nlog.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file