aaaaaaaaaaa
This commit is contained in:
parent
d1dff985e1
commit
66a55b2d90
@ -43,7 +43,7 @@ namespace FlowerShopBusinessLogic
|
|||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
return false;
|
return false;
|
||||||
return _shopStorage.SupplyFlowers(model, flower, count);
|
return SupplyFlowers(model, flower, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShopViewModel ReadElement(ShopSearchModel model)
|
public ShopViewModel ReadElement(ShopSearchModel model)
|
||||||
@ -131,5 +131,36 @@ namespace FlowerShopBusinessLogic
|
|||||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SupplyFlowers(ShopSearchModel model, IFlowerModel flower, int count)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
if (flower == null)
|
||||||
|
throw new ArgumentNullException(nameof(flower));
|
||||||
|
if (count <= 0)
|
||||||
|
throw new ArgumentNullException("Количество должно быть положительным числом");
|
||||||
|
|
||||||
|
var curModel = _shopStorage.GetElement(model);
|
||||||
|
if (curModel == null)
|
||||||
|
throw new ArgumentNullException(nameof(curModel));
|
||||||
|
if (curModel.ShopFlowers.TryGetValue(flower.Id, out var pair))
|
||||||
|
{
|
||||||
|
curModel.ShopFlowers[flower.Id] = (pair.Item1, pair.Item2 + count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curModel.ShopFlowers.Add(flower.Id, (flower, count));
|
||||||
|
}
|
||||||
|
Update(new()
|
||||||
|
{
|
||||||
|
Id = curModel.Id,
|
||||||
|
ShopName = curModel.ShopName,
|
||||||
|
DateOpen = curModel.DateOpen,
|
||||||
|
Address = curModel.Address,
|
||||||
|
ShopFlowers = curModel.ShopFlowers,
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@ namespace FlowerShopContracts.StoragesContracts
|
|||||||
ShopViewModel? Insert(ShopBindingModel model);
|
ShopViewModel? Insert(ShopBindingModel model);
|
||||||
ShopViewModel? Update(ShopBindingModel model);
|
ShopViewModel? Update(ShopBindingModel model);
|
||||||
ShopViewModel? Delete(ShopBindingModel model);
|
ShopViewModel? Delete(ShopBindingModel model);
|
||||||
bool SupplyFlowers(ShopSearchModel model, IFlowerModel flower, int Count);
|
//bool SupplyFlowers(ShopSearchModel model, IFlowerModel flower, int Count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,35 +106,5 @@ namespace FlowerShopListImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SupplyFlowers(ShopSearchModel model, IFlowerModel flower, int count)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
if (flower == null)
|
|
||||||
throw new ArgumentNullException(nameof(flower));
|
|
||||||
if (count <= 0)
|
|
||||||
throw new ArgumentNullException("Количество должно быть положительным числом");
|
|
||||||
|
|
||||||
ShopViewModel curModel = GetElement(model);
|
|
||||||
if (curModel == null)
|
|
||||||
throw new ArgumentNullException(nameof(curModel));
|
|
||||||
if (curModel.ShopFlowers.TryGetValue(flower.Id, out var pair))
|
|
||||||
{
|
|
||||||
curModel.ShopFlowers[flower.Id] = (pair.Item1, pair.Item2 + count);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
curModel.ShopFlowers.Add(flower.Id, (flower, count));
|
|
||||||
}
|
|
||||||
Update(new()
|
|
||||||
{
|
|
||||||
Id = curModel.Id,
|
|
||||||
ShopName = curModel.ShopName,
|
|
||||||
DateOpen = curModel.DateOpen,
|
|
||||||
Address = curModel.Address,
|
|
||||||
ShopFlowers = curModel.ShopFlowers,
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
ProjectFlowerShop/MainForm.Designer.cs
generated
20
ProjectFlowerShop/MainForm.Designer.cs
generated
@ -32,6 +32,8 @@
|
|||||||
ToolStripMenu = new ToolStripMenuItem();
|
ToolStripMenu = new ToolStripMenuItem();
|
||||||
КомпонентыStripMenuItem = new ToolStripMenuItem();
|
КомпонентыStripMenuItem = new ToolStripMenuItem();
|
||||||
ЦветыStripMenuItem = new ToolStripMenuItem();
|
ЦветыStripMenuItem = new ToolStripMenuItem();
|
||||||
|
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
поставкиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
DataGridView = new DataGridView();
|
DataGridView = new DataGridView();
|
||||||
CreateOrderButton = new Button();
|
CreateOrderButton = new Button();
|
||||||
TakeInWorkButton = new Button();
|
TakeInWorkButton = new Button();
|
||||||
@ -54,7 +56,7 @@
|
|||||||
//
|
//
|
||||||
// ToolStripMenu
|
// ToolStripMenu
|
||||||
//
|
//
|
||||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, ЦветыStripMenuItem });
|
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, ЦветыStripMenuItem, магазиныToolStripMenuItem, поставкиToolStripMenuItem });
|
||||||
ToolStripMenu.Name = "ToolStripMenu";
|
ToolStripMenu.Name = "ToolStripMenu";
|
||||||
ToolStripMenu.Size = new Size(117, 24);
|
ToolStripMenu.Size = new Size(117, 24);
|
||||||
ToolStripMenu.Text = "Справочники";
|
ToolStripMenu.Text = "Справочники";
|
||||||
@ -73,6 +75,20 @@
|
|||||||
ЦветыStripMenuItem.Text = "Цветы";
|
ЦветыStripMenuItem.Text = "Цветы";
|
||||||
ЦветыStripMenuItem.Click += ЦветыStripMenuItem_Click;
|
ЦветыStripMenuItem.Click += ЦветыStripMenuItem_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(224, 26);
|
||||||
|
поставкиToolStripMenuItem.Text = "Поставки";
|
||||||
|
поставкиToolStripMenuItem.Click += поставкиToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// DataGridView
|
// DataGridView
|
||||||
//
|
//
|
||||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
@ -167,5 +183,7 @@
|
|||||||
private Button ReadyButton;
|
private Button ReadyButton;
|
||||||
private Button IssuedButton;
|
private Button IssuedButton;
|
||||||
private Button RefreshButton;
|
private Button RefreshButton;
|
||||||
|
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem поставкиToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -37,6 +37,7 @@ namespace ProjectFlowerShop
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void MainForm_Load(object sender, EventArgs e)
|
private void MainForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
@ -179,5 +180,23 @@ namespace ProjectFlowerShop
|
|||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(ShopsForm));
|
||||||
|
if (service is ShopsForm form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void поставкиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(SupplyForm));
|
||||||
|
if (service is SupplyForm form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
ProjectFlowerShop/ShopForm.Designer.cs
generated
40
ProjectFlowerShop/ShopForm.Designer.cs
generated
@ -37,12 +37,17 @@
|
|||||||
labelAddress = new Label();
|
labelAddress = new Label();
|
||||||
DateTimePicker = new DateTimePicker();
|
DateTimePicker = new DateTimePicker();
|
||||||
labelDate = new Label();
|
labelDate = new Label();
|
||||||
|
ColumnID = new DataGridViewTextBoxColumn();
|
||||||
|
Name = new DataGridViewTextBoxColumn();
|
||||||
|
Price = new DataGridViewTextBoxColumn();
|
||||||
|
Number = new DataGridViewTextBoxColumn();
|
||||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// DataGridView
|
// DataGridView
|
||||||
//
|
//
|
||||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
DataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnID, Name, Price, Number });
|
||||||
DataGridView.Location = new Point(21, 12);
|
DataGridView.Location = new Point(21, 12);
|
||||||
DataGridView.Name = "DataGridView";
|
DataGridView.Name = "DataGridView";
|
||||||
DataGridView.RowHeadersWidth = 51;
|
DataGridView.RowHeadersWidth = 51;
|
||||||
@ -118,6 +123,35 @@
|
|||||||
labelDate.TabIndex = 8;
|
labelDate.TabIndex = 8;
|
||||||
labelDate.Text = "Дата";
|
labelDate.Text = "Дата";
|
||||||
//
|
//
|
||||||
|
// ColumnID
|
||||||
|
//
|
||||||
|
ColumnID.HeaderText = "ColumnID";
|
||||||
|
ColumnID.MinimumWidth = 6;
|
||||||
|
ColumnID.Name = "ColumnID";
|
||||||
|
ColumnID.Visible = false;
|
||||||
|
ColumnID.Width = 125;
|
||||||
|
//
|
||||||
|
// Name
|
||||||
|
//
|
||||||
|
Name.HeaderText = "Название";
|
||||||
|
Name.MinimumWidth = 6;
|
||||||
|
Name.Name = "Name";
|
||||||
|
Name.Width = 125;
|
||||||
|
//
|
||||||
|
// Price
|
||||||
|
//
|
||||||
|
Price.HeaderText = "Цена";
|
||||||
|
Price.MinimumWidth = 6;
|
||||||
|
Price.Name = "Price";
|
||||||
|
Price.Width = 125;
|
||||||
|
//
|
||||||
|
// Number
|
||||||
|
//
|
||||||
|
Number.HeaderText = "Количество";
|
||||||
|
Number.MinimumWidth = 6;
|
||||||
|
Number.Name = "Number";
|
||||||
|
Number.Width = 125;
|
||||||
|
//
|
||||||
// ShopForm
|
// ShopForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -132,7 +166,7 @@
|
|||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(DataGridView);
|
Controls.Add(DataGridView);
|
||||||
Name = "ShopForm";
|
//Name = "ShopForm";
|
||||||
Text = "ShopForm";
|
Text = "ShopForm";
|
||||||
Load += ShopForm_Load;
|
Load += ShopForm_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||||
@ -151,5 +185,9 @@
|
|||||||
private Label labelAddress;
|
private Label labelAddress;
|
||||||
private DateTimePicker DateTimePicker;
|
private DateTimePicker DateTimePicker;
|
||||||
private Label labelDate;
|
private Label labelDate;
|
||||||
|
private DataGridViewTextBoxColumn ColumnID;
|
||||||
|
private DataGridViewTextBoxColumn Name;
|
||||||
|
private DataGridViewTextBoxColumn Price;
|
||||||
|
private DataGridViewTextBoxColumn Number;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -117,4 +117,16 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="ColumnID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Price.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Number.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user