diff --git a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.Designer.cs b/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.Designer.cs
deleted file mode 100644
index bafa436..0000000
--- a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace ProjectConfectionaryFactory
-{
- 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/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.cs b/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.cs
deleted file mode 100644
index 08db427..0000000
--- a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace ProjectConfectionaryFactory
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Program.cs b/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Program.cs
deleted file mode 100644
index 0f46185..0000000
--- a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Program.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace ProjectConfectionaryFactory
-{
- 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/ProjectConfectionaryFactory/ProjectConfectionaryFactory/ProjectConfectionaryFactory.csproj b/ProjectConfectionaryFactory/ProjectConfectionaryFactory/ProjectConfectionaryFactory.csproj
deleted file mode 100644
index 663fdb8..0000000
--- a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/ProjectConfectionaryFactory.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- WinExe
- net8.0-windows
- enable
- true
- enable
-
-
-
\ No newline at end of file
diff --git a/ProjectConfectionaryFactory/ProjectConfectionaryFactory.sln b/ProjectConfectioneryFactory/ProjectConfectioneryFactory.sln
similarity index 83%
rename from ProjectConfectionaryFactory/ProjectConfectionaryFactory.sln
rename to ProjectConfectioneryFactory/ProjectConfectioneryFactory.sln
index 9b2256b..b9d63df 100644
--- a/ProjectConfectionaryFactory/ProjectConfectionaryFactory.sln
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35222.181
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectConfectionaryFactory", "ProjectConfectionaryFactory\ProjectConfectionaryFactory.csproj", "{B7790CDB-40A9-4462-AA15-04C10DCFCF7B}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectConfectioneryFactory", "ProjectConfectioneryFactory\ProjectConfectioneryFactory.csproj", "{B7790CDB-40A9-4462-AA15-04C10DCFCF7B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Client.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Client.cs
new file mode 100644
index 0000000..c9c7d15
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Client.cs
@@ -0,0 +1,22 @@
+namespace ProjectConfectioneryFactory.Entities;
+
+public class Client
+{
+ public int Id { get; private set; }
+ public string Name { get; private set; } = string.Empty;
+ public string Surname { get; private set; } = string.Empty;
+ public double Phone { get; private set; }
+ public string Address { get; private set; } = string.Empty;
+
+ public static Client CreateEntity(int id, string name, string surname, double phone, string address)
+ {
+ return new Client
+ {
+ Id = id,
+ Name = name ?? string.Empty,
+ Surname = surname ?? string.Empty,
+ Phone = phone,
+ Address = address ?? string.Empty,
+ };
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Component.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Component.cs
new file mode 100644
index 0000000..078d406
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Component.cs
@@ -0,0 +1,20 @@
+namespace ProjectConfectioneryFactory.Entities;
+
+public class Component
+{
+ public int Id { get; private set; }
+ public string Name { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public double Weight { get; private set; }
+
+ public static Component CreateEntity(int id, string name, double price, double weight)
+ {
+ return new Component
+ {
+ Id = id,
+ Name = name ?? string.Empty,
+ Price = price,
+ Weight = weight
+ };
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Enums/ConfectioneryType.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Enums/ConfectioneryType.cs
new file mode 100644
index 0000000..44ce073
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Enums/ConfectioneryType.cs
@@ -0,0 +1,11 @@
+namespace ProjectConfectioneryFactory.Entities.Enums;
+
+[Flags]
+public enum ConfectioneryType
+{
+ None = 0,
+ Cake = 1,
+ Roll = 2,
+ Cupcake = 4,
+ Cookie = 8
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Order.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Order.cs
new file mode 100644
index 0000000..14e25d8
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Order.cs
@@ -0,0 +1,22 @@
+namespace ProjectConfectioneryFactory.Entities;
+
+public class Order
+{
+ public int Id { get; private set; }
+ public int ClientId { get; private set; }
+ public bool Completed { get; private set; }
+ public DateTime Date { get; private set; }
+ public IEnumerable OrderProducts { get; private set; } = [];
+
+ public static Order CreateOperation(int id, int clientid, bool completed, IEnumerable orderProducts)
+ {
+ return new Order
+ {
+ Id = id,
+ ClientId = clientid,
+ Completed = completed,
+ Date = DateTime.Now,
+ OrderProducts = orderProducts
+ };
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/OrderProduct.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/OrderProduct.cs
new file mode 100644
index 0000000..9fd3cbe
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/OrderProduct.cs
@@ -0,0 +1,18 @@
+namespace ProjectConfectioneryFactory.Entities;
+
+public class OrderProduct
+{
+ public int OrderId { get; private set; }
+ public int ProductId { get; private set; }
+ public int Count { get; private set; }
+
+ public static OrderProduct CreateEntity(int orderid, int productid, int count)
+ {
+ return new OrderProduct
+ {
+ OrderId = orderid,
+ ProductId = productid,
+ Count = count
+ };
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Product.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Product.cs
new file mode 100644
index 0000000..2759cf9
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Product.cs
@@ -0,0 +1,24 @@
+using ProjectConfectioneryFactory.Entities.Enums;
+
+namespace ProjectConfectioneryFactory.Entities;
+
+public class Product
+{
+ public int Id { get; private set; }
+ public ConfectioneryType ConfectioneryType { get; private set; }
+ public string Name { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public IEnumerable ProductComponents { get; private set; } = [];
+
+ public static Product CreateEntity(int id, ConfectioneryType сonfectionaryType, string name, double price, IEnumerable productComponents)
+ {
+ return new Product
+ {
+ Id = id,
+ ConfectioneryType = сonfectionaryType,
+ Name = name ?? string.Empty,
+ Price = price,
+ ProductComponents = productComponents
+ };
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/ProductComponent.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/ProductComponent.cs
new file mode 100644
index 0000000..a98179e
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/ProductComponent.cs
@@ -0,0 +1,18 @@
+namespace ProjectConfectioneryFactory.Entities;
+
+public class ProductComponent
+{
+ public int ProductId { get; private set; }
+ public int ComponentId { get; private set; }
+ public double Weight { get; private set; }
+
+ public static ProductComponent CreateEntity(int productid, int componentid, double weight)
+ {
+ return new ProductComponent
+ {
+ ProductId = productid,
+ ComponentId = componentid,
+ Weight = weight
+ };
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Supplier.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Supplier.cs
new file mode 100644
index 0000000..f2d2b1d
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Supplier.cs
@@ -0,0 +1,20 @@
+namespace ProjectConfectioneryFactory.Entities;
+
+public class Supplier
+{
+ public int Id { get; private set; }
+ public string Name { get; private set; } = string.Empty;
+ public double Phone { get; private set; }
+ public string Address { get; private set; } = string.Empty;
+
+ public static Supplier CreateEntity(int id, string name, double phone, string address)
+ {
+ return new Supplier
+ {
+ Id = id,
+ Name = name ?? string.Empty,
+ Phone = phone,
+ Address = address ?? string.Empty
+ };
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Supply.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Supply.cs
new file mode 100644
index 0000000..a1a102c
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Supply.cs
@@ -0,0 +1,24 @@
+namespace ProjectConfectioneryFactory.Entities;
+
+public class Supply
+{
+ public int Id { get; private set; }
+ public int SupplierId { get; private set; }
+ public int ComponentId { get; private set; }
+ public double Weight { get; private set; }
+ public bool Completed { get; private set; }
+ public DateTime Date { get; private set; }
+
+ public static Supply CreateOperation(int id, int supplierid, int componentid, double weight, bool completed)
+ {
+ return new Supply
+ {
+ Id = id,
+ SupplierId = supplierid,
+ ComponentId = componentid,
+ Weight = weight,
+ Completed = completed,
+ Date = DateTime.Now
+ };
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/FormConfectioneryFactory.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/FormConfectioneryFactory.Designer.cs
new file mode 100644
index 0000000..0d97521
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/FormConfectioneryFactory.Designer.cs
@@ -0,0 +1,146 @@
+namespace ProjectConfectioneryFactory
+{
+ partial class FormConfectioneryFactory
+ {
+ ///
+ /// 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()
+ {
+ menuStrip1 = new MenuStrip();
+ справочникиToolStripMenuItem = new ToolStripMenuItem();
+ ClientsToolStripMenuItem = new ToolStripMenuItem();
+ ProductsToolStripMenuItem = new ToolStripMenuItem();
+ ComponentsToolStripMenuItem = new ToolStripMenuItem();
+ SuppliersToolStripMenuItem = new ToolStripMenuItem();
+ операцииToolStripMenuItem = new ToolStripMenuItem();
+ OrdersToolStripMenuItem = new ToolStripMenuItem();
+ SupplysToolStripMenuItem = new ToolStripMenuItem();
+ отчётыToolStripMenuItem = new ToolStripMenuItem();
+ menuStrip1.SuspendLayout();
+ SuspendLayout();
+ //
+ // menuStrip1
+ //
+ menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem });
+ menuStrip1.Location = new Point(0, 0);
+ menuStrip1.Name = "menuStrip1";
+ menuStrip1.Size = new Size(784, 24);
+ menuStrip1.TabIndex = 0;
+ menuStrip1.Text = "menuStrip1";
+ //
+ // справочникиToolStripMenuItem
+ //
+ справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ClientsToolStripMenuItem, ProductsToolStripMenuItem, ComponentsToolStripMenuItem, SuppliersToolStripMenuItem });
+ справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ справочникиToolStripMenuItem.Size = new Size(94, 20);
+ справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // ClientsToolStripMenuItem
+ //
+ ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
+ ClientsToolStripMenuItem.Size = new Size(180, 22);
+ ClientsToolStripMenuItem.Text = "Клиенты";
+ ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
+ //
+ // ProductsToolStripMenuItem
+ //
+ ProductsToolStripMenuItem.Name = "ProductsToolStripMenuItem";
+ ProductsToolStripMenuItem.Size = new Size(180, 22);
+ ProductsToolStripMenuItem.Text = "Продукты";
+ ProductsToolStripMenuItem.Click += ProductsToolStripMenuItem_Click;
+ //
+ // ComponentsToolStripMenuItem
+ //
+ ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
+ ComponentsToolStripMenuItem.Size = new Size(180, 22);
+ ComponentsToolStripMenuItem.Text = "Компоненты";
+ ComponentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
+ //
+ // SuppliersToolStripMenuItem
+ //
+ SuppliersToolStripMenuItem.Name = "SuppliersToolStripMenuItem";
+ SuppliersToolStripMenuItem.Size = new Size(180, 22);
+ SuppliersToolStripMenuItem.Text = "Поставщики";
+ SuppliersToolStripMenuItem.Click += SuppliersToolStripMenuItem_Click;
+ //
+ // операцииToolStripMenuItem
+ //
+ операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { OrdersToolStripMenuItem, SupplysToolStripMenuItem });
+ операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
+ операцииToolStripMenuItem.Size = new Size(75, 20);
+ операцииToolStripMenuItem.Text = "Операции";
+ //
+ // OrdersToolStripMenuItem
+ //
+ OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
+ OrdersToolStripMenuItem.Size = new Size(180, 22);
+ OrdersToolStripMenuItem.Text = "Заказы";
+ OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
+ //
+ // SupplysToolStripMenuItem
+ //
+ SupplysToolStripMenuItem.Name = "SupplysToolStripMenuItem";
+ SupplysToolStripMenuItem.Size = new Size(180, 22);
+ SupplysToolStripMenuItem.Text = "Поставки";
+ SupplysToolStripMenuItem.Click += SupplysToolStripMenuItem_Click;
+ //
+ // отчётыToolStripMenuItem
+ //
+ отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
+ отчётыToolStripMenuItem.Size = new Size(60, 20);
+ отчётыToolStripMenuItem.Text = "Отчёты";
+ //
+ // FormConfectioneryFactory
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ BackgroundImage = Properties.Resources.Croissant;
+ BackgroundImageLayout = ImageLayout.Stretch;
+ ClientSize = new Size(784, 411);
+ Controls.Add(menuStrip1);
+ MainMenuStrip = menuStrip1;
+ Name = "FormConfectioneryFactory";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Кондитерская фабрика";
+ menuStrip1.ResumeLayout(false);
+ menuStrip1.PerformLayout();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private ToolStripMenuItem ClientsToolStripMenuItem;
+ private ToolStripMenuItem операцииToolStripMenuItem;
+ private ToolStripMenuItem отчётыToolStripMenuItem;
+ private ToolStripMenuItem ProductsToolStripMenuItem;
+ private ToolStripMenuItem ComponentsToolStripMenuItem;
+ private ToolStripMenuItem SuppliersToolStripMenuItem;
+ private ToolStripMenuItem OrdersToolStripMenuItem;
+ private ToolStripMenuItem SupplysToolStripMenuItem;
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/FormConfectioneryFactory.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/FormConfectioneryFactory.cs
new file mode 100644
index 0000000..d220194
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/FormConfectioneryFactory.cs
@@ -0,0 +1,93 @@
+using ProjectConfectioneryFactory.Forms;
+using Unity;
+
+namespace ProjectConfectioneryFactory
+{
+ public partial class FormConfectioneryFactory : Form
+ {
+ private readonly IUnityContainer _container;
+
+ public FormConfectioneryFactory(IUnityContainer container)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ }
+
+ private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ProductsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void SuppliersToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void SupplysToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/FormConfectioneryFactory.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/FormConfectioneryFactory.resx
new file mode 100644
index 0000000..b48baf1
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/FormConfectioneryFactory.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/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.Designer.cs
new file mode 100644
index 0000000..762cd2a
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.Designer.cs
@@ -0,0 +1,165 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ partial class FormClient
+ {
+ ///
+ /// 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()
+ {
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ textBoxClientName = new TextBox();
+ label3 = new Label();
+ label2 = new Label();
+ label1 = new Label();
+ textBoxClientSurname = new TextBox();
+ label4 = new Label();
+ textBoxAddress = new TextBox();
+ maskedTextBoxPhone = new MaskedTextBox();
+ SuspendLayout();
+ //
+ // buttonCancel
+ //
+ buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonCancel.Location = new Point(297, 216);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 15;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonSave.Location = new Point(216, 216);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 14;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // textBoxClientName
+ //
+ textBoxClientName.Location = new Point(115, 30);
+ textBoxClientName.Name = "textBoxClientName";
+ textBoxClientName.Size = new Size(207, 23);
+ textBoxClientName.TabIndex = 11;
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(66, 161);
+ label3.Name = "label3";
+ label3.Size = new Size(43, 15);
+ label3.TabIndex = 10;
+ label3.Text = "Адрес:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(51, 117);
+ label2.Name = "label2";
+ label2.Size = new Size(58, 15);
+ label2.TabIndex = 9;
+ label2.Text = "Телефон:";
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(75, 33);
+ label1.Name = "label1";
+ label1.Size = new Size(34, 15);
+ label1.TabIndex = 8;
+ label1.Text = "Имя:";
+ //
+ // textBoxClientSurname
+ //
+ textBoxClientSurname.Location = new Point(115, 71);
+ textBoxClientSurname.Name = "textBoxClientSurname";
+ textBoxClientSurname.Size = new Size(207, 23);
+ textBoxClientSurname.TabIndex = 17;
+ //
+ // label4
+ //
+ label4.AutoSize = true;
+ label4.Location = new Point(48, 74);
+ label4.Name = "label4";
+ label4.Size = new Size(61, 15);
+ label4.TabIndex = 16;
+ label4.Text = "Фамилия:";
+ //
+ // textBoxAddress
+ //
+ textBoxAddress.Location = new Point(115, 158);
+ textBoxAddress.Name = "textBoxAddress";
+ textBoxAddress.Size = new Size(207, 23);
+ textBoxAddress.TabIndex = 18;
+ //
+ // maskedTextBoxPhone
+ //
+ maskedTextBoxPhone.Location = new Point(115, 114);
+ maskedTextBoxPhone.Mask = "+7 (999) 000-0000";
+ maskedTextBoxPhone.Name = "maskedTextBoxPhone";
+ maskedTextBoxPhone.Size = new Size(207, 23);
+ maskedTextBoxPhone.TabIndex = 19;
+ //
+ // FormClient
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(384, 251);
+ Controls.Add(maskedTextBoxPhone);
+ Controls.Add(textBoxAddress);
+ Controls.Add(textBoxClientSurname);
+ Controls.Add(label4);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxClientName);
+ Controls.Add(label3);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Name = "FormClient";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Клиент";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonCancel;
+ private Button buttonSave;
+ private TextBox textBoxClientName;
+ private Label label3;
+ private Label label2;
+ private Label label1;
+ private TextBox textBoxClientSurname;
+ private Label label4;
+ private TextBox textBoxAddress;
+ private MaskedTextBox maskedTextBoxPhone;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.cs
new file mode 100644
index 0000000..af390ac
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.cs
@@ -0,0 +1,72 @@
+using ProjectConfectioneryFactory.Entities;
+using ProjectConfectioneryFactory.Repositories;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormClient : Form
+ {
+ private readonly IClientRepository _clientRepository;
+
+ private int? _clientId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var client = _clientRepository.ReadClientById(value);
+ if (client == null)
+ {
+ throw new InvalidDataException(nameof(client));
+ }
+ textBoxClientName.Text = client.Name;
+ textBoxClientSurname.Text = client.Surname;
+ maskedTextBoxPhone.Text = client.Phone.ToString();
+ textBoxAddress.Text = client.Address;
+ _clientId = value;
+ }
+ catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
+ }
+ }
+
+ public FormClient(IClientRepository clientRepository)
+ {
+ InitializeComponent();
+ _clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxClientName.Text) || string.IsNullOrWhiteSpace(textBoxClientSurname.Text) || string.IsNullOrWhiteSpace(maskedTextBoxPhone.Text) || string.IsNullOrWhiteSpace(textBoxAddress.Text))
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_clientId.HasValue)
+ {
+ _clientRepository.UpdateClient(CreateClient(_clientId.Value));
+ }
+ else
+ {
+ _clientRepository.CreateClient(CreateClient(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Client CreateClient(int id) => Client.CreateEntity(
+ id,
+ textBoxClientName.Text,
+ textBoxClientSurname.Text,
+ Double.Parse(maskedTextBoxPhone.Text),
+ textBoxAddress.Text);
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.resx
new file mode 100644
index 0000000..8b2ff64
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.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/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClients.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClients.Designer.cs
new file mode 100644
index 0000000..578aa2d
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClients.Designer.cs
@@ -0,0 +1,126 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ partial class FormClients
+ {
+ ///
+ /// 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()
+ {
+ dataGridViewData = new DataGridView();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonAdd = new Button();
+ panel1 = new Panel();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
+ panel1.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridViewData
+ //
+ dataGridViewData.AllowUserToAddRows = false;
+ dataGridViewData.AllowUserToDeleteRows = false;
+ dataGridViewData.AllowUserToResizeColumns = false;
+ dataGridViewData.AllowUserToResizeRows = false;
+ dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewData.Dock = DockStyle.Fill;
+ dataGridViewData.Location = new Point(0, 0);
+ dataGridViewData.MultiSelect = false;
+ dataGridViewData.Name = "dataGridViewData";
+ dataGridViewData.ReadOnly = true;
+ dataGridViewData.RowHeadersVisible = false;
+ dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewData.Size = new Size(709, 450);
+ dataGridViewData.TabIndex = 3;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.BackgroundImage = Properties.Resources.Update;
+ buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdate.Location = new Point(14, 83);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(65, 65);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.BackgroundImage = Properties.Resources.Delete;
+ buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDelete.Location = new Point(14, 154);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(65, 65);
+ buttonDelete.TabIndex = 1;
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(14, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(65, 65);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // panel1
+ //
+ panel1.Controls.Add(buttonUpdate);
+ panel1.Controls.Add(buttonDelete);
+ panel1.Controls.Add(buttonAdd);
+ panel1.Dock = DockStyle.Right;
+ panel1.Location = new Point(709, 0);
+ panel1.Name = "panel1";
+ panel1.Size = new Size(91, 450);
+ panel1.TabIndex = 2;
+ //
+ // FormClients
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridViewData);
+ Controls.Add(panel1);
+ Name = "FormClients";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Клиенты";
+ Load += FormClients_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
+ panel1.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridViewData;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonAdd;
+ private Panel panel1;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClients.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClients.cs
new file mode 100644
index 0000000..490e18f
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClients.cs
@@ -0,0 +1,80 @@
+using ProjectConfectioneryFactory.Repositories;
+using Unity;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormClients : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IClientRepository _clientRepository;
+ public FormClients(IUnityContainer container, IClientRepository clientRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
+ }
+ private void FormClients_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ try
+ {
+ var form = _container.Resolve();
+ form.Id = findId;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; }
+ try
+ {
+ _clientRepository.DeleteClient(findId); LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void LoadList() => dataGridViewData.DataSource = _clientRepository.ReadClients();
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClients.resx
similarity index 93%
rename from ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.resx
rename to ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClients.resx
index 1af7de1..af32865 100644
--- a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.resx
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClients.resx
@@ -1,17 +1,17 @@
-
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponent.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponent.Designer.cs
new file mode 100644
index 0000000..7406365
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponent.Designer.cs
@@ -0,0 +1,152 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ 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()
+ {
+ label1 = new Label();
+ label2 = new Label();
+ label3 = new Label();
+ textBoxComponentName = new TextBox();
+ numericUpDownPrice = new NumericUpDown();
+ numericUpDownWeight = new NumericUpDown();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
+ SuspendLayout();
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(12, 38);
+ label1.Name = "label1";
+ label1.Size = new Size(132, 15);
+ label1.TabIndex = 0;
+ label1.Text = "Название компонента:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(106, 84);
+ label2.Name = "label2";
+ label2.Size = new Size(38, 15);
+ label2.TabIndex = 1;
+ label2.Text = "Цена:";
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(115, 130);
+ label3.Name = "label3";
+ label3.Size = new Size(29, 15);
+ label3.TabIndex = 2;
+ label3.Text = "Вес:";
+ //
+ // textBoxComponentName
+ //
+ textBoxComponentName.Location = new Point(150, 35);
+ textBoxComponentName.Name = "textBoxComponentName";
+ textBoxComponentName.Size = new Size(207, 23);
+ textBoxComponentName.TabIndex = 3;
+ //
+ // numericUpDownPrice
+ //
+ numericUpDownPrice.DecimalPlaces = 2;
+ numericUpDownPrice.Location = new Point(150, 82);
+ numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
+ numericUpDownPrice.Name = "numericUpDownPrice";
+ numericUpDownPrice.Size = new Size(96, 23);
+ numericUpDownPrice.TabIndex = 4;
+ numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 131072 });
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.DecimalPlaces = 3;
+ numericUpDownWeight.Location = new Point(150, 128);
+ numericUpDownWeight.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
+ numericUpDownWeight.Name = "numericUpDownWeight";
+ numericUpDownWeight.Size = new Size(96, 23);
+ numericUpDownWeight.TabIndex = 5;
+ numericUpDownWeight.Value = new decimal(new int[] { 1, 0, 0, 196608 });
+ //
+ // buttonSave
+ //
+ buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonSave.Location = new Point(211, 200);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonCancel.Location = new Point(292, 200);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 7;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormComponent
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(384, 236);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(numericUpDownWeight);
+ Controls.Add(numericUpDownPrice);
+ Controls.Add(textBoxComponentName);
+ Controls.Add(label3);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Name = "FormComponent";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Компонент";
+ ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label label2;
+ private Label label3;
+ private TextBox textBoxComponentName;
+ private NumericUpDown numericUpDownPrice;
+ private NumericUpDown numericUpDownWeight;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponent.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponent.cs
new file mode 100644
index 0000000..6b38436
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponent.cs
@@ -0,0 +1,70 @@
+using ProjectConfectioneryFactory.Entities;
+using ProjectConfectioneryFactory.Repositories;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormComponent : Form
+ {
+ private readonly IComponentRepository _componentRepository;
+
+ private int? _componentId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var component = _componentRepository.ReadComponentById(value);
+ if (component == null)
+ {
+ throw new InvalidDataException(nameof(component));
+ }
+ textBoxComponentName.Text = component.Name;
+ numericUpDownPrice.Value = (decimal)component.Price;
+ numericUpDownWeight.Value = (decimal)component.Weight;
+ _componentId = value;
+ }
+ catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
+ }
+ }
+
+ public FormComponent(IComponentRepository componentRepository)
+ {
+ InitializeComponent();
+ _componentRepository = componentRepository ?? throw new ArgumentNullException(nameof(componentRepository));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxComponentName.Text))
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_componentId.HasValue)
+ {
+ _componentRepository.UpdateComponent(CreateComponent(_componentId.Value));
+ }
+ else
+ {
+ _componentRepository.CreateComponent(CreateComponent(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Component CreateComponent(int id) => Component.CreateEntity(
+ id,
+ textBoxComponentName.Text,
+ Convert.ToInt32(numericUpDownPrice.Value),
+ Convert.ToDouble(numericUpDownWeight.Value));
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponent.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponent.resx
new file mode 100644
index 0000000..8b2ff64
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/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/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponents.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponents.Designer.cs
new file mode 100644
index 0000000..228586f
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponents.Designer.cs
@@ -0,0 +1,126 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ 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()
+ {
+ panel1 = new Panel();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonAdd = new Button();
+ dataGridViewData = new DataGridView();
+ panel1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
+ SuspendLayout();
+ //
+ // panel1
+ //
+ panel1.Controls.Add(buttonUpdate);
+ panel1.Controls.Add(buttonDelete);
+ panel1.Controls.Add(buttonAdd);
+ panel1.Dock = DockStyle.Right;
+ panel1.Location = new Point(709, 0);
+ panel1.Name = "panel1";
+ panel1.Size = new Size(91, 450);
+ panel1.TabIndex = 0;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.BackgroundImage = Properties.Resources.Update;
+ buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdate.Location = new Point(14, 83);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(65, 65);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.BackgroundImage = Properties.Resources.Delete;
+ buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDelete.Location = new Point(14, 154);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(65, 65);
+ buttonDelete.TabIndex = 1;
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(14, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(65, 65);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridViewData
+ //
+ dataGridViewData.AllowUserToAddRows = false;
+ dataGridViewData.AllowUserToDeleteRows = false;
+ dataGridViewData.AllowUserToResizeColumns = false;
+ dataGridViewData.AllowUserToResizeRows = false;
+ dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewData.Dock = DockStyle.Fill;
+ dataGridViewData.Location = new Point(0, 0);
+ dataGridViewData.MultiSelect = false;
+ dataGridViewData.Name = "dataGridViewData";
+ dataGridViewData.ReadOnly = true;
+ dataGridViewData.RowHeadersVisible = false;
+ dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewData.Size = new Size(709, 450);
+ dataGridViewData.TabIndex = 1;
+ //
+ // FormComponents
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridViewData);
+ Controls.Add(panel1);
+ Name = "FormComponents";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Компоненты";
+ Load += FormComponents_Load;
+ panel1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel panel1;
+ private Button buttonAdd;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private DataGridView dataGridViewData;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponents.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponents.cs
new file mode 100644
index 0000000..3f7a898
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponents.cs
@@ -0,0 +1,80 @@
+using ProjectConfectioneryFactory.Repositories;
+using Unity;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormComponents : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IComponentRepository _componentRepository;
+ public FormComponents(IUnityContainer container, IComponentRepository componentRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _componentRepository = componentRepository ?? throw new ArgumentNullException(nameof(componentRepository));
+ }
+ private void FormComponents_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ try
+ {
+ var form = _container.Resolve();
+ form.Id = findId;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; }
+ try
+ {
+ _componentRepository.DeleteComponent(findId); LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void LoadList() => dataGridViewData.DataSource = _componentRepository.ReadComponents();
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponents.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormComponents.resx
new file mode 100644
index 0000000..8b2ff64
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/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/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrder.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrder.Designer.cs
new file mode 100644
index 0000000..307f046
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrder.Designer.cs
@@ -0,0 +1,197 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ partial class FormOrder
+ {
+ ///
+ /// 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()
+ {
+ label4 = new Label();
+ label1 = new Label();
+ checkBoxCompleted = new CheckBox();
+ comboBoxClient = new ComboBox();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ label2 = new Label();
+ dateTimePickerOrderDate = new DateTimePicker();
+ groupBox1 = new GroupBox();
+ dataGridViewProducts = new DataGridView();
+ ColumnProductName = new DataGridViewComboBoxColumn();
+ ColumnProductCount = new DataGridViewTextBoxColumn();
+ groupBox1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewProducts).BeginInit();
+ SuspendLayout();
+ //
+ // label4
+ //
+ label4.AutoSize = true;
+ label4.Location = new Point(49, 64);
+ label4.Name = "label4";
+ label4.Size = new Size(67, 15);
+ label4.TabIndex = 18;
+ label4.Text = "Выполнен:";
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(67, 24);
+ label1.Name = "label1";
+ label1.Size = new Size(49, 15);
+ label1.TabIndex = 17;
+ label1.Text = "Клиент:";
+ //
+ // checkBoxCompleted
+ //
+ checkBoxCompleted.AutoSize = true;
+ checkBoxCompleted.Location = new Point(122, 65);
+ checkBoxCompleted.Name = "checkBoxCompleted";
+ checkBoxCompleted.Size = new Size(15, 14);
+ checkBoxCompleted.TabIndex = 19;
+ checkBoxCompleted.UseVisualStyleBackColor = true;
+ //
+ // comboBoxClient
+ //
+ comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxClient.FormattingEnabled = true;
+ comboBoxClient.Location = new Point(122, 21);
+ comboBoxClient.Name = "comboBoxClient";
+ comboBoxClient.Size = new Size(210, 23);
+ comboBoxClient.TabIndex = 20;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonCancel.Location = new Point(297, 416);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 22;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonSave.Location = new Point(216, 416);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 21;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(81, 104);
+ label2.Name = "label2";
+ label2.Size = new Size(35, 15);
+ label2.TabIndex = 23;
+ label2.Text = "Дата:";
+ //
+ // dateTimePickerOrderDate
+ //
+ dateTimePickerOrderDate.Enabled = false;
+ dateTimePickerOrderDate.Location = new Point(122, 98);
+ dateTimePickerOrderDate.Name = "dateTimePickerOrderDate";
+ dateTimePickerOrderDate.Size = new Size(200, 23);
+ dateTimePickerOrderDate.TabIndex = 24;
+ //
+ // groupBox1
+ //
+ groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ groupBox1.Controls.Add(dataGridViewProducts);
+ groupBox1.Location = new Point(12, 137);
+ groupBox1.Name = "groupBox1";
+ groupBox1.Size = new Size(360, 263);
+ groupBox1.TabIndex = 25;
+ groupBox1.TabStop = false;
+ groupBox1.Text = "Продукты";
+ //
+ // dataGridViewProducts
+ //
+ dataGridViewProducts.AllowUserToResizeColumns = false;
+ dataGridViewProducts.AllowUserToResizeRows = false;
+ dataGridViewProducts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridViewProducts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewProducts.Columns.AddRange(new DataGridViewColumn[] { ColumnProductName, ColumnProductCount });
+ dataGridViewProducts.Location = new Point(6, 22);
+ dataGridViewProducts.MultiSelect = false;
+ dataGridViewProducts.Name = "dataGridViewProducts";
+ dataGridViewProducts.RowHeadersVisible = false;
+ dataGridViewProducts.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewProducts.Size = new Size(354, 242);
+ dataGridViewProducts.TabIndex = 0;
+ //
+ // ColumnProductName
+ //
+ ColumnProductName.HeaderText = "Продукт";
+ ColumnProductName.Name = "ColumnProductName";
+ //
+ // ColumnProductCount
+ //
+ ColumnProductCount.HeaderText = "Количество";
+ ColumnProductCount.Name = "ColumnProductCount";
+ //
+ // FormOrder
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(384, 451);
+ Controls.Add(groupBox1);
+ Controls.Add(dateTimePickerOrderDate);
+ Controls.Add(label2);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(comboBoxClient);
+ Controls.Add(checkBoxCompleted);
+ Controls.Add(label4);
+ Controls.Add(label1);
+ Name = "FormOrder";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Заказ";
+ groupBox1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridViewProducts).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label4;
+ private Label label1;
+ private CheckBox checkBoxCompleted;
+ private ComboBox comboBoxClient;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private Label label2;
+ private DateTimePicker dateTimePickerOrderDate;
+ private GroupBox groupBox1;
+ private DataGridView dataGridViewProducts;
+ private DataGridViewComboBoxColumn ColumnProductName;
+ private DataGridViewTextBoxColumn ColumnProductCount;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrder.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrder.cs
new file mode 100644
index 0000000..fd32974
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrder.cs
@@ -0,0 +1,94 @@
+using ProjectConfectioneryFactory.Entities;
+using ProjectConfectioneryFactory.Repositories;
+using ProjectConfectioneryFactory.Repositories.Implementations;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormOrder : Form
+ {
+ private readonly IOrderRepository _orderRepository;
+
+ private int? _orderId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var order = _orderRepository.ReadOrderById(value);
+ if (order == null)
+ {
+ throw new InvalidDataException(nameof(order));
+ }
+ checkBoxCompleted.Enabled = order.Completed;
+ _orderId = value;
+ }
+ catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
+ }
+ }
+
+ public FormOrder(IOrderRepository orderRepository, IClientRepository clientRepository, IProductRepository productRepository)
+ {
+ InitializeComponent();
+ _orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
+ comboBoxClient.DataSource = clientRepository.ReadClients();
+ comboBoxClient.DisplayMember = "FirstName";
+ comboBoxClient.ValueMember = "Id";
+
+ ColumnProductName.DataSource = productRepository.ReadProducts();
+ ColumnProductName.DisplayMember = "Name";
+ ColumnProductName.ValueMember = "Id";
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0)
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_orderId.HasValue)
+ {
+ _orderRepository.UpdateOrder(CreateOrder(_orderId.Value));
+ }
+ else
+ {
+ _orderRepository.CreateOrder(CreateOrder(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private ListCreateListOrderProductFromDataGrid()
+ {
+ var list = new List();
+ foreach (DataGridViewRow row in dataGridViewProducts.Rows)
+ {
+ if (row.Cells["ColumnProductsName"].Value == null ||
+ row.Cells["ColumnProductCount"].Value == null)
+ {
+ continue;
+ }
+ list.Add(OrderProduct.CreateEntity(0,
+ Convert.ToInt32(row.Cells["ColumnProductsName"].Value),
+ Convert.ToInt32(row.Cells["ColumnProductCount"].Value)));
+ }
+ return list;
+ }
+
+ private Order CreateOrder(int id) => Order.CreateOperation(0,
+ (int)comboBoxClient.SelectedValue!,
+ checkBoxCompleted.Checked,
+ CreateListOrderProductFromDataGrid());
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrder.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrder.resx
new file mode 100644
index 0000000..bb53cc1
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrder.resx
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ True
+
+
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrders.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrders.Designer.cs
new file mode 100644
index 0000000..375499f
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrders.Designer.cs
@@ -0,0 +1,126 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ partial class FormOrders
+ {
+ ///
+ /// 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()
+ {
+ buttonAdd = new Button();
+ dataGridViewData = new DataGridView();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ panel1 = new Panel();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
+ panel1.SuspendLayout();
+ SuspendLayout();
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(14, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(65, 65);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridViewData
+ //
+ dataGridViewData.AllowUserToAddRows = false;
+ dataGridViewData.AllowUserToDeleteRows = false;
+ dataGridViewData.AllowUserToResizeColumns = false;
+ dataGridViewData.AllowUserToResizeRows = false;
+ dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewData.Dock = DockStyle.Fill;
+ dataGridViewData.Location = new Point(0, 0);
+ dataGridViewData.MultiSelect = false;
+ dataGridViewData.Name = "dataGridViewData";
+ dataGridViewData.ReadOnly = true;
+ dataGridViewData.RowHeadersVisible = false;
+ dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewData.Size = new Size(709, 450);
+ dataGridViewData.TabIndex = 5;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.BackgroundImage = Properties.Resources.Update;
+ buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdate.Location = new Point(14, 83);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(65, 65);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.BackgroundImage = Properties.Resources.Delete;
+ buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDelete.Location = new Point(14, 154);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(65, 65);
+ buttonDelete.TabIndex = 1;
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // panel1
+ //
+ panel1.Controls.Add(buttonUpdate);
+ panel1.Controls.Add(buttonDelete);
+ panel1.Controls.Add(buttonAdd);
+ panel1.Dock = DockStyle.Right;
+ panel1.Location = new Point(709, 0);
+ panel1.Name = "panel1";
+ panel1.Size = new Size(91, 450);
+ panel1.TabIndex = 4;
+ //
+ // FormOrders
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridViewData);
+ Controls.Add(panel1);
+ Name = "FormOrders";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "FormOrders";
+ Load += FormOrders_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
+ panel1.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonAdd;
+ private DataGridView dataGridViewData;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Panel panel1;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrders.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrders.cs
new file mode 100644
index 0000000..bc5ec03
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrders.cs
@@ -0,0 +1,80 @@
+using ProjectConfectioneryFactory.Repositories;
+using Unity;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormOrders : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IOrderRepository _orderRepository;
+ public FormOrders(IUnityContainer container, IOrderRepository orderRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
+ }
+ private void FormOrders_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ try
+ {
+ var form = _container.Resolve();
+ form.Id = findId;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; }
+ try
+ {
+ _orderRepository.DeleteOrder(findId); LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void LoadList() => dataGridViewData.DataSource = _orderRepository.ReadOrders();
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrders.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrders.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormOrders.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/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProduct.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProduct.Designer.cs
new file mode 100644
index 0000000..6ea107f
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProduct.Designer.cs
@@ -0,0 +1,198 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ partial class FormProduct
+ {
+ ///
+ /// 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()
+ {
+ numericUpDownPrice = new NumericUpDown();
+ textBoxProductName = new TextBox();
+ label2 = new Label();
+ label1 = new Label();
+ label3 = new Label();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ checkedListBoxConfectioneryType = new CheckedListBox();
+ groupBox1 = new GroupBox();
+ dataGridViewComponents = new DataGridView();
+ ColumnComponent = new DataGridViewComboBoxColumn();
+ ColumnWeight = new DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
+ groupBox1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewComponents).BeginInit();
+ SuspendLayout();
+ //
+ // numericUpDownPrice
+ //
+ numericUpDownPrice.DecimalPlaces = 2;
+ numericUpDownPrice.Location = new Point(150, 201);
+ numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
+ numericUpDownPrice.Name = "numericUpDownPrice";
+ numericUpDownPrice.Size = new Size(96, 23);
+ numericUpDownPrice.TabIndex = 8;
+ numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 131072 });
+ //
+ // textBoxProductName
+ //
+ textBoxProductName.Location = new Point(150, 161);
+ textBoxProductName.Name = "textBoxProductName";
+ textBoxProductName.Size = new Size(207, 23);
+ textBoxProductName.TabIndex = 7;
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(106, 203);
+ label2.Name = "label2";
+ label2.Size = new Size(38, 15);
+ label2.TabIndex = 6;
+ label2.Text = "Цена:";
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(29, 164);
+ label1.Name = "label1";
+ label1.Size = new Size(115, 15);
+ label1.TabIndex = 5;
+ label1.Text = "Название продукта:";
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(61, 31);
+ label3.Name = "label3";
+ label3.Size = new Size(83, 15);
+ label3.TabIndex = 9;
+ label3.Text = "Вид продукта:";
+ //
+ // buttonCancel
+ //
+ buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonCancel.Location = new Point(297, 544);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 11;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonSave.Location = new Point(216, 544);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 10;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // checkedListBoxConfectioneryType
+ //
+ checkedListBoxConfectioneryType.FormattingEnabled = true;
+ checkedListBoxConfectioneryType.Location = new Point(150, 31);
+ checkedListBoxConfectioneryType.Name = "checkedListBoxConfectioneryType";
+ checkedListBoxConfectioneryType.Size = new Size(207, 112);
+ checkedListBoxConfectioneryType.TabIndex = 12;
+ //
+ // groupBox1
+ //
+ groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ groupBox1.Controls.Add(dataGridViewComponents);
+ groupBox1.Location = new Point(12, 241);
+ groupBox1.Name = "groupBox1";
+ groupBox1.Size = new Size(360, 273);
+ groupBox1.TabIndex = 26;
+ groupBox1.TabStop = false;
+ groupBox1.Text = "Компоненты";
+ //
+ // dataGridViewComponents
+ //
+ dataGridViewComponents.AllowUserToResizeColumns = false;
+ dataGridViewComponents.AllowUserToResizeRows = false;
+ dataGridViewComponents.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewComponents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewComponents.Columns.AddRange(new DataGridViewColumn[] { ColumnComponent, ColumnWeight });
+ dataGridViewComponents.Dock = DockStyle.Fill;
+ dataGridViewComponents.Location = new Point(3, 19);
+ dataGridViewComponents.MultiSelect = false;
+ dataGridViewComponents.Name = "dataGridViewComponents";
+ dataGridViewComponents.RowHeadersVisible = false;
+ dataGridViewComponents.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewComponents.Size = new Size(354, 251);
+ dataGridViewComponents.TabIndex = 0;
+ //
+ // ColumnComponent
+ //
+ ColumnComponent.HeaderText = "Компонент";
+ ColumnComponent.Name = "ColumnComponent";
+ //
+ // ColumnWeight
+ //
+ ColumnWeight.HeaderText = "Вес";
+ ColumnWeight.MaxInputLength = 7;
+ ColumnWeight.Name = "ColumnWeight";
+ //
+ // FormProduct
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(384, 579);
+ Controls.Add(groupBox1);
+ Controls.Add(checkedListBoxConfectioneryType);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(label3);
+ Controls.Add(numericUpDownPrice);
+ Controls.Add(textBoxProductName);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Name = "FormProduct";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "FormProduct";
+ ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
+ groupBox1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridViewComponents).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+ private NumericUpDown numericUpDownPrice;
+ private TextBox textBoxProductName;
+ private Label label2;
+ private Label label1;
+ private Label label3;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private CheckedListBox checkedListBoxConfectioneryType;
+ private GroupBox groupBox1;
+ private DataGridView dataGridViewComponents;
+ private DataGridViewComboBoxColumn ColumnComponent;
+ private DataGridViewTextBoxColumn ColumnWeight;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProduct.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProduct.cs
new file mode 100644
index 0000000..916fd84
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProduct.cs
@@ -0,0 +1,118 @@
+using Microsoft.VisualBasic.FileIO;
+using ProjectConfectioneryFactory.Entities;
+using ProjectConfectioneryFactory.Entities.Enums;
+using ProjectConfectioneryFactory.Repositories;
+using ProjectConfectioneryFactory.Repositories.Implementations;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormProduct : Form
+ {
+ private readonly IProductRepository _productRepository;
+
+ private int? _productId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var product = _productRepository.ReadProductById(value);
+ if (product == null)
+ {
+ throw new InvalidDataException(nameof(product));
+ }
+ foreach (ConfectioneryType elem in Enum.GetValues(typeof(ConfectioneryType)))
+ {
+ if ((elem & product.ConfectioneryType) != 0)
+ {
+ checkedListBoxConfectioneryType.SetItemChecked(checkedListBoxConfectioneryType.Items.IndexOf(elem), true);
+ }
+ }
+ textBoxProductName.Text = product.Name;
+ numericUpDownPrice.Value = (decimal)product.Price;
+ _productId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormProduct(IProductRepository productRepository, IComponentRepository componentRepository)
+ {
+ InitializeComponent();
+ _productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
+
+ foreach (var elem in Enum.GetValues(typeof(ConfectioneryType)))
+ {
+ checkedListBoxConfectioneryType.Items.Add(elem);
+ }
+
+ ColumnComponent.DataSource = componentRepository.ReadComponents();
+ ColumnComponent.DisplayMember = "Name";
+ ColumnComponent.ValueMember = "Id";
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (checkedListBoxConfectioneryType.CheckedItems.Count == 0 || string.IsNullOrWhiteSpace(textBoxProductName.Text) || dataGridViewComponents.RowCount < 1)
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_productId.HasValue)
+ {
+ _productRepository.UpdateProduct(CreateProduct(_productId.Value));
+ }
+ else
+ {
+ _productRepository.CreateProduct(CreateProduct(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private List CreateListProductComponentFromDataGrid()
+ {
+ var list = new List();
+ foreach (DataGridViewRow row in dataGridViewComponents.Rows)
+ {
+ if (row.Cells["ColumnComponent"].Value == null ||
+ row.Cells["ColumnWeight"].Value == null)
+ {
+ continue;
+ }
+ list.Add(ProductComponent.CreateEntity(0,
+ Convert.ToInt32(row.Cells["ColumnComponent"].Value),
+ Convert.ToInt32(row.Cells["ColumnWeight"].Value)));
+ }
+ return list;
+ }
+
+ private Product CreateProduct(int id)
+ {
+ ConfectioneryType confectioneryType = ConfectioneryType.None;
+ foreach (var elem in checkedListBoxConfectioneryType.CheckedItems)
+ {
+ confectioneryType |= (ConfectioneryType)elem;
+ }
+ return Product.CreateEntity(
+ id,
+ confectioneryType,
+ textBoxProductName.Text,
+ (double)numericUpDownPrice.Value,
+ CreateListProductComponentFromDataGrid());
+ }
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProduct.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProduct.resx
new file mode 100644
index 0000000..666cdb1
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProduct.resx
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProducts.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProducts.Designer.cs
new file mode 100644
index 0000000..5b168be
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProducts.Designer.cs
@@ -0,0 +1,126 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ partial class FormProducts
+ {
+ ///
+ /// 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()
+ {
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonAdd = new Button();
+ dataGridViewData = new DataGridView();
+ panel1 = new Panel();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
+ panel1.SuspendLayout();
+ SuspendLayout();
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.BackgroundImage = Properties.Resources.Update;
+ buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdate.Location = new Point(14, 83);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(65, 65);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.BackgroundImage = Properties.Resources.Delete;
+ buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDelete.Location = new Point(14, 154);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(65, 65);
+ buttonDelete.TabIndex = 1;
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(14, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(65, 65);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridViewData
+ //
+ dataGridViewData.AllowUserToAddRows = false;
+ dataGridViewData.AllowUserToDeleteRows = false;
+ dataGridViewData.AllowUserToResizeColumns = false;
+ dataGridViewData.AllowUserToResizeRows = false;
+ dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewData.Dock = DockStyle.Fill;
+ dataGridViewData.Location = new Point(0, 0);
+ dataGridViewData.MultiSelect = false;
+ dataGridViewData.Name = "dataGridViewData";
+ dataGridViewData.ReadOnly = true;
+ dataGridViewData.RowHeadersVisible = false;
+ dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewData.Size = new Size(709, 450);
+ dataGridViewData.TabIndex = 3;
+ //
+ // panel1
+ //
+ panel1.Controls.Add(buttonUpdate);
+ panel1.Controls.Add(buttonDelete);
+ panel1.Controls.Add(buttonAdd);
+ panel1.Dock = DockStyle.Right;
+ panel1.Location = new Point(709, 0);
+ panel1.Name = "panel1";
+ panel1.Size = new Size(91, 450);
+ panel1.TabIndex = 2;
+ //
+ // FormProducts
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridViewData);
+ Controls.Add(panel1);
+ Name = "FormProducts";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "FormProducts";
+ Load += FormProducts_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
+ panel1.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonAdd;
+ private DataGridView dataGridViewData;
+ private Panel panel1;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProducts.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProducts.cs
new file mode 100644
index 0000000..73f70cf
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProducts.cs
@@ -0,0 +1,80 @@
+using ProjectConfectioneryFactory.Repositories;
+using Unity;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormProducts : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IProductRepository _productRepository;
+ public FormProducts(IUnityContainer container, IProductRepository productRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
+ }
+ private void FormProducts_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ try
+ {
+ var form = _container.Resolve();
+ form.Id = findId;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; }
+ try
+ {
+ _productRepository.DeleteProduct(findId); LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void LoadList() => dataGridViewData.DataSource = _productRepository.ReadProducts();
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProducts.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProducts.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormProducts.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/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplier.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplier.Designer.cs
new file mode 100644
index 0000000..beb2ca3
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplier.Designer.cs
@@ -0,0 +1,143 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ partial class FormSupplier
+ {
+ ///
+ /// 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()
+ {
+ maskedTextBoxPhone = new MaskedTextBox();
+ textBoxAddress = new TextBox();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ textBoxSupplierName = new TextBox();
+ label3 = new Label();
+ label2 = new Label();
+ label1 = new Label();
+ SuspendLayout();
+ //
+ // maskedTextBoxPhone
+ //
+ maskedTextBoxPhone.Location = new Point(121, 56);
+ maskedTextBoxPhone.Mask = "+7 (999) 000-0000";
+ maskedTextBoxPhone.Name = "maskedTextBoxPhone";
+ maskedTextBoxPhone.Size = new Size(207, 23);
+ maskedTextBoxPhone.TabIndex = 27;
+ //
+ // textBoxAddress
+ //
+ textBoxAddress.Location = new Point(121, 93);
+ textBoxAddress.Name = "textBoxAddress";
+ textBoxAddress.Size = new Size(207, 23);
+ textBoxAddress.TabIndex = 26;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonCancel.Location = new Point(297, 156);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 25;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonSave.Location = new Point(216, 156);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 24;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // textBoxSupplierName
+ //
+ textBoxSupplierName.Location = new Point(121, 20);
+ textBoxSupplierName.Name = "textBoxSupplierName";
+ textBoxSupplierName.Size = new Size(207, 23);
+ textBoxSupplierName.TabIndex = 23;
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(72, 96);
+ label3.Name = "label3";
+ label3.Size = new Size(43, 15);
+ label3.TabIndex = 22;
+ label3.Text = "Адрес:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(57, 59);
+ label2.Name = "label2";
+ label2.Size = new Size(58, 15);
+ label2.TabIndex = 21;
+ label2.Text = "Телефон:";
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(81, 23);
+ label1.Name = "label1";
+ label1.Size = new Size(34, 15);
+ label1.TabIndex = 20;
+ label1.Text = "Имя:";
+ //
+ // FormSupplier
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(384, 191);
+ Controls.Add(maskedTextBoxPhone);
+ Controls.Add(textBoxAddress);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxSupplierName);
+ Controls.Add(label3);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Name = "FormSupplier";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "FormSupplier";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MaskedTextBox maskedTextBoxPhone;
+ private TextBox textBoxAddress;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private TextBox textBoxSupplierName;
+ private Label label3;
+ private Label label2;
+ private Label label1;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplier.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplier.cs
new file mode 100644
index 0000000..c638ca0
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplier.cs
@@ -0,0 +1,70 @@
+using ProjectConfectioneryFactory.Entities;
+using ProjectConfectioneryFactory.Repositories;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormSupplier : Form
+ {
+ private readonly ISupplierRepository _supplierRepository;
+
+ private int? _supplierId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var supplier = _supplierRepository.ReadSupplierById(value);
+ if (supplier == null)
+ {
+ throw new InvalidDataException(nameof(supplier));
+ }
+ textBoxSupplierName.Text = supplier.Name;
+ maskedTextBoxPhone.Text = supplier.Phone.ToString();
+ textBoxAddress.Text = supplier.Address;
+ _supplierId = value;
+ }
+ catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
+ }
+ }
+
+ public FormSupplier(ISupplierRepository supplierRepository)
+ {
+ InitializeComponent();
+ _supplierRepository = supplierRepository ?? throw new ArgumentNullException(nameof(supplierRepository));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxSupplierName.Text) || string.IsNullOrWhiteSpace(maskedTextBoxPhone.Text) || string.IsNullOrWhiteSpace(textBoxAddress.Text))
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_supplierId.HasValue)
+ {
+ _supplierRepository.UpdateSupplier(CreateSupplier(_supplierId.Value));
+ }
+ else
+ {
+ _supplierRepository.CreateSupplier(CreateSupplier(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Supplier CreateSupplier(int id) => Supplier.CreateEntity(
+ id,
+ textBoxSupplierName.Text,
+ Double.Parse(maskedTextBoxPhone.Text),
+ textBoxAddress.Text);
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplier.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplier.resx
new file mode 100644
index 0000000..8b2ff64
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplier.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/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSuppliers.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSuppliers.Designer.cs
new file mode 100644
index 0000000..578f07e
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSuppliers.Designer.cs
@@ -0,0 +1,126 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ partial class FormSuppliers
+ {
+ ///
+ /// 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()
+ {
+ dataGridViewData = new DataGridView();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonAdd = new Button();
+ panel1 = new Panel();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
+ panel1.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridViewData
+ //
+ dataGridViewData.AllowUserToAddRows = false;
+ dataGridViewData.AllowUserToDeleteRows = false;
+ dataGridViewData.AllowUserToResizeColumns = false;
+ dataGridViewData.AllowUserToResizeRows = false;
+ dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewData.Dock = DockStyle.Fill;
+ dataGridViewData.Location = new Point(0, 0);
+ dataGridViewData.MultiSelect = false;
+ dataGridViewData.Name = "dataGridViewData";
+ dataGridViewData.ReadOnly = true;
+ dataGridViewData.RowHeadersVisible = false;
+ dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewData.Size = new Size(709, 450);
+ dataGridViewData.TabIndex = 5;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.BackgroundImage = Properties.Resources.Update;
+ buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdate.Location = new Point(14, 83);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(65, 65);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.BackgroundImage = Properties.Resources.Delete;
+ buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDelete.Location = new Point(14, 154);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(65, 65);
+ buttonDelete.TabIndex = 1;
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(14, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(65, 65);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // panel1
+ //
+ panel1.Controls.Add(buttonUpdate);
+ panel1.Controls.Add(buttonDelete);
+ panel1.Controls.Add(buttonAdd);
+ panel1.Dock = DockStyle.Right;
+ panel1.Location = new Point(709, 0);
+ panel1.Name = "panel1";
+ panel1.Size = new Size(91, 450);
+ panel1.TabIndex = 4;
+ //
+ // FormSuppliers
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridViewData);
+ Controls.Add(panel1);
+ Name = "FormSuppliers";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "FormSuppliers";
+ Load += FormSuppliers_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
+ panel1.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridViewData;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonAdd;
+ private Panel panel1;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSuppliers.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSuppliers.cs
new file mode 100644
index 0000000..00703b1
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSuppliers.cs
@@ -0,0 +1,80 @@
+using ProjectConfectioneryFactory.Repositories;
+using Unity;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormSuppliers : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly ISupplierRepository _supplierRepository;
+ public FormSuppliers(IUnityContainer container, ISupplierRepository supplierRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _supplierRepository = supplierRepository ?? throw new ArgumentNullException(nameof(supplierRepository));
+ }
+ private void FormSuppliers_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ try
+ {
+ var form = _container.Resolve();
+ form.Id = findId;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; }
+ try
+ {
+ _supplierRepository.DeleteSupplier(findId); LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void LoadList() => dataGridViewData.DataSource = _supplierRepository.ReadSuppliers();
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSuppliers.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSuppliers.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSuppliers.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/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupply.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupply.Designer.cs
new file mode 100644
index 0000000..97d6b41
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupply.Designer.cs
@@ -0,0 +1,198 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ partial class FormSupply
+ {
+ ///
+ /// 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()
+ {
+ dateTimePicker1 = new DateTimePicker();
+ label2 = new Label();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ comboBoxSupplier = new ComboBox();
+ checkBoxCompleted = new CheckBox();
+ label4 = new Label();
+ label1 = new Label();
+ comboBoxComponent = new ComboBox();
+ label3 = new Label();
+ numericUpDownWeight = new NumericUpDown();
+ label5 = new Label();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
+ SuspendLayout();
+ //
+ // dateTimePicker1
+ //
+ dateTimePicker1.Enabled = false;
+ dateTimePicker1.Location = new Point(108, 183);
+ dateTimePicker1.Name = "dateTimePicker1";
+ dateTimePicker1.Size = new Size(200, 23);
+ dateTimePicker1.TabIndex = 32;
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(67, 189);
+ label2.Name = "label2";
+ label2.Size = new Size(35, 15);
+ label2.TabIndex = 31;
+ label2.Text = "Дата:";
+ //
+ // buttonCancel
+ //
+ buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonCancel.Location = new Point(297, 251);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 30;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonSave.Location = new Point(216, 251);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 29;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // comboBoxSupplier
+ //
+ comboBoxSupplier.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxSupplier.FormattingEnabled = true;
+ comboBoxSupplier.Location = new Point(108, 25);
+ comboBoxSupplier.Name = "comboBoxSupplier";
+ comboBoxSupplier.Size = new Size(210, 23);
+ comboBoxSupplier.TabIndex = 28;
+ //
+ // checkBoxCompleted
+ //
+ checkBoxCompleted.AutoSize = true;
+ checkBoxCompleted.Location = new Point(108, 150);
+ checkBoxCompleted.Name = "checkBoxCompleted";
+ checkBoxCompleted.Size = new Size(15, 14);
+ checkBoxCompleted.TabIndex = 27;
+ checkBoxCompleted.UseVisualStyleBackColor = true;
+ //
+ // label4
+ //
+ label4.AutoSize = true;
+ label4.Location = new Point(35, 149);
+ label4.Name = "label4";
+ label4.Size = new Size(67, 15);
+ label4.TabIndex = 26;
+ label4.Text = "Выполнен:";
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(29, 28);
+ label1.Name = "label1";
+ label1.Size = new Size(73, 15);
+ label1.TabIndex = 25;
+ label1.Text = "Поставщик:";
+ //
+ // comboBoxComponent
+ //
+ comboBoxComponent.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxComponent.FormattingEnabled = true;
+ comboBoxComponent.Location = new Point(108, 66);
+ comboBoxComponent.Name = "comboBoxComponent";
+ comboBoxComponent.Size = new Size(210, 23);
+ comboBoxComponent.TabIndex = 34;
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(30, 69);
+ label3.Name = "label3";
+ label3.Size = new Size(72, 15);
+ label3.TabIndex = 33;
+ label3.Text = "Компонент:";
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.DecimalPlaces = 3;
+ numericUpDownWeight.Location = new Point(108, 105);
+ numericUpDownWeight.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
+ numericUpDownWeight.Name = "numericUpDownWeight";
+ numericUpDownWeight.Size = new Size(96, 23);
+ numericUpDownWeight.TabIndex = 36;
+ numericUpDownWeight.Value = new decimal(new int[] { 1, 0, 0, 196608 });
+ //
+ // label5
+ //
+ label5.AutoSize = true;
+ label5.Location = new Point(73, 107);
+ label5.Name = "label5";
+ label5.Size = new Size(29, 15);
+ label5.TabIndex = 35;
+ label5.Text = "Вес:";
+ //
+ // FormSupply
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(384, 286);
+ Controls.Add(numericUpDownWeight);
+ Controls.Add(label5);
+ Controls.Add(comboBoxComponent);
+ Controls.Add(label3);
+ Controls.Add(dateTimePicker1);
+ Controls.Add(label2);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(comboBoxSupplier);
+ Controls.Add(checkBoxCompleted);
+ Controls.Add(label4);
+ Controls.Add(label1);
+ Name = "FormSupply";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "FormSupply";
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private DateTimePicker dateTimePicker1;
+ private Label label2;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private ComboBox comboBoxSupplier;
+ private CheckBox checkBoxCompleted;
+ private Label label4;
+ private Label label1;
+ private ComboBox comboBoxComponent;
+ private Label label3;
+ private NumericUpDown numericUpDownWeight;
+ private Label label5;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupply.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupply.cs
new file mode 100644
index 0000000..8b102a2
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupply.cs
@@ -0,0 +1,76 @@
+using ProjectConfectioneryFactory.Entities;
+using ProjectConfectioneryFactory.Repositories;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormSupply : Form
+ {
+ private readonly ISupplyRepository _supplyRepository;
+
+ private int? _supplyId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var supply = _supplyRepository.ReadSupplyById(value);
+ if (supply == null)
+ {
+ throw new InvalidDataException(nameof(supply));
+ }
+ numericUpDownWeight.Value = (decimal)supply.Weight;
+ checkBoxCompleted.Enabled = supply.Completed;
+ _supplyId = value;
+ }
+ catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
+ }
+ }
+
+ public FormSupply(ISupplyRepository supplyRepository, ISupplierRepository supplierRepository, IComponentRepository componentRepository)
+ {
+ InitializeComponent();
+ _supplyRepository = supplyRepository ?? throw new ArgumentNullException(nameof(supplyRepository));
+ comboBoxSupplier.DataSource = supplierRepository.ReadSuppliers();
+ comboBoxSupplier.DisplayMember = "Name";
+ comboBoxSupplier.ValueMember = "Id";
+ comboBoxComponent.DataSource = componentRepository.ReadComponents();
+ comboBoxComponent.DisplayMember = "ComponentName";
+ comboBoxComponent.ValueMember = "Id";
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (comboBoxSupplier.SelectedIndex < 0 || comboBoxComponent.SelectedIndex < 0 || !checkBoxCompleted.Checked)
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_supplyId.HasValue)
+ {
+ _supplyRepository.UpdateSupply(CreateSupply(_supplyId.Value));
+ }
+ else
+ {
+ _supplyRepository.CreateSupply(CreateSupply(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Supply CreateSupply(int id) => Supply.CreateOperation(
+ id,
+ (int)comboBoxSupplier.SelectedValue!,
+ (int)comboBoxComponent.SelectedValue!,
+ Convert.ToDouble(numericUpDownWeight.Value),
+ checkBoxCompleted.Checked);
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupply.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupply.resx
new file mode 100644
index 0000000..8b2ff64
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupply.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/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplys.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplys.Designer.cs
new file mode 100644
index 0000000..c31ec8e
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplys.Designer.cs
@@ -0,0 +1,126 @@
+namespace ProjectConfectioneryFactory.Forms
+{
+ partial class FormSupplys
+ {
+ ///
+ /// 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()
+ {
+ dataGridViewData = new DataGridView();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonAdd = new Button();
+ panel1 = new Panel();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
+ panel1.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridViewData
+ //
+ dataGridViewData.AllowUserToAddRows = false;
+ dataGridViewData.AllowUserToDeleteRows = false;
+ dataGridViewData.AllowUserToResizeColumns = false;
+ dataGridViewData.AllowUserToResizeRows = false;
+ dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewData.Dock = DockStyle.Fill;
+ dataGridViewData.Location = new Point(0, 0);
+ dataGridViewData.MultiSelect = false;
+ dataGridViewData.Name = "dataGridViewData";
+ dataGridViewData.ReadOnly = true;
+ dataGridViewData.RowHeadersVisible = false;
+ dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewData.Size = new Size(709, 450);
+ dataGridViewData.TabIndex = 7;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.BackgroundImage = Properties.Resources.Update;
+ buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdate.Location = new Point(14, 83);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(65, 65);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.BackgroundImage = Properties.Resources.Delete;
+ buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDelete.Location = new Point(14, 154);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(65, 65);
+ buttonDelete.TabIndex = 1;
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(14, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(65, 65);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // panel1
+ //
+ panel1.Controls.Add(buttonUpdate);
+ panel1.Controls.Add(buttonDelete);
+ panel1.Controls.Add(buttonAdd);
+ panel1.Dock = DockStyle.Right;
+ panel1.Location = new Point(709, 0);
+ panel1.Name = "panel1";
+ panel1.Size = new Size(91, 450);
+ panel1.TabIndex = 6;
+ //
+ // FormSupplys
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridViewData);
+ Controls.Add(panel1);
+ Name = "FormSupplys";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "FormSupplys";
+ Load += FormSupplys_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
+ panel1.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridViewData;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonAdd;
+ private Panel panel1;
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplys.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplys.cs
new file mode 100644
index 0000000..42dee79
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplys.cs
@@ -0,0 +1,80 @@
+using ProjectConfectioneryFactory.Repositories;
+using Unity;
+
+namespace ProjectConfectioneryFactory.Forms
+{
+ public partial class FormSupplys : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly ISupplyRepository _supplyRepository;
+ public FormSupplys(IUnityContainer container, ISupplyRepository supplyRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _supplyRepository = supplyRepository ?? throw new ArgumentNullException(nameof(supplyRepository));
+ }
+ private void FormSupplys_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ try
+ {
+ var form = _container.Resolve();
+ form.Id = findId;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; }
+ try
+ {
+ _supplyRepository.DeleteSupply(findId); LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void LoadList() => dataGridViewData.DataSource = _supplyRepository.ReadSupplys();
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplys.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplys.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormSupplys.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/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Program.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Program.cs
new file mode 100644
index 0000000..41dc9af
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Program.cs
@@ -0,0 +1,34 @@
+using Unity.Lifetime;
+using Unity;
+using ProjectConfectioneryFactory.Repositories;
+using ProjectConfectioneryFactory.Repositories.Implementations;
+
+namespace ProjectConfectioneryFactory
+{
+ 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(CreateContainer().Resolve());
+ }
+
+ private static IUnityContainer CreateContainer()
+ {
+ var container = new UnityContainer();
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/ProjectConfectioneryFactory.csproj b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/ProjectConfectioneryFactory.csproj
new file mode 100644
index 0000000..accbdf0
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/ProjectConfectioneryFactory.csproj
@@ -0,0 +1,30 @@
+
+
+
+ WinExe
+ net8.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Properties/Resources.Designer.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..36ee312
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace ProjectConfectioneryFactory.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("ProjectConfectioneryFactory.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;
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Add {
+ get {
+ object obj = ResourceManager.GetObject("Add", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Croissant {
+ get {
+ object obj = ResourceManager.GetObject("Croissant", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Delete {
+ get {
+ object obj = ResourceManager.GetObject("Delete", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Update {
+ get {
+ object obj = ResourceManager.GetObject("Update", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Properties/Resources.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Properties/Resources.resx
new file mode 100644
index 0000000..d48d7ba
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Properties/Resources.resx
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+
+ ..\Resources\Delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\Croissant.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\Update.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IClientRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IClientRepository.cs
new file mode 100644
index 0000000..398585b
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IClientRepository.cs
@@ -0,0 +1,16 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories;
+
+public interface IClientRepository
+{
+ IEnumerable ReadClients();
+
+ Client ReadClientById(int id);
+
+ void CreateClient(Client client);
+
+ void UpdateClient(Client client);
+
+ void DeleteClient(int id);
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IComponentRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IComponentRepository.cs
new file mode 100644
index 0000000..b45e614
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IComponentRepository.cs
@@ -0,0 +1,16 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories;
+
+public interface IComponentRepository
+{
+ IEnumerable ReadComponents();
+
+ Component ReadComponentById(int id);
+
+ void CreateComponent(Component component);
+
+ void UpdateComponent(Component component);
+
+ void DeleteComponent(int id);
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IOrderRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IOrderRepository.cs
new file mode 100644
index 0000000..192fa09
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IOrderRepository.cs
@@ -0,0 +1,16 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories;
+
+public interface IOrderRepository
+{
+ IEnumerable ReadOrders();
+
+ Order ReadOrderById(int id);
+
+ void CreateOrder(Order order);
+
+ void UpdateOrder(Order order);
+
+ void DeleteOrder(int id);
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IProductRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IProductRepository.cs
new file mode 100644
index 0000000..1b371bd
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/IProductRepository.cs
@@ -0,0 +1,16 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories;
+
+public interface IProductRepository
+{
+ IEnumerable ReadProducts();
+
+ Product ReadProductById(int id);
+
+ void CreateProduct(Product product);
+
+ void UpdateProduct(Product product);
+
+ void DeleteProduct(int id);
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/ISupplierRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/ISupplierRepository.cs
new file mode 100644
index 0000000..d75db61
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/ISupplierRepository.cs
@@ -0,0 +1,17 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories;
+
+public interface ISupplierRepository
+{
+
+ IEnumerable ReadSuppliers();
+
+ Supplier ReadSupplierById(int id);
+
+ void CreateSupplier(Supplier supplier);
+
+ void UpdateSupplier(Supplier supplier);
+
+ void DeleteSupplier(int id);
+}
\ No newline at end of file
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/ISupplyRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/ISupplyRepository.cs
new file mode 100644
index 0000000..c33ebcc
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/ISupplyRepository.cs
@@ -0,0 +1,15 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories;
+public interface ISupplyRepository
+{
+ IEnumerable ReadSupplys();
+
+ Supply ReadSupplyById(int id);
+
+ void CreateSupply(Supply supply);
+
+ void UpdateSupply(Supply supply);
+
+ void DeleteSupply(int id);
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/ClientRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/ClientRepository.cs
new file mode 100644
index 0000000..59816a6
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/ClientRepository.cs
@@ -0,0 +1,28 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories.Implementations;
+
+public class ClientRepository : IClientRepository
+{
+ public void CreateClient(Client client)
+ {
+ }
+
+ public void DeleteClient(int id)
+ {
+ }
+
+ public Client ReadClientById(int id)
+ {
+ return Client.CreateEntity(0, string.Empty, string.Empty, 0, string.Empty);
+ }
+
+ public IEnumerable ReadClients()
+ {
+ return [];
+ }
+
+ public void UpdateClient(Client client)
+ {
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/ComponentRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/ComponentRepository.cs
new file mode 100644
index 0000000..2112a58
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/ComponentRepository.cs
@@ -0,0 +1,28 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories.Implementations;
+
+public class ComponentRepository : IComponentRepository
+{
+ public void CreateComponent(Component component)
+ {
+ }
+
+ public void DeleteComponent(int id)
+ {
+ }
+
+ public Component ReadComponentById(int id)
+ {
+ return Component.CreateEntity(0, string.Empty, 0, 0);
+ }
+
+ public IEnumerable ReadComponents()
+ {
+ return [];
+ }
+
+ public void UpdateComponent(Component component)
+ {
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/OrderRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/OrderRepository.cs
new file mode 100644
index 0000000..31a29ab
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/OrderRepository.cs
@@ -0,0 +1,28 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories.Implementations;
+
+public class OrderRepository : IOrderRepository
+{
+ public void CreateOrder(Order order)
+ {
+ }
+
+ public void DeleteOrder(int id)
+ {
+ }
+
+ public Order ReadOrderById(int id)
+ {
+ return Order.CreateOperation(0, 0, false, null);
+ }
+
+ public IEnumerable ReadOrders()
+ {
+ return [];
+ }
+
+ public void UpdateOrder(Order order)
+ {
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/ProductRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/ProductRepository.cs
new file mode 100644
index 0000000..f223b7d
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/ProductRepository.cs
@@ -0,0 +1,29 @@
+using ProjectConfectioneryFactory.Entities;
+using ProjectConfectioneryFactory.Entities.Enums;
+
+namespace ProjectConfectioneryFactory.Repositories.Implementations;
+
+public class ProductRepository : IProductRepository
+{
+ public void CreateProduct(Product product)
+ {
+ }
+
+ public void DeleteProduct(int id)
+ {
+ }
+
+ public Product ReadProductById(int id)
+ {
+ return Product.CreateEntity(0, ConfectioneryType.None, string.Empty, 0, null);
+ }
+
+ public IEnumerable ReadProducts()
+ {
+ return [];
+ }
+
+ public void UpdateProduct(Product product)
+ {
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/SupplierRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/SupplierRepository.cs
new file mode 100644
index 0000000..a32ab28
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/SupplierRepository.cs
@@ -0,0 +1,28 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories.Implementations;
+
+public class SupplierRepository : ISupplierRepository
+{
+ public void CreateSupplier(Supplier supplier)
+ {
+ }
+
+ public void DeleteSupplier(int id)
+ {
+ }
+
+ public Supplier ReadSupplierById(int id)
+ {
+ return Supplier.CreateEntity(0, string.Empty, 0, string.Empty);
+ }
+
+ public IEnumerable ReadSuppliers()
+ {
+ return [];
+ }
+
+ public void UpdateSupplier(Supplier supplier)
+ {
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/SupplyRepository.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/SupplyRepository.cs
new file mode 100644
index 0000000..999d3ec
--- /dev/null
+++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Repositories/Implementations/SupplyRepository.cs
@@ -0,0 +1,28 @@
+using ProjectConfectioneryFactory.Entities;
+
+namespace ProjectConfectioneryFactory.Repositories.Implementations;
+
+public class SupplyRepository : ISupplyRepository
+{
+ public void CreateSupply(Supply supply)
+ {
+ }
+
+ public void DeleteSupply(int id)
+ {
+ }
+
+ public Supply ReadSupplyById(int id)
+ {
+ return Supply.CreateOperation(0, 0, 0, 0, false);
+ }
+
+ public IEnumerable ReadSupplys()
+ {
+ return [];
+ }
+
+ public void UpdateSupply(Supply supply)
+ {
+ }
+}
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Add.png b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Add.png
new file mode 100644
index 0000000..a1722f1
Binary files /dev/null and b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Add.png differ
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Croissant.jpg b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Croissant.jpg
new file mode 100644
index 0000000..14691e7
Binary files /dev/null and b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Croissant.jpg differ
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Delete.png b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Delete.png
new file mode 100644
index 0000000..fb02509
Binary files /dev/null and b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Delete.png differ
diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Update.png b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Update.png
new file mode 100644
index 0000000..05f7434
Binary files /dev/null and b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Resources/Update.png differ