diff --git a/Confectionery/Confectionery/FormMain.Designer.cs b/Confectionery/Confectionery/FormMain.Designer.cs
index f2e480d..2d92211 100644
--- a/Confectionery/Confectionery/FormMain.Designer.cs
+++ b/Confectionery/Confectionery/FormMain.Designer.cs
@@ -33,13 +33,14 @@
this.ингредиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.пополнениеМагазинаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
this.buttonOrderReady = new System.Windows.Forms.Button();
this.buttonIssuedOrder = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
- this.пополнениеМагазинаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.списаниеToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
@@ -49,7 +50,8 @@
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникиToolStripMenuItem,
- this.пополнениеМагазинаToolStripMenuItem});
+ this.пополнениеМагазинаToolStripMenuItem,
+ this.списаниеToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1238, 28);
@@ -87,6 +89,13 @@
this.магазиныToolStripMenuItem.Text = "Магазины";
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click);
//
+ // пополнениеМагазинаToolStripMenuItem
+ //
+ this.пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
+ this.пополнениеМагазинаToolStripMenuItem.Size = new System.Drawing.Size(182, 24);
+ this.пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
+ this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.пополнениеМагазинаToolStripMenuItem_Click);
+ //
// dataGridView
//
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
@@ -150,12 +159,12 @@
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
//
- // пополнениеМагазинаToolStripMenuItem
+ // списаниеToolStripMenuItem
//
- this.пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
- this.пополнениеМагазинаToolStripMenuItem.Size = new System.Drawing.Size(182, 24);
- this.пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
- this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.пополнениеМагазинаToolStripMenuItem_Click);
+ this.списаниеToolStripMenuItem.Name = "списаниеToolStripMenuItem";
+ this.списаниеToolStripMenuItem.Size = new System.Drawing.Size(91, 24);
+ this.списаниеToolStripMenuItem.Text = "Списание";
+ this.списаниеToolStripMenuItem.Click += new System.EventHandler(this.списаниеToolStripMenuItem_Click);
//
// FormMain
//
@@ -195,5 +204,6 @@
private Button buttonRef;
private ToolStripMenuItem магазиныToolStripMenuItem;
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
+ private ToolStripMenuItem списаниеToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/Confectionery/Confectionery/FormMain.cs b/Confectionery/Confectionery/FormMain.cs
index 390c971..3b01002 100644
--- a/Confectionery/Confectionery/FormMain.cs
+++ b/Confectionery/Confectionery/FormMain.cs
@@ -170,5 +170,14 @@ namespace Confectionery
form.ShowDialog();
}
}
+
+ private void списаниеToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormSell));
+ if (service is FormSell form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
diff --git a/Confectionery/Confectionery/FormSell.Designer.cs b/Confectionery/Confectionery/FormSell.Designer.cs
new file mode 100644
index 0000000..61fa897
--- /dev/null
+++ b/Confectionery/Confectionery/FormSell.Designer.cs
@@ -0,0 +1,120 @@
+namespace Confectionery
+{
+ partial class FormSell
+ {
+ ///
+ /// 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.comboBoxPastry = new System.Windows.Forms.ComboBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonCreate = new System.Windows.Forms.Button();
+ this.textBoxSum = new System.Windows.Forms.TextBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // comboBoxPastry
+ //
+ this.comboBoxPastry.FormattingEnabled = true;
+ this.comboBoxPastry.Location = new System.Drawing.Point(129, 6);
+ this.comboBoxPastry.Name = "comboBoxPastry";
+ this.comboBoxPastry.Size = new System.Drawing.Size(219, 28);
+ this.comboBoxPastry.TabIndex = 22;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(254, 92);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(94, 29);
+ this.buttonCancel.TabIndex = 21;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // buttonCreate
+ //
+ this.buttonCreate.Location = new System.Drawing.Point(142, 92);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(94, 29);
+ this.buttonCreate.TabIndex = 20;
+ this.buttonCreate.Text = "Создать";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
+ //
+ // textBoxSum
+ //
+ this.textBoxSum.Location = new System.Drawing.Point(129, 46);
+ this.textBoxSum.Name = "textBoxSum";
+ this.textBoxSum.Size = new System.Drawing.Size(219, 27);
+ this.textBoxSum.TabIndex = 19;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(12, 49);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(93, 20);
+ this.label3.TabIndex = 18;
+ this.label3.Text = "Количество:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(12, 9);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(71, 20);
+ this.label2.TabIndex = 17;
+ this.label2.Text = "Изделие:";
+ //
+ // FormSell
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(360, 129);
+ this.Controls.Add(this.comboBoxPastry);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonCreate);
+ this.Controls.Add(this.textBoxSum);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Name = "FormSell";
+ this.Text = "Продажа";
+ this.Load += new System.EventHandler(this.FormSell_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private ComboBox comboBoxPastry;
+ private Button buttonCancel;
+ private Button buttonCreate;
+ private TextBox textBoxSum;
+ private Label label3;
+ private Label label2;
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/Confectionery/FormSell.cs b/Confectionery/Confectionery/FormSell.cs
new file mode 100644
index 0000000..9380f58
--- /dev/null
+++ b/Confectionery/Confectionery/FormSell.cs
@@ -0,0 +1,82 @@
+using ConfectioneryContracts.BindingModels;
+using ConfectioneryContracts.BusinessLogicsContracts;
+using ConfectioneryContracts.ViewModels;
+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 Confectionery
+{
+ public partial class FormSell : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPastryLogic _logicP;
+ private readonly IShopLogic _logicS;
+ private List? _listPastry;
+ public FormSell(ILogger logger, IPastryLogic logicP, IShopLogic logicS)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicP = logicP;
+ _logicS = logicS;
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ if (comboBoxPastry.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (String.IsNullOrEmpty(textBoxSum.Text))
+ {
+ MessageBox.Show("Заполните поле количество!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ try
+ {
+ int count = Convert.ToInt32(textBoxSum.Text);
+ bool operationResult = _logicS.Sell(Convert.ToInt32(comboBoxPastry.SelectedValue), count);
+ 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 FormSell_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Загрузка изделий для поставки");
+ _listPastry = _logicP.ReadList(null);
+ if (_listPastry != null)
+ {
+ comboBoxPastry.DisplayMember = "PastryName";
+ comboBoxPastry.ValueMember = "Id";
+ comboBoxPastry.DataSource = _listPastry;
+ comboBoxPastry.SelectedItem = null;
+ }
+ }
+ }
+}
diff --git a/Confectionery/Confectionery/FormSell.resx b/Confectionery/Confectionery/FormSell.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Confectionery/Confectionery/FormSell.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/Confectionery/Program.cs b/Confectionery/Confectionery/Program.cs
index 03d458e..9bd00dc 100644
--- a/Confectionery/Confectionery/Program.cs
+++ b/Confectionery/Confectionery/Program.cs
@@ -53,6 +53,7 @@ namespace Confectionery
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ShopLogic.cs b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ShopLogic.cs
index c4b8908..04f45e9 100644
--- a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ShopLogic.cs
+++ b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ShopLogic.cs
@@ -161,5 +161,10 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
});
return true;
}
+
+ public bool Sell(int pastryId, int count)
+ {
+ return _shopStorage.Sell(pastryId, count);
+ }
}
}
diff --git a/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs
index 24b6427..c6f1006 100644
--- a/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs
+++ b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs
@@ -18,5 +18,6 @@ namespace ConfectioneryContracts.BusinessLogicsContracts
bool Update(ShopBindingModel model);
bool Delete(ShopBindingModel model);
bool DeliverPastryToShop(ShopBindingModel shopModel, IPastryModel pastryModel, int count);
+ bool Sell(int pastryId, int count);
}
}
diff --git a/Confectionery/ConfectioneryFileImplements/Implements/ShopStorage.cs b/Confectionery/ConfectioneryFileImplements/Implements/ShopStorage.cs
index 89f46c2..214c74f 100644
--- a/Confectionery/ConfectioneryFileImplements/Implements/ShopStorage.cs
+++ b/Confectionery/ConfectioneryFileImplements/Implements/ShopStorage.cs
@@ -150,8 +150,8 @@ namespace ConfectioneryFileImplement.Implements
}
else
{
- count = 0;
shop.Pastries[pastryId] -= count;
+ count = 0;
shop.setShopPastriesNull();
}
if (count == 0)