diff --git a/Confectionery/Confectionery/Confectionery.csproj b/Confectionery/Confectionery/Confectionery.csproj
index c939607..3b235c0 100644
--- a/Confectionery/Confectionery/Confectionery.csproj
+++ b/Confectionery/Confectionery/Confectionery.csproj
@@ -10,6 +10,7 @@
+
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryBusinessLogic/ConfectioneryBusinessLogic.csproj b/Confectionery/ConfectioneryBusinessLogic/ConfectioneryBusinessLogic.csproj
index 7191769..6c8a45e 100644
--- a/Confectionery/ConfectioneryBusinessLogic/ConfectioneryBusinessLogic.csproj
+++ b/Confectionery/ConfectioneryBusinessLogic/ConfectioneryBusinessLogic.csproj
@@ -8,6 +8,7 @@
+
diff --git a/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs b/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs
index 79c4b81..41fcf7a 100644
--- a/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs
+++ b/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs
@@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace ConfectioneryBusinessLogic
{
- internal class PastryLogic : IPastryLogic
+ public class PastryLogic : IPastryLogic
{
private readonly ILogger _logger;
private readonly IPastryStorage _PastryStorage;
diff --git a/Confectionery/ConfectioneryContracts/ConfectioneryContracts.csproj b/Confectionery/ConfectioneryContracts/ConfectioneryContracts.csproj
index b6ffff9..aca6a26 100644
--- a/Confectionery/ConfectioneryContracts/ConfectioneryContracts.csproj
+++ b/Confectionery/ConfectioneryContracts/ConfectioneryContracts.csproj
@@ -1,4 +1,4 @@
-
+
net6.0
@@ -8,6 +8,7 @@
+
diff --git a/Confectionery/ConfectioneryDataModels/ConfectioneryDataModels.csproj b/Confectionery/ConfectioneryDataModels/ConfectioneryDataModels.csproj
index 28e9bd0..c2d19e9 100644
--- a/Confectionery/ConfectioneryDataModels/ConfectioneryDataModels.csproj
+++ b/Confectionery/ConfectioneryDataModels/ConfectioneryDataModels.csproj
@@ -8,6 +8,7 @@
+
diff --git a/Confectionery/ConfectioneryListImplement/ConfectioneryListImplement.csproj b/Confectionery/ConfectioneryListImplement/ConfectioneryListImplement.csproj
index 41b6c3e..48a2e81 100644
--- a/Confectionery/ConfectioneryListImplement/ConfectioneryListImplement.csproj
+++ b/Confectionery/ConfectioneryListImplement/ConfectioneryListImplement.csproj
@@ -6,6 +6,10 @@
enable
+
+
+
+
diff --git a/Confectionery/ConfectioneryView/ConfectioneryView.csproj b/Confectionery/ConfectioneryView/ConfectioneryView.csproj
index b51a6d5..c3d7fb7 100644
--- a/Confectionery/ConfectioneryView/ConfectioneryView.csproj
+++ b/Confectionery/ConfectioneryView/ConfectioneryView.csproj
@@ -8,6 +8,10 @@
enable
+
+
+
+
diff --git a/Confectionery/ConfectioneryView/FormComponents.Designer.cs b/Confectionery/ConfectioneryView/FormComponents.Designer.cs
new file mode 100644
index 0000000..e025eaa
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormComponents.Designer.cs
@@ -0,0 +1,114 @@
+namespace ConfectioneryView
+{
+ partial class FormComponents
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ buttonAdd = new Button();
+ buttonUpd = new Button();
+ buttonDel = new Button();
+ buttonRef = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 62;
+ dataGridView.RowTemplate.Height = 33;
+ dataGridView.Size = new Size(597, 522);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(669, 30);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(139, 55);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(669, 111);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(139, 55);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += buttonUpd_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(669, 192);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(139, 55);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += buttonDel_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(669, 276);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(139, 55);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // FormComponents
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(845, 546);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonDel);
+ Controls.Add(buttonUpd);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Name = "FormComponents";
+ Text = "Компоненты";
+ Load += FormComponents_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonRef;
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormComponents.cs b/Confectionery/ConfectioneryView/FormComponents.cs
new file mode 100644
index 0000000..fb3ad31
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormComponents.cs
@@ -0,0 +1,114 @@
+using ConfectioneryContracts.BindingModels;
+using ConfectioneryContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ConfectioneryView
+{
+ public partial class FormComponents : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentLogic _logic;
+ public FormComponents(ILogger logger, IComponentLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
+ if (service is FormComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void FormComponents_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["ComponentName"].AutoSizeMode =
+ DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка компонентов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонентов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormComponent));
+ if (service is FormComponent form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void buttonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Удаление компонента");
+ try
+ {
+ if (!_logic.Delete(new ComponentBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления компонента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ }
+ private void buttonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/Confectionery/ConfectioneryView/FormComponents.resx b/Confectionery/ConfectioneryView/FormComponents.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormComponents.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs b/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..453af41
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs
@@ -0,0 +1,143 @@
+namespace ConfectioneryView
+{
+ partial class FormCreateOrder
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelName = new Label();
+ labelCount = new Label();
+ labelSum = new Label();
+ comboBoxPastry = new ComboBox();
+ textBoxCount = new TextBox();
+ textBoxSum = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(90, 35);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(84, 25);
+ labelName.TabIndex = 0;
+ labelName.Text = "Изделие:";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(63, 92);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(111, 25);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Количество:";
+ //
+ // labelSum
+ //
+ labelSum.AutoSize = true;
+ labelSum.Location = new Point(90, 155);
+ labelSum.Name = "labelSum";
+ labelSum.Size = new Size(71, 25);
+ labelSum.TabIndex = 2;
+ labelSum.Text = "Сумма:";
+ //
+ // comboBoxPastry
+ //
+ comboBoxPastry.FormattingEnabled = true;
+ comboBoxPastry.Location = new Point(192, 32);
+ comboBoxPastry.Name = "comboBoxPastry";
+ comboBoxPastry.Size = new Size(434, 33);
+ comboBoxPastry.TabIndex = 3;
+ comboBoxPastry.SelectedIndexChanged += comboBoxProduct_SelectedIndexChanged;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(192, 92);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(434, 31);
+ textBoxCount.TabIndex = 4;
+ textBoxCount.TextChanged += textBoxCount_TextChanged;
+ //
+ // textBoxSum
+ //
+ textBoxSum.Location = new Point(192, 155);
+ textBoxSum.Name = "textBoxSum";
+ textBoxSum.Size = new Size(434, 31);
+ textBoxSum.TabIndex = 5;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(468, 249);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(112, 49);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранять";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(615, 249);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(112, 49);
+ buttonCancel.TabIndex = 7;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormCreateOrder
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(779, 333);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxSum);
+ Controls.Add(textBoxCount);
+ Controls.Add(comboBoxPastry);
+ Controls.Add(labelSum);
+ Controls.Add(labelCount);
+ Controls.Add(labelName);
+ Name = "FormCreateOrder";
+ Text = "FormCreateOrder";
+ Load += FormCreateOrder_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelName;
+ private Label labelCount;
+ private Label labelSum;
+ private ComboBox comboBoxPastry;
+ private TextBox textBoxCount;
+ private TextBox textBoxSum;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormCreateOrder.cs b/Confectionery/ConfectioneryView/FormCreateOrder.cs
new file mode 100644
index 0000000..568f60a
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormCreateOrder.cs
@@ -0,0 +1,123 @@
+using Microsoft.Extensions.Logging;
+using ConfectioneryContracts.BindingModels;
+using ConfectioneryContracts.BusinessLogicsContracts;
+using ConfectioneryContracts.SearchModels;
+using ConfectioneryContracts.ViewModels;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ConfectioneryView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPastryLogic _logicP;
+ private readonly IOrderLogic _logicO;
+ private List? _list;
+ public FormCreateOrder(ILogger logger, IPastryLogic logicP, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicP = logicP;
+ _logicO = logicO;
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxPastry.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ PastryId = Convert.ToInt32(comboBoxPastry.SelectedValue),
+ Count = Convert.ToInt32(textBoxCount.Text),
+ Sum = Convert.ToDouble(textBoxSum.Text)
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка создания заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+
+ }
+
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Загрузка суши для заказа");
+ _list = _logicP.ReadList(null);
+ if (_list != null)
+ {
+ comboBoxPastry.DisplayMember = "SushiName";
+ comboBoxPastry.ValueMember = "Id";
+ comboBoxPastry.DataSource = _list;
+ comboBoxPastry.SelectedItem = null;
+ _logger.LogInformation("Загрузка суши для заказа");
+ }
+ }
+ private void CalcSum()
+ {
+ if (comboBoxPastry.SelectedValue != null &&
+ !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxPastry.SelectedValue);
+ var product = _logicP.ReadElement(new PastrySearchModel { Id = id });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void textBoxCount_TextChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+ private void comboBoxProduct_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/Confectionery/ConfectioneryView/FormCreateOrder.resx b/Confectionery/ConfectioneryView/FormCreateOrder.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormCreateOrder.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormMain.Designer.cs b/Confectionery/ConfectioneryView/FormMain.Designer.cs
new file mode 100644
index 0000000..c7be7ea
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormMain.Designer.cs
@@ -0,0 +1,169 @@
+namespace ConfectioneryView
+{
+ partial class FormMain
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ menuStrip = new MenuStrip();
+ toolStripMenuItem = new ToolStripMenuItem();
+ componentsToolStripMenuItem = new ToolStripMenuItem();
+ pastryToolStripMenuItem = new ToolStripMenuItem();
+ buttonCreateOrder = new Button();
+ buttonTakeOrderInWork = new Button();
+ buttonOrderReady = new Button();
+ buttonIssuedOrder = new Button();
+ buttonRef = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ menuStrip.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 60);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 62;
+ dataGridView.RowTemplate.Height = 33;
+ dataGridView.Size = new Size(834, 549);
+ dataGridView.TabIndex = 0;
+ //
+ // menuStrip
+ //
+ menuStrip.ImageScalingSize = new Size(24, 24);
+ menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem });
+ menuStrip.Location = new Point(0, 0);
+ menuStrip.Name = "menuStrip";
+ menuStrip.Size = new Size(1156, 33);
+ menuStrip.TabIndex = 1;
+ menuStrip.Text = "menuStrip1";
+ //
+ // toolStripMenuItem
+ //
+ toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, pastryToolStripMenuItem });
+ toolStripMenuItem.Name = "toolStripMenuItem";
+ toolStripMenuItem.Size = new Size(139, 29);
+ toolStripMenuItem.Text = "Справочники";
+ //
+ // componentsToolStripMenuItem
+ //
+ componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
+ componentsToolStripMenuItem.Size = new Size(298, 34);
+ componentsToolStripMenuItem.Text = "Компоненты";
+ //
+ // pastryToolStripMenuItem
+ //
+ pastryToolStripMenuItem.Name = "pastryToolStripMenuItem";
+ pastryToolStripMenuItem.Size = new Size(298, 34);
+ pastryToolStripMenuItem.Text = "Кондитерские изделия";
+ //
+ // buttonCreateOrder
+ //
+ buttonCreateOrder.Location = new Point(889, 86);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(232, 34);
+ buttonCreateOrder.TabIndex = 2;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += buttonCreateOrder_Click;
+ //
+ // buttonTakeOrderInWork
+ //
+ buttonTakeOrderInWork.Location = new Point(889, 143);
+ buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ buttonTakeOrderInWork.Size = new Size(232, 34);
+ buttonTakeOrderInWork.TabIndex = 3;
+ buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
+ //
+ // buttonOrderReady
+ //
+ buttonOrderReady.Location = new Point(889, 200);
+ buttonOrderReady.Name = "buttonOrderReady";
+ buttonOrderReady.Size = new Size(232, 34);
+ buttonOrderReady.TabIndex = 4;
+ buttonOrderReady.Text = "Заказ готов";
+ buttonOrderReady.UseVisualStyleBackColor = true;
+ buttonOrderReady.Click += buttonOrderReady_Click;
+ //
+ // buttonIssuedOrder
+ //
+ buttonIssuedOrder.Location = new Point(889, 257);
+ buttonIssuedOrder.Name = "buttonIssuedOrder";
+ buttonIssuedOrder.Size = new Size(232, 34);
+ buttonIssuedOrder.TabIndex = 5;
+ buttonIssuedOrder.Text = "Заказ выдан";
+ buttonIssuedOrder.UseVisualStyleBackColor = true;
+ buttonIssuedOrder.Click += buttonIssuedOrder_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(889, 317);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(232, 34);
+ buttonRef.TabIndex = 6;
+ buttonRef.Text = "Обновить список";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1156, 621);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonIssuedOrder);
+ Controls.Add(buttonOrderReady);
+ Controls.Add(buttonTakeOrderInWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip);
+ MainMenuStrip = menuStrip;
+ Name = "FormMain";
+ Text = "FormMain";
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem toolStripMenuItem;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonRef;
+ private ToolStripMenuItem componentsToolStripMenuItem;
+ private ToolStripMenuItem pastryToolStripMenuItem;
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormMain.cs b/Confectionery/ConfectioneryView/FormMain.cs
new file mode 100644
index 0000000..fd3a866
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormMain.cs
@@ -0,0 +1,150 @@
+using ConfectioneryContracts.BindingModels;
+using ConfectioneryContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ConfectioneryView
+{
+ public partial class FormMain : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+ public FormMain(ILogger logger, IOrderLogic orderLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _orderLogic = orderLogic;
+ }
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка заказов");
+ // прописать логику
+ }
+ private void componentsToolStripMenuItem_Click(object sender, EventArgs
+e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
+ if (service is FormComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void pastryToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ // прописать логику
+ var service = Program.ServiceProvider?.GetService(typeof(FormPastrys));
+ if (service is FormPastrys form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void buttonCreateOrder_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
+ try
+ {
+ var operationResult = _orderLogic.TakeOrderInWork(new
+ OrderBindingModel
+ { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка передачи заказа в работу");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonOrderReady_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
+ id);
+ try
+ {
+ var operationResult = _orderLogic.FinishOrder(new
+ OrderBindingModel
+ { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonIssuedOrder_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new
+ OrderBindingModel
+ { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/Confectionery/ConfectioneryView/FormMain.resx b/Confectionery/ConfectioneryView/FormMain.resx
new file mode 100644
index 0000000..81a9e3d
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormMain.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormPastry.Designer.cs b/Confectionery/ConfectioneryView/FormPastry.Designer.cs
new file mode 100644
index 0000000..9414506
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormPastry.Designer.cs
@@ -0,0 +1,199 @@
+namespace ConfectioneryView
+{
+ partial class FormPastry
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ label1 = new Label();
+ label2 = new Label();
+ textBoxName = new TextBox();
+ textBoxPrice = new TextBox();
+ groupBoxComponents = new GroupBox();
+ buttonRef = new Button();
+ buttonDel = new Button();
+ buttonUpd = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ groupBoxComponents.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(54, 53);
+ label1.Name = "label1";
+ label1.Size = new Size(94, 25);
+ label1.TabIndex = 0;
+ label1.Text = "Название:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(45, 101);
+ label2.Name = "label2";
+ label2.Size = new Size(103, 25);
+ label2.TabIndex = 1;
+ label2.Text = "Стоимость:";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(154, 50);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(471, 31);
+ textBoxName.TabIndex = 2;
+ //
+ // textBoxPrice
+ //
+ textBoxPrice.Location = new Point(154, 98);
+ textBoxPrice.Name = "textBoxPrice";
+ textBoxPrice.Size = new Size(249, 31);
+ textBoxPrice.TabIndex = 3;
+ //
+ // groupBoxComponents
+ //
+ groupBoxComponents.Controls.Add(buttonRef);
+ groupBoxComponents.Controls.Add(buttonDel);
+ groupBoxComponents.Controls.Add(buttonUpd);
+ groupBoxComponents.Controls.Add(buttonAdd);
+ groupBoxComponents.Controls.Add(dataGridView);
+ groupBoxComponents.Location = new Point(12, 153);
+ groupBoxComponents.Name = "groupBoxComponents";
+ groupBoxComponents.Size = new Size(959, 411);
+ groupBoxComponents.TabIndex = 4;
+ groupBoxComponents.TabStop = false;
+ groupBoxComponents.Text = "Компоненты";
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(802, 269);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(124, 49);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(802, 194);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(124, 49);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += buttonDel_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(802, 122);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(124, 49);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += buttonUpd_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(802, 53);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(124, 49);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(10, 30);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 62;
+ dataGridView.RowTemplate.Height = 33;
+ dataGridView.Size = new Size(735, 363);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(643, 588);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(129, 46);
+ buttonSave.TabIndex = 5;
+ buttonSave.Text = "Создать";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(793, 588);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(129, 46);
+ buttonCancel.TabIndex = 6;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormPastry
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(983, 654);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(groupBoxComponents);
+ Controls.Add(textBoxPrice);
+ Controls.Add(textBoxName);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Name = "FormPastry";
+ Text = "FormPastry";
+ Load += FormPastry_Load;
+ groupBoxComponents.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label label2;
+ private TextBox textBoxName;
+ private TextBox textBoxPrice;
+ private GroupBox groupBoxComponents;
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormPastry.cs b/Confectionery/ConfectioneryView/FormPastry.cs
new file mode 100644
index 0000000..c41c136
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormPastry.cs
@@ -0,0 +1,224 @@
+using ConfectioneryContracts.BindingModels;
+using ConfectioneryContracts.BusinessLogicsContracts;
+using ConfectioneryContracts.SearchModels;
+using ConfectioneryDataModels.Models;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ConfectioneryView
+{
+ public partial class FormPastry : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPastryLogic _logic;
+ private int? _id;
+ private Dictionary _pastryComponents;
+ public int Id { set { _id = value; } }
+
+ public FormPastry(ILogger logger, IPastryLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _pastryComponents = new Dictionary();
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (string.IsNullOrEmpty(textBoxPrice.Text))
+ {
+ MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ return;
+ }
+ if (_pastryComponents == null || _pastryComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение изделия");
+ try
+ {
+ var model = new PastryBindingModel
+ {
+ Id = _id ?? 0,
+ PastryName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ PastryComponents = _pastryComponents
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void FormPastry_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+ try
+ {
+ var view = _logic.ReadElement(new PastrySearchModel
+ {
+ Id =
+ _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.PastryName;
+ textBoxPrice.Text = view.Price.ToString();
+ _pastryComponents = view.PastryComponents ?? new
+ Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка компонент изделия");
+ try
+ {
+ if (_pastryComponents != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var pc in _pastryComponents)
+ {
+ dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
+ }
+ textBoxPrice.Text = CalcPrice().ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонент изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPastryComponent));
+ if (service is FormPastryComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Добавление нового компонента:{ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
+ if (_pastryComponents.ContainsKey(form.Id))
+ {
+ _pastryComponents[form.Id] = (form.ComponentModel,
+ form.Count);
+ }
+ else
+ {
+ _pastryComponents.Add(form.Id, (form.ComponentModel,
+ form.Count));
+ }
+ LoadData();
+ }
+ }
+ }
+
+ private void buttonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormPastryComponent));
+ if (service is FormPastryComponent form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _pastryComponents[id].Item2;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
+ _pastryComponents[form.Id] = (form.ComponentModel, form.Count);
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void buttonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ try
+ {
+ _logger.LogInformation("Удаление компонента: {ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); _pastryComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ LoadData();
+ }
+ }
+ }
+
+ private void buttonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ private double CalcPrice()
+ {
+ double price = 0;
+ foreach (var elem in _pastryComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/Confectionery/ConfectioneryView/FormPastry.resx b/Confectionery/ConfectioneryView/FormPastry.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormPastry.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormPastryComponent.Designer.cs b/Confectionery/ConfectioneryView/FormPastryComponent.Designer.cs
new file mode 100644
index 0000000..a37e145
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormPastryComponent.Designer.cs
@@ -0,0 +1,118 @@
+namespace ConfectioneryView
+{
+ partial class FormPastryComponent
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ label1 = new Label();
+ label2 = new Label();
+ textBoxCount = new TextBox();
+ comboBoxComponent = new ComboBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(108, 55);
+ label1.Name = "label1";
+ label1.Size = new Size(107, 25);
+ label1.TabIndex = 0;
+ label1.Text = "Компонент:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(108, 125);
+ label2.Name = "label2";
+ label2.Size = new Size(111, 25);
+ label2.TabIndex = 1;
+ label2.Text = "Количество:";
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(234, 119);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(216, 31);
+ textBoxCount.TabIndex = 2;
+ //
+ // comboBoxComponent
+ //
+ comboBoxComponent.FormattingEnabled = true;
+ comboBoxComponent.Location = new Point(234, 55);
+ comboBoxComponent.Name = "comboBoxComponent";
+ comboBoxComponent.Size = new Size(392, 33);
+ comboBoxComponent.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(483, 180);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(126, 58);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Создать";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(633, 180);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(126, 58);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormPastryComponent
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(815, 267);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(comboBoxComponent);
+ Controls.Add(textBoxCount);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Name = "FormPastryComponent";
+ Text = "FormPastryComponent";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label label2;
+ private TextBox textBoxCount;
+ private ComboBox comboBoxComponent;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormPastryComponent.cs b/Confectionery/ConfectioneryView/FormPastryComponent.cs
new file mode 100644
index 0000000..64122e6
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormPastryComponent.cs
@@ -0,0 +1,88 @@
+using ConfectioneryContracts.BusinessLogicsContracts;
+using ConfectioneryContracts.ViewModels;
+using ConfectioneryDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ConfectioneryView
+{
+ public partial class FormPastryComponent : Form
+ {
+ private readonly List? _list;
+ public int Id
+ {
+ get
+ {
+ return Convert.ToInt32(comboBoxComponent.SelectedValue);
+ }
+ set
+ {
+ comboBoxComponent.SelectedValue = value;
+ }
+ }
+ public IComponentModel? ComponentModel
+ {
+ get
+ {
+ if (_list == null)
+ {
+ return null;
+ }
+ foreach (var elem in _list)
+ {
+ if (elem.Id == Id)
+ {
+ return elem;
+ }
+ }
+ return null;
+ }
+ }
+ public int Count
+ {
+ get { return Convert.ToInt32(textBoxCount.Text); }
+ set
+ { textBoxCount.Text = value.ToString(); }
+ }
+ public FormPastryComponent(IComponentLogic logic)
+ {
+ InitializeComponent();
+ _list = logic.ReadList(null);
+ if (_list != null)
+ {
+ comboBoxComponent.DisplayMember = "ComponentName";
+ comboBoxComponent.ValueMember = "Id";
+ comboBoxComponent.DataSource = _list;
+ comboBoxComponent.SelectedItem = null;
+ }
+ }
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxComponent.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/Confectionery/ConfectioneryView/FormPastryComponent.resx b/Confectionery/ConfectioneryView/FormPastryComponent.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormPastryComponent.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormPastrys.Designer.cs b/Confectionery/ConfectioneryView/FormPastrys.Designer.cs
new file mode 100644
index 0000000..6eeeae1
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormPastrys.Designer.cs
@@ -0,0 +1,109 @@
+namespace ConfectioneryView
+{
+ partial class FormPastrys
+ {
+ ///
+ /// 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()
+ {
+ dataGridView1 = new DataGridView();
+ buttonAdd = new Button();
+ buttonUpd = new Button();
+ buttonDel = new Button();
+ buttonRef = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView1
+ //
+ dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView1.Location = new Point(12, 12);
+ dataGridView1.Name = "dataGridView1";
+ dataGridView1.RowHeadersWidth = 62;
+ dataGridView1.RowTemplate.Height = 33;
+ dataGridView1.Size = new Size(1075, 635);
+ dataGridView1.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(1161, 53);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(133, 46);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(1161, 119);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(133, 46);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(1161, 185);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(133, 45);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(1161, 251);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(133, 48);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ //
+ // FormPastrys
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1325, 659);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonDel);
+ Controls.Add(buttonUpd);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView1);
+ Name = "FormPastrys";
+ Text = "Кондитерские изделия";
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView1;
+ private Button buttonAdd;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonRef;
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormPastrys.cs b/Confectionery/ConfectioneryView/FormPastrys.cs
new file mode 100644
index 0000000..2240405
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormPastrys.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ConfectioneryView
+{
+ public partial class FormPastrys : Form
+ {
+ public FormPastrys()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Confectionery/ConfectioneryView/FormPastrys.resx b/Confectionery/ConfectioneryView/FormPastrys.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormPastrys.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/Program.cs b/Confectionery/ConfectioneryView/Program.cs
index a590e70..7ae9212 100644
--- a/Confectionery/ConfectioneryView/Program.cs
+++ b/Confectionery/ConfectioneryView/Program.cs
@@ -1,17 +1,51 @@
+using ConfectioneryBusinessLogic;
+using ConfectioneryContracts.BusinessLogicsContracts;
+using ConfectioneryContracts.StoragesContracts;
+using ConfectioneryListImplement.Implements;
+using ConfectioneryListImplement;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+
namespace ConfectioneryView
{
internal static class Program
{
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormComponent());
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddLogging(option =>
+ {
+ option.SetMinimumLevel(LogLevel.Information);
+ option.AddNLog("nlog.config");
+ });
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file