diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs index 4f2a32a..2299c79 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs @@ -32,14 +32,15 @@ справочникToolStripMenuItem = new ToolStripMenuItem(); компонентыToolStripMenuItem = new ToolStripMenuItem(); изделияToolStripMenuItem = new ToolStripMenuItem(); + магазиныToolStripMenuItem = new ToolStripMenuItem(); + пополнениеМагазинаToolStripMenuItem = new ToolStripMenuItem(); + продажаИзделийToolStripMenuItem = new ToolStripMenuItem(); buttonRef = new Button(); buttonIssuedOrder = new Button(); buttonOrderReady = new Button(); buttonTakeOrderInWork = new Button(); buttonCreateOrder = new Button(); dataGridView = new DataGridView(); - магазиныToolStripMenuItem = new ToolStripMenuItem(); - пополнениеМагазинаToolStripMenuItem = new ToolStripMenuItem(); menuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -47,7 +48,7 @@ // menuStrip1 // menuStrip1.ImageScalingSize = new Size(20, 20); - menuStrip1.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, пополнениеМагазинаToolStripMenuItem }); + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, пополнениеМагазинаToolStripMenuItem, продажаИзделийToolStripMenuItem }); menuStrip1.Location = new Point(0, 0); menuStrip1.Name = "menuStrip1"; menuStrip1.Padding = new Padding(6, 3, 0, 3); @@ -76,6 +77,27 @@ изделияToolStripMenuItem.Text = "Изделия"; изделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click; // + // магазиныToolStripMenuItem + // + магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; + магазиныToolStripMenuItem.Size = new Size(224, 26); + магазиныToolStripMenuItem.Text = "Магазины"; + магазиныToolStripMenuItem.Click += МагазиныToolStripMenuItem_Click; + // + // пополнениеМагазинаToolStripMenuItem + // + пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem"; + пополнениеМагазинаToolStripMenuItem.Size = new Size(182, 24); + пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина"; + пополнениеМагазинаToolStripMenuItem.Click += ПополнениеМагазинаToolStripMenuItem_Click; + // + // продажаИзделийToolStripMenuItem + // + продажаИзделийToolStripMenuItem.Name = "продажаИзделийToolStripMenuItem"; + продажаИзделийToolStripMenuItem.Size = new Size(149, 24); + продажаИзделийToolStripMenuItem.Text = "Продажа изделий"; + продажаИзделийToolStripMenuItem.Click += ПродажаИзделийToolStripMenuItem_Click; + // // buttonRef // buttonRef.Location = new Point(931, 273); @@ -84,7 +106,7 @@ buttonRef.TabIndex = 23; buttonRef.Text = "Обновить список"; buttonRef.UseVisualStyleBackColor = true; - buttonRef.Click += ButtonRef_Click; + buttonRef.Click += ButtonUpd_Click; // // buttonIssuedOrder // @@ -136,20 +158,6 @@ dataGridView.Size = new Size(925, 374); dataGridView.TabIndex = 18; // - // магазиныToolStripMenuItem - // - магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; - магазиныToolStripMenuItem.Size = new Size(224, 26); - магазиныToolStripMenuItem.Text = "Магазины"; - магазиныToolStripMenuItem.Click += МагазиныToolStripMenuItem_Click; - // - // пополнениеМагазинаToolStripMenuItem - // - пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem"; - пополнениеМагазинаToolStripMenuItem.Size = new Size(182, 24); - пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина"; - пополнениеМагазинаToolStripMenuItem.Click += ПополнениеМагазинаToolStripMenuItem_Click; - // // FormMain // AutoScaleDimensions = new SizeF(8F, 20F); @@ -187,5 +195,6 @@ private DataGridView dataGridView; private ToolStripMenuItem магазиныToolStripMenuItem; private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem; + private ToolStripMenuItem продажаИзделийToolStripMenuItem; } } \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs index ff7d4d3..79aed03 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs @@ -38,15 +38,15 @@ namespace PrecastConcretePlantView dataGridView.Columns["ReinforcedId"].Visible = false; dataGridView.Columns["reinforcedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } - _logger.LogInformation("青沭箸赅 玎赅珙"); + _logger.LogInformation("Загрузка заказов"); } catch (Exception ex) { - _logger.LogError(ex, "硒栳赅 玎沭箸觇 玎赅珙"); - MessageBox.Show(ex.Message, "硒栳赅", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void 暑祜铐屙螓ToolStripMenuItem_Click(object sender, EventArgs e) + private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormComponentS)); @@ -55,8 +55,7 @@ namespace PrecastConcretePlantView form.ShowDialog(); } } - private void 如溴腓ToolStripMenuItem_Click(object sender, EventArgs e) - + private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedS)); if (service is FormReinforcedS form) @@ -64,7 +63,7 @@ namespace PrecastConcretePlantView form.ShowDialog(); } } - private void 锑汔玷睇ToolStripMenuItem_Click(object sender, EventArgs e) + private void МагазиныToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormShops)); if (service is FormShops form) @@ -72,7 +71,7 @@ namespace PrecastConcretePlantView form.ShowDialog(); } } - private void 项镱腠屙桢锑汔玷磬ToolStripMenuItem_Click(object sender, EventArgs e) + private void ПополнениеМагазинаToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormShopReplenishment)); if (service is FormShopReplenishment form) @@ -80,7 +79,7 @@ namespace PrecastConcretePlantView form.ShowDialog(); } } - private void 橡钿噫嗳玟咫栝ToolStripMenuItem_Click(object sender, EventArgs e) + private void ПродажаИзделийToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedSale)); if (service is FormReinforcedSale form) @@ -104,20 +103,20 @@ namespace PrecastConcretePlantView { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("青赅 箋id}. 体<> 耱囹篑 磬 '<27> 疣犷蝈'", id); + _logger.LogInformation("Заказ {id}. Меняется статус на 'В работе'", id); try { var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); if (!operationResult) { - throw new Exception("硒栳赅 镳<> 耦躔囗屙梃.念镱腠栩咫 桧纛痨圉 <20> 腩汔."); + throw new Exception("Ошибка при сохранении.Дополнительная информация в логах."); } LoadData(); } catch (Exception ex) { - _logger.LogError(ex, "硒栳赅 镥疱溧麒 玎赅玎 <20> 疣犷蝮"); - MessageBox.Show(ex.Message, "硒栳赅", MessageBoxButtons.OK, + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -128,7 +127,7 @@ namespace PrecastConcretePlantView { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("青赅 箋id}. 体<> 耱囹篑 磬 '妙蝾'", + _logger.LogInformation("Заказ {id}. Меняется статус на 'Готов'", id); try { @@ -137,14 +136,14 @@ namespace PrecastConcretePlantView { Id = id }); if (!operationResult) { - throw new Exception("硒栳赅 镳<> 耦躔囗屙梃. 念镱腠栩咫 桧纛痨圉 <20> 腩汔."); + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } LoadData(); } catch (Exception ex) { - _logger.LogError(ex, "硒栳赅 铗戾蜿 <20> 泐蝾忭铖蜩 玎赅玎"); - MessageBox.Show(ex.Message, "硒栳赅", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } @@ -154,21 +153,21 @@ namespace PrecastConcretePlantView { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("青赅 箋id}. 体<> 耱囹篑 磬 '蔓溧'", id); + _logger.LogInformation("Заказ {id}. Меняется статус на 'Выдан'", id); try { var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); if (!operationResult) { - throw new Exception("硒栳赅"); + throw new Exception("Ошибка"); } - _logger.LogInformation("青赅 箋id} 恹溧", id); + _logger.LogInformation("Заказ {id} выдан", id); LoadData(); } catch (Exception ex) { - _logger.LogError(ex, "硒栳赅 铗戾蜿 <20> 恹溧麒 玎赅玎"); - MessageBox.Show(ex.Message, "硒栳赅", MessageBoxButtons.OK, + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedSale.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedSale.Designer.cs new file mode 100644 index 0000000..c36794e --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedSale.Designer.cs @@ -0,0 +1,128 @@ +namespace PrecastConcretePlantView +{ + partial class FormReinforcedSale + { + /// + /// 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() + { + buttonCancel = new Button(); + buttonSale = new Button(); + textBoxCount = new TextBox(); + labelCount = new Label(); + comboBoxReinforced = new ComboBox(); + labelReinforced = new Label(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Location = new Point(289, 111); + buttonCancel.Margin = new Padding(5, 4, 5, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(101, 36); + buttonCancel.TabIndex = 17; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSale + // + buttonSale.Location = new Point(182, 111); + buttonSale.Margin = new Padding(5, 4, 5, 4); + buttonSale.Name = "buttonSale"; + buttonSale.Size = new Size(101, 36); + buttonSale.TabIndex = 16; + buttonSale.Text = "Продать"; + buttonSale.UseVisualStyleBackColor = true; + buttonSale.Click += ButtonSale_Click; + // + // textBoxCount + // + textBoxCount.Location = new Point(115, 68); + textBoxCount.Margin = new Padding(5, 4, 5, 4); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(287, 27); + textBoxCount.TabIndex = 15; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(15, 72); + labelCount.Margin = new Padding(5, 0, 5, 0); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(93, 20); + labelCount.TabIndex = 14; + labelCount.Text = "Количество:"; + // + // comboBoxReinforced + // + comboBoxReinforced.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxReinforced.FormattingEnabled = true; + comboBoxReinforced.Location = new Point(115, 20); + comboBoxReinforced.Margin = new Padding(5, 4, 5, 4); + comboBoxReinforced.Name = "comboBoxReinforced"; + comboBoxReinforced.Size = new Size(287, 28); + comboBoxReinforced.TabIndex = 13; + // + // labelReinforced + // + labelReinforced.AutoSize = true; + labelReinforced.Location = new Point(15, 25); + labelReinforced.Margin = new Padding(5, 0, 5, 0); + labelReinforced.Name = "labelReinforced"; + labelReinforced.Size = new Size(71, 20); + labelReinforced.TabIndex = 12; + labelReinforced.Text = "Изделие:"; + // + // FormReinforcedSale + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(426, 164); + Controls.Add(buttonCancel); + Controls.Add(buttonSale); + Controls.Add(textBoxCount); + Controls.Add(labelCount); + Controls.Add(comboBoxReinforced); + Controls.Add(labelReinforced); + Margin = new Padding(3, 4, 3, 4); + Name = "FormReinforcedSale"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Продажа изделий"; + Load += FormReinforcedSale_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonSale; + private TextBox textBoxCount; + private Label labelCount; + private ComboBox comboBoxReinforced; + private Label labelReinforced; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedSale.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedSale.cs new file mode 100644 index 0000000..238f726 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedSale.cs @@ -0,0 +1,87 @@ +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.BindingModels; +using Microsoft.Extensions.Logging; + +namespace PrecastConcretePlantView +{ + public partial class FormReinforcedSale : Form + { + private readonly ILogger _logger; + + private readonly IReinforcedLogic _logicReinforced; + + private readonly IShopLogic _logicShop; + + public FormReinforcedSale(ILogger logger, IReinforcedLogic logicReinforced, IShopLogic logicShop) + { + InitializeComponent(); + _logger = logger; + _logicReinforced = logicReinforced; + _logicShop = logicShop; + } + + private void FormReinforcedSale_Load(object sender, EventArgs e) + { + _logger.LogInformation("Reinforceds loading"); + try + { + var list = _logicReinforced.ReadList(null); + if (list != null) + { + comboBoxReinforced.DisplayMember = "ReinforcedName"; + comboBoxReinforced.ValueMember = "Id"; + comboBoxReinforced.DataSource = list; + comboBoxReinforced.SelectedItem = null; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Reinforceds loading error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonSale_Click(object sender, EventArgs e) + { + if (comboBoxReinforced.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Reinforced sale"); + try + { + var operationResult = _logicShop.MakeSale( + new ReinforcedBindingModel + { + Id = Convert.ToInt32(comboBoxReinforced.SelectedValue) + }, + Convert.ToInt32(textBoxCount.Text) + ); + if (!operationResult) + { + throw new Exception("Ошибка при продаже."); + } + MessageBox.Show("Продажа прошла успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Reinforced sale error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedSale.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedSale.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedSale.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 diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormShop.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormShop.Designer.cs index 78f5a73..1e9c361 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormShop.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormShop.Designer.cs @@ -36,11 +36,13 @@ labelOpeningDate = new Label(); groupBoxReinforceds = new GroupBox(); dataGridView = new DataGridView(); - buttonSave = new Button(); - buttonCancel = new Button(); ColumnId = new DataGridViewTextBoxColumn(); ColumnName = new DataGridViewTextBoxColumn(); ColumnCount = new DataGridViewTextBoxColumn(); + buttonSave = new Button(); + buttonCancel = new Button(); + textBoxMax = new Label(); + textBoxMaximum = new TextBox(); groupBoxReinforceds.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -60,7 +62,7 @@ textBoxName.Location = new Point(105, 9); textBoxName.Margin = new Padding(5, 4, 5, 4); textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(287, 27); + textBoxName.Size = new Size(302, 27); textBoxName.TabIndex = 2; // // labelAddress @@ -78,7 +80,7 @@ textBoxAddress.Location = new Point(105, 49); textBoxAddress.Margin = new Padding(5, 4, 5, 4); textBoxAddress.Name = "textBoxAddress"; - textBoxAddress.Size = new Size(287, 27); + textBoxAddress.Size = new Size(302, 27); textBoxAddress.TabIndex = 4; // // dateTimePicker @@ -86,7 +88,7 @@ dateTimePicker.Location = new Point(144, 88); dateTimePicker.Margin = new Padding(3, 4, 3, 4); dateTimePicker.Name = "dateTimePicker"; - dateTimePicker.Size = new Size(249, 27); + dateTimePicker.Size = new Size(263, 27); dateTimePicker.TabIndex = 5; // // labelOpeningDate @@ -102,11 +104,11 @@ // groupBoxReinforceds // groupBoxReinforceds.Controls.Add(dataGridView); - groupBoxReinforceds.Location = new Point(5, 133); + groupBoxReinforceds.Location = new Point(5, 183); groupBoxReinforceds.Margin = new Padding(5, 4, 5, 4); groupBoxReinforceds.Name = "groupBoxReinforceds"; groupBoxReinforceds.Padding = new Padding(5, 4, 5, 4); - groupBoxReinforceds.Size = new Size(536, 384); + groupBoxReinforceds.Size = new Size(536, 395); groupBoxReinforceds.TabIndex = 7; groupBoxReinforceds.TabStop = false; groupBoxReinforceds.Text = "Изделие"; @@ -127,31 +129,9 @@ dataGridView.RowHeadersVisible = false; dataGridView.RowHeadersWidth = 51; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(522, 356); + dataGridView.Size = new Size(522, 367); dataGridView.TabIndex = 0; // - // buttonSave - // - buttonSave.Location = new Point(291, 525); - buttonSave.Margin = new Padding(5, 4, 5, 4); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(101, 36); - buttonSave.TabIndex = 8; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += ButtonSave_Click; - // - // buttonCancel - // - buttonCancel.Location = new Point(410, 525); - buttonCancel.Margin = new Padding(5, 4, 5, 4); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(101, 36); - buttonCancel.TabIndex = 9; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += ButtonCancel_Click; - // // ColumnId // ColumnId.HeaderText = "Id"; @@ -177,11 +157,51 @@ ColumnCount.ReadOnly = true; ColumnCount.Width = 125; // + // buttonSave + // + buttonSave.Location = new Point(306, 586); + buttonSave.Margin = new Padding(5, 4, 5, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(101, 36); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(417, 586); + buttonCancel.Margin = new Padding(5, 4, 5, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(101, 36); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // textBoxMax + // + textBoxMax.AutoSize = true; + textBoxMax.Location = new Point(16, 141); + textBoxMax.Name = "textBoxMax"; + textBoxMax.Size = new Size(270, 20); + textBoxMax.TabIndex = 10; + textBoxMax.Text = "Максимальное колличество изделий:"; + // + // textBoxMaximum + // + textBoxMaximum.Location = new Point(306, 138); + textBoxMaximum.Name = "textBoxMaximum"; + textBoxMaximum.Size = new Size(101, 27); + textBoxMaximum.TabIndex = 11; + // // FormShop // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(546, 576); + ClientSize = new Size(546, 635); + Controls.Add(textBoxMaximum); + Controls.Add(textBoxMax); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(groupBoxReinforceds); @@ -217,5 +237,7 @@ private DataGridViewTextBoxColumn ColumnId; private DataGridViewTextBoxColumn ColumnName; private DataGridViewTextBoxColumn ColumnCount; + private Label textBoxMax; + private TextBox textBoxMaximum; } } \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormShop.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormShop.cs index 8c3ed32..f02ac17 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormShop.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormShop.cs @@ -4,7 +4,6 @@ using PrecastConcretePlantContracts.SearchModels; using PrecastConcretePlantDataModels.Models; using Microsoft.Extensions.Logging; using PrecastConcretePlantListImplement.Models; -using System.Windows.Forms; namespace PrecastConcretePlantView { @@ -41,6 +40,7 @@ namespace PrecastConcretePlantView textBoxName.Text = view.ShopName; textBoxAddress.Text = view.Address; dateTimePicker.Value = view.DateOpening; + textBoxMaximum.Text = view.ReinforcedsMax.ToString(); _shopReinforceds = view.ShopReinforceds ?? new Dictionary(); LoadData(); } @@ -91,6 +91,11 @@ namespace PrecastConcretePlantView MessageBox.Show("Заполните дату", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } + if (string.IsNullOrEmpty(textBoxMaximum.Text)) + { + MessageBox.Show("Заполните максимальное количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } _logger.LogInformation("Shop saving"); try { @@ -100,6 +105,7 @@ namespace PrecastConcretePlantView ShopName = textBoxName.Text, Address = textBoxAddress.Text, DateOpening = dateTimePicker.Value, + ReinforcedsMax = Convert.ToInt32(textBoxMaximum.Text), ShopReinforceds = _shopReinforceds }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormShopRefill.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormShopRefill.cs index c272b61..fd340ab 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormShopRefill.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormShopRefill.cs @@ -95,7 +95,7 @@ namespace PrecastConcretePlantView { throw new Exception("Изделие не найдено."); } - var operationResult = _logicShop.RefillShop(new ShopSearchModel + var operationResult = _logicShop.ReplenishShop(new ShopSearchModel { Id = Convert.ToInt32(comboBoxShop.SelectedValue) }, diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormShopReplenishment.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormShopReplenishment.Designer.cs new file mode 100644 index 0000000..1114748 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormShopReplenishment.Designer.cs @@ -0,0 +1,145 @@ +namespace PrecastConcretePlantView +{ + partial class FormShopReplenishment + { + /// + /// 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() + { + labelShop = new Label(); + labelReinforced = new Label(); + labelCount = new Label(); + comboBoxShop = new ComboBox(); + comboBoxReinforced = new ComboBox(); + textBoxCount = new TextBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // labelShop + // + labelShop.AutoSize = true; + labelShop.Location = new Point(27, 29); + labelShop.Name = "labelShop"; + labelShop.Size = new Size(72, 20); + labelShop.TabIndex = 0; + labelShop.Text = "Магазин:"; + // + // labelReinforced + // + labelReinforced.AutoSize = true; + labelReinforced.Location = new Point(27, 73); + labelReinforced.Name = "labelReinforced"; + labelReinforced.Size = new Size(71, 20); + labelReinforced.TabIndex = 1; + labelReinforced.Text = "Изделие:"; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(27, 118); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(93, 20); + labelCount.TabIndex = 2; + labelCount.Text = "Количество:"; + // + // comboBoxShop + // + comboBoxShop.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxShop.FormattingEnabled = true; + comboBoxShop.Location = new Point(136, 29); + comboBoxShop.Name = "comboBoxShop"; + comboBoxShop.Size = new Size(239, 28); + comboBoxShop.TabIndex = 3; + // + // comboBoxReinforced + // + comboBoxReinforced.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxReinforced.FormattingEnabled = true; + comboBoxReinforced.Location = new Point(136, 73); + comboBoxReinforced.Name = "comboBoxReinforced"; + comboBoxReinforced.Size = new Size(239, 28); + comboBoxReinforced.TabIndex = 4; + // + // textBoxCount + // + textBoxCount.Location = new Point(136, 118); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(239, 27); + textBoxCount.TabIndex = 5; + // + // buttonCancel + // + buttonCancel.Location = new Point(282, 162); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(93, 29); + buttonCancel.TabIndex = 6; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(182, 162); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 7; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormShopReplenishment + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(422, 203); + Controls.Add(buttonSave); + Controls.Add(buttonCancel); + Controls.Add(textBoxCount); + Controls.Add(comboBoxReinforced); + Controls.Add(comboBoxShop); + Controls.Add(labelCount); + Controls.Add(labelReinforced); + Controls.Add(labelShop); + Name = "FormShopReplenishment"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Пополнение магазина"; + Load += FormShopReplenishment_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelShop; + private Label labelReinforced; + private Label labelCount; + private ComboBox comboBoxShop; + private ComboBox comboBoxReinforced; + private TextBox textBoxCount; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormShopReplenishment.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormShopReplenishment.cs new file mode 100644 index 0000000..8a7ea68 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormShopReplenishment.cs @@ -0,0 +1,126 @@ +using Microsoft.Extensions.Logging; + +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantListImplement.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 PrecastConcretePlantView +{ + public partial class FormShopReplenishment : Form + { + private readonly ILogger _logger; + + private readonly IReinforcedLogic _logicReinforced; + + private readonly IShopLogic _logicShop; + + public FormShopReplenishment(ILogger logger, IReinforcedLogic logicReinforced, IShopLogic logicShop) + { + InitializeComponent(); + _logger = logger; + _logicReinforced = logicReinforced; + _logicShop = logicShop; + } + + private void FormShopReplenishment_Load(object sender, EventArgs e) + { + _logger.LogInformation("Reinforceds loading"); + try + { + var list = _logicReinforced.ReadList(null); + if (list != null) + { + comboBoxReinforced.DisplayMember = "ReinforcedName"; + comboBoxReinforced.ValueMember = "Id"; + comboBoxReinforced.DataSource = list; + comboBoxReinforced.SelectedItem = null; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Reinforceds loading error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + _logger.LogInformation("Shops loading"); + try + { + var list = _logicShop.ReadList(null); + if (list != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = list; + comboBoxShop.SelectedItem = null; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Shops loading error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxReinforced.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Shop replenishment"); + try + { + var reinforced = _logicReinforced.ReadElement(new ReinforcedSearchModel + { Id = Convert.ToInt32(comboBoxReinforced.SelectedValue) }); + if (reinforced == null) + { + throw new Exception("Изделие не найдено."); + } + var operationResult = _logicShop.ReplenishShop(new ShopSearchModel + { + Id = Convert.ToInt32(comboBoxShop.SelectedValue) + }, + reinforced, Convert.ToInt32(textBoxCount.Text)); + if (!operationResult) + { + throw new Exception("Ошибка при проведении поставки."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Shop replenishment error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + DialogResult = DialogResult.OK; + Close(); + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormShopReplenishment.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormShopReplenishment.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormShopReplenishment.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 diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormShopS.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormShopS.cs index 2ecf768..ac07dd0 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormShopS.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormShopS.cs @@ -1,7 +1,6 @@ using PrecastConcretePlantContracts.BindingModels; using PrecastConcretePlantContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; -using System.Windows.Forms; namespace PrecastConcretePlantView { diff --git a/PrecastConcretePlant/PrecastConcretePlantView/Program.cs b/PrecastConcretePlant/PrecastConcretePlantView/Program.cs index 81aca21..9cdcd31 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/Program.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/Program.cs @@ -1,11 +1,11 @@ +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantBusinessLogic.BusinessLogics; +using PrecastConcretePlantContracts.StoragesContracts; +using PrecastConcretePlantFileImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; -using PrecastConcretePlantBusinessLogic.BusinessLogics; -using PrecastConcretePlantContracts.BusinessLogicsContracts; -using PrecastConcretePlantContracts.StoragesContracts; -using PrecastConcretePlantFileImplement.Implements; -using System; + namespace PrecastConcretePlantView { @@ -34,7 +34,6 @@ namespace PrecastConcretePlantView option.SetMinimumLevel(LogLevel.Information); option.AddNLog("nlog.config"); }); - services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -54,7 +53,8 @@ namespace PrecastConcretePlantView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file