diff --git a/Pizzeria/Pizzeria/FormMain.Designer.cs b/Pizzeria/Pizzeria/FormMain.Designer.cs index f00039f..bd01748 100644 --- a/Pizzeria/Pizzeria/FormMain.Designer.cs +++ b/Pizzeria/Pizzeria/FormMain.Designer.cs @@ -42,6 +42,7 @@ this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.button6 = new System.Windows.Forms.Button(); + this.buttonSell = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -174,11 +175,23 @@ this.button6.UseVisualStyleBackColor = true; this.button6.Click += new System.EventHandler(this.ButtonRestore_Click); // + // buttonSell + // + this.buttonSell.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSell.Location = new System.Drawing.Point(987, 328); + this.buttonSell.Name = "buttonSell"; + this.buttonSell.Size = new System.Drawing.Size(209, 29); + this.buttonSell.TabIndex = 13; + this.buttonSell.Text = "Продать"; + this.buttonSell.UseVisualStyleBackColor = true; + this.buttonSell.Click += new System.EventHandler(this.ButtonSell_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1233, 439); + this.Controls.Add(this.buttonSell); this.Controls.Add(this.button6); this.Controls.Add(this.menuStrip1); this.Controls.Add(this.button3); @@ -214,5 +227,6 @@ private ToolStripMenuItem изделияToolStripMenuItem; private ToolStripMenuItem магазиныToolStripMenuItem; private Button button6; + private Button buttonSell; } } \ No newline at end of file diff --git a/Pizzeria/Pizzeria/FormMain.cs b/Pizzeria/Pizzeria/FormMain.cs index 4f2c854..f48dbbb 100644 --- a/Pizzeria/Pizzeria/FormMain.cs +++ b/Pizzeria/Pizzeria/FormMain.cs @@ -159,6 +159,11 @@ namespace Pizzeria LoadData(); } + private void ButtonSell_Click(object sender, EventArgs e) + { + LoadData(); + } + private void ButtonRestore_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormShopPizza)); diff --git a/Pizzeria/Pizzeria/FormShop.Designer.cs b/Pizzeria/Pizzeria/FormShop.Designer.cs index 921424f..5c4799e 100644 --- a/Pizzeria/Pizzeria/FormShop.Designer.cs +++ b/Pizzeria/Pizzeria/FormShop.Designer.cs @@ -41,6 +41,8 @@ this.labelShop = new System.Windows.Forms.Label(); this.buttonSave = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); + this.textBoxCapacity = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); // @@ -103,7 +105,7 @@ this.dataGridView.Name = "dataGridView"; this.dataGridView.RowHeadersWidth = 62; this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(664, 296); + this.dataGridView.Size = new System.Drawing.Size(870, 296); this.dataGridView.TabIndex = 21; // // ColumnID @@ -147,7 +149,7 @@ // buttonSave // this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSave.Location = new System.Drawing.Point(415, 383); + this.buttonSave.Location = new System.Drawing.Point(621, 383); this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonSave.Name = "buttonSave"; this.buttonSave.Size = new System.Drawing.Size(137, 30); @@ -159,7 +161,7 @@ // 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(558, 383); + this.buttonCancel.Location = new System.Drawing.Point(764, 383); this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(118, 30); @@ -168,11 +170,30 @@ this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // + // textBoxCapacity + // + this.textBoxCapacity.Location = new System.Drawing.Point(696, 36); + this.textBoxCapacity.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.textBoxCapacity.Name = "textBoxCapacity"; + this.textBoxCapacity.Size = new System.Drawing.Size(186, 27); + this.textBoxCapacity.TabIndex = 29; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(696, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(100, 20); + this.label1.TabIndex = 30; + this.label1.Text = "Вместимость"; + // // FormShop // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(704, 426); + this.ClientSize = new System.Drawing.Size(910, 426); + this.Controls.Add(this.label1); + this.Controls.Add(this.textBoxCapacity); this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.dateTimePicker); @@ -206,5 +227,7 @@ private Label labelShop; private Button buttonSave; private Button buttonCancel; + private TextBox textBoxCapacity; + private Label label1; } } \ No newline at end of file diff --git a/Pizzeria/Pizzeria/FormShop.cs b/Pizzeria/Pizzeria/FormShop.cs index f0298e4..9d0875f 100644 --- a/Pizzeria/Pizzeria/FormShop.cs +++ b/Pizzeria/Pizzeria/FormShop.cs @@ -90,6 +90,7 @@ namespace Pizzeria Id = _id ?? 0, ShopName = textBoxName.Text, Addres = textBoxAddres.Text, + Capacity = Convert.ToInt32(textBoxCapacity.Text), OpenTime = dateTimePicker.Value.Date, ShopPizzas = _shopPizzas }; diff --git a/Pizzeria/PizzeriaContracts/BindingModels/ShopBindingModel.cs b/Pizzeria/PizzeriaContracts/BindingModels/ShopBindingModel.cs index 621cafe..1787239 100644 --- a/Pizzeria/PizzeriaContracts/BindingModels/ShopBindingModel.cs +++ b/Pizzeria/PizzeriaContracts/BindingModels/ShopBindingModel.cs @@ -10,6 +10,7 @@ namespace PizzeriaContracts.BindingModels public string Addres { get; set; } = String.Empty; public DateTime OpenTime { get; set; } + public int Capacity { get; set; } public Dictionary ShopPizzas { diff --git a/Pizzeria/PizzeriaContracts/ViewModels/ShopViewModel.cs b/Pizzeria/PizzeriaContracts/ViewModels/ShopViewModel.cs index ef7b3e1..c86ebfe 100644 --- a/Pizzeria/PizzeriaContracts/ViewModels/ShopViewModel.cs +++ b/Pizzeria/PizzeriaContracts/ViewModels/ShopViewModel.cs @@ -13,7 +13,8 @@ namespace PizzeriaContracts.ViewModels public string Addres { get; set; } = string.Empty; [DisplayName("Дата открытия")] public DateTime OpenTime { get; set; } - + [DisplayName("Вместимость")] + public int Capacity { get; set; } public Dictionary ShopPizzas { get; diff --git a/Pizzeria/PizzeriaDataModels/Models/IShopModel.cs b/Pizzeria/PizzeriaDataModels/Models/IShopModel.cs index 7760585..3b19692 100644 --- a/Pizzeria/PizzeriaDataModels/Models/IShopModel.cs +++ b/Pizzeria/PizzeriaDataModels/Models/IShopModel.cs @@ -12,6 +12,7 @@ namespace PizzeriaDataModels string Addres { get; } DateTime OpenTime { get; } + int Capacity { get; } Dictionary ShopPizzas { get; } } } diff --git a/Pizzeria/PizzeriaShopFileImplement/DataFileSingleton.cs b/Pizzeria/PizzeriaShopFileImplement/DataFileSingleton.cs index 3e309f1..1aa6d12 100644 --- a/Pizzeria/PizzeriaShopFileImplement/DataFileSingleton.cs +++ b/Pizzeria/PizzeriaShopFileImplement/DataFileSingleton.cs @@ -24,6 +24,7 @@ namespace PizzeriaFileImplement } public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement); public void SavePizzas() => SaveData(Pizzas, PizzaFileName, "Pizzas", x => x.GetXElement); + public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement); public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); private DataFileSingleton() { diff --git a/Pizzeria/PizzeriaShopFileImplement/Implements/ShopStorage.cs b/Pizzeria/PizzeriaShopFileImplement/Implements/ShopStorage.cs index 8605fca..04f9a85 100644 --- a/Pizzeria/PizzeriaShopFileImplement/Implements/ShopStorage.cs +++ b/Pizzeria/PizzeriaShopFileImplement/Implements/ShopStorage.cs @@ -50,7 +50,7 @@ namespace PizzeriaFileImplement.Implements return null; } source.Shops.Add(newShop); - source.SaveData(); + source.SaveShops(); return newShop.GetViewModel; } public ShopViewModel? Update(ShopBindingModel model) @@ -61,7 +61,7 @@ namespace PizzeriaFileImplement.Implements return null; } shop.Update(model); - source.SaveData(); + source.SaveShops(); return shop.GetViewModel; } public ShopViewModel? Delete(ShopBindingModel model) @@ -70,7 +70,7 @@ namespace PizzeriaFileImplement.Implements if (element != null) { source.Shops.Remove(element); - source.SaveData(); + source.SaveShops(); return element.GetViewModel; } return null; diff --git a/Pizzeria/PizzeriaShopFileImplement/models/Shop.cs b/Pizzeria/PizzeriaShopFileImplement/models/Shop.cs index 0090f9d..9af508f 100644 --- a/Pizzeria/PizzeriaShopFileImplement/models/Shop.cs +++ b/Pizzeria/PizzeriaShopFileImplement/models/Shop.cs @@ -11,6 +11,7 @@ namespace PizzeriaFileImplement.models public string ShopName { get; set; } = string.Empty; public string Addres { get; set; } = string.Empty; public DateTime OpenTime { get; set; } + public int Capacity { get; set; } public Dictionary Pizzas { get; private set; } = new(); private Dictionary? _shopPizzas = null; public Dictionary ShopPizzas @@ -40,6 +41,7 @@ namespace PizzeriaFileImplement.models ShopName = model.ShopName, Addres = model.Addres, OpenTime = model.OpenTime, + Capacity = model.Capacity, Pizzas = model.ShopPizzas.ToDictionary(x => x.Key, x => x.Value.Item2) }; } @@ -49,11 +51,14 @@ namespace PizzeriaFileImplement.models { return null; } + return new Shop() { Id = Convert.ToInt32(element.Attribute("Id")!.Value), ShopName = element.Element("ShopName")!.Value, - Addres = element.Element("Price")!.Value, + Addres = element.Element("Addres")!.Value, + OpenTime = DateTime.Parse(element.Element("OpenTime")!.Value), + Capacity = Convert.ToInt32(element.Element("Capacity")!.Value), Pizzas = element.Element("ShopPizzas")!.Elements("ShopPizza") .ToDictionary( x => Convert.ToInt32(x.Element("Key")?.Value), @@ -78,12 +83,15 @@ namespace PizzeriaFileImplement.models ShopName = ShopName, Addres = Addres, OpenTime = OpenTime, + Capacity = Capacity, ShopPizzas = ShopPizzas }; public XElement GetXElement => new("Shop", new XAttribute("Id", Id), new XElement("ShopName", ShopName), new XElement("Addres", Addres), + new XElement("OpenTime", OpenTime), + new XElement("Capacity", Capacity), new XElement("ShopPizzas", Pizzas.Select(x => new XElement("ShopPizza", new XElement("Key", x.Key),