diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormShops.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormShops.cs
index 892417a..327add1 100644
--- a/BlacksmithWorkshop/BlacksmithWorkshop/FormShops.cs
+++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormShops.cs
@@ -35,7 +35,7 @@ namespace BlacksmithWorkshop
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Address"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["DateOpen"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
- dataGridView.Columns["ShopComputers"].Visible = false;
+ dataGridView.Columns["ShopManufactures"].Visible = false;
}
_logger.LogInformation("Загрузка магазинов");
}
diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormSupply.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormSupply.Designer.cs
new file mode 100644
index 0000000..3894c27
--- /dev/null
+++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormSupply.Designer.cs
@@ -0,0 +1,107 @@
+namespace BlacksmithWorkshop
+{
+ partial class FormSupply
+ {
+ ///
+ /// 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()
+ {
+ ShopComboBox = new ComboBox();
+ ManufactureComboBox = new ComboBox();
+ CountTextBox = new TextBox();
+ button1 = new Button();
+ button2 = new Button();
+ SuspendLayout();
+ //
+ // ShopComboBox
+ //
+ ShopComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
+ ShopComboBox.FormattingEnabled = true;
+ ShopComboBox.Location = new Point(12, 12);
+ ShopComboBox.Name = "ShopComboBox";
+ ShopComboBox.Size = new Size(224, 23);
+ ShopComboBox.TabIndex = 0;
+ //
+ // ManufactureComboBox
+ //
+ ManufactureComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
+ ManufactureComboBox.FormattingEnabled = true;
+ ManufactureComboBox.Location = new Point(242, 12);
+ ManufactureComboBox.Name = "ManufactureComboBox";
+ ManufactureComboBox.Size = new Size(224, 23);
+ ManufactureComboBox.TabIndex = 1;
+ //
+ // CountTextBox
+ //
+ CountTextBox.Location = new Point(472, 12);
+ CountTextBox.Name = "CountTextBox";
+ CountTextBox.Size = new Size(224, 23);
+ CountTextBox.TabIndex = 2;
+ //
+ // button1
+ //
+ button1.Location = new Point(162, 47);
+ button1.Name = "button1";
+ button1.Size = new Size(157, 28);
+ button1.TabIndex = 3;
+ button1.Text = "Сохранить";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += SaveButton_Click;
+ //
+ // button2
+ //
+ button2.Location = new Point(394, 47);
+ button2.Name = "button2";
+ button2.Size = new Size(157, 28);
+ button2.TabIndex = 4;
+ button2.Text = "Отмена";
+ button2.UseVisualStyleBackColor = true;
+ button2.Click += CancelButton_Click;
+ //
+ // FormSupply
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(707, 87);
+ Controls.Add(button2);
+ Controls.Add(button1);
+ Controls.Add(CountTextBox);
+ Controls.Add(ManufactureComboBox);
+ Controls.Add(ShopComboBox);
+ Name = "FormSupply";
+ Text = "FormSupply";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private ComboBox ShopComboBox;
+ private ComboBox ManufactureComboBox;
+ private TextBox CountTextBox;
+ private Button button1;
+ private Button button2;
+ }
+}
\ No newline at end of file
diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormSupply.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormSupply.cs
new file mode 100644
index 0000000..8e2c04c
--- /dev/null
+++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormSupply.cs
@@ -0,0 +1,139 @@
+using BlacksmithWorkshopContracts.BusinessLogicsContracts;
+using BlacksmithWorkshopContracts.SearchModels;
+using BlacksmithWorkshopContracts.ViewModels;
+using BlacksmithWorkshopDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace BlacksmithWorkshop
+{
+ public partial class FormSupply : Form
+ {
+ private readonly List? _manufactureList;
+ private readonly List? _shopsList;
+ IShopLogic _shopLogic;
+ IManufactureLogic _ManufactureLogic;
+ public int ShopId
+ {
+ get
+ {
+ return Convert.ToInt32(ShopComboBox.SelectedValue);
+ }
+ set
+ {
+ ShopComboBox.SelectedValue = value;
+ }
+ }
+ public int ManufactureId
+ {
+ get
+ {
+ return Convert.ToInt32(ManufactureComboBox.SelectedValue);
+ }
+ set
+ {
+ ManufactureComboBox.SelectedValue = value;
+ }
+ }
+ public IManufactureModel? ManufactureModel
+ {
+ get
+ {
+ if (_manufactureList == null)
+ {
+ return null;
+ }
+ foreach (var elem in _manufactureList)
+ {
+ if (elem.Id == ManufactureId)
+ {
+ return elem;
+ }
+ }
+ return null;
+ }
+ }
+ public int Count
+ {
+ get { return Convert.ToInt32(CountTextBox.Text); }
+ set { CountTextBox.Text = value.ToString(); }
+ }
+ public FormSupply(IManufactureLogic ManufactureLogic, IShopLogic shopLogic)
+ {
+ InitializeComponent();
+ _shopLogic = shopLogic;
+ _ManufactureLogic = ManufactureLogic;
+ _manufactureList = ManufactureLogic.ReadList(null);
+ _shopsList = shopLogic.ReadList(null);
+ if (_manufactureList != null)
+ {
+ ManufactureComboBox.DisplayMember = "ManufactureName";
+ ManufactureComboBox.ValueMember = "Id";
+ ManufactureComboBox.DataSource = _manufactureList;
+ ManufactureComboBox.SelectedItem = null;
+ }
+ if (_shopsList != null)
+ {
+ ShopComboBox.DisplayMember = "ShopName";
+ ShopComboBox.ValueMember = "Id";
+ ShopComboBox.DataSource = _shopsList;
+ ShopComboBox.SelectedItem = null;
+ }
+ }
+ private void SaveButton_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(CountTextBox.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (ManufactureComboBox.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите кузнечное изделие", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (ShopComboBox.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите магазин", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ try
+ {
+ int count = Convert.ToInt32(CountTextBox.Text);
+ bool res = _shopLogic.ReplenishManufactures(
+ new ShopSearchModel() { Id = Convert.ToInt32(ShopComboBox.SelectedValue) },
+ _ManufactureLogic.ReadElement(new() { Id = Convert.ToInt32(ManufactureComboBox.SelectedValue) }),
+ count
+ );
+ if (!res)
+ {
+ throw new Exception("Ошибка при пополнении. Дополнительная информация в логах");
+ }
+ MessageBox.Show("Пополнение прошло успешно");
+ DialogResult = DialogResult.OK;
+ Close();
+
+ }
+ catch (Exception)
+ {
+ MessageBox.Show("Ошибка пополнения");
+ return;
+ }
+ }
+ private void CancelButton_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormSupply.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormSupply.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormSupply.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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