Удален неиспользуемый метод
This commit is contained in:
parent
39bf568539
commit
5d93f4126c
@ -213,5 +213,10 @@ namespace ConfectioneryBusinessLogic
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SellPastries(IPastryModel pastry, int needCount)
|
||||
{
|
||||
return _shopStorage.SellPastries(pastry, needCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using ConfectioneryContracts.SearchModels;
|
||||
using ConfectioneryContracts.StoragesContract;
|
||||
using ConfectioneryContracts.ViewModels;
|
||||
using ConfectioneryDataModels;
|
||||
using ConfectioneryDataModels.Models;
|
||||
|
||||
namespace ConfectioneryFileImplement
|
||||
@ -94,11 +95,12 @@ namespace ConfectioneryFileImplement
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach (var pair in _source.Shops.Where(shop => shop.Pastries.ContainsKey(pastry.Id)))
|
||||
foreach (var shop in _source.Shops.Where(shop => shop.Pastries.ContainsKey(pastry.Id)))
|
||||
{
|
||||
var tuple = pair.Pastries[pastry.Id];
|
||||
var tuple = shop.Pastries[pastry.Id];
|
||||
var diff = Math.Min(tuple.Item2, needCount);
|
||||
pair.Pastries[pastry.Id] = (tuple.Item1, tuple.Item2 - diff);
|
||||
shop.Pastries[pastry.Id] = (tuple.Item1, tuple.Item2 - diff);
|
||||
|
||||
needCount -= diff;
|
||||
if (needCount <= 0)
|
||||
{
|
||||
|
20
Confectionery/FormMain.Designer.cs
generated
20
Confectionery/FormMain.Designer.cs
generated
@ -40,6 +40,7 @@
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.button4 = new System.Windows.Forms.Button();
|
||||
this.buttonAddPastryInShop = new System.Windows.Forms.Button();
|
||||
this.buttonSellPastry = new System.Windows.Forms.Button();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -94,7 +95,7 @@
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 27);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(606, 341);
|
||||
this.dataGridView.Size = new System.Drawing.Size(606, 399);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
@ -155,7 +156,7 @@
|
||||
// buttonAddPastryInShop
|
||||
//
|
||||
this.buttonAddPastryInShop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonAddPastryInShop.Location = new System.Drawing.Point(624, 326);
|
||||
this.buttonAddPastryInShop.Location = new System.Drawing.Point(624, 384);
|
||||
this.buttonAddPastryInShop.Name = "buttonAddPastryInShop";
|
||||
this.buttonAddPastryInShop.Size = new System.Drawing.Size(147, 31);
|
||||
this.buttonAddPastryInShop.TabIndex = 7;
|
||||
@ -163,11 +164,23 @@
|
||||
this.buttonAddPastryInShop.UseVisualStyleBackColor = true;
|
||||
this.buttonAddPastryInShop.Click += new System.EventHandler(this.ButtonAddPastryInShop_Click);
|
||||
//
|
||||
// buttonSellPastry
|
||||
//
|
||||
this.buttonSellPastry.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonSellPastry.Location = new System.Drawing.Point(624, 331);
|
||||
this.buttonSellPastry.Name = "buttonSellPastry";
|
||||
this.buttonSellPastry.Size = new System.Drawing.Size(147, 31);
|
||||
this.buttonSellPastry.TabIndex = 8;
|
||||
this.buttonSellPastry.Text = "Продать изделие";
|
||||
this.buttonSellPastry.UseVisualStyleBackColor = true;
|
||||
this.buttonSellPastry.Click += new System.EventHandler(this.ButtonSellPastry_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(783, 380);
|
||||
this.ClientSize = new System.Drawing.Size(783, 438);
|
||||
this.Controls.Add(this.buttonSellPastry);
|
||||
this.Controls.Add(this.buttonAddPastryInShop);
|
||||
this.Controls.Add(this.button4);
|
||||
this.Controls.Add(this.button3);
|
||||
@ -202,5 +215,6 @@
|
||||
private ToolStripMenuItem componentToolStripMenuItem;
|
||||
private ToolStripMenuItem ShopsToolStripMenuItem;
|
||||
private Button buttonAddPastryInShop;
|
||||
private Button buttonSellPastry;
|
||||
}
|
||||
}
|
@ -170,5 +170,14 @@ namespace ConfectioneryView
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSellPastry_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellPastry));
|
||||
if (service is FormSellPastry form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
Confectionery/FormSellPastry.Designer.cs
generated
Normal file
133
Confectionery/FormSellPastry.Designer.cs
generated
Normal file
@ -0,0 +1,133 @@
|
||||
namespace ConfectioneryView
|
||||
{
|
||||
partial class FormSellPastry
|
||||
{
|
||||
/// <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.comboBoxPastry = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
|
||||
this.buttonSell = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// comboBoxPastry
|
||||
//
|
||||
this.comboBoxPastry.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.comboBoxPastry.FormattingEnabled = true;
|
||||
this.comboBoxPastry.Location = new System.Drawing.Point(141, 12);
|
||||
this.comboBoxPastry.Name = "comboBoxPastry";
|
||||
this.comboBoxPastry.Size = new System.Drawing.Size(121, 23);
|
||||
this.comboBoxPastry.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 15);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(123, 15);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Изделие на продажу:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(60, 46);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(75, 15);
|
||||
this.label2.TabIndex = 2;
|
||||
this.label2.Text = "Количество:";
|
||||
//
|
||||
// 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, 46);
|
||||
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(120, 23);
|
||||
this.numericUpDownCount.TabIndex = 3;
|
||||
//
|
||||
// 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(12, 90);
|
||||
this.buttonSell.Name = "buttonSell";
|
||||
this.buttonSell.Size = new System.Drawing.Size(123, 23);
|
||||
this.buttonSell.TabIndex = 4;
|
||||
this.buttonSell.Text = "Продать";
|
||||
this.buttonSell.UseVisualStyleBackColor = true;
|
||||
this.buttonSell.Click += new System.EventHandler(this.ButtonSell_Click);
|
||||
//
|
||||
// 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(142, 90);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(123, 23);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormSellPastry
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(277, 122);
|
||||
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.comboBoxPastry);
|
||||
this.Name = "FormSellPastry";
|
||||
this.Text = "Продажа изделия";
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBoxPastry;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private NumericUpDown numericUpDownCount;
|
||||
private Button buttonSell;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
67
Confectionery/FormSellPastry.cs
Normal file
67
Confectionery/FormSellPastry.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||
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 ConfectioneryView
|
||||
{
|
||||
public partial class FormSellPastry : Form
|
||||
{
|
||||
private readonly IShopLogic _shopLogic;
|
||||
private readonly IPastryLogic _pastryLogic;
|
||||
|
||||
public FormSellPastry(IPastryLogic logic, IShopLogic shopLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_pastryLogic = logic;
|
||||
_shopLogic = shopLogic;
|
||||
var list = logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxPastry.DisplayMember = "PastryName";
|
||||
comboBoxPastry.ValueMember = "Id";
|
||||
comboBoxPastry.DataSource = list;
|
||||
comboBoxPastry.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSell_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxPastry.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 pastry = _pastryLogic.ReadElement(new() { Id = (int)comboBoxPastry.SelectedValue });
|
||||
if (pastry == null || !_shopLogic.SellPastries(pastry, count))
|
||||
{
|
||||
MessageBox.Show("Не удалось продать изделия. Информацию смотрите в логах", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
Confectionery/FormSellPastry.resx
Normal file
60
Confectionery/FormSellPastry.resx
Normal 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>
|
@ -53,6 +53,7 @@ namespace ConfectioneryView
|
||||
services.AddTransient<FormAddPastryInShop>();
|
||||
services.AddTransient<FormViewShops>();
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormSellPastry>();
|
||||
}
|
||||
}
|
||||
}
|
@ -15,5 +15,6 @@ namespace ConfectioneryContracts.BusinessLogicsContracts
|
||||
bool AddPastry(ShopSearchModel model, IPastryModel pastry, int count);
|
||||
int GetFreePlacesWithPastriesInShops(int countPastries);
|
||||
bool AddPastriesInShops(IPastryModel pastry, int count);
|
||||
public bool SellPastries(IPastryModel pastry, int needCount);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user