aaaaaaaaaaa

This commit is contained in:
antoc0der 2024-02-28 15:39:48 +03:00
parent d1dff985e1
commit 66a55b2d90
7 changed files with 122 additions and 34 deletions

View File

@ -43,7 +43,7 @@ namespace FlowerShopBusinessLogic
{
if (model == null)
return false;
return _shopStorage.SupplyFlowers(model, flower, count);
return SupplyFlowers(model, flower, count);
}
public ShopViewModel ReadElement(ShopSearchModel model)
@ -131,5 +131,36 @@ namespace FlowerShopBusinessLogic
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;
}
}
}

View File

@ -18,6 +18,6 @@ namespace FlowerShopContracts.StoragesContracts
ShopViewModel? Insert(ShopBindingModel model);
ShopViewModel? Update(ShopBindingModel model);
ShopViewModel? Delete(ShopBindingModel model);
bool SupplyFlowers(ShopSearchModel model, IFlowerModel flower, int Count);
//bool SupplyFlowers(ShopSearchModel model, IFlowerModel flower, int Count);
}
}

View File

@ -106,35 +106,5 @@ namespace FlowerShopListImplement.Implements
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;
}
}
}

View File

@ -32,6 +32,8 @@
ToolStripMenu = new ToolStripMenuItem();
КомпонентыStripMenuItem = new ToolStripMenuItem();
ЦветыStripMenuItem = new ToolStripMenuItem();
магазиныToolStripMenuItem = new ToolStripMenuItem();
поставкиToolStripMenuItem = new ToolStripMenuItem();
DataGridView = new DataGridView();
CreateOrderButton = new Button();
TakeInWorkButton = new Button();
@ -54,7 +56,7 @@
//
// ToolStripMenu
//
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, ЦветыStripMenuItem });
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, ЦветыStripMenuItem, магазиныToolStripMenuItem, поставкиToolStripMenuItem });
ToolStripMenu.Name = "ToolStripMenu";
ToolStripMenu.Size = new Size(117, 24);
ToolStripMenu.Text = "Справочники";
@ -73,6 +75,20 @@
ЦветыStripMenuItem.Text = "Цветы";
Цветы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.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
@ -167,5 +183,7 @@
private Button ReadyButton;
private Button IssuedButton;
private Button RefreshButton;
private ToolStripMenuItem магазиныToolStripMenuItem;
private ToolStripMenuItem поставкиToolStripMenuItem;
}
}

View File

@ -37,6 +37,7 @@ namespace ProjectFlowerShop
}
private void MainForm_Load(object sender, EventArgs e)
{
LoadData();
@ -179,5 +180,23 @@ namespace ProjectFlowerShop
{
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();
}
}
}
}

View File

@ -37,12 +37,17 @@
labelAddress = new Label();
DateTimePicker = new DateTimePicker();
labelDate = new Label();
ColumnID = new DataGridViewTextBoxColumn();
Name = new DataGridViewTextBoxColumn();
Price = new DataGridViewTextBoxColumn();
Number = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
SuspendLayout();
//
// DataGridView
//
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
DataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnID, Name, Price, Number });
DataGridView.Location = new Point(21, 12);
DataGridView.Name = "DataGridView";
DataGridView.RowHeadersWidth = 51;
@ -118,6 +123,35 @@
labelDate.TabIndex = 8;
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
//
AutoScaleDimensions = new SizeF(8F, 20F);
@ -132,7 +166,7 @@
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(DataGridView);
Name = "ShopForm";
//Name = "ShopForm";
Text = "ShopForm";
Load += ShopForm_Load;
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
@ -151,5 +185,9 @@
private Label labelAddress;
private DateTimePicker DateTimePicker;
private Label labelDate;
private DataGridViewTextBoxColumn ColumnID;
private DataGridViewTextBoxColumn Name;
private DataGridViewTextBoxColumn Price;
private DataGridViewTextBoxColumn Number;
}
}

View File

@ -117,4 +117,16 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</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>