Добавлено пополнение магазина в главную форму и внедрены все новые зависимости
This commit is contained in:
parent
6ea2ac3a75
commit
78a3293bb5
@ -1,4 +1,5 @@
|
|||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
using ConfectioneryContracts.ViewModels;
|
using ConfectioneryContracts.ViewModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -17,33 +18,84 @@ namespace ConfectioneryView
|
|||||||
public partial class FormAddPastryInShop : Form
|
public partial class FormAddPastryInShop : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
private readonly IShopLogic _shopLogic;
|
||||||
|
private readonly IPastryLogic _pastryLogic;
|
||||||
private readonly List<ShopViewModel>? _listShops;
|
private readonly List<ShopViewModel>? _listShops;
|
||||||
private readonly List<PastryViewModel>? _listPastries;
|
private readonly List<PastryViewModel>? _listPastries;
|
||||||
|
|
||||||
public FormAddPastryInShop(ILogger<FormAddPastryInShop> logger, IShopLogic shopLogic, IPastryLogic pastryLogic)
|
public FormAddPastryInShop(ILogger<FormAddPastryInShop> logger, IShopLogic shopLogic, IPastryLogic pastryLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_shopLogic = shopLogic;
|
||||||
|
_pastryLogic = pastryLogic;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_listShops = shopLogic.ReadList(null);
|
_listShops = shopLogic.ReadList(null);
|
||||||
if (_listShops != null)
|
if (_listShops != null)
|
||||||
{
|
{
|
||||||
comboBoxShop.DisplayMember = "ComponentName";
|
comboBoxShop.DisplayMember = "Name";
|
||||||
comboBoxShop.ValueMember = "Id";
|
comboBoxShop.ValueMember = "Id";
|
||||||
comboBoxShop.DataSource = _listShops;
|
comboBoxShop.DataSource = _listShops;
|
||||||
comboBoxShop.SelectedItem = null;
|
comboBoxShop.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_listPastries
|
_listPastries = pastryLogic.ReadList(null);
|
||||||
|
if (_listPastries != null)
|
||||||
|
{
|
||||||
|
comboBoxPastry.DisplayMember = "PastryName";
|
||||||
|
comboBoxPastry.ValueMember= "Id";
|
||||||
|
comboBoxPastry.DataSource = _listPastries;
|
||||||
|
comboBoxPastry.SelectedItem = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (comboBoxShop.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxPastry.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Добавление изделия в магазин");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pastry = _pastryLogic.ReadElement(new()
|
||||||
|
{
|
||||||
|
Id = (int)comboBoxPastry.SelectedValue
|
||||||
|
});
|
||||||
|
if (pastry == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Не найдено изделие. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
var resultOperation = _shopLogic.AddPastry(
|
||||||
|
model: new() { Id = (int)comboBoxShop.SelectedValue },
|
||||||
|
pastry: pastry,
|
||||||
|
count: (int)numericUpDownCount.Value
|
||||||
|
);
|
||||||
|
if (!resultOperation)
|
||||||
|
{
|
||||||
|
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)
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
Confectionery/FormMain.Designer.cs
generated
25
Confectionery/FormMain.Designer.cs
generated
@ -32,13 +32,14 @@
|
|||||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.pastryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.pastryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ShopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
||||||
this.button2 = new System.Windows.Forms.Button();
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
this.button3 = new System.Windows.Forms.Button();
|
this.button3 = new System.Windows.Forms.Button();
|
||||||
this.button4 = new System.Windows.Forms.Button();
|
this.button4 = new System.Windows.Forms.Button();
|
||||||
this.ShopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.buttonAddPastryInShop = new System.Windows.Forms.Button();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -77,6 +78,13 @@
|
|||||||
this.componentToolStripMenuItem.Text = "Компоненты";
|
this.componentToolStripMenuItem.Text = "Компоненты";
|
||||||
this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// ShopsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem";
|
||||||
|
this.ShopsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.ShopsToolStripMenuItem.Text = "Магазины";
|
||||||
|
this.ShopsToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
@ -144,18 +152,22 @@
|
|||||||
this.button4.UseVisualStyleBackColor = true;
|
this.button4.UseVisualStyleBackColor = true;
|
||||||
this.button4.Click += new System.EventHandler(this.ButtonRef_Click);
|
this.button4.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
//
|
//
|
||||||
// ShopsToolStripMenuItem
|
// buttonAddPastryInShop
|
||||||
//
|
//
|
||||||
this.ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem";
|
this.buttonAddPastryInShop.Location = new System.Drawing.Point(624, 326);
|
||||||
this.ShopsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.buttonAddPastryInShop.Name = "buttonAddPastryInShop";
|
||||||
this.ShopsToolStripMenuItem.Text = "Магазины";
|
this.buttonAddPastryInShop.Size = new System.Drawing.Size(147, 31);
|
||||||
this.ShopsToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click);
|
this.buttonAddPastryInShop.TabIndex = 7;
|
||||||
|
this.buttonAddPastryInShop.Text = "Пополнение магазина";
|
||||||
|
this.buttonAddPastryInShop.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddPastryInShop.Click += new System.EventHandler(this.ButtonAddPastryInShop_Click);
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(783, 380);
|
this.ClientSize = new System.Drawing.Size(783, 380);
|
||||||
|
this.Controls.Add(this.buttonAddPastryInShop);
|
||||||
this.Controls.Add(this.button4);
|
this.Controls.Add(this.button4);
|
||||||
this.Controls.Add(this.button3);
|
this.Controls.Add(this.button3);
|
||||||
this.Controls.Add(this.button2);
|
this.Controls.Add(this.button2);
|
||||||
@ -187,5 +199,6 @@
|
|||||||
private ToolStripMenuItem pastryToolStripMenuItem;
|
private ToolStripMenuItem pastryToolStripMenuItem;
|
||||||
private ToolStripMenuItem componentToolStripMenuItem;
|
private ToolStripMenuItem componentToolStripMenuItem;
|
||||||
private ToolStripMenuItem ShopsToolStripMenuItem;
|
private ToolStripMenuItem ShopsToolStripMenuItem;
|
||||||
|
private Button buttonAddPastryInShop;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,8 +30,8 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
/*dataGridView.Columns["PastryName"].AutoSizeMode =
|
dataGridView.Columns["PastryName"].AutoSizeMode =
|
||||||
DataGridViewAutoSizeColumnMode.Fill;*/
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Çàãðóçêà çàêàçîâ");
|
_logger.LogInformation("Çàãðóçêà çàêàçîâ");
|
||||||
}
|
}
|
||||||
@ -158,7 +158,15 @@ namespace ConfectioneryView
|
|||||||
if (service is FormViewShops form)
|
if (service is FormViewShops form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAddPastryInShop_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormAddPastryInShop));
|
||||||
|
if (service is FormAddPastryInShop form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AbstractShopListImplement.Implements;
|
using AbstractShopListImplement.Implements;
|
||||||
|
using ConfectioneryBusinessLogic;
|
||||||
using ConfectioneryBusinessLogic.BusinessLogics;
|
using ConfectioneryBusinessLogic.BusinessLogics;
|
||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
using ConfectioneryContracts.StoragesContract;
|
using ConfectioneryContracts.StoragesContract;
|
||||||
@ -38,9 +39,11 @@ namespace ConfectioneryView
|
|||||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
services.AddTransient<IPastryStorage, PastryStorage>();
|
services.AddTransient<IPastryStorage, PastryStorage>();
|
||||||
|
services.AddTransient<IShopStorage, ShopStorage>();
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IPastryLogic, PastryLogic>();
|
services.AddTransient<IPastryLogic, PastryLogic>();
|
||||||
|
services.AddTransient<IShopLogic, ShopLogic>();
|
||||||
services.AddTransient<FormMain>();
|
services.AddTransient<FormMain>();
|
||||||
services.AddTransient<FormComponent>();
|
services.AddTransient<FormComponent>();
|
||||||
services.AddTransient<FormComponents>();
|
services.AddTransient<FormComponents>();
|
||||||
@ -48,6 +51,8 @@ namespace ConfectioneryView
|
|||||||
services.AddTransient<FormPastry>();
|
services.AddTransient<FormPastry>();
|
||||||
services.AddTransient<FormPastryComponent>();
|
services.AddTransient<FormPastryComponent>();
|
||||||
services.AddTransient<FormViewPastry>();
|
services.AddTransient<FormViewPastry>();
|
||||||
|
services.AddTransient<FormAddPastryInShop>();
|
||||||
|
services.AddTransient<FormViewShops>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user