diff --git a/FlowerShopBusinessLogic/ShopLogic.cs b/FlowerShopBusinessLogic/ShopLogic.cs
index 050e6ca..e22e00b 100644
--- a/FlowerShopBusinessLogic/ShopLogic.cs
+++ b/FlowerShopBusinessLogic/ShopLogic.cs
@@ -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;
+ }
}
}
diff --git a/FlowerShopContracts/StoragesContracts/IShopStorage.cs b/FlowerShopContracts/StoragesContracts/IShopStorage.cs
index de5a976..122a79f 100644
--- a/FlowerShopContracts/StoragesContracts/IShopStorage.cs
+++ b/FlowerShopContracts/StoragesContracts/IShopStorage.cs
@@ -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);
}
}
diff --git a/FlowerShopListImplement/ShopStorage.cs b/FlowerShopListImplement/ShopStorage.cs
index 77219a3..a97253b 100644
--- a/FlowerShopListImplement/ShopStorage.cs
+++ b/FlowerShopListImplement/ShopStorage.cs
@@ -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;
- }
}
}
diff --git a/ProjectFlowerShop/MainForm.Designer.cs b/ProjectFlowerShop/MainForm.Designer.cs
index 56eb0e9..40db63c 100644
--- a/ProjectFlowerShop/MainForm.Designer.cs
+++ b/ProjectFlowerShop/MainForm.Designer.cs
@@ -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;
}
}
\ No newline at end of file
diff --git a/ProjectFlowerShop/MainForm.cs b/ProjectFlowerShop/MainForm.cs
index 5d70efb..cc1bea1 100644
--- a/ProjectFlowerShop/MainForm.cs
+++ b/ProjectFlowerShop/MainForm.cs
@@ -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();
+ }
+ }
}
}
diff --git a/ProjectFlowerShop/ShopForm.Designer.cs b/ProjectFlowerShop/ShopForm.Designer.cs
index a9b799c..ffdac20 100644
--- a/ProjectFlowerShop/ShopForm.Designer.cs
+++ b/ProjectFlowerShop/ShopForm.Designer.cs
@@ -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;
}
}
\ No newline at end of file
diff --git a/ProjectFlowerShop/ShopForm.resx b/ProjectFlowerShop/ShopForm.resx
index af32865..e4ea5ef 100644
--- a/ProjectFlowerShop/ShopForm.resx
+++ b/ProjectFlowerShop/ShopForm.resx
@@ -117,4 +117,16 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
\ No newline at end of file