diff --git a/IceCreamShop/IceCreamBusinessLogic/IceCreamBusinessLogic.csproj b/IceCreamShop/IceCreamBusinessLogic/IceCreamBusinessLogic.csproj
index cb5b1cf..3165a92 100644
--- a/IceCreamShop/IceCreamBusinessLogic/IceCreamBusinessLogic.csproj
+++ b/IceCreamShop/IceCreamBusinessLogic/IceCreamBusinessLogic.csproj
@@ -8,6 +8,7 @@
+
diff --git a/IceCreamShop/IceCreamShop/FormCreateOrder.Designer.cs b/IceCreamShop/IceCreamShop/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..3e62ed4
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormCreateOrder.Designer.cs
@@ -0,0 +1,149 @@
+namespace IceCreamShopView
+{
+ partial class FormCreateOrder
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.textBoxSum = new System.Windows.Forms.TextBox();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.comboBoxIceCream = new System.Windows.Forms.ComboBox();
+ this.labelSum = new System.Windows.Forms.Label();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.labelName = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(283, 114);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(82, 22);
+ this.buttonCancel.TabIndex = 15;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(195, 114);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(82, 22);
+ this.buttonSave.TabIndex = 14;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // textBoxSum
+ //
+ this.textBoxSum.Location = new System.Drawing.Point(136, 75);
+ this.textBoxSum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBoxSum.Name = "textBoxSum";
+ this.textBoxSum.Size = new System.Drawing.Size(230, 23);
+ this.textBoxSum.TabIndex = 13;
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(136, 41);
+ this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(230, 23);
+ this.textBoxCount.TabIndex = 12;
+ this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCount_TextChanged);
+ //
+ // comboBoxIceCream
+ //
+ this.comboBoxIceCream.FormattingEnabled = true;
+ this.comboBoxIceCream.Location = new System.Drawing.Point(136, 6);
+ this.comboBoxIceCream.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.comboBoxIceCream.Name = "comboBoxIceCream";
+ this.comboBoxIceCream.Size = new System.Drawing.Size(230, 23);
+ this.comboBoxIceCream.TabIndex = 11;
+ this.comboBoxIceCream.SelectedIndexChanged += new System.EventHandler(this.comboBoxIceCream_SelectedIndexChanged);
+ //
+ // labelSum
+ //
+ this.labelSum.AutoSize = true;
+ this.labelSum.Location = new System.Drawing.Point(12, 80);
+ this.labelSum.Name = "labelSum";
+ this.labelSum.Size = new System.Drawing.Size(48, 15);
+ this.labelSum.TabIndex = 10;
+ this.labelSum.Text = "Сумма:";
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(12, 43);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(75, 15);
+ this.labelCount.TabIndex = 9;
+ this.labelCount.Text = "Количество:";
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(12, 6);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(77, 15);
+ this.labelName.TabIndex = 8;
+ this.labelName.Text = "Мороженое:";
+ //
+ // FormCreateOrder
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(376, 150);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxSum);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.comboBoxIceCream);
+ this.Controls.Add(this.labelSum);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.labelName);
+ this.Name = "FormCreateOrder";
+ this.Text = "Заказ";
+ this.Load += new System.EventHandler(this.FormCreateOrder_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Button buttonCancel;
+ private Button buttonSave;
+ private TextBox textBoxSum;
+ private TextBox textBoxCount;
+ private ComboBox comboBoxIceCream;
+ private Label labelSum;
+ private Label labelCount;
+ private Label labelName;
+ }
+}
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormCreateOrder.cs b/IceCreamShop/IceCreamShop/FormCreateOrder.cs
new file mode 100644
index 0000000..68e3139
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormCreateOrder.cs
@@ -0,0 +1,128 @@
+using IceCreamShopContracts.BindingModels;
+using IceCreamShopContracts.BusinessLogicsContracts;
+using IceCreamShopContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace IceCreamShopView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IIceCreamLogic _logicI;
+ private readonly IOrderLogic _logicO;
+ public FormCreateOrder(ILogger logger, IIceCreamLogic logicI, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicI = logicI;
+ _logicO = logicO;
+ }
+
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Загрузка мороженого для заказа");
+ try
+ {
+ var list = _logicI.ReadList(null);
+ if (list != null)
+ {
+ comboBoxIceCream.DisplayMember = "IceCreamName";
+ comboBoxIceCream.ValueMember = "Id";
+ comboBoxIceCream.DataSource = list;
+ comboBoxIceCream.SelectedItem = null;
+ }
+
+ }
+ 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 comboBoxIceCream_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+
+ private void CalcSum()
+ {
+ if (comboBoxIceCream.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxIceCream.SelectedValue);
+ var iceCream = _logicI.ReadElement(new IceCreamSearchModel
+ {
+ Id = id
+ });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (iceCream?.Price ?? 0), 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxIceCream.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ IceCreamId = Convert.ToInt32(comboBoxIceCream.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 buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/IceCreamShop/IceCreamShop/FormCreateOrder.resx b/IceCreamShop/IceCreamShop/FormCreateOrder.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/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/IceCreamShop/IceCreamShop/FormIceCream.Designer.cs b/IceCreamShop/IceCreamShop/FormIceCream.Designer.cs
index af11562..45cd701 100644
--- a/IceCreamShop/IceCreamShop/FormIceCream.Designer.cs
+++ b/IceCreamShop/IceCreamShop/FormIceCream.Designer.cs
@@ -28,20 +28,218 @@
///
private void InitializeComponent()
{
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.groupBoxComponents = new System.Windows.Forms.GroupBox();
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonEdit = new System.Windows.Forms.Button();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnBlankName = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.textBoxPrice = new System.Windows.Forms.TextBox();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.labelPrice = new System.Windows.Forms.Label();
+ this.labelName = new System.Windows.Forms.Label();
+ this.groupBoxComponents.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(470, 308);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(136, 22);
+ this.buttonCancel.TabIndex = 13;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(328, 308);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(136, 22);
+ this.buttonSave.TabIndex = 12;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // groupBoxComponents
+ //
+ this.groupBoxComponents.Controls.Add(this.buttonUpdate);
+ this.groupBoxComponents.Controls.Add(this.buttonDelete);
+ this.groupBoxComponents.Controls.Add(this.buttonEdit);
+ this.groupBoxComponents.Controls.Add(this.buttonAdd);
+ this.groupBoxComponents.Controls.Add(this.dataGridView);
+ this.groupBoxComponents.Location = new System.Drawing.Point(12, 83);
+ this.groupBoxComponents.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.groupBoxComponents.Name = "groupBoxComponents";
+ this.groupBoxComponents.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.groupBoxComponents.Size = new System.Drawing.Size(645, 206);
+ this.groupBoxComponents.TabIndex = 11;
+ this.groupBoxComponents.TabStop = false;
+ this.groupBoxComponents.Text = "Компоненты";
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(503, 150);
+ this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(136, 35);
+ this.buttonUpdate.TabIndex = 4;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(503, 111);
+ this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(136, 35);
+ this.buttonDelete.TabIndex = 3;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
+ //
+ // buttonEdit
+ //
+ this.buttonEdit.Location = new System.Drawing.Point(503, 72);
+ this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonEdit.Name = "buttonEdit";
+ this.buttonEdit.Size = new System.Drawing.Size(136, 35);
+ this.buttonEdit.TabIndex = 2;
+ this.buttonEdit.Text = "Изменить";
+ this.buttonEdit.UseVisualStyleBackColor = true;
+ this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(503, 33);
+ this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(136, 35);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ID,
+ this.ColumnBlankName,
+ this.ColumnCount});
+ this.dataGridView.Location = new System.Drawing.Point(5, 20);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(480, 182);
+ this.dataGridView.TabIndex = 0;
+ //
+ // ID
+ //
+ this.ID.HeaderText = "ID";
+ this.ID.MinimumWidth = 6;
+ this.ID.Name = "ID";
+ this.ID.Visible = false;
+ this.ID.Width = 125;
+ //
+ // ColumnBlankName
+ //
+ this.ColumnBlankName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+ this.ColumnBlankName.HeaderText = "Компоненты";
+ this.ColumnBlankName.MinimumWidth = 6;
+ this.ColumnBlankName.Name = "ColumnBlankName";
+ this.ColumnBlankName.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+ this.ColumnBlankName.Width = 312;
+ //
+ // ColumnCount
+ //
+ this.ColumnCount.HeaderText = "Количество";
+ this.ColumnCount.MinimumWidth = 6;
+ this.ColumnCount.Name = "ColumnCount";
+ this.ColumnCount.Width = 125;
+ //
+ // textBoxPrice
+ //
+ this.textBoxPrice.Location = new System.Drawing.Point(95, 40);
+ this.textBoxPrice.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBoxPrice.Name = "textBoxPrice";
+ this.textBoxPrice.Size = new System.Drawing.Size(138, 23);
+ this.textBoxPrice.TabIndex = 10;
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(95, 6);
+ this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(276, 23);
+ this.textBoxName.TabIndex = 9;
+ //
+ // labelPrice
+ //
+ this.labelPrice.AutoSize = true;
+ this.labelPrice.Location = new System.Drawing.Point(12, 43);
+ this.labelPrice.Name = "labelPrice";
+ this.labelPrice.Size = new System.Drawing.Size(70, 15);
+ this.labelPrice.TabIndex = 8;
+ this.labelPrice.Text = "Стоимость:";
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(12, 9);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(62, 15);
+ this.labelName.TabIndex = 7;
+ this.labelName.Text = "Название:";
+ //
// FormIceCream
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
+ this.ClientSize = new System.Drawing.Size(669, 339);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.groupBoxComponents);
+ this.Controls.Add(this.textBoxPrice);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.labelPrice);
+ this.Controls.Add(this.labelName);
this.Name = "FormIceCream";
- this.Text = "FormIceCream";
+ this.Text = "Мороженое";
this.Load += new System.EventHandler(this.FormIceCream_Load);
+ this.groupBoxComponents.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
+ this.PerformLayout();
}
#endregion
+
+ private Button buttonCancel;
+ private Button buttonSave;
+ private GroupBox groupBoxComponents;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonEdit;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn ID;
+ private DataGridViewTextBoxColumn ColumnBlankName;
+ private DataGridViewTextBoxColumn ColumnCount;
+ private TextBox textBoxPrice;
+ private TextBox textBoxName;
+ private Label labelPrice;
+ private Label labelName;
}
}
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormIceCream.cs b/IceCreamShop/IceCreamShop/FormIceCream.cs
index b29689c..cdb5b03 100644
--- a/IceCreamShop/IceCreamShop/FormIceCream.cs
+++ b/IceCreamShop/IceCreamShop/FormIceCream.cs
@@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AbstractIceCreamShopDataModels.Models;
+using IceCreamShop;
using IceCreamShopContracts.BindingModels;
using IceCreamShopContracts.BusinessLogicsContracts;
using IceCreamShopContracts.SearchModels;
@@ -35,26 +36,188 @@ namespace IceCreamShopView
{
if (_id.HasValue)
{
- _logger.LogInformation("Загрузка изделия");
+ _logger.LogInformation("Загрузка мороженого");
try
{
- var view = _logic.ReadElement(new ProductSearchModel { Id = _id.Value });
+ var view = _logic.ReadElement(new IceCreamSearchModel { Id = _id.Value });
if (view != null)
{
- textBoxName.Text = view.ProductName;
+ textBoxName.Text = view.IceCreamName;
textBoxPrice.Text = view.Price.ToString();
- _productComponents = view.ProductComponents ?? new
+ _iceCreamComponents = view.IceCreamComponents ?? new
Dictionary();
LoadData();
}
}
catch (Exception ex)
{
- _logger.LogError(ex, "Ошибка загрузки изделия");
+ _logger.LogError(ex, "Ошибка загрузки мороженого");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка бланков документа");
+ try
+ {
+ if (_iceCreamComponents != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var pc in _iceCreamComponents)
+ {
+ 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 double CalcPrice()
+ {
+ double price = 0;
+ foreach (var elem in _iceCreamComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+ return Math.Round(price * 1.1, 2);
+ }
+
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormIceCreamComponent));
+ if (service is FormIceCreamComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Добавление нового компонента:{ ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count);
+ if (_iceCreamComponents.ContainsKey(form.Id))
+ {
+ _iceCreamComponents[form.Id] = (form.ComponentModel, form.Count);
+ }
+ else
+ {
+ _iceCreamComponents.Add(form.Id, (form.ComponentModel, form.Count));
+ }
+ LoadData();
+ }
+ }
+ }
+
+ private void buttonEdit_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormIceCreamComponent));
+ if (service is FormIceCreamComponent form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _iceCreamComponents[id].Item2;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Изменение бланка:{ ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count);
+ _iceCreamComponents[form.Id] = (form.ComponentModel, form.Count);
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void buttonDelete_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);
+ _iceCreamComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ LoadData();
+ }
+ }
+ }
+
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (string.IsNullOrEmpty(textBoxPrice.Text))
+ {
+ MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (_iceCreamComponents == null || _iceCreamComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните бланки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение документа");
+ try
+ {
+ var model = new IceCreamBindingModel
+ {
+ Id = _id ?? 0,
+ IceCreamName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ IceCreamComponents = _iceCreamComponents
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения документа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
}
}
}
diff --git a/IceCreamShop/IceCreamShop/FormIceCream.resx b/IceCreamShop/IceCreamShop/FormIceCream.resx
index f298a7b..36ba197 100644
--- a/IceCreamShop/IceCreamShop/FormIceCream.resx
+++ b/IceCreamShop/IceCreamShop/FormIceCream.resx
@@ -57,4 +57,13 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ True
+
+
+ True
+
+
+ True
+
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormMain.Designer.cs b/IceCreamShop/IceCreamShop/FormMain.Designer.cs
new file mode 100644
index 0000000..b4ab36f
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormMain.Designer.cs
@@ -0,0 +1,182 @@
+namespace IceCreamShopView
+{
+ 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()
+ {
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ this.buttonSetToFinish = new System.Windows.Forms.Button();
+ this.buttonSetToDone = new System.Windows.Forms.Button();
+ this.buttonSetToWork = new System.Windows.Forms.Button();
+ this.buttonCreateOrder = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.menuStrip = new System.Windows.Forms.MenuStrip();
+ this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.мороженоеToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.menuStrip.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(878, 294);
+ this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(170, 37);
+ this.buttonUpdate.TabIndex = 13;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
+ //
+ // buttonSetToFinish
+ //
+ this.buttonSetToFinish.Location = new System.Drawing.Point(878, 225);
+ this.buttonSetToFinish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonSetToFinish.Name = "buttonSetToFinish";
+ this.buttonSetToFinish.Size = new System.Drawing.Size(170, 37);
+ this.buttonSetToFinish.TabIndex = 12;
+ this.buttonSetToFinish.Text = "Заказ выдан";
+ this.buttonSetToFinish.UseVisualStyleBackColor = true;
+ this.buttonSetToFinish.Click += new System.EventHandler(this.buttonSetToFinish_Click);
+ //
+ // buttonSetToDone
+ //
+ this.buttonSetToDone.Location = new System.Drawing.Point(878, 160);
+ this.buttonSetToDone.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonSetToDone.Name = "buttonSetToDone";
+ this.buttonSetToDone.Size = new System.Drawing.Size(170, 37);
+ this.buttonSetToDone.TabIndex = 11;
+ this.buttonSetToDone.Text = "Заказ готов";
+ this.buttonSetToDone.UseVisualStyleBackColor = true;
+ this.buttonSetToDone.Click += new System.EventHandler(this.buttonSetToDone_Click);
+ //
+ // buttonSetToWork
+ //
+ this.buttonSetToWork.Location = new System.Drawing.Point(878, 93);
+ this.buttonSetToWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonSetToWork.Name = "buttonSetToWork";
+ this.buttonSetToWork.Size = new System.Drawing.Size(170, 37);
+ this.buttonSetToWork.TabIndex = 10;
+ this.buttonSetToWork.Text = "Отдать на выполнение";
+ this.buttonSetToWork.UseVisualStyleBackColor = true;
+ this.buttonSetToWork.Click += new System.EventHandler(this.buttonSetToWork_Click);
+ //
+ // buttonCreateOrder
+ //
+ this.buttonCreateOrder.Location = new System.Drawing.Point(878, 26);
+ this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonCreateOrder.Name = "buttonCreateOrder";
+ this.buttonCreateOrder.Size = new System.Drawing.Size(170, 37);
+ this.buttonCreateOrder.TabIndex = 9;
+ this.buttonCreateOrder.Text = "Создать заказ";
+ this.buttonCreateOrder.UseVisualStyleBackColor = true;
+ this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 26);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(848, 305);
+ this.dataGridView.TabIndex = 8;
+ //
+ // menuStrip
+ //
+ this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.справочникиToolStripMenuItem});
+ this.menuStrip.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip.Name = "menuStrip";
+ this.menuStrip.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
+ this.menuStrip.Size = new System.Drawing.Size(1072, 24);
+ this.menuStrip.TabIndex = 7;
+ this.menuStrip.Text = "Справочники";
+ //
+ // справочникиToolStripMenuItem
+ //
+ this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.компонентыToolStripMenuItem,
+ this.мороженоеToolStripMenuItem});
+ this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
+ this.справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // компонентыToolStripMenuItem
+ //
+ this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.компонентыToolStripMenuItem.Text = "Компоненты";
+ this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
+ //
+ // мороженоеToolStripMenuItem
+ //
+ this.мороженоеToolStripMenuItem.Name = "мороженоеToolStripMenuItem";
+ this.мороженоеToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.мороженоеToolStripMenuItem.Text = "Мороженое";
+ this.мороженоеToolStripMenuItem.Click += new System.EventHandler(this.мороженоеToolStripMenuItem_Click);
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1072, 347);
+ this.Controls.Add(this.buttonUpdate);
+ this.Controls.Add(this.buttonSetToFinish);
+ this.Controls.Add(this.buttonSetToDone);
+ this.Controls.Add(this.buttonSetToWork);
+ this.Controls.Add(this.buttonCreateOrder);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.menuStrip);
+ this.Name = "FormMain";
+ this.Text = "Магазин мороженого";
+ this.Load += new System.EventHandler(this.FormMain_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.menuStrip.ResumeLayout(false);
+ this.menuStrip.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Button buttonUpdate;
+ private Button buttonSetToFinish;
+ private Button buttonSetToDone;
+ private Button buttonSetToWork;
+ private Button buttonCreateOrder;
+ private DataGridView dataGridView;
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private ToolStripMenuItem компонентыToolStripMenuItem;
+ private ToolStripMenuItem мороженоеToolStripMenuItem;
+ }
+}
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormMain.cs b/IceCreamShop/IceCreamShop/FormMain.cs
new file mode 100644
index 0000000..c7eaf0e
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormMain.cs
@@ -0,0 +1,182 @@
+using AbstractIceCreamShopDataModels.Enums;
+using IceCreamShop;
+using IceCreamShopContracts.BindingModels;
+using IceCreamShopContracts.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 IceCreamShopView
+{
+ 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("Загрузка заказов");
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["IceCreamId"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка заказов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
+ if (service is FormComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void мороженоеToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormIceCream));
+ if (service is FormIceCream 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 buttonSetToWork_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,
+ IceCreamId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["IceCreamId"].Value),
+ Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
+ Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
+ Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
+ DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка передачи заказа в работу");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonSetToDone_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,
+ IceCreamId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["IceCreamId"].Value),
+ Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
+ Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
+ Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
+ DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonSetToFinish_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,
+ IceCreamId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["IceCreamId"].Value),
+ Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
+ Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
+ Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
+ DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
+ });
+ 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 buttonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/IceCreamShop/IceCreamShop/FormMain.resx b/IceCreamShop/IceCreamShop/FormMain.resx
new file mode 100644
index 0000000..81a9e3d
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/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/IceCreamShop/IceCreamShop/IceCreamShopView.csproj b/IceCreamShop/IceCreamShop/IceCreamShopView.csproj
index caaeae7..6a7e820 100644
--- a/IceCreamShop/IceCreamShop/IceCreamShopView.csproj
+++ b/IceCreamShop/IceCreamShop/IceCreamShopView.csproj
@@ -10,11 +10,13 @@
+
+
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/Program.cs b/IceCreamShop/IceCreamShop/Program.cs
index 6731fbe..dc96dbd 100644
--- a/IceCreamShop/IceCreamShop/Program.cs
+++ b/IceCreamShop/IceCreamShop/Program.cs
@@ -1,7 +1,19 @@
+using IceCreamShopContracts.BusinessLogicsContracts;
+using IceCreamShopContracts.StoragesContracts;
+using IceCreamShopListImplement.Implements;
+using IceCreamBusinessLogic.BusinessLogics;
+using IceCreamShopView;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using IceCreamShopBusinessLogic.BusinessLogics;
+
namespace IceCreamShop
{
internal static class Program
{
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
///
/// The main entry point for the application.
///
@@ -11,7 +23,33 @@ namespace IceCreamShop
// 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
diff --git a/IceCreamShop/IceCreamShopContracts/IceCreamShopContracts.csproj b/IceCreamShop/IceCreamShopContracts/IceCreamShopContracts.csproj
index b7213e7..981e7c0 100644
--- a/IceCreamShop/IceCreamShopContracts/IceCreamShopContracts.csproj
+++ b/IceCreamShop/IceCreamShopContracts/IceCreamShopContracts.csproj
@@ -8,6 +8,7 @@
+
diff --git a/IceCreamShop/IceCreamShopDataModels/IceCreamShopDataModels.csproj b/IceCreamShop/IceCreamShopDataModels/IceCreamShopDataModels.csproj
index 6ea4cf5..45fc359 100644
--- a/IceCreamShop/IceCreamShopDataModels/IceCreamShopDataModels.csproj
+++ b/IceCreamShop/IceCreamShopDataModels/IceCreamShopDataModels.csproj
@@ -8,6 +8,7 @@
+
diff --git a/IceCreamShop/IceCreamShopListImplement/IceCreamShopListImplement.csproj b/IceCreamShop/IceCreamShopListImplement/IceCreamShopListImplement.csproj
index 0689277..b6d75cd 100644
--- a/IceCreamShop/IceCreamShopListImplement/IceCreamShopListImplement.csproj
+++ b/IceCreamShop/IceCreamShopListImplement/IceCreamShopListImplement.csproj
@@ -6,6 +6,10 @@
enable
+
+
+
+