fix and complete

This commit is contained in:
Павел Путилин 2023-04-21 23:22:44 +04:00
parent 9f4419ada0
commit 203097dbdd
8 changed files with 295 additions and 23 deletions

View File

@ -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;
}
}

View File

@ -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();
}
}
}
}

View File

@ -0,0 +1,133 @@
namespace PrecastConcretePlantView
{
partial class FormSellReinforced
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -58,6 +58,7 @@ namespace PrecastConcretePlant
services.AddTransient<FormAddReinforcedInShop>();
services.AddTransient<FormViewShops>();
services.AddTransient<FormShop>();
services.AddTransient<FormSellReinforced>();
}
}
}

View File

@ -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);
}
}

View File

@ -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)