From 203097dbddab8d0f973371e48aa8d898875b1f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Fri, 21 Apr 2023 23:22:44 +0400 Subject: [PATCH] fix and complete --- .../PrecastConcretePlant/FormMain.Designer.cs | 47 ++++--- .../PrecastConcretePlant/FormMain.cs | 9 ++ .../FormSellReinforced.Designer.cs | 133 ++++++++++++++++++ .../FormSellReinforced.cs | 56 ++++++++ .../FormSellReinforced.resx | 60 ++++++++ .../PrecastConcretePlant/Program.cs | 1 + .../BusinessLogicsContracts/IShopLogic.cs | 4 +- .../ReinforcedStorage.cs | 8 +- 8 files changed, 295 insertions(+), 23 deletions(-) create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.resx diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs index 73c89fc..9fc0826 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs @@ -38,8 +38,9 @@ this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reinforcedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.buttonAddReinforcedInShop = new System.Windows.Forms.Button(); this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonAddReinforcedInShop = new System.Windows.Forms.Button(); + this.buttonSellReinforced = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -47,7 +48,7 @@ // buttonRef // this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRef.Location = new System.Drawing.Point(840, 276); + this.buttonRef.Location = new System.Drawing.Point(786, 276); this.buttonRef.Name = "buttonRef"; this.buttonRef.Size = new System.Drawing.Size(147, 32); this.buttonRef.TabIndex = 12; @@ -58,7 +59,7 @@ // buttonFinish // this.buttonFinish.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonFinish.Location = new System.Drawing.Point(840, 217); + this.buttonFinish.Location = new System.Drawing.Point(786, 217); this.buttonFinish.Name = "buttonFinish"; this.buttonFinish.Size = new System.Drawing.Size(147, 32); this.buttonFinish.TabIndex = 11; @@ -69,7 +70,7 @@ // buttonReady // this.buttonReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonReady.Location = new System.Drawing.Point(840, 159); + this.buttonReady.Location = new System.Drawing.Point(786, 159); this.buttonReady.Name = "buttonReady"; this.buttonReady.Size = new System.Drawing.Size(147, 32); this.buttonReady.TabIndex = 10; @@ -80,7 +81,7 @@ // buttonTakeOrderInWork // this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonTakeOrderInWork.Location = new System.Drawing.Point(840, 100); + this.buttonTakeOrderInWork.Location = new System.Drawing.Point(786, 100); this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; this.buttonTakeOrderInWork.Size = new System.Drawing.Size(147, 32); this.buttonTakeOrderInWork.TabIndex = 9; @@ -91,7 +92,7 @@ // buttonCreateOrder // this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCreateOrder.Location = new System.Drawing.Point(840, 41); + this.buttonCreateOrder.Location = new System.Drawing.Point(786, 41); this.buttonCreateOrder.Name = "buttonCreateOrder"; this.buttonCreateOrder.Size = new System.Drawing.Size(147, 32); this.buttonCreateOrder.TabIndex = 8; @@ -108,7 +109,7 @@ this.dataGridView.Location = new System.Drawing.Point(12, 29); this.dataGridView.Name = "dataGridView"; this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(805, 348); + this.dataGridView.Size = new System.Drawing.Size(751, 396); this.dataGridView.TabIndex = 7; // // menuStrip1 @@ -117,7 +118,7 @@ this.справочникиToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(999, 24); + this.menuStrip1.Size = new System.Drawing.Size(945, 24); this.menuStrip1.TabIndex = 13; this.menuStrip1.Text = "menuStrip1"; // @@ -145,10 +146,17 @@ this.componentToolStripMenuItem.Text = "Компоненты"; this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_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); + // // buttonAddReinforcedInShop // - this.buttonAddReinforcedInShop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonAddReinforcedInShop.Location = new System.Drawing.Point(840, 337); + this.buttonAddReinforcedInShop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAddReinforcedInShop.Location = new System.Drawing.Point(786, 337); this.buttonAddReinforcedInShop.Name = "buttonAddReinforcedInShop"; this.buttonAddReinforcedInShop.Size = new System.Drawing.Size(147, 31); this.buttonAddReinforcedInShop.TabIndex = 14; @@ -156,18 +164,23 @@ this.buttonAddReinforcedInShop.UseVisualStyleBackColor = true; this.buttonAddReinforcedInShop.Click += new System.EventHandler(this.ButtonAddReinforcedInShop_Click); // - // магазиныToolStripMenuItem + // buttonSellReinforced // - this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; - this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.магазиныToolStripMenuItem.Text = "Магазины"; - this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click); + this.buttonSellReinforced.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSellReinforced.Location = new System.Drawing.Point(786, 395); + this.buttonSellReinforced.Name = "buttonSellReinforced"; + this.buttonSellReinforced.Size = new System.Drawing.Size(147, 31); + this.buttonSellReinforced.TabIndex = 15; + this.buttonSellReinforced.Text = "Продать изделие"; + this.buttonSellReinforced.UseVisualStyleBackColor = true; + this.buttonSellReinforced.Click += new System.EventHandler(this.ButtonSellReinforced_Click); // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(999, 389); + this.ClientSize = new System.Drawing.Size(945, 437); + this.Controls.Add(this.buttonSellReinforced); this.Controls.Add(this.buttonAddReinforcedInShop); this.Controls.Add(this.menuStrip1); this.Controls.Add(this.buttonRef); @@ -178,7 +191,6 @@ this.Controls.Add(this.dataGridView); this.Name = "FormMain"; this.Text = "Заказы"; - this.Load += new System.EventHandler(this.FormMain_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.menuStrip1.ResumeLayout(false); @@ -202,5 +214,6 @@ private ToolStripMenuItem componentToolStripMenuItem; private Button buttonAddReinforcedInShop; private ToolStripMenuItem магазиныToolStripMenuItem; + private Button buttonSellReinforced; } } \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs b/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs index 3c41bda..9601a51 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs @@ -170,5 +170,14 @@ namespace PrecastConcretePlantView form.ShowDialog(); } } + + private void ButtonSellReinforced_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSellReinforced)); + if (service is FormSellReinforced form) + { + form.ShowDialog(); + } + } } } diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.Designer.cs new file mode 100644 index 0000000..8a5b68e --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.Designer.cs @@ -0,0 +1,133 @@ +namespace PrecastConcretePlantView +{ + partial class FormSellReinforced + { + /// + /// 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.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSell = new System.Windows.Forms.Button(); + this.numericUpDownCount = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.comboBoxReinforced = new System.Windows.Forms.ComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.Location = new System.Drawing.Point(179, 79); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(123, 23); + this.buttonCancel.TabIndex = 11; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSell + // + this.buttonSell.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSell.Location = new System.Drawing.Point(32, 79); + this.buttonSell.Name = "buttonSell"; + this.buttonSell.Size = new System.Drawing.Size(123, 23); + this.buttonSell.TabIndex = 10; + this.buttonSell.Text = "Продать"; + this.buttonSell.UseVisualStyleBackColor = true; + this.buttonSell.Click += new System.EventHandler(this.ButtonSell_Click); + // + // numericUpDownCount + // + this.numericUpDownCount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.numericUpDownCount.Location = new System.Drawing.Point(142, 40); + this.numericUpDownCount.Maximum = new decimal(new int[] { + 10000000, + 0, + 0, + 0}); + this.numericUpDownCount.Name = "numericUpDownCount"; + this.numericUpDownCount.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.numericUpDownCount.Size = new System.Drawing.Size(160, 23); + this.numericUpDownCount.TabIndex = 9; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(60, 40); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(75, 15); + this.label2.TabIndex = 8; + this.label2.Text = "Количество:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(123, 15); + this.label1.TabIndex = 7; + this.label1.Text = "Изделие на продажу:"; + // + // comboBoxReinforced + // + this.comboBoxReinforced.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.comboBoxReinforced.FormattingEnabled = true; + this.comboBoxReinforced.Location = new System.Drawing.Point(141, 6); + this.comboBoxReinforced.Name = "comboBoxReinforced"; + this.comboBoxReinforced.Size = new System.Drawing.Size(161, 23); + this.comboBoxReinforced.TabIndex = 6; + // + // FormSellReinforced + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(314, 114); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSell); + this.Controls.Add(this.numericUpDownCount); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.comboBoxReinforced); + this.Name = "FormSellReinforced"; + this.Text = "FormSellReinforced"; + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button buttonCancel; + private Button buttonSell; + private NumericUpDown numericUpDownCount; + private Label label2; + private Label label1; + private ComboBox comboBoxReinforced; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.cs b/PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.cs new file mode 100644 index 0000000..46626c9 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.cs @@ -0,0 +1,56 @@ +using PrecastConcretePlantContracts.BusinessLogicsContracts; + +namespace PrecastConcretePlantView +{ + public partial class FormSellReinforced : Form + { + private readonly IShopLogic _shopLogic; + private readonly IReinforcedLogic _reinforcedLogic; + public FormSellReinforced(IReinforcedLogic logic, IShopLogic shopLogic) + { + InitializeComponent(); + _reinforcedLogic = logic; + _shopLogic = shopLogic; + var list = logic.ReadList(null); + if (list != null) + { + comboBoxReinforced.DisplayMember = "ReinforcedName"; + comboBoxReinforced.ValueMember = "Id"; + comboBoxReinforced.DataSource = list; + comboBoxReinforced.SelectedItem = null; + } + } + + private void ButtonSell_Click(object sender, EventArgs e) + { + if (comboBoxReinforced.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (numericUpDownCount.Value <= 0) + { + MessageBox.Show("Количество должно быть больше нуля", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + var count = (int)numericUpDownCount.Value; + var reinforced = _reinforcedLogic.ReadElement(new() { Id = (int)comboBoxReinforced.SelectedValue }); + if (reinforced == null || !_shopLogic.SellReinforceds(reinforced, count)) + { + MessageBox.Show("Не удалось продать изделия. Информацию смотрите в логах", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + DialogResult = DialogResult.OK; + Close(); + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.resx b/PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormSellReinforced.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/PrecastConcretePlant/PrecastConcretePlant/Program.cs b/PrecastConcretePlant/PrecastConcretePlant/Program.cs index 4303847..d6086ea 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/Program.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/Program.cs @@ -58,6 +58,7 @@ namespace PrecastConcretePlant services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IShopLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IShopLogic.cs index cee1038..0094dce 100644 --- a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IShopLogic.cs +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IShopLogic.cs @@ -13,7 +13,7 @@ namespace PrecastConcretePlantContracts.BusinessLogicsContracts bool Update(ShopBindingModel model); bool Delete(ShopBindingModel model); bool AddReinforced(ShopSearchModel model, IReinforcedModel reinforced, int count); - bool AddReinforcedsInShops(IReinforcedModel reinforceds, int count); - public bool SellReinforceds(IReinforcedModel reinforceds, int needCount); + bool AddReinforcedsInShops(IReinforcedModel reinforced, int count); + public bool SellReinforceds(IReinforcedModel reinforced, int needCount); } } diff --git a/PrecastConcretePlant/PrecastConcretePlantFileImplement/ReinforcedStorage.cs b/PrecastConcretePlant/PrecastConcretePlantFileImplement/ReinforcedStorage.cs index e8a565e..c31a0b1 100644 --- a/PrecastConcretePlant/PrecastConcretePlantFileImplement/ReinforcedStorage.cs +++ b/PrecastConcretePlant/PrecastConcretePlantFileImplement/ReinforcedStorage.cs @@ -60,14 +60,14 @@ namespace PrecastConcretePlantFileImplement public ReinforcedViewModel? Insert(ReinforcedBindingModel model) { model.Id = _source.Reinforceds.Count > 0 ? _source.Reinforceds.Max(x => x.Id) + 1 : 1; - var newPastry = Reinforced.Create(model); - if (newPastry == null) + var newReinforced = Reinforced.Create(model); + if (newReinforced == null) { return null; } - _source.Reinforceds.Add(newPastry); + _source.Reinforceds.Add(newReinforced); _source.SaveReinforceds(); - return newPastry.GetViewModel; + return newReinforced.GetViewModel; } public ReinforcedViewModel? Update(ReinforcedBindingModel model)