diff --git a/ProjectOptika/ProjectOptika.csproj b/ProjectOptika/ProjectOptika.csproj
index 663fdb8..accbdf0 100644
--- a/ProjectOptika/ProjectOptika.csproj
+++ b/ProjectOptika/ProjectOptika.csproj
@@ -8,4 +8,23 @@
enable
+
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
\ No newline at end of file
diff --git a/ProjectOptika/Properties/Resources.Designer.cs b/ProjectOptika/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..c835558
--- /dev/null
+++ b/ProjectOptika/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace ProjectOptika.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("ProjectOptika.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 optika {
+ get {
+ object obj = ResourceManager.GetObject("optika", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Remove {
+ get {
+ object obj = ResourceManager.GetObject("Remove", 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/ProjectOptika/Properties/Resources.resx b/ProjectOptika/Properties/Resources.resx
new file mode 100644
index 0000000..985f188
--- /dev/null
+++ b/ProjectOptika/Properties/Resources.resx
@@ -0,0 +1,136 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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\Add.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\Remove.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\optika.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\Update.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\optika1.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/ProjectOptika/Resources/Add.jpg b/ProjectOptika/Resources/Add.jpg
new file mode 100644
index 0000000..12ff7b3
Binary files /dev/null and b/ProjectOptika/Resources/Add.jpg differ
diff --git a/ProjectOptika/Resources/Remove.jpg b/ProjectOptika/Resources/Remove.jpg
new file mode 100644
index 0000000..2cd0d77
Binary files /dev/null and b/ProjectOptika/Resources/Remove.jpg differ
diff --git a/ProjectOptika/Resources/Update.jpg b/ProjectOptika/Resources/Update.jpg
new file mode 100644
index 0000000..413f7f4
Binary files /dev/null and b/ProjectOptika/Resources/Update.jpg differ
diff --git a/ProjectOptika/Resources/optika.jpg b/ProjectOptika/Resources/optika.jpg
new file mode 100644
index 0000000..b078b7a
Binary files /dev/null and b/ProjectOptika/Resources/optika.jpg differ
diff --git a/ProjectOptika/Resources/optika1.jpg b/ProjectOptika/Resources/optika1.jpg
new file mode 100644
index 0000000..b078b7a
Binary files /dev/null and b/ProjectOptika/Resources/optika1.jpg differ
diff --git a/ProjectOptika/Scripts/Entities/Accessories.cs b/ProjectOptika/Scripts/Entities/Accessories.cs
new file mode 100644
index 0000000..b3747ce
--- /dev/null
+++ b/ProjectOptika/Scripts/Entities/Accessories.cs
@@ -0,0 +1,38 @@
+using ProjectOptika.Scripts.Entities.Enums;
+
+namespace ProjectOptika.Scripts.Entities
+{
+ public class Accessories
+ {
+ public int ID { get; private set; }
+
+ public string Name { get; private set; }
+
+ public string Brand { get; private set; }
+
+ public int Cost { get; private set; }
+
+ public int StockAvailability { get; private set; }
+
+ public int AvailabilityStore { get; private set; }
+
+ public DateTime DeliveryDate { get; private set; }
+
+ public CategoryType CategoryName { get; private set; }
+
+ public static Accessories CreateEntity(int id, string name, string brand, int cost, int stockAvailability, int availabilityStore, DateTime deliveryDate, CategoryType categoryName)
+ {
+ return new Accessories
+ {
+ ID = id,
+ Name = name,
+ Brand = brand,
+ Cost = cost,
+ StockAvailability = stockAvailability,
+ AvailabilityStore = availabilityStore,
+ DeliveryDate = deliveryDate,
+ CategoryName = categoryName
+ };
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Entities/AccessoriesOrder.cs b/ProjectOptika/Scripts/Entities/AccessoriesOrder.cs
new file mode 100644
index 0000000..7c12c91
--- /dev/null
+++ b/ProjectOptika/Scripts/Entities/AccessoriesOrder.cs
@@ -0,0 +1,21 @@
+namespace ProjectOptika.Scripts.Entities
+{
+ public class AccessoriesOrder
+ {
+ public int ID { get; private set; }
+
+ public int AccesoryId { get; private set; }
+
+ public int Count { get; private set; }
+
+ public static AccessoriesOrder CreateElement(int id, int accesoryId, int count)
+ {
+ return new AccessoriesOrder
+ {
+ ID = id,
+ AccesoryId = accesoryId,
+ Count = count
+ };
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Entities/Client.cs b/ProjectOptika/Scripts/Entities/Client.cs
new file mode 100644
index 0000000..d74ca73
--- /dev/null
+++ b/ProjectOptika/Scripts/Entities/Client.cs
@@ -0,0 +1,32 @@
+using ProjectOptika.Scripts.Entities.Enums;
+
+namespace ProjectOptika.Scripts.Entities
+{
+ public class Client
+ {
+ public int ID { get; private set; }
+
+ public ClientType ClientType { get; private set; }
+
+ public string FirstName { get; private set; }
+
+ public string SecondName { get; private set; }
+
+ public string Surname { get; private set; }
+
+ public string PhoneNumber { get; private set; }
+
+ public static Client CreateEntity(int id, ClientType clientType, string firstName, string secondName, string surname, string phoneNumber)
+ {
+ return new Client
+ {
+ ID = id,
+ ClientType = clientType,
+ FirstName = firstName,
+ SecondName = secondName,
+ Surname = surname,
+ PhoneNumber = phoneNumber
+ };
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Entities/Employee.cs b/ProjectOptika/Scripts/Entities/Employee.cs
new file mode 100644
index 0000000..6ab44eb
--- /dev/null
+++ b/ProjectOptika/Scripts/Entities/Employee.cs
@@ -0,0 +1,28 @@
+using ProjectOptika.Scripts.Entities.Enums;
+
+namespace ProjectOptika.Scripts.Entities
+{
+ public class Employee
+ {
+ public int ID { get; private set; }
+
+ public PositionEmployee PositionEmployee { get; private set; }
+
+ public string FirstName { get; private set; }
+
+ public string SecondName { get; private set; }
+
+ public string Surname { get; private set; }
+
+ public static Employee CreateEntity(int id, PositionEmployee positionEmployee, string firstName, string secondName, string surname) {
+ return new Employee
+ {
+ ID = id,
+ PositionEmployee = positionEmployee,
+ FirstName = firstName,
+ SecondName = secondName,
+ Surname = surname
+ };
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Entities/Enums/CategoryType.cs b/ProjectOptika/Scripts/Entities/Enums/CategoryType.cs
new file mode 100644
index 0000000..5c831a1
--- /dev/null
+++ b/ProjectOptika/Scripts/Entities/Enums/CategoryType.cs
@@ -0,0 +1,13 @@
+namespace ProjectOptika.Scripts.Entities.Enums
+{
+ public enum CategoryType
+ {
+ None = 0,
+
+ Lenses = 1,
+
+ Glasses = 2,
+
+ Accessories = 3
+ }
+}
diff --git a/ProjectOptika/Scripts/Entities/Enums/ClientType.cs b/ProjectOptika/Scripts/Entities/Enums/ClientType.cs
new file mode 100644
index 0000000..158d8d3
--- /dev/null
+++ b/ProjectOptika/Scripts/Entities/Enums/ClientType.cs
@@ -0,0 +1,9 @@
+namespace ProjectOptika.Scripts.Entities.Enums
+{
+ public enum ClientType
+ {
+ Regular,
+ VIP,
+ Corporate
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Entities/Enums/PositionEmployee.cs b/ProjectOptika/Scripts/Entities/Enums/PositionEmployee.cs
new file mode 100644
index 0000000..b131bd0
--- /dev/null
+++ b/ProjectOptika/Scripts/Entities/Enums/PositionEmployee.cs
@@ -0,0 +1,13 @@
+namespace ProjectOptika.Scripts.Entities.Enums
+{
+ [System.Flags]
+ public enum PositionEmployee
+ {
+ None = 0,
+ SeniorSalesman = 1,
+ Salesman = 2,
+ SellerCashier = 4,
+ Administrator = 8,
+ Accountant = 16
+ }
+}
diff --git a/ProjectOptika/Scripts/Entities/Order.cs b/ProjectOptika/Scripts/Entities/Order.cs
new file mode 100644
index 0000000..514faf4
--- /dev/null
+++ b/ProjectOptika/Scripts/Entities/Order.cs
@@ -0,0 +1,29 @@
+namespace ProjectOptika.Scripts.Entities
+{
+ public class Order
+ {
+ public int ID { get; private set; }
+
+ public int EmployeeID { get; private set; }
+
+ public int ClientID { get; private set; }
+
+ public DateTime OrderDate { get; private set; }
+
+ public double TotalCost { get; private set; }
+
+ public IEnumerable AccesoriesOrders { get; private set; } = [];
+
+ public static Order CreateOperation(int id, int employeeID, int clientID, double totalCost, IEnumerable accesoriesOrders)
+ {
+ return new Order {
+ ID = id,
+ EmployeeID = employeeID,
+ ClientID = clientID,
+ OrderDate = DateTime.Now,
+ TotalCost = totalCost,
+ AccesoriesOrders = accesoriesOrders
+ };
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Entities/Specifications.cs b/ProjectOptika/Scripts/Entities/Specifications.cs
new file mode 100644
index 0000000..26be3ce
--- /dev/null
+++ b/ProjectOptika/Scripts/Entities/Specifications.cs
@@ -0,0 +1,33 @@
+namespace ProjectOptika.Scripts.Entities
+{
+ public class Specifications
+ {
+ public int ID { get; private set; }
+
+ public int AccessoriesID { get; private set; }
+
+ public string Material { get; private set; }
+
+ public string Astigmatism { get; private set; }
+
+ public string Dioptericity { get; private set; }
+
+ public string OriginCountry { get; private set; }
+
+ public double TimeProduction { get; private set; }
+
+ public static Specifications CreateEntity(int id, int accessoriesID, string material, string astigmatism, string dioptericity, string originCountry, double timeProduction)
+ {
+ return new Specifications
+ {
+ ID = id,
+ AccessoriesID = accessoriesID,
+ Material = material,
+ Astigmatism = astigmatism,
+ Dioptericity = dioptericity,
+ OriginCountry = originCountry,
+ TimeProduction = timeProduction
+ };
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/Form1.Designer.cs b/ProjectOptika/Scripts/Forms/Form1.Designer.cs
deleted file mode 100644
index 353d9a4..0000000
--- a/ProjectOptika/Scripts/Forms/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace ProjectOptika
-{
- 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/ProjectOptika/Scripts/Forms/Form1.cs b/ProjectOptika/Scripts/Forms/Form1.cs
deleted file mode 100644
index 1f16f1b..0000000
--- a/ProjectOptika/Scripts/Forms/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace ProjectOptika
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/ProjectOptika/Scripts/Forms/FormAccessories.Designer.cs b/ProjectOptika/Scripts/Forms/FormAccessories.Designer.cs
new file mode 100644
index 0000000..d170095
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormAccessories.Designer.cs
@@ -0,0 +1,127 @@
+namespace ProjectOptika.Scripts.Forms
+{
+ partial class FormAccessories
+ {
+ ///
+ /// 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()
+ {
+ buttonRemove = new Button();
+ buttonUpdate = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ panel = new Panel();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ panel.SuspendLayout();
+ SuspendLayout();
+ //
+ // buttonRemove
+ //
+ buttonRemove.BackgroundImage = Properties.Resources.Remove;
+ buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonRemove.Location = new Point(3, 166);
+ buttonRemove.Name = "buttonRemove";
+ buttonRemove.Size = new Size(96, 71);
+ buttonRemove.TabIndex = 2;
+ buttonRemove.UseVisualStyleBackColor = true;
+ buttonRemove.Click += ButtonRemove_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.BackgroundImage = Properties.Resources.Update;
+ buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdate.Location = new Point(3, 89);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(96, 71);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(3, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(96, 71);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.AllowUserToResizeColumns = false;
+ dataGridView.AllowUserToResizeRows = false;
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Fill;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.MultiSelect = false;
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(670, 390);
+ dataGridView.TabIndex = 5;
+ //
+ // panel
+ //
+ panel.Controls.Add(buttonRemove);
+ panel.Controls.Add(buttonUpdate);
+ panel.Controls.Add(buttonAdd);
+ panel.Dock = DockStyle.Right;
+ panel.Location = new Point(670, 0);
+ panel.Name = "panel";
+ panel.Size = new Size(104, 390);
+ panel.TabIndex = 4;
+ //
+ // FormAccessories
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(774, 390);
+ Controls.Add(dataGridView);
+ Controls.Add(panel);
+ Name = "FormAccessories";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Аксессуары";
+ Load += Form_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ panel.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonRemove;
+ private Button buttonUpdate;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ private Panel panel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Forms/FormAccessories.cs b/ProjectOptika/Scripts/Forms/FormAccessories.cs
new file mode 100644
index 0000000..6e9de83
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormAccessories.cs
@@ -0,0 +1,97 @@
+using ProjectOptika.Scripts.Repositories;
+using Unity;
+
+namespace ProjectOptika.Scripts.Forms
+{
+ public partial class FormAccessories : Form
+ {
+ private readonly IUnityContainer _container;
+
+ private readonly IAccessoriesRepository _accessoriesRepositories;
+
+ public FormAccessories(IUnityContainer container, IAccessoriesRepository accessoriesRepositories)
+ {
+ InitializeComponent();
+
+ _container = container ??
+ throw new ArgumentException(nameof(container));
+
+ _accessoriesRepositories = accessoriesRepositories ??
+ throw new ArgumentException(nameof(accessoriesRepositories));
+ }
+
+ private void Form_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
+
+ try
+ {
+ var form = _container.Resolve();
+ form.ID = findID;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonRemove_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
+
+ if (MessageBox.Show("Удалить запись?", "Удалить", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
+
+ try
+ {
+ _accessoriesRepositories.DeleteAccessories(findID);
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridView.DataSource = _accessoriesRepositories.GetAccessories();
+
+ private bool TryGetIdentifierFromSelectedRows(out int id)
+ {
+ id = 0;
+ if (dataGridView.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+
+ id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/Form1.resx b/ProjectOptika/Scripts/Forms/FormAccessories.resx
similarity index 93%
rename from ProjectOptika/Scripts/Forms/Form1.resx
rename to ProjectOptika/Scripts/Forms/FormAccessories.resx
index 1af7de1..af32865 100644
--- a/ProjectOptika/Scripts/Forms/Form1.resx
+++ b/ProjectOptika/Scripts/Forms/FormAccessories.resx
@@ -1,17 +1,17 @@
-
diff --git a/ProjectOptika/Scripts/Forms/FormAccessory.Designer.cs b/ProjectOptika/Scripts/Forms/FormAccessory.Designer.cs
new file mode 100644
index 0000000..2e864ca
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormAccessory.Designer.cs
@@ -0,0 +1,236 @@
+namespace ProjectOptika.Scripts.Forms
+{
+ partial class FormAccessory
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelName = new Label();
+ labelBrand = new Label();
+ labelCost = new Label();
+ labelStockAvailability = new Label();
+ labelAvailabilityStore = new Label();
+ labelDeliveryDate = new Label();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ textBoxName = new TextBox();
+ textBoxBrand = new TextBox();
+ dateTimePickerDeliveryDate = new DateTimePicker();
+ numericUpDownAvailabilityStore = new NumericUpDown();
+ numericUpDownStockAvailability = new NumericUpDown();
+ numericUpDownCost = new NumericUpDown();
+ labelCategory = new Label();
+ comboBoxCategoryName = new ComboBox();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownAvailabilityStore).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownStockAvailability).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownCost).BeginInit();
+ SuspendLayout();
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(27, 26);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(77, 20);
+ labelName.TabIndex = 0;
+ labelName.Text = "Название";
+ //
+ // labelBrand
+ //
+ labelBrand.AutoSize = true;
+ labelBrand.Location = new Point(27, 83);
+ labelBrand.Name = "labelBrand";
+ labelBrand.Size = new Size(52, 20);
+ labelBrand.TabIndex = 1;
+ labelBrand.Text = "Бренд";
+ //
+ // labelCost
+ //
+ labelCost.AutoSize = true;
+ labelCost.Location = new Point(21, 137);
+ labelCost.Name = "labelCost";
+ labelCost.Size = new Size(83, 20);
+ labelCost.TabIndex = 2;
+ labelCost.Text = "Стоимость";
+ //
+ // labelStockAvailability
+ //
+ labelStockAvailability.AutoSize = true;
+ labelStockAvailability.Location = new Point(289, 26);
+ labelStockAvailability.Name = "labelStockAvailability";
+ labelStockAvailability.Size = new Size(152, 20);
+ labelStockAvailability.TabIndex = 3;
+ labelStockAvailability.Text = "Наличие в магазине";
+ //
+ // labelAvailabilityStore
+ //
+ labelAvailabilityStore.AutoSize = true;
+ labelAvailabilityStore.Location = new Point(289, 83);
+ labelAvailabilityStore.Name = "labelAvailabilityStore";
+ labelAvailabilityStore.Size = new Size(141, 20);
+ labelAvailabilityStore.TabIndex = 4;
+ labelAvailabilityStore.Text = "Наличие на складе";
+ //
+ // labelDeliveryDate
+ //
+ labelDeliveryDate.AutoSize = true;
+ labelDeliveryDate.Location = new Point(289, 137);
+ labelDeliveryDate.Name = "labelDeliveryDate";
+ labelDeliveryDate.Size = new Size(107, 20);
+ labelDeliveryDate.TabIndex = 5;
+ labelDeliveryDate.Text = "Дата доставки";
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(145, 261);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 7;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(20, 261);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 29);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(110, 23);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(156, 27);
+ textBoxName.TabIndex = 8;
+ //
+ // textBoxBrand
+ //
+ textBoxBrand.Location = new Point(110, 80);
+ textBoxBrand.Name = "textBoxBrand";
+ textBoxBrand.Size = new Size(156, 27);
+ textBoxBrand.TabIndex = 9;
+ //
+ // dateTimePickerDeliveryDate
+ //
+ dateTimePickerDeliveryDate.Location = new Point(447, 130);
+ dateTimePickerDeliveryDate.Name = "dateTimePickerDeliveryDate";
+ dateTimePickerDeliveryDate.Size = new Size(171, 27);
+ dateTimePickerDeliveryDate.TabIndex = 10;
+ //
+ // numericUpDownAvailabilityStore
+ //
+ numericUpDownAvailabilityStore.Location = new Point(447, 80);
+ numericUpDownAvailabilityStore.Name = "numericUpDownAvailabilityStore";
+ numericUpDownAvailabilityStore.Size = new Size(171, 27);
+ numericUpDownAvailabilityStore.TabIndex = 11;
+ //
+ // numericUpDownStockAvailability
+ //
+ numericUpDownStockAvailability.Location = new Point(447, 19);
+ numericUpDownStockAvailability.Name = "numericUpDownStockAvailability";
+ numericUpDownStockAvailability.Size = new Size(171, 27);
+ numericUpDownStockAvailability.TabIndex = 12;
+ //
+ // numericUpDownCost
+ //
+ numericUpDownCost.Location = new Point(110, 135);
+ numericUpDownCost.Name = "numericUpDownCost";
+ numericUpDownCost.Size = new Size(156, 27);
+ numericUpDownCost.TabIndex = 13;
+ //
+ // labelCategory
+ //
+ labelCategory.AutoSize = true;
+ labelCategory.Location = new Point(27, 191);
+ labelCategory.Name = "labelCategory";
+ labelCategory.Size = new Size(35, 20);
+ labelCategory.TabIndex = 14;
+ labelCategory.Text = "Тип";
+ //
+ // comboBoxCategoryName
+ //
+ comboBoxCategoryName.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxCategoryName.FormattingEnabled = true;
+ comboBoxCategoryName.Location = new Point(110, 191);
+ comboBoxCategoryName.Name = "comboBoxCategoryName";
+ comboBoxCategoryName.Size = new Size(151, 28);
+ comboBoxCategoryName.TabIndex = 15;
+ //
+ // FormAccessory
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(670, 302);
+ Controls.Add(comboBoxCategoryName);
+ Controls.Add(labelCategory);
+ Controls.Add(numericUpDownCost);
+ Controls.Add(numericUpDownStockAvailability);
+ Controls.Add(numericUpDownAvailabilityStore);
+ Controls.Add(dateTimePickerDeliveryDate);
+ Controls.Add(textBoxBrand);
+ Controls.Add(textBoxName);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(labelDeliveryDate);
+ Controls.Add(labelAvailabilityStore);
+ Controls.Add(labelStockAvailability);
+ Controls.Add(labelCost);
+ Controls.Add(labelBrand);
+ Controls.Add(labelName);
+ Name = "FormAccessory";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Аксессуар";
+ ((System.ComponentModel.ISupportInitialize)numericUpDownAvailabilityStore).EndInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownStockAvailability).EndInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownCost).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelName;
+ private Label labelBrand;
+ private Label labelCost;
+ private Label labelStockAvailability;
+ private Label labelAvailabilityStore;
+ private Label labelDeliveryDate;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private TextBox textBoxName;
+ private TextBox textBoxBrand;
+ private DateTimePicker dateTimePickerDeliveryDate;
+ private NumericUpDown numericUpDownAvailabilityStore;
+ private NumericUpDown numericUpDownStockAvailability;
+ private NumericUpDown numericUpDownCost;
+ private Label labelCategory;
+ private ComboBox comboBoxCategoryName;
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Forms/FormAccessory.cs b/ProjectOptika/Scripts/Forms/FormAccessory.cs
new file mode 100644
index 0000000..028a8db
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormAccessory.cs
@@ -0,0 +1,86 @@
+using ProjectOptika.Scripts.Entities;
+using ProjectOptika.Scripts.Entities.Enums;
+using ProjectOptika.Scripts.Repositories;
+
+namespace ProjectOptika.Scripts.Forms
+{
+ public partial class FormAccessory : Form
+ {
+ private readonly IAccessoriesRepository _accessoriesRepositories;
+
+ private int? _accessoriesID;
+
+ public int ID
+ {
+ set
+ {
+ try
+ {
+ var accessory = _accessoriesRepositories.GetAccessoriesByID(value);
+
+ if (accessory == null) throw new InvalidDataException(nameof(accessory));
+
+ _accessoriesID = accessory.ID;
+ textBoxBrand.Text = accessory.Brand;
+ textBoxName.Text = accessory.Name;
+ numericUpDownCost.Value = accessory.Cost;
+ numericUpDownAvailabilityStore.Value = accessory.AvailabilityStore;
+ numericUpDownStockAvailability.Value = accessory.StockAvailability;
+ dateTimePickerDeliveryDate.Value = accessory.DeliveryDate;
+
+ comboBoxCategoryName.SelectedIndex = (int)accessory.CategoryName;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormAccessory(IAccessoriesRepository accessoriesRepositories)
+ {
+ InitializeComponent();
+
+ _accessoriesRepositories = accessoriesRepositories
+ ?? throw new ArgumentNullException(nameof(accessoriesRepositories));
+
+ comboBoxCategoryName.DataSource = Enum.GetValues(typeof(CategoryType));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (comboBoxCategoryName.SelectedIndex < 1 || string.IsNullOrEmpty(textBoxName.Text) || string.IsNullOrEmpty(textBoxBrand.Text))
+ {
+ throw new Exception("Имеются незаполненные данные");
+ }
+
+ if (_accessoriesID.HasValue)
+ {
+ _accessoriesRepositories.UpdateAccessories(CreateAccessories(_accessoriesID.Value));
+ }
+ else
+ {
+ _accessoriesRepositories.CreateAccessories(CreateAccessories(0));
+ }
+ Close();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private Accessories CreateAccessories(int id)
+ {
+ return Accessories.CreateEntity(id, textBoxName.Text, textBoxBrand.Text, (int)numericUpDownCost.Value, (int)numericUpDownStockAvailability.Value, (int)numericUpDownAvailabilityStore.Value, dateTimePickerDeliveryDate.Value, (CategoryType)comboBoxCategoryName.SelectedIndex);
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormAccessory.resx b/ProjectOptika/Scripts/Forms/FormAccessory.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormAccessory.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/ProjectOptika/Scripts/Forms/FormClient.Designer.cs b/ProjectOptika/Scripts/Forms/FormClient.Designer.cs
new file mode 100644
index 0000000..af0f573
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormClient.Designer.cs
@@ -0,0 +1,186 @@
+namespace ProjectOptika.Scripts.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();
+ textBoxSurname = new TextBox();
+ labelSurname = new Label();
+ textBoxSecondName = new TextBox();
+ labelSecondName = new Label();
+ textBoxFirstName = new TextBox();
+ labelFirstName = new Label();
+ labelPhoneNumber = new Label();
+ textBoxPhoneNumber = new TextBox();
+ labelClientType = new Label();
+ comboBoxClientType = new ComboBox();
+ SuspendLayout();
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(426, 114);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 23;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(314, 114);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 29);
+ buttonSave.TabIndex = 22;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // textBoxSurname
+ //
+ textBoxSurname.Location = new Point(108, 111);
+ textBoxSurname.Name = "textBoxSurname";
+ textBoxSurname.Size = new Size(125, 27);
+ textBoxSurname.TabIndex = 21;
+ //
+ // labelSurname
+ //
+ labelSurname.AutoSize = true;
+ labelSurname.Location = new Point(11, 114);
+ labelSurname.Name = "labelSurname";
+ labelSurname.Size = new Size(74, 20);
+ labelSurname.TabIndex = 20;
+ labelSurname.Text = "Фимилия";
+ //
+ // textBoxSecondName
+ //
+ textBoxSecondName.Location = new Point(108, 60);
+ textBoxSecondName.Name = "textBoxSecondName";
+ textBoxSecondName.Size = new Size(125, 27);
+ textBoxSecondName.TabIndex = 19;
+ //
+ // labelSecondName
+ //
+ labelSecondName.AutoSize = true;
+ labelSecondName.Location = new Point(11, 63);
+ labelSecondName.Name = "labelSecondName";
+ labelSecondName.Size = new Size(72, 20);
+ labelSecondName.TabIndex = 18;
+ labelSecondName.Text = "Отчество";
+ //
+ // textBoxFirstName
+ //
+ textBoxFirstName.Location = new Point(108, 12);
+ textBoxFirstName.Name = "textBoxFirstName";
+ textBoxFirstName.Size = new Size(125, 27);
+ textBoxFirstName.TabIndex = 17;
+ //
+ // labelFirstName
+ //
+ labelFirstName.AutoSize = true;
+ labelFirstName.Location = new Point(11, 15);
+ labelFirstName.Name = "labelFirstName";
+ labelFirstName.Size = new Size(39, 20);
+ labelFirstName.TabIndex = 16;
+ labelFirstName.Text = "Имя";
+ //
+ // labelPhoneNumber
+ //
+ labelPhoneNumber.AutoSize = true;
+ labelPhoneNumber.Location = new Point(249, 15);
+ labelPhoneNumber.Name = "labelPhoneNumber";
+ labelPhoneNumber.Size = new Size(127, 20);
+ labelPhoneNumber.TabIndex = 24;
+ labelPhoneNumber.Text = "Номер телефона";
+ //
+ // textBoxPhoneNumber
+ //
+ textBoxPhoneNumber.Location = new Point(399, 12);
+ textBoxPhoneNumber.Name = "textBoxPhoneNumber";
+ textBoxPhoneNumber.Size = new Size(183, 27);
+ textBoxPhoneNumber.TabIndex = 25;
+ //
+ // labelClientType
+ //
+ labelClientType.AutoSize = true;
+ labelClientType.Location = new Point(249, 70);
+ labelClientType.Name = "labelClientType";
+ labelClientType.Size = new Size(94, 20);
+ labelClientType.TabIndex = 26;
+ labelClientType.Text = "Тип клиента";
+ //
+ // comboBoxClientType
+ //
+ comboBoxClientType.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxClientType.FormattingEnabled = true;
+ comboBoxClientType.Location = new Point(399, 67);
+ comboBoxClientType.Name = "comboBoxClientType";
+ comboBoxClientType.Size = new Size(183, 28);
+ comboBoxClientType.TabIndex = 27;
+ //
+ // FormClient
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(594, 152);
+ Controls.Add(comboBoxClientType);
+ Controls.Add(labelClientType);
+ Controls.Add(textBoxPhoneNumber);
+ Controls.Add(labelPhoneNumber);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxSurname);
+ Controls.Add(labelSurname);
+ Controls.Add(textBoxSecondName);
+ Controls.Add(labelSecondName);
+ Controls.Add(textBoxFirstName);
+ Controls.Add(labelFirstName);
+ Name = "FormClient";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Клиент";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonCancel;
+ private Button buttonSave;
+ private TextBox textBoxSurname;
+ private Label labelSurname;
+ private TextBox textBoxSecondName;
+ private Label labelSecondName;
+ private TextBox textBoxFirstName;
+ private Label labelFirstName;
+ private Label labelPhoneNumber;
+ private TextBox textBoxPhoneNumber;
+ private Label labelClientType;
+ private ComboBox comboBoxClientType;
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Forms/FormClient.cs b/ProjectOptika/Scripts/Forms/FormClient.cs
new file mode 100644
index 0000000..73866ef
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormClient.cs
@@ -0,0 +1,84 @@
+using ProjectOptika.Scripts.Entities;
+using ProjectOptika.Scripts.Entities.Enums;
+using ProjectOptika.Scripts.Repositories;
+
+namespace ProjectOptika.Scripts.Forms
+{
+ public partial class FormClient : Form
+ {
+ private readonly IClientRepositiory _clientRepositories;
+
+ private int? _clientID;
+
+ public int ID
+ {
+ set
+ {
+ try
+ {
+ var client = _clientRepositories.GetClientById(value);
+
+ if (client == null) throw new InvalidDataException(nameof(client));
+
+ _clientID = client.ID;
+ textBoxFirstName.Text = client.FirstName;
+ textBoxSecondName.Text = client.SecondName;
+ textBoxSurname.Text = client.Surname;
+ textBoxPhoneNumber.Text = client.PhoneNumber;
+
+ comboBoxClientType.SelectedIndex = (int)client.ClientType;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormClient(IClientRepositiory clientRepositories)
+ {
+ InitializeComponent();
+
+ _clientRepositories = clientRepositories ??
+ throw new ArgumentNullException(nameof(clientRepositories));
+
+ comboBoxClientType.DataSource = Enum.GetValues(typeof(ClientType));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(textBoxSecondName.Text) || string.IsNullOrEmpty(textBoxSurname.Text) || string.IsNullOrEmpty(textBoxFirstName.Text))
+ {
+ throw new Exception("Имеются незаполненные данные");
+ }
+
+ if (_clientID.HasValue)
+ {
+ _clientRepositories.UpdateClient(CreateClient(_clientID.Value));
+ }
+ else
+ {
+ _clientRepositories.CreateClient(CreateClient(0));
+ }
+ Close();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private Client CreateClient(int id)
+ {
+ return Client.CreateEntity(id, (ClientType)comboBoxClientType.SelectedIndex, textBoxFirstName.Text, textBoxSecondName.Text, textBoxSurname.Text, textBoxPhoneNumber.Text);
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormClient.resx b/ProjectOptika/Scripts/Forms/FormClient.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectOptika/Scripts/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/ProjectOptika/Scripts/Forms/FormClients.Designer.cs b/ProjectOptika/Scripts/Forms/FormClients.Designer.cs
new file mode 100644
index 0000000..0ffb803
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormClients.Designer.cs
@@ -0,0 +1,127 @@
+namespace ProjectOptika.Scripts.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()
+ {
+ buttonRemove = new Button();
+ buttonUpdate = new Button();
+ buttonAdd = new Button();
+ panel = new Panel();
+ dataGridView = new DataGridView();
+ panel.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // buttonRemove
+ //
+ buttonRemove.BackgroundImage = Properties.Resources.Remove;
+ buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonRemove.Location = new Point(3, 166);
+ buttonRemove.Name = "buttonRemove";
+ buttonRemove.Size = new Size(96, 71);
+ buttonRemove.TabIndex = 2;
+ buttonRemove.UseVisualStyleBackColor = true;
+ buttonRemove.Click += ButtonRemove_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.BackgroundImage = Properties.Resources.Update;
+ buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdate.Location = new Point(3, 89);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(96, 71);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(3, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(96, 71);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // panel
+ //
+ panel.Controls.Add(buttonRemove);
+ panel.Controls.Add(buttonUpdate);
+ panel.Controls.Add(buttonAdd);
+ panel.Dock = DockStyle.Right;
+ panel.Location = new Point(696, 0);
+ panel.Name = "panel";
+ panel.Size = new Size(104, 450);
+ panel.TabIndex = 8;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.AllowUserToResizeColumns = false;
+ dataGridView.AllowUserToResizeRows = false;
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Fill;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.MultiSelect = false;
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(800, 450);
+ dataGridView.TabIndex = 9;
+ //
+ // FormClients
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(panel);
+ Controls.Add(dataGridView);
+ Name = "FormClients";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Клиенты";
+ Load += Form_Load;
+ panel.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonRemove;
+ private Button buttonUpdate;
+ private Button buttonAdd;
+ private Panel panel;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Forms/FormClients.cs b/ProjectOptika/Scripts/Forms/FormClients.cs
new file mode 100644
index 0000000..5fd525b
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormClients.cs
@@ -0,0 +1,97 @@
+using ProjectOptika.Scripts.Repositories;
+using Unity;
+
+namespace ProjectOptika.Scripts.Forms
+{
+ public partial class FormClients : Form
+ {
+ private readonly IUnityContainer _container;
+
+ private readonly IClientRepositiory _clientRepositories;
+
+ public FormClients(IUnityContainer container, IClientRepositiory clientRepositories)
+ {
+ InitializeComponent();
+
+ _container = container ??
+ throw new ArgumentException(nameof(container));
+
+ _clientRepositories = clientRepositories ??
+ throw new ArgumentException(nameof(clientRepositories));
+ }
+
+ private void Form_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
+
+ try
+ {
+ var form = _container.Resolve();
+ form.ID = findID;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonRemove_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
+
+ if (MessageBox.Show("Удалить запись?", "Удалить", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
+
+ try
+ {
+ _clientRepositories.DeleteClient(findID);
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridView.DataSource = _clientRepositories.GetClients();
+
+ private bool TryGetIdentifierFromSelectedRows(out int id)
+ {
+ id = 0;
+ if (dataGridView.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+
+ id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormClients.resx b/ProjectOptika/Scripts/Forms/FormClients.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormClients.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/ProjectOptika/Scripts/Forms/FormEmployee.Designer.cs b/ProjectOptika/Scripts/Forms/FormEmployee.Designer.cs
new file mode 100644
index 0000000..6f8f368
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormEmployee.Designer.cs
@@ -0,0 +1,163 @@
+namespace ProjectOptika.Scripts.Forms
+{
+ partial class FormEmployee
+ {
+ ///
+ /// 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()
+ {
+ checkedListBoxPositionEmployee = new CheckedListBox();
+ labelFirstName = new Label();
+ textBoxFirstName = new TextBox();
+ textBoxSecondName = new TextBox();
+ labelSecondName = new Label();
+ textBoxSurname = new TextBox();
+ labelSurname = new Label();
+ labelPositionEmployee = new Label();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ SuspendLayout();
+ //
+ // checkedListBoxPositionEmployee
+ //
+ checkedListBoxPositionEmployee.FormattingEnabled = true;
+ checkedListBoxPositionEmployee.Location = new Point(298, 45);
+ checkedListBoxPositionEmployee.Name = "checkedListBoxPositionEmployee";
+ checkedListBoxPositionEmployee.Size = new Size(225, 180);
+ checkedListBoxPositionEmployee.TabIndex = 0;
+ //
+ // labelFirstName
+ //
+ labelFirstName.AutoSize = true;
+ labelFirstName.Location = new Point(12, 9);
+ labelFirstName.Name = "labelFirstName";
+ labelFirstName.Size = new Size(39, 20);
+ labelFirstName.TabIndex = 1;
+ labelFirstName.Text = "Имя";
+ //
+ // textBoxFirstName
+ //
+ textBoxFirstName.Location = new Point(109, 6);
+ textBoxFirstName.Name = "textBoxFirstName";
+ textBoxFirstName.Size = new Size(125, 27);
+ textBoxFirstName.TabIndex = 2;
+ //
+ // textBoxSecondName
+ //
+ textBoxSecondName.Location = new Point(109, 54);
+ textBoxSecondName.Name = "textBoxSecondName";
+ textBoxSecondName.Size = new Size(125, 27);
+ textBoxSecondName.TabIndex = 4;
+ //
+ // labelSecondName
+ //
+ labelSecondName.AutoSize = true;
+ labelSecondName.Location = new Point(12, 57);
+ labelSecondName.Name = "labelSecondName";
+ labelSecondName.Size = new Size(72, 20);
+ labelSecondName.TabIndex = 3;
+ labelSecondName.Text = "Отчество";
+ //
+ // textBoxSurname
+ //
+ textBoxSurname.Location = new Point(109, 105);
+ textBoxSurname.Name = "textBoxSurname";
+ textBoxSurname.Size = new Size(125, 27);
+ textBoxSurname.TabIndex = 6;
+ //
+ // labelSurname
+ //
+ labelSurname.AutoSize = true;
+ labelSurname.Location = new Point(12, 108);
+ labelSurname.Name = "labelSurname";
+ labelSurname.Size = new Size(74, 20);
+ labelSurname.TabIndex = 5;
+ labelSurname.Text = "Фимилия";
+ //
+ // labelPositionEmployee
+ //
+ labelPositionEmployee.AutoSize = true;
+ labelPositionEmployee.Location = new Point(298, 13);
+ labelPositionEmployee.Name = "labelPositionEmployee";
+ labelPositionEmployee.Size = new Size(86, 20);
+ labelPositionEmployee.TabIndex = 7;
+ labelPositionEmployee.Text = "Должность";
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(151, 196);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 15;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(12, 196);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 29);
+ buttonSave.TabIndex = 14;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // FormEmployee
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(537, 255);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(labelPositionEmployee);
+ Controls.Add(textBoxSurname);
+ Controls.Add(labelSurname);
+ Controls.Add(textBoxSecondName);
+ Controls.Add(labelSecondName);
+ Controls.Add(textBoxFirstName);
+ Controls.Add(labelFirstName);
+ Controls.Add(checkedListBoxPositionEmployee);
+ Name = "FormEmployee";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Сотрудник";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private CheckedListBox checkedListBoxPositionEmployee;
+ private Label labelFirstName;
+ private TextBox textBoxFirstName;
+ private TextBox textBoxSecondName;
+ private Label labelSecondName;
+ private TextBox textBoxSurname;
+ private Label labelSurname;
+ private Label labelPositionEmployee;
+ private Button buttonCancel;
+ private Button buttonSave;
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Forms/FormEmployee.cs b/ProjectOptika/Scripts/Forms/FormEmployee.cs
new file mode 100644
index 0000000..9d62656
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormEmployee.cs
@@ -0,0 +1,99 @@
+using ProjectOptika.Scripts.Entities.Enums;
+using ProjectOptika.Scripts.Entities;
+using ProjectOptika.Scripts.Repositories;
+
+namespace ProjectOptika.Scripts.Forms
+{
+ public partial class FormEmployee : Form
+ {
+ private readonly IEmployeeRepository _employeeRepositories;
+
+ private int? _employeeID;
+
+ public int ID
+ {
+ set
+ {
+ try
+ {
+ var employee = _employeeRepositories.GetEmployeerByID(value);
+
+ if (employee == null) throw new InvalidDataException(nameof(employee));
+
+ _employeeID = employee.ID;
+ textBoxFirstName.Text = employee.FirstName;
+ textBoxSecondName.Text = employee.SecondName;
+ textBoxSurname.Text = employee.Surname;
+
+ foreach(PositionEmployee element in Enum.GetValues(typeof(PositionEmployee)))
+ {
+ if ((element & employee.PositionEmployee) != 0)
+ {
+ checkedListBoxPositionEmployee.SetItemChecked(checkedListBoxPositionEmployee.Items.IndexOf(element), true);
+ }
+ }
+
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormEmployee(IEmployeeRepository employeeRepositories)
+ {
+ InitializeComponent();
+
+ _employeeRepositories = employeeRepositories ??
+ throw new ArgumentNullException(nameof(employeeRepositories));
+
+ foreach (var i in Enum.GetValues(typeof(PositionEmployee)))
+ {
+ checkedListBoxPositionEmployee.Items.Add(i);
+ }
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(textBoxSecondName.Text) || string.IsNullOrEmpty(textBoxSurname.Text) || string.IsNullOrEmpty(textBoxFirstName.Text))
+ {
+ throw new Exception("Имеются незаполненные данные");
+ }
+
+ if (_employeeID.HasValue)
+ {
+ _employeeRepositories.UpdateEmployee(CreateEmployee(_employeeID.Value));
+ }
+ else
+ {
+ _employeeRepositories.CreateEmployee(CreateEmployee(0));
+ }
+ Close();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private Employee CreateEmployee(int id)
+ {
+ PositionEmployee positionEmployee = PositionEmployee.None;
+ foreach(var element in checkedListBoxPositionEmployee.CheckedItems)
+ {
+ positionEmployee |= (PositionEmployee)element;
+ }
+
+ return Employee.CreateEntity(id, positionEmployee, textBoxFirstName.Text, textBoxSecondName.Text, textBoxSurname.Text);
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormEmployee.resx b/ProjectOptika/Scripts/Forms/FormEmployee.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormEmployee.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/ProjectOptika/Scripts/Forms/FormEmplyees.Designer.cs b/ProjectOptika/Scripts/Forms/FormEmplyees.Designer.cs
new file mode 100644
index 0000000..6cde149
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormEmplyees.Designer.cs
@@ -0,0 +1,127 @@
+namespace ProjectOptika.Scripts.Forms
+{
+ partial class FormEmplyees
+ {
+ ///
+ /// 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()
+ {
+ panel = new Panel();
+ buttonRemove = new Button();
+ buttonUpdate = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ panel.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // panel
+ //
+ panel.Controls.Add(buttonRemove);
+ panel.Controls.Add(buttonUpdate);
+ panel.Controls.Add(buttonAdd);
+ panel.Dock = DockStyle.Right;
+ panel.Location = new Point(696, 0);
+ panel.Name = "panel";
+ panel.Size = new Size(104, 450);
+ panel.TabIndex = 6;
+ //
+ // buttonRemove
+ //
+ buttonRemove.BackgroundImage = Properties.Resources.Remove;
+ buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonRemove.Location = new Point(3, 166);
+ buttonRemove.Name = "buttonRemove";
+ buttonRemove.Size = new Size(96, 71);
+ buttonRemove.TabIndex = 2;
+ buttonRemove.UseVisualStyleBackColor = true;
+ buttonRemove.Click += ButtonRemove_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.BackgroundImage = Properties.Resources.Update;
+ buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdate.Location = new Point(3, 89);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(96, 71);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(3, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(96, 71);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.AllowUserToResizeColumns = false;
+ dataGridView.AllowUserToResizeRows = false;
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Fill;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.MultiSelect = false;
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(800, 450);
+ dataGridView.TabIndex = 7;
+ //
+ // FormEmplyees
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(panel);
+ Controls.Add(dataGridView);
+ Name = "FormEmplyees";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Сотрудники";
+ Load += Form_Load;
+ panel.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel panel;
+ private Button buttonRemove;
+ private Button buttonUpdate;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Forms/FormEmplyees.cs b/ProjectOptika/Scripts/Forms/FormEmplyees.cs
new file mode 100644
index 0000000..325aeeb
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormEmplyees.cs
@@ -0,0 +1,97 @@
+using ProjectOptika.Scripts.Repositories;
+using Unity;
+
+namespace ProjectOptika.Scripts.Forms
+{
+ public partial class FormEmplyees : Form
+ {
+ private readonly IUnityContainer _container;
+
+ private readonly IEmployeeRepository _employeeRepositories;
+
+ public FormEmplyees(IUnityContainer container, IEmployeeRepository employeeRepositories)
+ {
+ InitializeComponent();
+
+ _container = container ??
+ throw new ArgumentException(nameof(container));
+
+ _employeeRepositories = employeeRepositories ??
+ throw new ArgumentException(nameof(employeeRepositories));
+ }
+
+ private void Form_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
+
+ try
+ {
+ var form = _container.Resolve();
+ form.ID = findID;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonRemove_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
+
+ if (MessageBox.Show("Удалить запись?", "Удалить", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
+
+ try
+ {
+ _employeeRepositories.DeleteEmployee(findID);
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridView.DataSource = _employeeRepositories.GetEmployees();
+
+ private bool TryGetIdentifierFromSelectedRows(out int id)
+ {
+ id = 0;
+ if (dataGridView.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+
+ id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormEmplyees.resx b/ProjectOptika/Scripts/Forms/FormEmplyees.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormEmplyees.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/ProjectOptika/Scripts/Forms/FormItemOrder.Designer.cs b/ProjectOptika/Scripts/Forms/FormItemOrder.Designer.cs
new file mode 100644
index 0000000..6dc71e3
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormItemOrder.Designer.cs
@@ -0,0 +1,217 @@
+namespace ProjectOptika.Scripts.Forms
+{
+ partial class FormItemOrder
+ {
+ ///
+ /// 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();
+ groupBoxAccessories = new GroupBox();
+ dataGridViewAccessories = new DataGridView();
+ ColumnAccessory = new DataGridViewComboBoxColumn();
+ ColumnCount = new DataGridViewTextBoxColumn();
+ labelEmployee = new Label();
+ labelClient = new Label();
+ labelDate = new Label();
+ labelTotalCost = new Label();
+ comboBoxEmployee = new ComboBox();
+ comboBoxClient = new ComboBox();
+ dateTimePickerData = new DateTimePicker();
+ numericUpDownNumTotalCost = new NumericUpDown();
+ groupBoxAccessories.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewAccessories).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownNumTotalCost).BeginInit();
+ SuspendLayout();
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(215, 445);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(122, 41);
+ buttonCancel.TabIndex = 8;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(12, 445);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(122, 41);
+ buttonSave.TabIndex = 7;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // groupBoxAccessories
+ //
+ groupBoxAccessories.Controls.Add(dataGridViewAccessories);
+ groupBoxAccessories.Location = new Point(464, 12);
+ groupBoxAccessories.Name = "groupBoxAccessories";
+ groupBoxAccessories.Size = new Size(307, 445);
+ groupBoxAccessories.TabIndex = 13;
+ groupBoxAccessories.TabStop = false;
+ groupBoxAccessories.Text = "Аксессуары:";
+ //
+ // dataGridViewAccessories
+ //
+ dataGridViewAccessories.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewAccessories.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewAccessories.Columns.AddRange(new DataGridViewColumn[] { ColumnAccessory, ColumnCount });
+ dataGridViewAccessories.Location = new Point(6, 26);
+ dataGridViewAccessories.Name = "dataGridViewAccessories";
+ dataGridViewAccessories.RowHeadersVisible = false;
+ dataGridViewAccessories.RowHeadersWidth = 51;
+ dataGridViewAccessories.Size = new Size(295, 413);
+ dataGridViewAccessories.TabIndex = 0;
+ //
+ // ColumnAccessory
+ //
+ ColumnAccessory.HeaderText = "Аксессуары";
+ ColumnAccessory.MinimumWidth = 6;
+ ColumnAccessory.Name = "ColumnAccessory";
+ //
+ // ColumnCount
+ //
+ ColumnCount.HeaderText = "Количество";
+ ColumnCount.MinimumWidth = 6;
+ ColumnCount.Name = "ColumnCount";
+ //
+ // labelEmployee
+ //
+ labelEmployee.AutoSize = true;
+ labelEmployee.Location = new Point(12, 24);
+ labelEmployee.Name = "labelEmployee";
+ labelEmployee.Size = new Size(82, 20);
+ labelEmployee.TabIndex = 14;
+ labelEmployee.Text = "Сотрудник";
+ //
+ // labelClient
+ //
+ labelClient.AutoSize = true;
+ labelClient.Location = new Point(12, 104);
+ labelClient.Name = "labelClient";
+ labelClient.Size = new Size(58, 20);
+ labelClient.TabIndex = 15;
+ labelClient.Text = "Клиент";
+ //
+ // labelDate
+ //
+ labelDate.AutoSize = true;
+ labelDate.Location = new Point(12, 192);
+ labelDate.Name = "labelDate";
+ labelDate.Size = new Size(41, 20);
+ labelDate.TabIndex = 16;
+ labelDate.Text = "Дата";
+ //
+ // labelTotalCost
+ //
+ labelTotalCost.AutoSize = true;
+ labelTotalCost.Location = new Point(12, 274);
+ labelTotalCost.Name = "labelTotalCost";
+ labelTotalCost.Size = new Size(133, 20);
+ labelTotalCost.TabIndex = 17;
+ labelTotalCost.Text = "Общая стоимость";
+ //
+ // comboBoxEmployee
+ //
+ comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxEmployee.FormattingEnabled = true;
+ comboBoxEmployee.Location = new Point(194, 21);
+ comboBoxEmployee.Name = "comboBoxEmployee";
+ comboBoxEmployee.Size = new Size(238, 28);
+ comboBoxEmployee.TabIndex = 18;
+ //
+ // comboBoxClient
+ //
+ comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxClient.FormattingEnabled = true;
+ comboBoxClient.Location = new Point(194, 101);
+ comboBoxClient.Name = "comboBoxClient";
+ comboBoxClient.Size = new Size(238, 28);
+ comboBoxClient.TabIndex = 19;
+ //
+ // dateTimePickerData
+ //
+ dateTimePickerData.Enabled = false;
+ dateTimePickerData.Location = new Point(194, 187);
+ dateTimePickerData.Name = "dateTimePickerData";
+ dateTimePickerData.Size = new Size(238, 27);
+ dateTimePickerData.TabIndex = 20;
+ //
+ // numericUpDownNumTotalCost
+ //
+ numericUpDownNumTotalCost.Location = new Point(194, 272);
+ numericUpDownNumTotalCost.Name = "numericUpDownNumTotalCost";
+ numericUpDownNumTotalCost.Size = new Size(238, 27);
+ numericUpDownNumTotalCost.TabIndex = 21;
+ numericUpDownNumTotalCost.Value = new decimal(new int[] { 1, 0, 0, 0 });
+ //
+ // FormItemOrder
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 498);
+ Controls.Add(numericUpDownNumTotalCost);
+ Controls.Add(dateTimePickerData);
+ Controls.Add(comboBoxClient);
+ Controls.Add(comboBoxEmployee);
+ Controls.Add(labelTotalCost);
+ Controls.Add(labelDate);
+ Controls.Add(labelClient);
+ Controls.Add(labelEmployee);
+ Controls.Add(groupBoxAccessories);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Name = "FormItemOrder";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Заказ";
+ groupBoxAccessories.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridViewAccessories).EndInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownNumTotalCost).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonCancel;
+ private Button buttonSave;
+ private GroupBox groupBoxAccessories;
+ private DataGridView dataGridViewAccessories;
+ private DataGridViewComboBoxColumn ColumnAccessory;
+ private DataGridViewTextBoxColumn ColumnCount;
+ private Label labelEmployee;
+ private Label labelClient;
+ private Label labelDate;
+ private Label labelTotalCost;
+ private ComboBox comboBoxEmployee;
+ private ComboBox comboBoxClient;
+ private DateTimePicker dateTimePickerData;
+ private NumericUpDown numericUpDownNumTotalCost;
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Forms/FormItemOrder.cs b/ProjectOptika/Scripts/Forms/FormItemOrder.cs
new file mode 100644
index 0000000..ca19e88
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormItemOrder.cs
@@ -0,0 +1,77 @@
+
+using ProjectOptika.Scripts.Entities;
+using ProjectOptika.Scripts.Repositories;
+using ProjectOptika.Scripts.Repositories.Implementations;
+
+namespace ProjectOptika.Scripts.Forms
+{
+ public partial class FormItemOrder : Form
+ {
+ private readonly IOrderRepository _orderRepository;
+
+ public FormItemOrder(IOrderRepository orderRepository, IEmployeeRepository employeeRepository, IClientRepositiory clientRepositiory, IAccessoriesRepository accessoriesRepository)
+ {
+ InitializeComponent();
+
+ _orderRepository = orderRepository ??
+ throw new ArgumentNullException(nameof(orderRepository));
+
+ comboBoxEmployee.DataSource = employeeRepository.GetEmployees();
+ comboBoxEmployee.DisplayMember = "Surname";
+ comboBoxEmployee.ValueMember = "ID";
+
+ comboBoxClient.DataSource = clientRepositiory.GetClients();
+ comboBoxClient.DisplayMember = "Surname";
+ comboBoxClient.ValueMember = "ID";
+
+ ColumnAccessory.DataSource = accessoriesRepository.GetAccessories();
+ ColumnAccessory.DisplayMember = "Name";
+ ColumnAccessory.ValueMember = "ID";
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (comboBoxClient.SelectedIndex < 0 ||
+ comboBoxEmployee.SelectedIndex < 0 ||
+ dataGridViewAccessories.RowCount < 1)
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ _orderRepository.CreateOrder(Order.CreateOperation(0,
+ (int)comboBoxEmployee.SelectedValue!,
+ (int)comboBoxClient.SelectedValue!,
+ (double)numericUpDownNumTotalCost.Value,
+ CreateListAccessoriesOrderReceptionsFromDataGrid()));
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private List CreateListAccessoriesOrderReceptionsFromDataGrid()
+
+ {
+ var list = new List();
+ foreach (DataGridViewRow row in dataGridViewAccessories.Rows)
+ {
+ if (row.Cells["ColumnAccessory"].Value == null ||
+ row.Cells["ColumnCount"].Value == null)
+ {
+ continue;
+ }
+ list.Add(AccessoriesOrder.CreateElement(0,
+ Convert.ToInt32(row.Cells["ColumnAccessory"].Value),
+ Convert.ToInt32(row.Cells["ColumnCount"].Value)));
+ }
+ return list;
+
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormItemOrder.resx b/ProjectOptika/Scripts/Forms/FormItemOrder.resx
new file mode 100644
index 0000000..f00c176
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormItemOrder.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/ProjectOptika/Scripts/Forms/FormItemOrders.Designer.cs b/ProjectOptika/Scripts/Forms/FormItemOrders.Designer.cs
new file mode 100644
index 0000000..a9b1ed2
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormItemOrders.Designer.cs
@@ -0,0 +1,113 @@
+namespace ProjectOptika.Scripts.Forms
+{
+ partial class FormItemOrders
+ {
+ ///
+ /// 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()
+ {
+ panel = new Panel();
+ buttonRemove = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ panel.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // panel
+ //
+ panel.Controls.Add(buttonRemove);
+ panel.Controls.Add(buttonAdd);
+ panel.Dock = DockStyle.Right;
+ panel.Location = new Point(696, 0);
+ panel.Name = "panel";
+ panel.Size = new Size(104, 450);
+ panel.TabIndex = 8;
+ //
+ // buttonRemove
+ //
+ buttonRemove.BackgroundImage = Properties.Resources.Remove;
+ buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonRemove.Location = new Point(3, 89);
+ buttonRemove.Name = "buttonRemove";
+ buttonRemove.Size = new Size(96, 71);
+ buttonRemove.TabIndex = 2;
+ buttonRemove.UseVisualStyleBackColor = true;
+ buttonRemove.Click += ButtonDel_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(3, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(96, 71);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.AllowUserToResizeColumns = false;
+ dataGridView.AllowUserToResizeRows = false;
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Fill;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.MultiSelect = false;
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(800, 450);
+ dataGridView.TabIndex = 9;
+ //
+ // FormItemOrders
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(panel);
+ Controls.Add(dataGridView);
+ Name = "FormItemOrders";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Заказы";
+ Load += Form_Load;
+ panel.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel panel;
+ private Button buttonRemove;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Forms/FormItemOrders.cs b/ProjectOptika/Scripts/Forms/FormItemOrders.cs
new file mode 100644
index 0000000..9b66a4c
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormItemOrders.cs
@@ -0,0 +1,88 @@
+using ProjectOptika.Scripts.Repositories;
+using Unity;
+
+namespace ProjectOptika.Scripts.Forms
+{
+ public partial class FormItemOrders : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IOrderRepository _orderRepository;
+
+ public FormItemOrders(IUnityContainer container, IOrderRepository orderRepository)
+ {
+ InitializeComponent();
+ _container = container ??
+ throw new ArgumentNullException(nameof(container));
+ _orderRepository = orderRepository ??
+ throw new ArgumentNullException(nameof(orderRepository));
+ }
+
+ private void Form_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridView.DataSource =
+ _orderRepository.GetOrders();
+
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridView.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+
+ 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 ButtonDel_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);
+ }
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormItemOrders.resx b/ProjectOptika/Scripts/Forms/FormItemOrders.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormItemOrders.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/ProjectOptika/Scripts/Forms/FormOptika.Designer.cs b/ProjectOptika/Scripts/Forms/FormOptika.Designer.cs
new file mode 100644
index 0000000..221e767
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormOptika.Designer.cs
@@ -0,0 +1,138 @@
+namespace ProjectOptika
+{
+ partial class FormOptika
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ menuStrip = new MenuStrip();
+ справочникиToolStripMenuItem = new ToolStripMenuItem();
+ аксессуарыToolStripMenuItem = new ToolStripMenuItem();
+ характеристикиToolStripMenuItem = new ToolStripMenuItem();
+ сотрудникToolStripMenuItem = new ToolStripMenuItem();
+ клиентToolStripMenuItem = new ToolStripMenuItem();
+ операцииToolStripMenuItem = new ToolStripMenuItem();
+ заказToolStripMenuItem = new ToolStripMenuItem();
+ отчетToolStripMenuItem = new ToolStripMenuItem();
+ menuStrip.SuspendLayout();
+ SuspendLayout();
+ //
+ // menuStrip
+ //
+ menuStrip.ImageScalingSize = new Size(20, 20);
+ menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетToolStripMenuItem });
+ menuStrip.Location = new Point(0, 0);
+ menuStrip.Name = "menuStrip";
+ menuStrip.Size = new Size(800, 28);
+ menuStrip.TabIndex = 0;
+ menuStrip.Text = "menuStrip1";
+ //
+ // справочникиToolStripMenuItem
+ //
+ справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { аксессуарыToolStripMenuItem, характеристикиToolStripMenuItem, сотрудникToolStripMenuItem, клиентToolStripMenuItem });
+ справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ справочникиToolStripMenuItem.Size = new Size(117, 24);
+ справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // аксессуарыToolStripMenuItem
+ //
+ аксессуарыToolStripMenuItem.Name = "аксессуарыToolStripMenuItem";
+ аксессуарыToolStripMenuItem.Size = new Size(203, 26);
+ аксессуарыToolStripMenuItem.Text = "Аксессуар";
+ аксессуарыToolStripMenuItem.Click += AccessoriesToolStripMenuItem_Click;
+ //
+ // характеристикиToolStripMenuItem
+ //
+ характеристикиToolStripMenuItem.Name = "характеристикиToolStripMenuItem";
+ характеристикиToolStripMenuItem.Size = new Size(203, 26);
+ характеристикиToolStripMenuItem.Text = "Характеристики";
+ характеристикиToolStripMenuItem.Click += SpecificationToolStripMenuItem_Click;
+ //
+ // сотрудникToolStripMenuItem
+ //
+ сотрудникToolStripMenuItem.Name = "сотрудникToolStripMenuItem";
+ сотрудникToolStripMenuItem.Size = new Size(203, 26);
+ сотрудникToolStripMenuItem.Text = "Сотрудник";
+ сотрудникToolStripMenuItem.Click += EmplyeeToolStripMenuItem_Click;
+ //
+ // клиентToolStripMenuItem
+ //
+ клиентToolStripMenuItem.Name = "клиентToolStripMenuItem";
+ клиентToolStripMenuItem.Size = new Size(203, 26);
+ клиентToolStripMenuItem.Text = "Клиент";
+ клиентToolStripMenuItem.Click += ClientToolStripMenuItem_Click;
+ //
+ // операцииToolStripMenuItem
+ //
+ операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказToolStripMenuItem });
+ операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
+ операцииToolStripMenuItem.Size = new Size(95, 24);
+ операцииToolStripMenuItem.Text = "Операции";
+ //
+ // заказToolStripMenuItem
+ //
+ заказToolStripMenuItem.Name = "заказToolStripMenuItem";
+ заказToolStripMenuItem.Size = new Size(196, 26);
+ заказToolStripMenuItem.Text = "Оптовый заказ";
+ заказToolStripMenuItem.Click += ItemOrderToolStripMenuItem_Click;
+ //
+ // отчетToolStripMenuItem
+ //
+ отчетToolStripMenuItem.Name = "отчетToolStripMenuItem";
+ отчетToolStripMenuItem.Size = new Size(73, 24);
+ отчетToolStripMenuItem.Text = "Отчеты";
+ //
+ // FormOptika
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ BackgroundImage = Properties.Resources.optika;
+ BackgroundImageLayout = ImageLayout.Stretch;
+ ClientSize = new Size(800, 450);
+ Controls.Add(menuStrip);
+ MainMenuStrip = menuStrip;
+ Name = "FormOptika";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Оптика";
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private ToolStripMenuItem операцииToolStripMenuItem;
+ private ToolStripMenuItem отчетToolStripMenuItem;
+ private ToolStripMenuItem аксессуарыToolStripMenuItem;
+ private ToolStripMenuItem заказToolStripMenuItem;
+ private ToolStripMenuItem характеристикиToolStripMenuItem;
+ private ToolStripMenuItem сотрудникToolStripMenuItem;
+ private ToolStripMenuItem клиентToolStripMenuItem;
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormOptika.cs b/ProjectOptika/Scripts/Forms/FormOptika.cs
new file mode 100644
index 0000000..c501912
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormOptika.cs
@@ -0,0 +1,78 @@
+using ProjectOptika.Scripts.Forms;
+using Unity;
+
+namespace ProjectOptika
+{
+ public partial class FormOptika : Form
+ {
+ private IUnityContainer _container;
+
+ public FormOptika(IUnityContainer container)
+ {
+ InitializeComponent();
+
+ _container = container ??
+ throw new ArgumentNullException(nameof(container));
+ }
+
+ private void AccessoriesToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void SpecificationToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ItemOrderToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void EmplyeeToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormOptika.resx b/ProjectOptika/Scripts/Forms/FormOptika.resx
new file mode 100644
index 0000000..6c82d08
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormOptika.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/ProjectOptika/Scripts/Forms/FormSpecification.Designer.cs b/ProjectOptika/Scripts/Forms/FormSpecification.Designer.cs
new file mode 100644
index 0000000..06b8c6b
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormSpecification.Designer.cs
@@ -0,0 +1,210 @@
+namespace ProjectOptika.Scripts.Forms
+{
+ partial class FormSpecification
+ {
+ ///
+ /// 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()
+ {
+ labelMaterial = new Label();
+ textBoxMaterial = new TextBox();
+ textBoxAstigmatism = new TextBox();
+ labelAstigmatism = new Label();
+ textBoxDioptericity = new TextBox();
+ labelDioptericity = new Label();
+ textBoxOriginCountry = new TextBox();
+ labelOriginCountry = new Label();
+ labelTimeProduction = new Label();
+ numericUpDownTimeProduction = new NumericUpDown();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ comboBoxAccessory = new ComboBox();
+ labelAccessory = new Label();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownTimeProduction).BeginInit();
+ SuspendLayout();
+ //
+ // labelMaterial
+ //
+ labelMaterial.AutoSize = true;
+ labelMaterial.Location = new Point(12, 69);
+ labelMaterial.Name = "labelMaterial";
+ labelMaterial.Size = new Size(78, 20);
+ labelMaterial.TabIndex = 0;
+ labelMaterial.Text = "Материал";
+ //
+ // textBoxMaterial
+ //
+ textBoxMaterial.Location = new Point(175, 66);
+ textBoxMaterial.Name = "textBoxMaterial";
+ textBoxMaterial.Size = new Size(125, 27);
+ textBoxMaterial.TabIndex = 1;
+ //
+ // textBoxAstigmatism
+ //
+ textBoxAstigmatism.Location = new Point(175, 122);
+ textBoxAstigmatism.Name = "textBoxAstigmatism";
+ textBoxAstigmatism.Size = new Size(125, 27);
+ textBoxAstigmatism.TabIndex = 3;
+ //
+ // labelAstigmatism
+ //
+ labelAstigmatism.AutoSize = true;
+ labelAstigmatism.Location = new Point(12, 125);
+ labelAstigmatism.Name = "labelAstigmatism";
+ labelAstigmatism.Size = new Size(99, 20);
+ labelAstigmatism.TabIndex = 2;
+ labelAstigmatism.Text = "Астигматизм";
+ //
+ // textBoxDioptericity
+ //
+ textBoxDioptericity.Location = new Point(175, 178);
+ textBoxDioptericity.Name = "textBoxDioptericity";
+ textBoxDioptericity.Size = new Size(125, 27);
+ textBoxDioptericity.TabIndex = 5;
+ //
+ // labelDioptericity
+ //
+ labelDioptericity.AutoSize = true;
+ labelDioptericity.Location = new Point(12, 181);
+ labelDioptericity.Name = "labelDioptericity";
+ labelDioptericity.Size = new Size(118, 20);
+ labelDioptericity.TabIndex = 4;
+ labelDioptericity.Text = "Диоптрийность";
+ //
+ // textBoxOriginCountry
+ //
+ textBoxOriginCountry.Location = new Point(175, 227);
+ textBoxOriginCountry.Name = "textBoxOriginCountry";
+ textBoxOriginCountry.Size = new Size(125, 27);
+ textBoxOriginCountry.TabIndex = 7;
+ //
+ // labelOriginCountry
+ //
+ labelOriginCountry.AutoSize = true;
+ labelOriginCountry.Location = new Point(12, 230);
+ labelOriginCountry.Name = "labelOriginCountry";
+ labelOriginCountry.Size = new Size(155, 20);
+ labelOriginCountry.TabIndex = 6;
+ labelOriginCountry.Text = "Страна изготовителя";
+ //
+ // labelTimeProduction
+ //
+ labelTimeProduction.AutoSize = true;
+ labelTimeProduction.Location = new Point(12, 280);
+ labelTimeProduction.Name = "labelTimeProduction";
+ labelTimeProduction.Size = new Size(121, 20);
+ labelTimeProduction.TabIndex = 8;
+ labelTimeProduction.Text = "Время поставки";
+ //
+ // numericUpDownTimeProduction
+ //
+ numericUpDownTimeProduction.Location = new Point(175, 278);
+ numericUpDownTimeProduction.Name = "numericUpDownTimeProduction";
+ numericUpDownTimeProduction.Size = new Size(125, 27);
+ numericUpDownTimeProduction.TabIndex = 9;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(175, 331);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 11;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(36, 331);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 29);
+ buttonSave.TabIndex = 10;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // comboBoxAccessory
+ //
+ comboBoxAccessory.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxAccessory.FormattingEnabled = true;
+ comboBoxAccessory.Location = new Point(175, 12);
+ comboBoxAccessory.Name = "comboBoxAccessory";
+ comboBoxAccessory.Size = new Size(125, 28);
+ comboBoxAccessory.TabIndex = 20;
+ //
+ // labelAccessory
+ //
+ labelAccessory.AutoSize = true;
+ labelAccessory.Location = new Point(12, 20);
+ labelAccessory.Name = "labelAccessory";
+ labelAccessory.Size = new Size(79, 20);
+ labelAccessory.TabIndex = 19;
+ labelAccessory.Text = "Аксессуар";
+ //
+ // FormSpecification
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(316, 378);
+ Controls.Add(comboBoxAccessory);
+ Controls.Add(labelAccessory);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(numericUpDownTimeProduction);
+ Controls.Add(labelTimeProduction);
+ Controls.Add(textBoxOriginCountry);
+ Controls.Add(labelOriginCountry);
+ Controls.Add(textBoxDioptericity);
+ Controls.Add(labelDioptericity);
+ Controls.Add(textBoxAstigmatism);
+ Controls.Add(labelAstigmatism);
+ Controls.Add(textBoxMaterial);
+ Controls.Add(labelMaterial);
+ Name = "FormSpecification";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Характеристика";
+ ((System.ComponentModel.ISupportInitialize)numericUpDownTimeProduction).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelMaterial;
+ private TextBox textBoxMaterial;
+ private TextBox textBoxAstigmatism;
+ private Label labelAstigmatism;
+ private TextBox textBoxDioptericity;
+ private Label labelDioptericity;
+ private TextBox textBoxOriginCountry;
+ private Label labelOriginCountry;
+ private Label labelTimeProduction;
+ private NumericUpDown numericUpDownTimeProduction;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private ComboBox comboBoxAccessory;
+ private Label labelAccessory;
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Forms/FormSpecification.cs b/ProjectOptika/Scripts/Forms/FormSpecification.cs
new file mode 100644
index 0000000..77031cc
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormSpecification.cs
@@ -0,0 +1,85 @@
+using ProjectOptika.Scripts.Entities;
+using ProjectOptika.Scripts.Repositories;
+
+namespace ProjectOptika.Scripts.Forms
+{
+ public partial class FormSpecification : Form
+ {
+ private readonly ISpecificationsRepository _specificationsRepositories;
+
+ private int? _specificationsID;
+
+ public int ID
+ {
+ set
+ {
+ try
+ {
+ var specifications = _specificationsRepositories.GetSpecificationsByID(value);
+
+ if (specifications == null) throw new InvalidDataException(nameof(specifications));
+
+ _specificationsID = specifications.ID;
+ textBoxMaterial.Text = specifications.Material;
+ textBoxAstigmatism.Text = specifications.Astigmatism;
+ textBoxDioptericity.Text = specifications.Dioptericity;
+ textBoxOriginCountry.Text = specifications.OriginCountry;
+ numericUpDownTimeProduction.Value = (decimal)specifications.TimeProduction;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormSpecification(ISpecificationsRepository specifications, IAccessoriesRepository accessories)
+ {
+ InitializeComponent();
+
+ _specificationsRepositories = specifications
+ ?? throw new ArgumentNullException(nameof(specifications));
+
+ comboBoxAccessory.DataSource = accessories.GetAccessories();
+ comboBoxAccessory.DisplayMember = "Name";
+ comboBoxAccessory.ValueMember = "ID";
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(textBoxMaterial.Text) || string.IsNullOrEmpty(textBoxAstigmatism.Text) ||
+ string.IsNullOrEmpty(textBoxDioptericity.Text) || string.IsNullOrEmpty(textBoxOriginCountry.Text))
+ {
+ throw new Exception("Имеются незаполненные данные");
+ }
+
+ if (_specificationsID.HasValue)
+ {
+ _specificationsRepositories.UpdateSpecifications(CreateSpecifications(_specificationsID.Value));
+ }
+ else
+ {
+ _specificationsRepositories.CreateSpecifications(CreateSpecifications(0));
+ }
+ Close();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private Specifications CreateSpecifications(int id)
+ {
+ return Specifications.CreateEntity(id, (int)comboBoxAccessory.SelectedValue!, textBoxMaterial.Text, textBoxAstigmatism.Text, textBoxDioptericity.Text, textBoxOriginCountry.Text, (double)numericUpDownTimeProduction.Value);
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormSpecification.resx b/ProjectOptika/Scripts/Forms/FormSpecification.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormSpecification.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/ProjectOptika/Scripts/Forms/FormSpecifications.Designer.cs b/ProjectOptika/Scripts/Forms/FormSpecifications.Designer.cs
new file mode 100644
index 0000000..7f72b1a
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormSpecifications.Designer.cs
@@ -0,0 +1,127 @@
+namespace ProjectOptika.Scripts.Forms
+{
+ partial class FormSpecifications
+ {
+ ///
+ /// 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()
+ {
+ panel = new Panel();
+ buttonRemove = new Button();
+ buttonUpdate = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ panel.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // panel
+ //
+ panel.Controls.Add(buttonRemove);
+ panel.Controls.Add(buttonUpdate);
+ panel.Controls.Add(buttonAdd);
+ panel.Dock = DockStyle.Right;
+ panel.Location = new Point(696, 0);
+ panel.Name = "panel";
+ panel.Size = new Size(104, 450);
+ panel.TabIndex = 6;
+ //
+ // buttonRemove
+ //
+ buttonRemove.BackgroundImage = Properties.Resources.Remove;
+ buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonRemove.Location = new Point(3, 166);
+ buttonRemove.Name = "buttonRemove";
+ buttonRemove.Size = new Size(96, 71);
+ buttonRemove.TabIndex = 2;
+ buttonRemove.UseVisualStyleBackColor = true;
+ buttonRemove.Click += ButtonRemove_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.BackgroundImage = Properties.Resources.Update;
+ buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdate.Location = new Point(3, 89);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(96, 71);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Add;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(3, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(96, 71);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.AllowUserToResizeColumns = false;
+ dataGridView.AllowUserToResizeRows = false;
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Fill;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.MultiSelect = false;
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(800, 450);
+ dataGridView.TabIndex = 7;
+ //
+ // FormSpecifications
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(panel);
+ Controls.Add(dataGridView);
+ Name = "FormSpecifications";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Характеристики";
+ Load += Form_Load;
+ panel.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel panel;
+ private Button buttonRemove;
+ private Button buttonUpdate;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Forms/FormSpecifications.cs b/ProjectOptika/Scripts/Forms/FormSpecifications.cs
new file mode 100644
index 0000000..9ad8c5b
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormSpecifications.cs
@@ -0,0 +1,97 @@
+using ProjectOptika.Scripts.Repositories;
+using Unity;
+
+namespace ProjectOptika.Scripts.Forms
+{
+ public partial class FormSpecifications : Form
+ {
+ private readonly IUnityContainer _container;
+
+ private readonly ISpecificationsRepository _specificationRepositories;
+
+ public FormSpecifications(IUnityContainer container, ISpecificationsRepository lensRepositories)
+ {
+ InitializeComponent();
+
+ _container = container ??
+ throw new ArgumentException(nameof(container));
+
+ _specificationRepositories = lensRepositories ??
+ throw new ArgumentException(nameof(lensRepositories));
+ }
+
+ private void Form_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
+
+ try
+ {
+ var form = _container.Resolve();
+ form.ID = findID;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonRemove_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
+
+ if (MessageBox.Show("Удалить запись?", "Удалить", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
+
+ try
+ {
+ _specificationRepositories.DeleteSpecifications(findID);
+ LoadList();
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridView.DataSource = _specificationRepositories.GetSpecifications();
+
+ private bool TryGetIdentifierFromSelectedRows(out int id)
+ {
+ id = 0;
+ if (dataGridView.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+
+ id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Forms/FormSpecifications.resx b/ProjectOptika/Scripts/Forms/FormSpecifications.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectOptika/Scripts/Forms/FormSpecifications.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/ProjectOptika/Scripts/Program.cs b/ProjectOptika/Scripts/Program.cs
index 2d124dd..ea58915 100644
--- a/ProjectOptika/Scripts/Program.cs
+++ b/ProjectOptika/Scripts/Program.cs
@@ -1,3 +1,7 @@
+using ProjectOptika.Scripts.Repositories;
+using ProjectOptika.Scripts.Repositories.Implementations;
+using Unity;
+
namespace ProjectOptika.Scripts
{
internal static class Program
@@ -11,7 +15,19 @@ namespace ProjectOptika.Scripts
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ Application.Run(CreateContainer().Resolve());
+ }
+
+ private static UnityContainer CreateContainer () {
+ var container = new UnityContainer ();
+
+ container.RegisterType();
+ container.RegisterType();
+ container.RegisterType();
+ container.RegisterType();
+ container.RegisterType();
+
+ return container;
}
}
}
\ No newline at end of file
diff --git a/ProjectOptika/Scripts/Repositories/IAccessoriesRepository.cs b/ProjectOptika/Scripts/Repositories/IAccessoriesRepository.cs
new file mode 100644
index 0000000..d006c3b
--- /dev/null
+++ b/ProjectOptika/Scripts/Repositories/IAccessoriesRepository.cs
@@ -0,0 +1,17 @@
+using ProjectOptika.Scripts.Entities;
+
+namespace ProjectOptika.Scripts.Repositories
+{
+ public interface IAccessoriesRepository
+ {
+ IEnumerable GetAccessories();
+
+ Accessories GetAccessoriesByID(int id);
+
+ void CreateAccessories(Accessories accessories);
+
+ void UpdateAccessories(Accessories accessories);
+
+ void DeleteAccessories(int id);
+ }
+}
diff --git a/ProjectOptika/Scripts/Repositories/IClientRepositiory.cs b/ProjectOptika/Scripts/Repositories/IClientRepositiory.cs
new file mode 100644
index 0000000..8be3cb6
--- /dev/null
+++ b/ProjectOptika/Scripts/Repositories/IClientRepositiory.cs
@@ -0,0 +1,18 @@
+using ProjectOptika.Scripts.Entities;
+
+namespace ProjectOptika.Scripts.Repositories
+{
+ public interface IClientRepositiory
+ {
+ IEnumerable GetClients();
+
+ Client GetClientById(int id);
+
+ void CreateClient(Client client);
+
+ void UpdateClient(Client client);
+
+ void DeleteClient(int id);
+
+ }
+}
diff --git a/ProjectOptika/Scripts/Repositories/IEmployeeRepository.cs b/ProjectOptika/Scripts/Repositories/IEmployeeRepository.cs
new file mode 100644
index 0000000..22ed7d0
--- /dev/null
+++ b/ProjectOptika/Scripts/Repositories/IEmployeeRepository.cs
@@ -0,0 +1,17 @@
+using ProjectOptika.Scripts.Entities;
+
+namespace ProjectOptika.Scripts.Repositories
+{
+ public interface IEmployeeRepository
+ {
+ IEnumerable GetEmployees();
+
+ Employee GetEmployeerByID(int id);
+
+ void CreateEmployee(Employee employee);
+
+ void UpdateEmployee(Employee employee);
+
+ void DeleteEmployee(int id);
+ }
+}
diff --git a/ProjectOptika/Scripts/Repositories/IOrderRepository.cs b/ProjectOptika/Scripts/Repositories/IOrderRepository.cs
new file mode 100644
index 0000000..30b22f5
--- /dev/null
+++ b/ProjectOptika/Scripts/Repositories/IOrderRepository.cs
@@ -0,0 +1,13 @@
+using ProjectOptika.Scripts.Entities;
+
+namespace ProjectOptika.Scripts.Repositories
+{
+ public interface IOrderRepository
+ {
+ IEnumerable GetOrders(DateTime? startDate = null, DateTime? endDate = null, double? totalCost = null, int? id = null, int? employeeID = null, int? clientID = null);
+
+ void CreateOrder(Order order);
+
+ void DeleteOrder(int id);
+ }
+}
diff --git a/ProjectOptika/Scripts/Repositories/ISpecificationsRepository.cs b/ProjectOptika/Scripts/Repositories/ISpecificationsRepository.cs
new file mode 100644
index 0000000..1035642
--- /dev/null
+++ b/ProjectOptika/Scripts/Repositories/ISpecificationsRepository.cs
@@ -0,0 +1,17 @@
+using ProjectOptika.Scripts.Entities;
+
+namespace ProjectOptika.Scripts.Repositories
+{
+ public interface ISpecificationsRepository
+ {
+ IEnumerable GetSpecifications();
+
+ Specifications GetSpecificationsByID(int id);
+
+ void CreateSpecifications(Specifications specifications);
+
+ void UpdateSpecifications(Specifications specifications);
+
+ void DeleteSpecifications(int id);
+ }
+}
diff --git a/ProjectOptika/Scripts/Repositories/Implementations/AccessoriesRepository.cs b/ProjectOptika/Scripts/Repositories/Implementations/AccessoriesRepository.cs
new file mode 100644
index 0000000..e1e3c1c
--- /dev/null
+++ b/ProjectOptika/Scripts/Repositories/Implementations/AccessoriesRepository.cs
@@ -0,0 +1,29 @@
+using ProjectOptika.Scripts.Entities;
+
+namespace ProjectOptika.Scripts.Repositories.Implementations
+{
+ public class AccessoriesRepository : IAccessoriesRepository
+ {
+ public void CreateAccessories(Accessories order)
+ {
+ }
+
+ public void DeleteAccessories(int id)
+ {
+ }
+
+ public IEnumerable GetAccessories()
+ {
+ return [];
+ }
+
+ public Accessories GetAccessoriesByID(int id)
+ {
+ return Accessories.CreateEntity(0, string.Empty, string.Empty, 0, 0, 0, DateTime.Now, 0);
+ }
+
+ public void UpdateAccessories(Accessories order)
+ {
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Repositories/Implementations/ClientRepositiory.cs b/ProjectOptika/Scripts/Repositories/Implementations/ClientRepositiory.cs
new file mode 100644
index 0000000..af70591
--- /dev/null
+++ b/ProjectOptika/Scripts/Repositories/Implementations/ClientRepositiory.cs
@@ -0,0 +1,29 @@
+using ProjectOptika.Scripts.Entities;
+
+namespace ProjectOptika.Scripts.Repositories.Implementations
+{
+ public class ClientRepositiory : IClientRepositiory
+ {
+ public void CreateClient(Client client)
+ {
+ }
+
+ public void DeleteClient(int id)
+ {
+ }
+
+ public Client GetClientById(int id)
+ {
+ return Client.CreateEntity(0, Entities.Enums.ClientType.Corporate, string.Empty, string.Empty, string.Empty, string.Empty);
+ }
+
+ public IEnumerable GetClients()
+ {
+ return [];
+ }
+
+ public void UpdateClient(Client client)
+ {
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Repositories/Implementations/EmployeeRepository.cs b/ProjectOptika/Scripts/Repositories/Implementations/EmployeeRepository.cs
new file mode 100644
index 0000000..924e738
--- /dev/null
+++ b/ProjectOptika/Scripts/Repositories/Implementations/EmployeeRepository.cs
@@ -0,0 +1,29 @@
+using ProjectOptika.Scripts.Entities;
+
+namespace ProjectOptika.Scripts.Repositories.Implementations
+{
+ public class EmployeeRepository : IEmployeeRepository
+ {
+ public void CreateEmployee(Employee employee)
+ {
+ }
+
+ public void DeleteEmployee(int id)
+ {
+ }
+
+ public Employee GetEmployeerByID(int id)
+ {
+ return Employee.CreateEntity(0, Entities.Enums.PositionEmployee.None, string.Empty, string.Empty, string.Empty);
+ }
+
+ public IEnumerable GetEmployees()
+ {
+ return [];
+ }
+
+ public void UpdateEmployee(Employee employee)
+ {
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Repositories/Implementations/OrderRepository.cs b/ProjectOptika/Scripts/Repositories/Implementations/OrderRepository.cs
new file mode 100644
index 0000000..c979287
--- /dev/null
+++ b/ProjectOptika/Scripts/Repositories/Implementations/OrderRepository.cs
@@ -0,0 +1,20 @@
+using ProjectOptika.Scripts.Entities;
+
+namespace ProjectOptika.Scripts.Repositories.Implementations
+{
+ public class OrderRepository : IOrderRepository
+ {
+ public void CreateOrder(Order order)
+ {
+ }
+
+ public void DeleteOrder(int id)
+ {
+ }
+
+ public IEnumerable GetOrders(DateTime? startDate = null, DateTime? endDate = null, double? totalCost = null, int? id = null, int? employeeID = null, int? clientID = null)
+ {
+ return [];
+ }
+ }
+}
diff --git a/ProjectOptika/Scripts/Repositories/Implementations/SpecificationsRepository.cs b/ProjectOptika/Scripts/Repositories/Implementations/SpecificationsRepository.cs
new file mode 100644
index 0000000..32f9ab2
--- /dev/null
+++ b/ProjectOptika/Scripts/Repositories/Implementations/SpecificationsRepository.cs
@@ -0,0 +1,29 @@
+using ProjectOptika.Scripts.Entities;
+
+namespace ProjectOptika.Scripts.Repositories.Implementations
+{
+ public class SpecificationsRepository : ISpecificationsRepository
+ {
+ public void CreateSpecifications(Specifications specification)
+ {
+ }
+
+ public void DeleteSpecifications(int id)
+ {
+ }
+
+ public IEnumerable GetSpecifications()
+ {
+ return [];
+ }
+
+ public Specifications GetSpecificationsByID(int id)
+ {
+ return Specifications.CreateEntity(0, 0, string.Empty, string.Empty, string.Empty, string.Empty, 0.0);
+ }
+
+ public void UpdateSpecifications(Specifications specification)
+ {
+ }
+ }
+}