From a4e4b5208be03ade6cbc6ab99f046ecb05d1c1bf Mon Sep 17 00:00:00 2001 From: malimova Date: Wed, 28 Feb 2024 22:48:48 +0400 Subject: [PATCH 1/6] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D0=BE=20Lab1?= =?UTF-8?q?=5Fhard.=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20Shop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConfectioneryBusinessLogic/ShopLogic.cs | 12 ++++++++++++ .../BindingModels/ShopBindingModel.cs | 12 ++++++++++++ .../BindingModels/SupplyBindingModel.cs | 12 ++++++++++++ .../BusinessLogicsContracts/IShopLogic.cs | 12 ++++++++++++ .../SearchModels/ShopSearchModel.cs | 12 ++++++++++++ .../StoragesContracts/IShopStorage.cs | 12 ++++++++++++ .../ViewModels/ShopViewModel.cs | 12 ++++++++++++ Confectionery/ConfectioneryDataModels/IShopModel.cs | 12 ++++++++++++ .../ConfectioneryDataModels/ISupplyModel.cs | 12 ++++++++++++ Confectionery/ConfectioneryListImplement/Shop.cs | 12 ++++++++++++ .../ConfectioneryListImplement/ShopStorage.cs | 12 ++++++++++++ 11 files changed, 132 insertions(+) create mode 100644 Confectionery/ConfectioneryBusinessLogic/ShopLogic.cs create mode 100644 Confectionery/ConfectioneryContracts/BindingModels/ShopBindingModel.cs create mode 100644 Confectionery/ConfectioneryContracts/BindingModels/SupplyBindingModel.cs create mode 100644 Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs create mode 100644 Confectionery/ConfectioneryContracts/SearchModels/ShopSearchModel.cs create mode 100644 Confectionery/ConfectioneryContracts/StoragesContracts/IShopStorage.cs create mode 100644 Confectionery/ConfectioneryContracts/ViewModels/ShopViewModel.cs create mode 100644 Confectionery/ConfectioneryDataModels/IShopModel.cs create mode 100644 Confectionery/ConfectioneryDataModels/ISupplyModel.cs create mode 100644 Confectionery/ConfectioneryListImplement/Shop.cs create mode 100644 Confectionery/ConfectioneryListImplement/ShopStorage.cs diff --git a/Confectionery/ConfectioneryBusinessLogic/ShopLogic.cs b/Confectionery/ConfectioneryBusinessLogic/ShopLogic.cs new file mode 100644 index 0000000..8bb7f7c --- /dev/null +++ b/Confectionery/ConfectioneryBusinessLogic/ShopLogic.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryBusinessLogic +{ + public class ShopLogic + { + } +} diff --git a/Confectionery/ConfectioneryContracts/BindingModels/ShopBindingModel.cs b/Confectionery/ConfectioneryContracts/BindingModels/ShopBindingModel.cs new file mode 100644 index 0000000..73d2372 --- /dev/null +++ b/Confectionery/ConfectioneryContracts/BindingModels/ShopBindingModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.BindingModels +{ + public class ShopBindingModel + { + } +} diff --git a/Confectionery/ConfectioneryContracts/BindingModels/SupplyBindingModel.cs b/Confectionery/ConfectioneryContracts/BindingModels/SupplyBindingModel.cs new file mode 100644 index 0000000..3f27b91 --- /dev/null +++ b/Confectionery/ConfectioneryContracts/BindingModels/SupplyBindingModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.BindingModels +{ + public class SupplyBindingModel + { + } +} diff --git a/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs new file mode 100644 index 0000000..9692fce --- /dev/null +++ b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.BusinessLogicsContracts +{ + public interface IShopLogic + { + } +} diff --git a/Confectionery/ConfectioneryContracts/SearchModels/ShopSearchModel.cs b/Confectionery/ConfectioneryContracts/SearchModels/ShopSearchModel.cs new file mode 100644 index 0000000..ff32c27 --- /dev/null +++ b/Confectionery/ConfectioneryContracts/SearchModels/ShopSearchModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.SearchModels +{ + public class ShopSearchModel + { + } +} diff --git a/Confectionery/ConfectioneryContracts/StoragesContracts/IShopStorage.cs b/Confectionery/ConfectioneryContracts/StoragesContracts/IShopStorage.cs new file mode 100644 index 0000000..8ec518d --- /dev/null +++ b/Confectionery/ConfectioneryContracts/StoragesContracts/IShopStorage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.StoragesContracts +{ + public interface IShopStorage + { + } +} diff --git a/Confectionery/ConfectioneryContracts/ViewModels/ShopViewModel.cs b/Confectionery/ConfectioneryContracts/ViewModels/ShopViewModel.cs new file mode 100644 index 0000000..d92717a --- /dev/null +++ b/Confectionery/ConfectioneryContracts/ViewModels/ShopViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.ViewModels +{ + public class ShopViewModel + { + } +} diff --git a/Confectionery/ConfectioneryDataModels/IShopModel.cs b/Confectionery/ConfectioneryDataModels/IShopModel.cs new file mode 100644 index 0000000..7315e2f --- /dev/null +++ b/Confectionery/ConfectioneryDataModels/IShopModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryDataModels +{ + internal interface IShopModel + { + } +} diff --git a/Confectionery/ConfectioneryDataModels/ISupplyModel.cs b/Confectionery/ConfectioneryDataModels/ISupplyModel.cs new file mode 100644 index 0000000..a4ad9c1 --- /dev/null +++ b/Confectionery/ConfectioneryDataModels/ISupplyModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryDataModels +{ + internal interface ISupplyModel + { + } +} diff --git a/Confectionery/ConfectioneryListImplement/Shop.cs b/Confectionery/ConfectioneryListImplement/Shop.cs new file mode 100644 index 0000000..1ede304 --- /dev/null +++ b/Confectionery/ConfectioneryListImplement/Shop.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryListImplement +{ + internal class Shop + { + } +} diff --git a/Confectionery/ConfectioneryListImplement/ShopStorage.cs b/Confectionery/ConfectioneryListImplement/ShopStorage.cs new file mode 100644 index 0000000..571e6a7 --- /dev/null +++ b/Confectionery/ConfectioneryListImplement/ShopStorage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryListImplement +{ + internal class ShopStorage + { + } +} -- 2.25.1 From d8840f6861be6d6540af9f8f70b2e43468e7635a Mon Sep 17 00:00:00 2001 From: malimova Date: Wed, 28 Feb 2024 22:55:32 +0400 Subject: [PATCH 2/6] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D1=8B?= =?UTF-8?q?=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormCreateSupply.Designer.cs | 39 ++++++ .../ConfectioneryView/FormCreateSupply.cs | 20 +++ .../ConfectioneryView/FormCreateSupply.resx | 120 ++++++++++++++++++ .../ConfectioneryView/FormShop.Designer.cs | 39 ++++++ Confectionery/ConfectioneryView/FormShop.cs | 20 +++ Confectionery/ConfectioneryView/FormShop.resx | 120 ++++++++++++++++++ .../ConfectioneryView/FormShops.Designer.cs | 39 ++++++ Confectionery/ConfectioneryView/FormShops.cs | 20 +++ .../ConfectioneryView/FormShops.resx | 120 ++++++++++++++++++ 9 files changed, 537 insertions(+) create mode 100644 Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs create mode 100644 Confectionery/ConfectioneryView/FormCreateSupply.cs create mode 100644 Confectionery/ConfectioneryView/FormCreateSupply.resx create mode 100644 Confectionery/ConfectioneryView/FormShop.Designer.cs create mode 100644 Confectionery/ConfectioneryView/FormShop.cs create mode 100644 Confectionery/ConfectioneryView/FormShop.resx create mode 100644 Confectionery/ConfectioneryView/FormShops.Designer.cs create mode 100644 Confectionery/ConfectioneryView/FormShops.cs create mode 100644 Confectionery/ConfectioneryView/FormShops.resx diff --git a/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs b/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs new file mode 100644 index 0000000..eb08a31 --- /dev/null +++ b/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs @@ -0,0 +1,39 @@ +namespace ConfectioneryView +{ + partial class FormCreateSupply + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "FormCreateSupply"; + } + + #endregion + } +} \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormCreateSupply.cs b/Confectionery/ConfectioneryView/FormCreateSupply.cs new file mode 100644 index 0000000..f1ce332 --- /dev/null +++ b/Confectionery/ConfectioneryView/FormCreateSupply.cs @@ -0,0 +1,20 @@ +using System; +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 FormCreateSupply : Form + { + public FormCreateSupply() + { + InitializeComponent(); + } + } +} diff --git a/Confectionery/ConfectioneryView/FormCreateSupply.resx b/Confectionery/ConfectioneryView/FormCreateSupply.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Confectionery/ConfectioneryView/FormCreateSupply.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormShop.Designer.cs b/Confectionery/ConfectioneryView/FormShop.Designer.cs new file mode 100644 index 0000000..e4b1671 --- /dev/null +++ b/Confectionery/ConfectioneryView/FormShop.Designer.cs @@ -0,0 +1,39 @@ +namespace ConfectioneryView +{ + partial class FormShop + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "FormShop"; + } + + #endregion + } +} \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormShop.cs b/Confectionery/ConfectioneryView/FormShop.cs new file mode 100644 index 0000000..e872cd3 --- /dev/null +++ b/Confectionery/ConfectioneryView/FormShop.cs @@ -0,0 +1,20 @@ +using System; +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 FormShop : Form + { + public FormShop() + { + InitializeComponent(); + } + } +} diff --git a/Confectionery/ConfectioneryView/FormShop.resx b/Confectionery/ConfectioneryView/FormShop.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Confectionery/ConfectioneryView/FormShop.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormShops.Designer.cs b/Confectionery/ConfectioneryView/FormShops.Designer.cs new file mode 100644 index 0000000..15a3683 --- /dev/null +++ b/Confectionery/ConfectioneryView/FormShops.Designer.cs @@ -0,0 +1,39 @@ +namespace ConfectioneryView +{ + partial class FormShops + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "FormShops"; + } + + #endregion + } +} \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormShops.cs b/Confectionery/ConfectioneryView/FormShops.cs new file mode 100644 index 0000000..75f0dfb --- /dev/null +++ b/Confectionery/ConfectioneryView/FormShops.cs @@ -0,0 +1,20 @@ +using System; +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 FormShops : Form + { + public FormShops() + { + InitializeComponent(); + } + } +} diff --git a/Confectionery/ConfectioneryView/FormShops.resx b/Confectionery/ConfectioneryView/FormShops.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Confectionery/ConfectioneryView/FormShops.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file -- 2.25.1 From e4cf753875b74be32046623e431dbef869576f77 Mon Sep 17 00:00:00 2001 From: malimova Date: Thu, 29 Feb 2024 21:38:29 +0400 Subject: [PATCH 3/6] =?UTF-8?q?=D0=A0=D0=B0=D1=81=D0=BF=D0=BE=D0=BB=D0=BE?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D1=8B=20=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D1=8B=20=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConfectioneryContracts/Class1.cs | 7 - .../FormCreateSupply.Designer.cs | 84 +++++++++++- .../ConfectioneryView/FormCreateSupply.resx | 62 +-------- .../ConfectioneryView/FormShop.Designer.cs | 122 +++++++++++++++++- Confectionery/ConfectioneryView/FormShop.resx | 62 +-------- .../ConfectioneryView/FormShops.Designer.cs | 79 +++++++++++- .../ConfectioneryView/FormShops.resx | 62 +-------- 7 files changed, 276 insertions(+), 202 deletions(-) delete mode 100644 Confectionery/ConfectioneryContracts/Class1.cs diff --git a/Confectionery/ConfectioneryContracts/Class1.cs b/Confectionery/ConfectioneryContracts/Class1.cs deleted file mode 100644 index 0dcf35f..0000000 --- a/Confectionery/ConfectioneryContracts/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace ConfectioneryContracts -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs b/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs index eb08a31..a4a7a2b 100644 --- a/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs +++ b/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs @@ -28,12 +28,88 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "FormCreateSupply"; + labelShop = new Label(); + labelPastry = new Label(); + labelCount = new Label(); + comboBox1 = new ComboBox(); + comboBox2 = new ComboBox(); + textBox1 = new TextBox(); + SuspendLayout(); + // + // labelShop + // + labelShop.AutoSize = true; + labelShop.Location = new Point(42, 42); + labelShop.Name = "labelShop"; + labelShop.Size = new Size(85, 25); + labelShop.TabIndex = 0; + labelShop.Text = "Магазин:"; + // + // labelPastry + // + labelPastry.AutoSize = true; + labelPastry.Location = new Point(42, 101); + labelPastry.Name = "labelPastry"; + labelPastry.Size = new Size(84, 25); + labelPastry.TabIndex = 1; + labelPastry.Text = "Изделие:"; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(42, 161); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(111, 25); + labelCount.TabIndex = 2; + labelCount.Text = "Количество:"; + // + // comboBox1 + // + comboBox1.FormattingEnabled = true; + comboBox1.Location = new Point(162, 39); + comboBox1.Name = "comboBox1"; + comboBox1.Size = new Size(383, 33); + comboBox1.TabIndex = 3; + // + // comboBox2 + // + comboBox2.FormattingEnabled = true; + comboBox2.Location = new Point(162, 98); + comboBox2.Name = "comboBox2"; + comboBox2.Size = new Size(383, 33); + comboBox2.TabIndex = 4; + // + // textBox1 + // + textBox1.Location = new Point(162, 158); + textBox1.Name = "textBox1"; + textBox1.Size = new Size(383, 31); + textBox1.TabIndex = 5; + // + // FormCreateSupply + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(608, 240); + Controls.Add(textBox1); + Controls.Add(comboBox2); + Controls.Add(comboBox1); + Controls.Add(labelCount); + Controls.Add(labelPastry); + Controls.Add(labelShop); + Name = "FormCreateSupply"; + Text = "Поставка"; + ResumeLayout(false); + PerformLayout(); } #endregion + + private Label labelShop; + private Label labelPastry; + private Label labelCount; + private ComboBox comboBox1; + private ComboBox comboBox2; + private TextBox textBox1; } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormCreateSupply.resx b/Confectionery/ConfectioneryView/FormCreateSupply.resx index 1af7de1..f298a7b 100644 --- a/Confectionery/ConfectioneryView/FormCreateSupply.resx +++ b/Confectionery/ConfectioneryView/FormCreateSupply.resx @@ -1,64 +1,4 @@ - - - + diff --git a/Confectionery/ConfectioneryView/FormShop.Designer.cs b/Confectionery/ConfectioneryView/FormShop.Designer.cs index e4b1671..af6d641 100644 --- a/Confectionery/ConfectioneryView/FormShop.Designer.cs +++ b/Confectionery/ConfectioneryView/FormShop.Designer.cs @@ -28,12 +28,126 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "FormShop"; + dataGridView = new DataGridView(); + labelName = new Label(); + labelAddress = new Label(); + labelOpen = new Label(); + textBoxName = new TextBox(); + textBoxAddress = new TextBox(); + dateTimePickerOpen = new DateTimePicker(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.BackgroundColor = Color.AliceBlue; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 225); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 62; + dataGridView.RowTemplate.Height = 33; + dataGridView.Size = new Size(765, 393); + dataGridView.TabIndex = 0; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(36, 50); + labelName.Name = "labelName"; + labelName.Size = new Size(94, 25); + labelName.TabIndex = 1; + labelName.Text = "Название:"; + // + // labelAddress + // + labelAddress.AutoSize = true; + labelAddress.Location = new Point(36, 98); + labelAddress.Name = "labelAddress"; + labelAddress.Size = new Size(66, 25); + labelAddress.TabIndex = 2; + labelAddress.Text = "Адрес:"; + // + // labelOpen + // + labelOpen.AutoSize = true; + labelOpen.Location = new Point(36, 146); + labelOpen.Name = "labelOpen"; + labelOpen.Size = new Size(135, 25); + labelOpen.TabIndex = 3; + labelOpen.Text = "Дата открытия:"; + // + // textBoxName + // + textBoxName.Location = new Point(201, 47); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(378, 31); + textBoxName.TabIndex = 4; + // + // textBoxAddress + // + textBoxAddress.Location = new Point(201, 95); + textBoxAddress.Name = "textBoxAddress"; + textBoxAddress.Size = new Size(378, 31); + textBoxAddress.TabIndex = 5; + // + // dateTimePickerOpen + // + dateTimePickerOpen.Location = new Point(201, 146); + dateTimePickerOpen.Name = "dateTimePickerOpen"; + dateTimePickerOpen.Size = new Size(378, 31); + dateTimePickerOpen.TabIndex = 6; + // + // buttonSave + // + buttonSave.Location = new Point(466, 650); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(139, 55); + buttonSave.TabIndex = 7; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + // + // buttonCancel + // + buttonCancel.Location = new Point(639, 650); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(138, 55); + buttonCancel.TabIndex = 8; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // FormShop + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(805, 743); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(dateTimePickerOpen); + Controls.Add(textBoxAddress); + Controls.Add(textBoxName); + Controls.Add(labelOpen); + Controls.Add(labelAddress); + Controls.Add(labelName); + Controls.Add(dataGridView); + Name = "FormShop"; + Text = "Магазин"; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); } #endregion + + private DataGridView dataGridView; + private Label labelName; + private Label labelAddress; + private Label labelOpen; + private TextBox textBoxName; + private TextBox textBoxAddress; + private DateTimePicker dateTimePickerOpen; + private Button buttonSave; + private Button buttonCancel; } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormShop.resx b/Confectionery/ConfectioneryView/FormShop.resx index 1af7de1..f298a7b 100644 --- a/Confectionery/ConfectioneryView/FormShop.resx +++ b/Confectionery/ConfectioneryView/FormShop.resx @@ -1,64 +1,4 @@ - - - + diff --git a/Confectionery/ConfectioneryView/FormShops.Designer.cs b/Confectionery/ConfectioneryView/FormShops.Designer.cs index 15a3683..0ef5b8c 100644 --- a/Confectionery/ConfectioneryView/FormShops.Designer.cs +++ b/Confectionery/ConfectioneryView/FormShops.Designer.cs @@ -28,12 +28,83 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "FormShops"; + dataGridView1 = new DataGridView(); + buttonAdd = new Button(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonRef = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + SuspendLayout(); + // + // dataGridView1 + // + dataGridView1.BackgroundColor = Color.AliceBlue; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Location = new Point(12, 30); + dataGridView1.Name = "dataGridView1"; + dataGridView1.RowHeadersWidth = 62; + dataGridView1.RowTemplate.Height = 33; + dataGridView1.Size = new Size(756, 486); + dataGridView1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.Location = new Point(823, 54); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(142, 51); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + // + // buttonUpd + // + buttonUpd.Location = new Point(823, 135); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(142, 51); + buttonUpd.TabIndex = 2; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + // + // buttonDel + // + buttonDel.Location = new Point(823, 219); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(142, 51); + buttonDel.TabIndex = 3; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + // + // buttonRef + // + buttonRef.Location = new Point(823, 306); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(142, 51); + buttonRef.TabIndex = 4; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + // + // FormShops + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1016, 529); + Controls.Add(buttonRef); + Controls.Add(buttonDel); + Controls.Add(buttonUpd); + Controls.Add(buttonAdd); + Controls.Add(dataGridView1); + Name = "FormShops"; + Text = "Магазины"; + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ResumeLayout(false); } #endregion + + private DataGridView dataGridView1; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private Button buttonRef; } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormShops.resx b/Confectionery/ConfectioneryView/FormShops.resx index 1af7de1..f298a7b 100644 --- a/Confectionery/ConfectioneryView/FormShops.resx +++ b/Confectionery/ConfectioneryView/FormShops.resx @@ -1,64 +1,4 @@ - - - + -- 2.25.1 From 8da5dc0943ee8ece8a1701d80ab51f0c84efc317 Mon Sep 17 00:00:00 2001 From: malimova Date: Thu, 29 Feb 2024 23:33:00 +0400 Subject: [PATCH 4/6] =?UTF-8?q?=D0=9B=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConfectioneryBusinessLogic/ShopLogic.cs | 152 +++++++++++++++++- .../BindingModels/ShopBindingModel.cs | 10 +- .../BindingModels/SupplyBindingModel.cs | 8 +- .../BusinessLogicsContracts/IShopLogic.cs | 11 +- .../SearchModels/ShopSearchModel.cs | 2 + .../StoragesContracts/IShopStorage.cs | 11 +- .../ViewModels/ShopViewModel.cs | 14 +- .../ConfectioneryDataModels/IShopModel.cs | 8 +- .../ConfectioneryDataModels/ISupplyModel.cs | 5 +- .../DataListSingleton.cs | 3 + .../ConfectioneryListImplement/Shop.cs | 49 +++++- .../ConfectioneryListImplement/ShopStorage.cs | 105 +++++++++++- .../FormCreateSupply.Designer.cs | 81 ++++++---- .../ConfectioneryView/FormCreateSupply.cs | 81 +++++++++- .../ConfectioneryView/FormMain.Designer.cs | 22 ++- Confectionery/ConfectioneryView/FormMain.cs | 18 +++ .../ConfectioneryView/FormShop.Designer.cs | 3 + Confectionery/ConfectioneryView/FormShop.cs | 110 ++++++++++++- .../ConfectioneryView/FormShops.Designer.cs | 33 ++-- Confectionery/ConfectioneryView/FormShops.cs | 100 +++++++++++- Confectionery/ConfectioneryView/Program.cs | 5 + 21 files changed, 764 insertions(+), 67 deletions(-) diff --git a/Confectionery/ConfectioneryBusinessLogic/ShopLogic.cs b/Confectionery/ConfectioneryBusinessLogic/ShopLogic.cs index 8bb7f7c..5685de7 100644 --- a/Confectionery/ConfectioneryBusinessLogic/ShopLogic.cs +++ b/Confectionery/ConfectioneryBusinessLogic/ShopLogic.cs @@ -1,4 +1,10 @@ -using System; +using Microsoft.Extensions.Logging; +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.BusinessLogicsContracts; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.StoragesContracts; +using ConfectioneryContracts.ViewModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +12,149 @@ using System.Threading.Tasks; namespace ConfectioneryBusinessLogic { - public class ShopLogic + public class ShopLogic : IShopLogic { + private readonly ILogger _logger; + private readonly IShopStorage _shopStorage; + private readonly IPastryStorage _pastryStorage; + + public ShopLogic(ILogger logger, IShopStorage shopStorage, IPastryStorage pastryStorage) + { + _logger = logger; + _shopStorage = shopStorage; + _pastryStorage = pastryStorage; + } + + public List? ReadList(ShopSearchModel? model) + { + _logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id}", model?.ShopName, model?.Id); + var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public ShopViewModel? ReadElement(ShopSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id); + var element = _shopStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + + public bool Create(ShopBindingModel model) + { + CheckModel(model); + if (_shopStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Update(ShopBindingModel model) + { + CheckModel(model); + if (_shopStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + public bool Delete(ShopBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_shopStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public bool MakeSupply(SupplyBindingModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (model.Count <= 0) + { + throw new ArgumentException("Количество изделий должно быть больше 0"); + } + var shop = _shopStorage.GetElement(new ShopSearchModel + { + Id = model.ShopId + }); + if (shop == null) + { + throw new ArgumentException("Магазина не существует"); + } + if (shop.ShopPastrys.ContainsKey(model.PastryId)) + { + var oldValue = shop.ShopPastrys[model.PastryId]; + oldValue.Item2 += model.Count; + shop.ShopPastrys[model.PastryId] = oldValue; + } + else + { + var Pastry = _pastryStorage.GetElement(new PastrySearchModel + { + Id = model.PastryId + }); + if (Pastry == null) + { + throw new ArgumentException($"Поставка: Товар с id:{model.PastryId} не найденн"); + } + shop.ShopPastrys.Add(model.PastryId, (Pastry, model.Count)); + } + return true; + } + + private void CheckModel(ShopBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Address)) + { + throw new ArgumentException("Адрес магазина длжен быть заполнен", nameof(model.Address)); + } + if (string.IsNullOrEmpty(model.ShopName)) + { + throw new ArgumentException("Название магазина должно быть заполнено", nameof(model.ShopName)); + } + _logger.LogInformation("Shop. ShopName:{ShopName}.Adres:{Adres}.OpeningDate:{OpeningDate}.Id:{ Id}", model.ShopName, model.Address, model.OpeningDate, model.Id); + var element = _shopStorage.GetElement(new ShopSearchModel + { + ShopName = model.ShopName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Магазин с таким названием уже есть"); + } + } } } diff --git a/Confectionery/ConfectioneryContracts/BindingModels/ShopBindingModel.cs b/Confectionery/ConfectioneryContracts/BindingModels/ShopBindingModel.cs index 73d2372..6cac88b 100644 --- a/Confectionery/ConfectioneryContracts/BindingModels/ShopBindingModel.cs +++ b/Confectionery/ConfectioneryContracts/BindingModels/ShopBindingModel.cs @@ -1,4 +1,5 @@ -using System; +using ConfectioneryDataModels.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +7,12 @@ using System.Threading.Tasks; namespace ConfectioneryContracts.BindingModels { - public class ShopBindingModel + public class ShopBindingModel : IShopModel { + public int Id { get; set; } + public string ShopName { get; set; } = string.Empty; + public string Address { get; set; } = string.Empty; + public DateTime OpeningDate { get; set; } = DateTime.Now; + public Dictionary ShopPastrys { get; set; } = new(); } } diff --git a/Confectionery/ConfectioneryContracts/BindingModels/SupplyBindingModel.cs b/Confectionery/ConfectioneryContracts/BindingModels/SupplyBindingModel.cs index 3f27b91..8bf9092 100644 --- a/Confectionery/ConfectioneryContracts/BindingModels/SupplyBindingModel.cs +++ b/Confectionery/ConfectioneryContracts/BindingModels/SupplyBindingModel.cs @@ -1,4 +1,5 @@ -using System; +using ConfectioneryDataModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +7,10 @@ using System.Threading.Tasks; namespace ConfectioneryContracts.BindingModels { - public class SupplyBindingModel + public class SupplyBindingModel : ISupplyModel { + public int ShopId { get; set; } + public int PastryId { get; set; } + public int Count { get; set; } } } diff --git a/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs index 9692fce..20fd9da 100644 --- a/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs +++ b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IShopLogic.cs @@ -1,4 +1,7 @@ -using System; +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.ViewModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,5 +11,11 @@ namespace ConfectioneryContracts.BusinessLogicsContracts { public interface IShopLogic { + List? ReadList(ShopSearchModel? model); + ShopViewModel? ReadElement(ShopSearchModel model); + bool Create(ShopBindingModel model); + bool Update(ShopBindingModel model); + bool Delete(ShopBindingModel model); + bool MakeSupply(SupplyBindingModel model); } } diff --git a/Confectionery/ConfectioneryContracts/SearchModels/ShopSearchModel.cs b/Confectionery/ConfectioneryContracts/SearchModels/ShopSearchModel.cs index ff32c27..36ddd80 100644 --- a/Confectionery/ConfectioneryContracts/SearchModels/ShopSearchModel.cs +++ b/Confectionery/ConfectioneryContracts/SearchModels/ShopSearchModel.cs @@ -8,5 +8,7 @@ namespace ConfectioneryContracts.SearchModels { public class ShopSearchModel { + public int? Id { get; set; } + public string? ShopName { get; set; } } } diff --git a/Confectionery/ConfectioneryContracts/StoragesContracts/IShopStorage.cs b/Confectionery/ConfectioneryContracts/StoragesContracts/IShopStorage.cs index 8ec518d..86d0e18 100644 --- a/Confectionery/ConfectioneryContracts/StoragesContracts/IShopStorage.cs +++ b/Confectionery/ConfectioneryContracts/StoragesContracts/IShopStorage.cs @@ -1,4 +1,7 @@ -using System; +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.ViewModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,5 +11,11 @@ namespace ConfectioneryContracts.StoragesContracts { public interface IShopStorage { + List GetFullList(); + List GetFilteredList(ShopSearchModel model); + ShopViewModel? GetElement(ShopSearchModel model); + ShopViewModel? Insert(ShopBindingModel model); + ShopViewModel? Update(ShopBindingModel model); + ShopViewModel? Delete(ShopBindingModel model); } } diff --git a/Confectionery/ConfectioneryContracts/ViewModels/ShopViewModel.cs b/Confectionery/ConfectioneryContracts/ViewModels/ShopViewModel.cs index d92717a..85b7b6f 100644 --- a/Confectionery/ConfectioneryContracts/ViewModels/ShopViewModel.cs +++ b/Confectionery/ConfectioneryContracts/ViewModels/ShopViewModel.cs @@ -1,12 +1,22 @@ -using System; +using ConfectioneryDataModels.Models; +using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConfectioneryContracts.ViewModels { - public class ShopViewModel + public class ShopViewModel : IShopModel { + public int Id { get; set; } + [DisplayName("Название")] + public string ShopName { get; set; } = string.Empty; + [DisplayName("Адрес")] + public string Address { get; set; } = string.Empty; + [DisplayName("Дата открытия")] + public DateTime OpeningDate { get; set; } + public Dictionary ShopPastrys { get; set; } = new(); } } diff --git a/Confectionery/ConfectioneryDataModels/IShopModel.cs b/Confectionery/ConfectioneryDataModels/IShopModel.cs index 7315e2f..1892e41 100644 --- a/Confectionery/ConfectioneryDataModels/IShopModel.cs +++ b/Confectionery/ConfectioneryDataModels/IShopModel.cs @@ -4,9 +4,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ConfectioneryDataModels +namespace ConfectioneryDataModels.Models { - internal interface IShopModel + public interface IShopModel : IId { + string ShopName { get; } + string Address { get; } + DateTime OpeningDate { get; } + Dictionary ShopPastrys { get; } } } diff --git a/Confectionery/ConfectioneryDataModels/ISupplyModel.cs b/Confectionery/ConfectioneryDataModels/ISupplyModel.cs index a4ad9c1..75a85e9 100644 --- a/Confectionery/ConfectioneryDataModels/ISupplyModel.cs +++ b/Confectionery/ConfectioneryDataModels/ISupplyModel.cs @@ -6,7 +6,10 @@ using System.Threading.Tasks; namespace ConfectioneryDataModels { - internal interface ISupplyModel + public interface ISupplyModel { + int ShopId { get; } + int PastryId { get; } + int Count { get; } } } diff --git a/Confectionery/ConfectioneryListImplement/DataListSingleton.cs b/Confectionery/ConfectioneryListImplement/DataListSingleton.cs index 37eca03..c4077ee 100644 --- a/Confectionery/ConfectioneryListImplement/DataListSingleton.cs +++ b/Confectionery/ConfectioneryListImplement/DataListSingleton.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using ConfectioneryListImplement.Models; +using static System.Formats.Asn1.AsnWriter; namespace ConfectioneryListImplement { @@ -13,11 +14,13 @@ namespace ConfectioneryListImplement public List Components { get; set; } public List Orders { get; set; } public List Pastrys { get; set; } + public List Shops { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); Pastrys = new List(); + Shops = new List(); } public static DataListSingleton GetInstance() { diff --git a/Confectionery/ConfectioneryListImplement/Shop.cs b/Confectionery/ConfectioneryListImplement/Shop.cs index 1ede304..9eb9ac4 100644 --- a/Confectionery/ConfectioneryListImplement/Shop.cs +++ b/Confectionery/ConfectioneryListImplement/Shop.cs @@ -1,12 +1,55 @@ -using System; +using ConfectioneryDataModels.Models; +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.ViewModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ConfectioneryListImplement +namespace ConfectioneryListImplement.Models { - internal class Shop + public class Shop : IShopModel { + public int Id { get; private set; } + public string ShopName { get; private set; } = string.Empty; + public string Address { get; private set; } = string.Empty; + public DateTime OpeningDate { get; private set; } + public Dictionary ShopPastrys { get; private set; } = new(); + + public static Shop? Create(ShopBindingModel? model) + { + if (model == null) + { + return null; + } + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Address = model.Address, + OpeningDate = model.OpeningDate + }; + } + + public void Update(ShopBindingModel? model) + { + if (model == null) + { + return; + } + ShopName = model.ShopName; + Address = model.Address; + OpeningDate = model.OpeningDate; + } + + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Address = Address, + OpeningDate = OpeningDate, + ShopPastrys = ShopPastrys + }; } } diff --git a/Confectionery/ConfectioneryListImplement/ShopStorage.cs b/Confectionery/ConfectioneryListImplement/ShopStorage.cs index 571e6a7..f55b849 100644 --- a/Confectionery/ConfectioneryListImplement/ShopStorage.cs +++ b/Confectionery/ConfectioneryListImplement/ShopStorage.cs @@ -1,4 +1,9 @@ -using System; +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.StoragesContracts; +using ConfectioneryContracts.ViewModels; +using ConfectioneryListImplement.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +11,103 @@ using System.Threading.Tasks; namespace ConfectioneryListImplement { - internal class ShopStorage + public class ShopStorage : IShopStorage { + private readonly DataListSingleton _source; + + public ShopStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public List GetFullList() + { + var result = new List(); + foreach (var shop in _source.Shops) + { + result.Add(shop.GetViewModel); + } + return result; + } + + public List GetFilteredList(ShopSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ShopName)) + { + return result; + } + foreach (var shop in _source.Shops) + { + if (shop.ShopName.Contains(model.ShopName)) + { + result.Add(shop.GetViewModel); + } + } + return result; + } + + public ShopViewModel? GetElement(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue) + { + return null; + } + foreach (var shop in _source.Shops) + { + if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || + (model.Id.HasValue && shop.Id == model.Id)) + { + return shop.GetViewModel; + } + } + return null; + } + + public ShopViewModel? Insert(ShopBindingModel model) + { + model.Id = 1; + foreach (var shop in _source.Shops) + { + if (model.Id <= shop.Id) + { + model.Id = shop.Id + 1; + } + } + var newShop = Shop.Create(model); + if (newShop == null) + { + return null; + } + _source.Shops.Add(newShop); + return newShop.GetViewModel; + } + + public ShopViewModel? Update(ShopBindingModel model) + { + foreach (var shop in _source.Shops) + { + if (shop.Id == model.Id) + { + shop.Update(model); + return shop.GetViewModel; + } + } + return null; + } + + public ShopViewModel? Delete(ShopBindingModel model) + { + for (int i = 0; i < _source.Shops.Count; ++i) + { + if (_source.Shops[i].Id == model.Id) + { + var element = _source.Shops[i]; + _source.Shops.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } } } diff --git a/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs b/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs index a4a7a2b..0190fa1 100644 --- a/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs +++ b/Confectionery/ConfectioneryView/FormCreateSupply.Designer.cs @@ -31,9 +31,11 @@ labelShop = new Label(); labelPastry = new Label(); labelCount = new Label(); - comboBox1 = new ComboBox(); - comboBox2 = new ComboBox(); - textBox1 = new TextBox(); + comboBoxShop = new ComboBox(); + comboBoxPastry = new ComboBox(); + textBoxCount = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); SuspendLayout(); // // labelShop @@ -63,42 +65,65 @@ labelCount.TabIndex = 2; labelCount.Text = "Количество:"; // - // comboBox1 + // comboBoxShop // - comboBox1.FormattingEnabled = true; - comboBox1.Location = new Point(162, 39); - comboBox1.Name = "comboBox1"; - comboBox1.Size = new Size(383, 33); - comboBox1.TabIndex = 3; + comboBoxShop.FormattingEnabled = true; + comboBoxShop.Location = new Point(162, 39); + comboBoxShop.Name = "comboBoxShop"; + comboBoxShop.Size = new Size(383, 33); + comboBoxShop.TabIndex = 3; // - // comboBox2 + // comboBoxPastry // - comboBox2.FormattingEnabled = true; - comboBox2.Location = new Point(162, 98); - comboBox2.Name = "comboBox2"; - comboBox2.Size = new Size(383, 33); - comboBox2.TabIndex = 4; + comboBoxPastry.FormattingEnabled = true; + comboBoxPastry.Location = new Point(162, 98); + comboBoxPastry.Name = "comboBoxPastry"; + comboBoxPastry.Size = new Size(383, 33); + comboBoxPastry.TabIndex = 4; // - // textBox1 + // textBoxCount // - textBox1.Location = new Point(162, 158); - textBox1.Name = "textBox1"; - textBox1.Size = new Size(383, 31); - textBox1.TabIndex = 5; + textBoxCount.Location = new Point(162, 158); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(383, 31); + textBoxCount.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(318, 214); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(127, 49); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(471, 214); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(127, 49); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; // // FormCreateSupply // AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(608, 240); - Controls.Add(textBox1); - Controls.Add(comboBox2); - Controls.Add(comboBox1); + ClientSize = new Size(647, 288); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxCount); + Controls.Add(comboBoxPastry); + Controls.Add(comboBoxShop); Controls.Add(labelCount); Controls.Add(labelPastry); Controls.Add(labelShop); Name = "FormCreateSupply"; Text = "Поставка"; + Load += FormCreateSupply_Load; ResumeLayout(false); PerformLayout(); } @@ -108,8 +133,10 @@ private Label labelShop; private Label labelPastry; private Label labelCount; - private ComboBox comboBox1; - private ComboBox comboBox2; - private TextBox textBox1; + private ComboBox comboBoxShop; + private ComboBox comboBoxPastry; + private TextBox textBoxCount; + private Button buttonSave; + private Button buttonCancel; } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormCreateSupply.cs b/Confectionery/ConfectioneryView/FormCreateSupply.cs index f1ce332..d276e30 100644 --- a/Confectionery/ConfectioneryView/FormCreateSupply.cs +++ b/Confectionery/ConfectioneryView/FormCreateSupply.cs @@ -1,4 +1,8 @@ -using System; +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.BusinessLogicsContracts; +using ConfectioneryContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,9 +16,82 @@ namespace ConfectioneryView { public partial class FormCreateSupply : Form { - public FormCreateSupply() + private readonly ILogger _logger; + private readonly IPastryLogic _logicP; + private readonly IShopLogic _logicS; + private List _shopList = new List(); + private List _pastryList = new List(); + + public FormCreateSupply(ILogger logger, IPastryLogic logicP, IShopLogic logicS) { InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicS = logicS; + } + + private void FormCreateSupply_Load(object sender, EventArgs e) + { + _shopList = _logicS.ReadList(null); + _pastryList = _logicP.ReadList(null); + if (_shopList != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = _shopList; + comboBoxShop.SelectedItem = null; + _logger.LogInformation("Загрузка магазинов для поставок"); + } + if (_pastryList != null) + { + comboBoxPastry.DisplayMember = "PastryName"; + comboBoxPastry.ValueMember = "Id"; + comboBoxPastry.DataSource = _pastryList; + comboBoxPastry.SelectedItem = null; + _logger.LogInformation("Загрузка кондитерского изделия для поставок"); + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxPastry.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание поставки"); + try + { + var operationResult = _logicS.MakeSupply(new SupplyBindingModel + { + ShopId = Convert.ToInt32(comboBoxShop.SelectedValue), + PastryId = Convert.ToInt32(comboBoxPastry.SelectedValue), + Count = Convert.ToInt32(textBoxCount.Text) + }); + if (!operationResult) + { + throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания поставки"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); } } } diff --git a/Confectionery/ConfectioneryView/FormMain.Designer.cs b/Confectionery/ConfectioneryView/FormMain.Designer.cs index 3c95edf..4726972 100644 --- a/Confectionery/ConfectioneryView/FormMain.Designer.cs +++ b/Confectionery/ConfectioneryView/FormMain.Designer.cs @@ -33,6 +33,8 @@ toolStripMenuItem = new ToolStripMenuItem(); componentsToolStripMenuItem = new ToolStripMenuItem(); pastryToolStripMenuItem = new ToolStripMenuItem(); + shopsToolStripMenuItem = new ToolStripMenuItem(); + supplyToolStripMenuItem = new ToolStripMenuItem(); buttonCreateOrder = new Button(); buttonTakeOrderInWork = new Button(); buttonOrderReady = new Button(); @@ -56,7 +58,7 @@ // menuStrip // menuStrip.ImageScalingSize = new Size(24, 24); - menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem }); + menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, supplyToolStripMenuItem }); menuStrip.Location = new Point(0, 0); menuStrip.Name = "menuStrip"; menuStrip.Size = new Size(1375, 33); @@ -65,7 +67,7 @@ // // toolStripMenuItem // - toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, pastryToolStripMenuItem }); + toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, pastryToolStripMenuItem, shopsToolStripMenuItem }); toolStripMenuItem.Name = "toolStripMenuItem"; toolStripMenuItem.Size = new Size(139, 29); toolStripMenuItem.Text = "Справочники"; @@ -84,6 +86,20 @@ pastryToolStripMenuItem.Text = "Кондитерские изделия"; pastryToolStripMenuItem.Click += pastryToolStripMenuItem_Click; // + // shopsToolStripMenuItem + // + shopsToolStripMenuItem.Name = "shopsToolStripMenuItem"; + shopsToolStripMenuItem.Size = new Size(298, 34); + shopsToolStripMenuItem.Text = "Магазины"; + shopsToolStripMenuItem.Click += shopsToolStripMenuItem_Click; + // + // supplyToolStripMenuItem + // + supplyToolStripMenuItem.Name = "supplyToolStripMenuItem"; + supplyToolStripMenuItem.Size = new Size(130, 29); + supplyToolStripMenuItem.Text = "Пополнение"; + supplyToolStripMenuItem.Click += supplyToolStripMenuItem_Click; + // // buttonCreateOrder // buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; @@ -174,5 +190,7 @@ private Button buttonRef; private ToolStripMenuItem componentsToolStripMenuItem; private ToolStripMenuItem pastryToolStripMenuItem; + private ToolStripMenuItem supplyToolStripMenuItem; + private ToolStripMenuItem shopsToolStripMenuItem; } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormMain.cs b/Confectionery/ConfectioneryView/FormMain.cs index 0cd8423..13470b5 100644 --- a/Confectionery/ConfectioneryView/FormMain.cs +++ b/Confectionery/ConfectioneryView/FormMain.cs @@ -157,5 +157,23 @@ namespace ConfectioneryView { LoadData(); } + + private void supplyToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply)); + if (service is FormCreateSupply form) + { + form.ShowDialog(); + } + } + + private void shopsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) + { + form.ShowDialog(); + } + } } } diff --git a/Confectionery/ConfectioneryView/FormShop.Designer.cs b/Confectionery/ConfectioneryView/FormShop.Designer.cs index af6d641..57f5e82 100644 --- a/Confectionery/ConfectioneryView/FormShop.Designer.cs +++ b/Confectionery/ConfectioneryView/FormShop.Designer.cs @@ -107,6 +107,7 @@ buttonSave.TabIndex = 7; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; // // buttonCancel // @@ -116,6 +117,7 @@ buttonCancel.TabIndex = 8; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; // // FormShop // @@ -133,6 +135,7 @@ Controls.Add(dataGridView); Name = "FormShop"; Text = "Магазин"; + Load += FormShop_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); PerformLayout(); diff --git a/Confectionery/ConfectioneryView/FormShop.cs b/Confectionery/ConfectioneryView/FormShop.cs index e872cd3..09be130 100644 --- a/Confectionery/ConfectioneryView/FormShop.cs +++ b/Confectionery/ConfectioneryView/FormShop.cs @@ -1,4 +1,9 @@ -using System; +using ConfectioneryContracts.BusinessLogicsContracts; +using ConfectioneryDataModels.Models; +using Microsoft.Extensions.Logging; +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.SearchModels; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -7,14 +12,115 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using Microsoft.VisualBasic.Logging; namespace ConfectioneryView { public partial class FormShop : Form { - public FormShop() + private readonly ILogger _logger; + private readonly IShopLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + private Dictionary _ShopPastrys; + private DateTime? _openingDate = null; + public FormShop(ILogger logger, IShopLogic logic) { InitializeComponent(); + _logger = logger; + _logic = logic; + _ShopPastrys = new Dictionary(); + } + private void FormShop_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка магазина"); + try + { + var view = _logic.ReadElement(new ShopSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ShopName; + textBoxAddress.Text = view.Address; + dateTimePickerOpen.Value = view.OpeningDate; + _ShopPastrys = view.ShopPastrys ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка изделий в магазине"); + try + { + if (_ShopPastrys != null) + { + dataGridView.Rows.Clear(); + foreach (var sr in _ShopPastrys) + { + dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.PastryName, sr.Value.Item2 }); + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделий магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxAddress.Text)) + { + MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение магазина"); + try + { + var model = new ShopBindingModel + { + Id = _id ?? 0, + ShopName = textBoxName.Text, + Address = textBoxAddress.Text, + OpeningDate = dateTimePickerOpen.Value + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); } } } diff --git a/Confectionery/ConfectioneryView/FormShops.Designer.cs b/Confectionery/ConfectioneryView/FormShops.Designer.cs index 0ef5b8c..1176161 100644 --- a/Confectionery/ConfectioneryView/FormShops.Designer.cs +++ b/Confectionery/ConfectioneryView/FormShops.Designer.cs @@ -28,24 +28,24 @@ /// private void InitializeComponent() { - dataGridView1 = new DataGridView(); + dataGridView = new DataGridView(); buttonAdd = new Button(); buttonUpd = new Button(); buttonDel = new Button(); buttonRef = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // - // dataGridView1 + // dataGridView // - dataGridView1.BackgroundColor = Color.AliceBlue; - dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView1.Location = new Point(12, 30); - dataGridView1.Name = "dataGridView1"; - dataGridView1.RowHeadersWidth = 62; - dataGridView1.RowTemplate.Height = 33; - dataGridView1.Size = new Size(756, 486); - dataGridView1.TabIndex = 0; + dataGridView.BackgroundColor = Color.AliceBlue; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 30); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 62; + dataGridView.RowTemplate.Height = 33; + dataGridView.Size = new Size(756, 486); + dataGridView.TabIndex = 0; // // buttonAdd // @@ -55,6 +55,7 @@ buttonAdd.TabIndex = 1; buttonAdd.Text = "Добавить"; buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; // // buttonUpd // @@ -64,6 +65,7 @@ buttonUpd.TabIndex = 2; buttonUpd.Text = "Изменить"; buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; // // buttonDel // @@ -73,6 +75,7 @@ buttonDel.TabIndex = 3; buttonDel.Text = "Удалить"; buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; // // buttonRef // @@ -82,6 +85,7 @@ buttonRef.TabIndex = 4; buttonRef.Text = "Обновить"; buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; // // FormShops // @@ -92,16 +96,17 @@ Controls.Add(buttonDel); Controls.Add(buttonUpd); Controls.Add(buttonAdd); - Controls.Add(dataGridView1); + Controls.Add(dataGridView); Name = "FormShops"; Text = "Магазины"; - ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + Load += FormShops_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } #endregion - private DataGridView dataGridView1; + private DataGridView dataGridView; private Button buttonAdd; private Button buttonUpd; private Button buttonDel; diff --git a/Confectionery/ConfectioneryView/FormShops.cs b/Confectionery/ConfectioneryView/FormShops.cs index 75f0dfb..cc82fc5 100644 --- a/Confectionery/ConfectioneryView/FormShops.cs +++ b/Confectionery/ConfectioneryView/FormShops.cs @@ -1,4 +1,7 @@ -using System; +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,9 +15,102 @@ namespace ConfectioneryView { public partial class FormShops : Form { - public FormShops() + private readonly ILogger _logger; + private readonly IShopLogic _logic; + + public FormShops(ILogger logger, IShopLogic logic) { InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormShops_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ShopPastrys"].Visible = false; + dataGridView.Columns["ShopName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка магазинов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазинов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void buttonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление магазина"); + try + { + if (!_logic.Delete(new ShopBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void buttonRef_Click(object sender, EventArgs e) + { + LoadData(); } } } diff --git a/Confectionery/ConfectioneryView/Program.cs b/Confectionery/ConfectioneryView/Program.cs index 7ae9212..b9693d0 100644 --- a/Confectionery/ConfectioneryView/Program.cs +++ b/Confectionery/ConfectioneryView/Program.cs @@ -46,6 +46,11 @@ namespace ConfectioneryView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file -- 2.25.1 From 4e9423b82c5e6f8ae4a55a531530999ae321ae42 Mon Sep 17 00:00:00 2001 From: malimova Date: Thu, 14 Mar 2024 23:26:40 +0400 Subject: [PATCH 5/6] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConfectioneryView/FormShop.Designer.cs | 36 ++++++++++++++++++- Confectionery/ConfectioneryView/FormShop.cs | 2 +- Confectionery/ConfectioneryView/FormShop.resx | 9 +++++ Confectionery/ConfectioneryView/nlog.config | 15 ++++++++ 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 Confectionery/ConfectioneryView/nlog.config diff --git a/Confectionery/ConfectioneryView/FormShop.Designer.cs b/Confectionery/ConfectioneryView/FormShop.Designer.cs index 57f5e82..35e4ece 100644 --- a/Confectionery/ConfectioneryView/FormShop.Designer.cs +++ b/Confectionery/ConfectioneryView/FormShop.Designer.cs @@ -29,6 +29,9 @@ private void InitializeComponent() { dataGridView = new DataGridView(); + id = new DataGridViewTextBoxColumn(); + PastryName = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); labelName = new Label(); labelAddress = new Label(); labelOpen = new Label(); @@ -42,15 +45,43 @@ // // dataGridView // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView.BackgroundColor = Color.AliceBlue; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { id, PastryName, Count }); dataGridView.Location = new Point(12, 225); dataGridView.Name = "dataGridView"; - dataGridView.RowHeadersWidth = 62; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; + dataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; dataGridView.RowTemplate.Height = 33; dataGridView.Size = new Size(765, 393); dataGridView.TabIndex = 0; // + // id + // + id.HeaderText = "id"; + id.MinimumWidth = 8; + id.Name = "id"; + id.ReadOnly = true; + id.Visible = false; + // + // PastryName + // + PastryName.HeaderText = "Кондитерское изделие"; + PastryName.MinimumWidth = 8; + PastryName.Name = "PastryName"; + PastryName.ReadOnly = true; + // + // Count + // + Count.HeaderText = "Количество"; + Count.MinimumWidth = 8; + Count.Name = "Count"; + Count.ReadOnly = true; + // // labelName // labelName.AutoSize = true; @@ -152,5 +183,8 @@ private DateTimePicker dateTimePickerOpen; private Button buttonSave; private Button buttonCancel; + private DataGridViewTextBoxColumn id; + private DataGridViewTextBoxColumn PastryName; + private DataGridViewTextBoxColumn Count; } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormShop.cs b/Confectionery/ConfectioneryView/FormShop.cs index 09be130..4f53f29 100644 --- a/Confectionery/ConfectioneryView/FormShop.cs +++ b/Confectionery/ConfectioneryView/FormShop.cs @@ -104,7 +104,7 @@ namespace ConfectioneryView var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + throw new Exception("Ошибка при сохранении"); } MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; diff --git a/Confectionery/ConfectioneryView/FormShop.resx b/Confectionery/ConfectioneryView/FormShop.resx index f298a7b..d3dc922 100644 --- a/Confectionery/ConfectioneryView/FormShop.resx +++ b/Confectionery/ConfectioneryView/FormShop.resx @@ -57,4 +57,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/nlog.config b/Confectionery/ConfectioneryView/nlog.config new file mode 100644 index 0000000..85797a7 --- /dev/null +++ b/Confectionery/ConfectioneryView/nlog.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file -- 2.25.1 From 555d255fb390ae57ddc501a358b268ce528a06c2 Mon Sep 17 00:00:00 2001 From: malimova Date: Thu, 14 Mar 2024 23:34:51 +0400 Subject: [PATCH 6/6] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=20=D1=852?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Confectionery/ConfectioneryView/nlog.config | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Confectionery/ConfectioneryView/nlog.config diff --git a/Confectionery/ConfectioneryView/nlog.config b/Confectionery/ConfectioneryView/nlog.config deleted file mode 100644 index 85797a7..0000000 --- a/Confectionery/ConfectioneryView/nlog.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file -- 2.25.1