From 4e0ca60e928faae4b7f1b9407517cbbcbd639bed Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 12 Feb 2023 23:21:21 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=BE=D1=80=D0=BC=D1=8B=20=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=80=D0=BE=D0=B4=D0=B5=20=D0=B3=D0=BE=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FurnitureAssembly/FormMain.Designer.cs | 24 ++- .../FurnitureAssembly/FormMain.cs | 69 ++++++++- .../FormReplenishmentShop.Designer.cs | 142 ++++++++++++++++++ .../FormReplenishmentShop.cs | 142 ++++++++++++++++++ .../FormReplenishmentShop.resx | 60 ++++++++ .../FurnitureAssembly/FormShop.Designer.cs | 46 +++++- .../FurnitureAssembly/FormShop.cs | 30 ++++ .../FurnitureAssembly/FormShop.resx | 9 ++ .../FurnitureAssembly/FormShops.Designer.cs | 2 +- .../FurnitureAssembly/Program.cs | 5 + .../Models/Shop.cs | 16 ++ 11 files changed, 536 insertions(+), 9 deletions(-) create mode 100644 FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.Designer.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.resx diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs index 0199789..f81c725 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs @@ -38,6 +38,8 @@ 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.пополнениеМагазинаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -104,7 +106,8 @@ // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - 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(1065, 24); @@ -115,7 +118,8 @@ // this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.компонентыToolStripMenuItem, - this.изделияToolStripMenuItem}); + this.изделияToolStripMenuItem, + this.магазиныToolStripMenuItem}); this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); this.справочникиToolStripMenuItem.Text = "Справочники"; @@ -134,6 +138,20 @@ this.изделияToolStripMenuItem.Text = "Изделия"; this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click); // + // магазиныToolStripMenuItem + // + this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; + this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(145, 22); + this.магазиныToolStripMenuItem.Text = "Магазины"; + this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click); + // + // пополнениеМагазинаToolStripMenuItem + // + this.пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem"; + this.пополнениеМагазинаToolStripMenuItem.Size = new System.Drawing.Size(143, 20); + this.пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина"; + this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.ReplenishmentToolStripMenuItem_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -170,5 +188,7 @@ private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem изделияToolStripMenuItem; + private ToolStripMenuItem магазиныToolStripMenuItem; + private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem; } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.cs index 62e043a..cc422a4 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.cs @@ -18,11 +18,13 @@ namespace FurnitureAssembly { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + private readonly IShopLogic _shopLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IShopLogic shopLogic) { InitializeComponent(); _logger = logger; - _orderLogic = orderLogic; + _orderLogic = orderLogic; + _shopLogic = shopLogic; } private void FormMain_Load(object sender, EventArgs e) { @@ -153,6 +155,67 @@ namespace FurnitureAssembly private void ButtonRef_Click(object sender, EventArgs e) { LoadData(); - } + } + + private OrderBindingModel GetOrderBindingModel() + { + return new OrderBindingModel + { + Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value), + FurnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value), + FurnitureName = dataGridView.SelectedRows[0].Cells["FurnitureName"].Value.ToString(), + 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()) + }; + } + + private void ShopsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) + { + form.ShowDialog(); + } + } + + private void ReplenishmentToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReplenishmentShop)); + if (service is FormReplenishmentShop form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ShopModel == null || form.FurnitureModel == null) + { + return; + } + _logger.LogInformation("Добавление в магазин {ShopName} изделия: { FurnitureName}- { Count}", form.ShopModel.ShopName, form.FurnitureModel.FurnitureName, form.Count); + + var modelShop = new ShopBindingModel + { + Id = form.Id, + ShopName = form.ShopModel.ShopName, + Address = form.ShopModel.Address, + DateOpening = form.ShopModel.DateOpening, + }; + + var modelFurn = new FurnitureBindingModel + { + Id = form.FurnitureId, + FurnitureName = form.FurnitureModel.FurnitureName, + Price = form.FurnitureModel.Price, + FurnitureComponents = form.FurnitureModel.FurnitureComponents + }; + + var operationResult = _shopLogic.AddFurniture(modelShop, modelFurn, form.Count); + if (!operationResult) + { + throw new Exception("Ошибка при пополнении магазина. Дополнительная информация в логах."); + } + } + } + } } } diff --git a/FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.Designer.cs new file mode 100644 index 0000000..4b4f438 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.Designer.cs @@ -0,0 +1,142 @@ +namespace FurnitureAssembly +{ + partial class FormReplenishmentShop + { + /// + /// 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.comboBoxShop = new System.Windows.Forms.ComboBox(); + this.labelShop = new System.Windows.Forms.Label(); + this.comboBoxFurniture = new System.Windows.Forms.ComboBox(); + this.labelFurniture = new System.Windows.Forms.Label(); + this.labelNum = new System.Windows.Forms.Label(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // comboBoxShop + // + this.comboBoxShop.FormattingEnabled = true; + this.comboBoxShop.Location = new System.Drawing.Point(133, 18); + this.comboBoxShop.Name = "comboBoxShop"; + this.comboBoxShop.Size = new System.Drawing.Size(296, 23); + this.comboBoxShop.TabIndex = 0; + // + // labelShop + // + this.labelShop.AutoSize = true; + this.labelShop.Location = new System.Drawing.Point(46, 21); + this.labelShop.Name = "labelShop"; + this.labelShop.Size = new System.Drawing.Size(54, 15); + this.labelShop.TabIndex = 1; + this.labelShop.Text = "Магазин"; + // + // comboBoxFurniture + // + this.comboBoxFurniture.FormattingEnabled = true; + this.comboBoxFurniture.Location = new System.Drawing.Point(133, 62); + this.comboBoxFurniture.Name = "comboBoxFurniture"; + this.comboBoxFurniture.Size = new System.Drawing.Size(296, 23); + this.comboBoxFurniture.TabIndex = 2; + // + // labelFurniture + // + this.labelFurniture.AutoSize = true; + this.labelFurniture.Location = new System.Drawing.Point(46, 65); + this.labelFurniture.Name = "labelFurniture"; + this.labelFurniture.Size = new System.Drawing.Size(53, 15); + this.labelFurniture.TabIndex = 4; + this.labelFurniture.Text = "Изделие"; + // + // labelNum + // + this.labelNum.AutoSize = true; + this.labelNum.Location = new System.Drawing.Point(46, 106); + this.labelNum.Name = "labelNum"; + this.labelNum.Size = new System.Drawing.Size(72, 15); + this.labelNum.TabIndex = 5; + this.labelNum.Text = "Количество"; + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(194, 161); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(99, 29); + this.buttonAdd.TabIndex = 6; + this.buttonAdd.Text = "Пополнить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(330, 161); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(99, 29); + this.buttonCancel.TabIndex = 7; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(133, 103); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(160, 23); + this.textBoxCount.TabIndex = 8; + // + // FormReplenishmentShop + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(479, 214); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.labelNum); + this.Controls.Add(this.labelFurniture); + this.Controls.Add(this.comboBoxFurniture); + this.Controls.Add(this.labelShop); + this.Controls.Add(this.comboBoxShop); + this.Name = "FormReplenishmentShop"; + this.Text = "Пополнение магазина"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private ComboBox comboBoxShop; + private Label labelShop; + private ComboBox comboBoxFurniture; + private Label labelFurniture; + private Label labelNum; + private Button buttonAdd; + private Button buttonCancel; + private TextBox textBoxCount; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.cs b/FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.cs new file mode 100644 index 0000000..4ae0fb4 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.cs @@ -0,0 +1,142 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using FurnitureAssemblyContracts.ViewModels; +using FurnitureAssemblyDataModels.Models; +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 FurnitureAssembly +{ + public partial class FormReplenishmentShop : Form + { + + private readonly List? _listShops; + private readonly List? _listFurnitures; + + public int Id + { + get + { + return Convert.ToInt32(comboBoxShop.SelectedValue); + } + set + { + comboBoxShop.SelectedValue = value; + } + } + public IShopModel? ShopModel + { + get + { + if (_listShops == null) + { + return null; + } + foreach (var elem in _listShops) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + + public int FurnitureId + { + get + { + return Convert.ToInt32(comboBoxFurniture.SelectedValue); + } + set + { + comboBoxFurniture.SelectedValue = value; + } + } + public IFurnitureModel? FurnitureModel + { + get + { + if (_listFurnitures == null) + { + return null; + } + foreach (var elem in _listFurnitures) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + + public int Count + { + get { return Convert.ToInt32(textBoxCount.Text); } + set + { textBoxCount.Text = value.ToString(); } + } + public FormReplenishmentShop(IShopLogic shopLogic, IFurnitureLogic furnitureLogic) + { + InitializeComponent(); + _listShops = shopLogic.ReadList(null); + _listFurnitures = furnitureLogic.ReadList(null); + if (_listShops != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = _listShops; + comboBoxShop.SelectedItem = null; + } + if (_listFurnitures != null) + { + comboBoxFurniture.DisplayMember = "FurnitureName"; + comboBoxFurniture.ValueMember = "Id"; + comboBoxFurniture.DataSource = _listFurnitures; + comboBoxFurniture.SelectedItem = null; + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxFurniture.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Укажите количество поступившего изделия", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.resx b/FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReplenishmentShop.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/FurnitureAssembly/FurnitureAssembly/FormShop.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormShop.Designer.cs index 59820d1..d7dc3a8 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormShop.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormShop.Designer.cs @@ -36,6 +36,11 @@ this.dateTimePicker = new System.Windows.Forms.DateTimePicker(); this.ButtonSave = new System.Windows.Forms.Button(); this.ButtonCancel = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.FurnitureId = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.FurnitureName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // labelShopName @@ -88,7 +93,7 @@ // // ButtonSave // - this.ButtonSave.Location = new System.Drawing.Point(230, 169); + this.ButtonSave.Location = new System.Drawing.Point(382, 490); this.ButtonSave.Name = "ButtonSave"; this.ButtonSave.Size = new System.Drawing.Size(99, 28); this.ButtonSave.TabIndex = 7; @@ -98,7 +103,7 @@ // // ButtonCancel // - this.ButtonCancel.Location = new System.Drawing.Point(351, 169); + this.ButtonCancel.Location = new System.Drawing.Point(509, 490); this.ButtonCancel.Name = "ButtonCancel"; this.ButtonCancel.Size = new System.Drawing.Size(99, 28); this.ButtonCancel.TabIndex = 8; @@ -106,11 +111,41 @@ this.ButtonCancel.UseVisualStyleBackColor = true; this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // + // dataGridView1 + // + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.FurnitureId, + this.FurnitureName, + this.Count}); + this.dataGridView1.Location = new System.Drawing.Point(37, 177); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowTemplate.Height = 25; + this.dataGridView1.Size = new System.Drawing.Size(571, 289); + this.dataGridView1.TabIndex = 9; + // + // FurnitureId + // + this.FurnitureId.HeaderText = "Id"; + this.FurnitureId.Name = "FurnitureId"; + this.FurnitureId.Visible = false; + // + // FurnitureName + // + this.FurnitureName.HeaderText = "Название"; + this.FurnitureName.Name = "FurnitureName"; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.Name = "Count"; + // // FormShop // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(498, 209); + this.ClientSize = new System.Drawing.Size(631, 530); + this.Controls.Add(this.dataGridView1); this.Controls.Add(this.ButtonCancel); this.Controls.Add(this.ButtonSave); this.Controls.Add(this.dateTimePicker); @@ -122,6 +157,7 @@ this.Name = "FormShop"; this.Text = "Магазин"; this.Load += new System.EventHandler(this.FormShop_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -137,5 +173,9 @@ private DateTimePicker dateTimePicker; private Button ButtonSave; private Button ButtonCancel; + private DataGridView dataGridView1; + private DataGridViewTextBoxColumn FurnitureId; + private DataGridViewTextBoxColumn FurnitureName; + private DataGridViewTextBoxColumn Count; } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormShop.cs b/FurnitureAssembly/FurnitureAssembly/FormShop.cs index 7e388a8..b49158b 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormShop.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormShop.cs @@ -1,6 +1,7 @@ using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.BusinessLogicsContarcts; using FurnitureAssemblyContracts.SearchModels; +using FurnitureAssemblyDataModels.Models; using Microsoft.Extensions.Logging; namespace FurnitureAssembly @@ -9,6 +10,7 @@ namespace FurnitureAssembly { private readonly ILogger _logger; private readonly IShopLogic _logic; + private Dictionary _shopFurnitures; private int? _id; public int Id { set { _id = value; } } @@ -17,6 +19,7 @@ namespace FurnitureAssembly InitializeComponent(); _logger = logger; _logic = logic; + _shopFurnitures = new Dictionary(); } @@ -91,6 +94,10 @@ namespace FurnitureAssembly textBoxName.Text = view.ShopName; textBoxAddress.Text = view.Address.ToString(); dateTimePicker.Value = view.DateOpening; + _shopFurnitures = view.Furnitures ?? new + Dictionary(); + dta + LoadData(); } } catch (Exception ex) @@ -101,5 +108,28 @@ namespace FurnitureAssembly } } } + + private void LoadData() + { + _logger.LogInformation("Загрузка компонент изделия"); + try + { + if (_shopFurnitures != null) + { + dataGridView1.Rows.Clear(); + foreach (var pc in _shopFurnitures) + { + dataGridView1.Rows.Add(new object[] { pc.Key, pc.Value.Item1.FurnitureName, pc.Value.Item2 }); + } + + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонент изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } } } diff --git a/FurnitureAssembly/FurnitureAssembly/FormShop.resx b/FurnitureAssembly/FurnitureAssembly/FormShop.resx index f298a7b..565a3a5 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormShop.resx +++ b/FurnitureAssembly/FurnitureAssembly/FormShop.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/FurnitureAssembly/FurnitureAssembly/FormShops.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormShops.Designer.cs index f9bfdce..ee13c0d 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormShops.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormShops.Designer.cs @@ -96,7 +96,7 @@ this.Controls.Add(this.ButtonAdd); this.Controls.Add(this.dataGridView); this.Name = "FormShops"; - this.Text = "FormShops"; + this.Text = "Магазины"; this.Load += new System.EventHandler(this.FormShops_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/FurnitureAssembly/FurnitureAssembly/Program.cs b/FurnitureAssembly/FurnitureAssembly/Program.cs index 2cc7ecb..2209e02 100644 --- a/FurnitureAssembly/FurnitureAssembly/Program.cs +++ b/FurnitureAssembly/FurnitureAssembly/Program.cs @@ -38,9 +38,11 @@ namespace FurnitureAssembly services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -48,6 +50,9 @@ namespace FurnitureAssembly services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Shop.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Shop.cs index 8e96c90..780811a 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Shop.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Shop.cs @@ -48,6 +48,22 @@ namespace FurnitureAssemblyListImplement.Models DateOpening = model.DateOpening; Furnitures = model.Furnitures; } + + public void AddFurniture(ShopBindingModel? model, FurnitureBindingModel furniture, int count) + { + if (model == null) + { + return; + } + if (Furnitures.ContainsKey(furniture.Id)) + { + int prev_count = Furnitures[furniture.Id].Item2; + Furnitures[furniture.Id] = (furniture, prev_count + count); + } else + { + Furnitures[furniture.Id] = (furniture, count); + } + } public ShopViewModel GetViewModel => new() { Id = Id,