From e97e7a3218c83cb5981d863a3af0fe126b2e871d Mon Sep 17 00:00:00 2001 From: Shtyrkin_Egor Date: Wed, 7 Feb 2024 10:50:18 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=B4=D0=B8=D1=8F=20cont?= =?UTF-8?q?racts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/ShopBindingModel.cs | 18 ++++++++++++++++ .../BindingModels/ShopCannedBindingModel.cs | 15 +++++++++++++ .../BusinessLogicsContracts/IShopLogic.cs | 21 +++++++++++++++++++ .../SearchModels/ShopSearchModel.cs | 14 +++++++++++++ .../StoragesContracts/IShopCannedStorage.cs | 12 +++++++++++ .../StoragesContracts/IShopStorage.cs | 12 +++++++++++ .../ViewModels/ShopViewModel.cs | 12 +++++++++++ .../FishFactoryDataModel.csproj | 4 ---- .../Models/IShopCannedModel.cs | 15 +++++++++++++ FishFactoryDataModels/Models/IShopModel.cs | 16 ++++++++++++++ 10 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 FishFactoryContracts/BindingModels/ShopBindingModel.cs create mode 100644 FishFactoryContracts/BindingModels/ShopCannedBindingModel.cs create mode 100644 FishFactoryContracts/BusinessLogicsContracts/IShopLogic.cs create mode 100644 FishFactoryContracts/SearchModels/ShopSearchModel.cs create mode 100644 FishFactoryContracts/StoragesContracts/IShopCannedStorage.cs create mode 100644 FishFactoryContracts/StoragesContracts/IShopStorage.cs create mode 100644 FishFactoryContracts/ViewModels/ShopViewModel.cs create mode 100644 FishFactoryDataModels/Models/IShopCannedModel.cs create mode 100644 FishFactoryDataModels/Models/IShopModel.cs diff --git a/FishFactoryContracts/BindingModels/ShopBindingModel.cs b/FishFactoryContracts/BindingModels/ShopBindingModel.cs new file mode 100644 index 0000000..7183ee7 --- /dev/null +++ b/FishFactoryContracts/BindingModels/ShopBindingModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FishFactoryDataModel.Models; + +namespace FishFactoryContracts.BindingModels +{ + public class ShopBindingModel + { + public int Id { get; set; } + public string ShopName { get; set; } = string.Empty; + public string Adress { get; set; } = string.Empty; + public DateTime OpeningDate { get; set; } = DateTime.Now; + public Dictionary ShopCanneds { get; set; } = new(); + } +} diff --git a/FishFactoryContracts/BindingModels/ShopCannedBindingModel.cs b/FishFactoryContracts/BindingModels/ShopCannedBindingModel.cs new file mode 100644 index 0000000..e8861c6 --- /dev/null +++ b/FishFactoryContracts/BindingModels/ShopCannedBindingModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FishFactoryContracts.BindingModels +{ + public class ShopCannedBindingModel + { + public int ShopId { get; set; } + public int CannedId { get; set; } + public int Count { get; set; } + } +} diff --git a/FishFactoryContracts/BusinessLogicsContracts/IShopLogic.cs b/FishFactoryContracts/BusinessLogicsContracts/IShopLogic.cs new file mode 100644 index 0000000..27854e1 --- /dev/null +++ b/FishFactoryContracts/BusinessLogicsContracts/IShopLogic.cs @@ -0,0 +1,21 @@ +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.SearchModels; +using FishFactoryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FishFactoryContracts.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(ShopCannedBindingModel model); + } +} diff --git a/FishFactoryContracts/SearchModels/ShopSearchModel.cs b/FishFactoryContracts/SearchModels/ShopSearchModel.cs new file mode 100644 index 0000000..1bc6f33 --- /dev/null +++ b/FishFactoryContracts/SearchModels/ShopSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FishFactoryContracts.SearchModels +{ + internal class ShopSearchModel + { + punlic int? Id { get; set; } + public string ShopName { get; set; } + } +} diff --git a/FishFactoryContracts/StoragesContracts/IShopCannedStorage.cs b/FishFactoryContracts/StoragesContracts/IShopCannedStorage.cs new file mode 100644 index 0000000..ae176ff --- /dev/null +++ b/FishFactoryContracts/StoragesContracts/IShopCannedStorage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FishFactoryContracts.StoragesContracts +{ + internal interface IShopCannedStorage + { + } +} diff --git a/FishFactoryContracts/StoragesContracts/IShopStorage.cs b/FishFactoryContracts/StoragesContracts/IShopStorage.cs new file mode 100644 index 0000000..0eb9b09 --- /dev/null +++ b/FishFactoryContracts/StoragesContracts/IShopStorage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FishFactoryContracts.StoragesContracts +{ + public interface IShopStorage + { + } +} diff --git a/FishFactoryContracts/ViewModels/ShopViewModel.cs b/FishFactoryContracts/ViewModels/ShopViewModel.cs new file mode 100644 index 0000000..968df1e --- /dev/null +++ b/FishFactoryContracts/ViewModels/ShopViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FishFactoryContracts.ViewModels +{ + internal class ShopViewModel + { + } +} diff --git a/FishFactoryDataModels/FishFactoryDataModel.csproj b/FishFactoryDataModels/FishFactoryDataModel.csproj index e30cfc1..4e12194 100644 --- a/FishFactoryDataModels/FishFactoryDataModel.csproj +++ b/FishFactoryDataModels/FishFactoryDataModel.csproj @@ -7,8 +7,4 @@ AnyCPU;x86 - - - - diff --git a/FishFactoryDataModels/Models/IShopCannedModel.cs b/FishFactoryDataModels/Models/IShopCannedModel.cs new file mode 100644 index 0000000..aa84a61 --- /dev/null +++ b/FishFactoryDataModels/Models/IShopCannedModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FishFactoryDataModel.Models +{ + public interface IShopCannedModel + { + int ShopId { get; } + int CannedId { get; } + int Count { get; } + } +} diff --git a/FishFactoryDataModels/Models/IShopModel.cs b/FishFactoryDataModels/Models/IShopModel.cs new file mode 100644 index 0000000..1389ba6 --- /dev/null +++ b/FishFactoryDataModels/Models/IShopModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FishFactoryDataModel.Models +{ + public interface IShopModel : IId + { + string ShopName { get; } + string Adress { get; } + DateTime OpeningDate { get; } + Dictionary ShopCanneds { get; } + } +} -- 2.25.1 From 676d37152fcf9083acae765277e966168749a711 Mon Sep 17 00:00:00 2001 From: dex_moth Date: Tue, 20 Feb 2024 01:34:14 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D1=83=20=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FishFactory/FormShop.Designer.cs | 178 ++++++++++++++++++ FishFactory/FormShop.cs | 30 +++ FishFactory/FormShop.resx | 132 +++++++++++++ FishFactory/FormShopReplenish.Designer.cs | 141 ++++++++++++++ FishFactory/FormShopReplenish.cs | 30 +++ FishFactory/FormShopReplenish.resx | 120 ++++++++++++ FishFactory/FormShops.Designer.cs | 120 ++++++++++++ FishFactory/FormShops.cs | 40 ++++ FishFactory/FormShops.resx | 120 ++++++++++++ .../SearchModels/ShopSearchModel.cs | 6 +- .../StoragesContracts/IShopCannedStorage.cs | 12 -- .../StoragesContracts/IShopStorage.cs | 11 +- .../ViewModels/ShopViewModel.cs | 15 +- FishFactoryListImplement/DataListSingleton.cs | 2 + .../Implements/ShopStorage.cs | 105 +++++++++++ FishFactoryListImplement/Models/Shop.cs | 59 ++++++ 16 files changed, 1103 insertions(+), 18 deletions(-) create mode 100644 FishFactory/FormShop.Designer.cs create mode 100644 FishFactory/FormShop.cs create mode 100644 FishFactory/FormShop.resx create mode 100644 FishFactory/FormShopReplenish.Designer.cs create mode 100644 FishFactory/FormShopReplenish.cs create mode 100644 FishFactory/FormShopReplenish.resx create mode 100644 FishFactory/FormShops.Designer.cs create mode 100644 FishFactory/FormShops.cs create mode 100644 FishFactory/FormShops.resx delete mode 100644 FishFactoryContracts/StoragesContracts/IShopCannedStorage.cs create mode 100644 FishFactoryListImplement/Implements/ShopStorage.cs create mode 100644 FishFactoryListImplement/Models/Shop.cs diff --git a/FishFactory/FormShop.Designer.cs b/FishFactory/FormShop.Designer.cs new file mode 100644 index 0000000..8c47b80 --- /dev/null +++ b/FishFactory/FormShop.Designer.cs @@ -0,0 +1,178 @@ +namespace FishFactory +{ + 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() + { + label1 = new Label(); + label2 = new Label(); + textBoxShopName = new TextBox(); + textBoxAdress = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + dataGridView = new DataGridView(); + CannedName = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); + label3 = new Label(); + dateTimePicker = new DateTimePicker(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 23); + label1.Name = "label1"; + label1.Size = new Size(80, 20); + label1.TabIndex = 0; + label1.Text = "Название:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 67); + label2.Name = "label2"; + label2.Size = new Size(54, 20); + label2.TabIndex = 1; + label2.Text = "Адрес:"; + // + // textBoxShopName + // + textBoxShopName.Location = new Point(103, 20); + textBoxShopName.Name = "textBoxShopName"; + textBoxShopName.Size = new Size(304, 27); + textBoxShopName.TabIndex = 2; + // + // textBoxAdress + // + textBoxAdress.Location = new Point(103, 60); + textBoxAdress.Name = "textBoxAdress"; + textBoxAdress.Size = new Size(304, 27); + textBoxAdress.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(513, 509); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(123, 33); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(663, 509); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(123, 33); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { CannedName, Count }); + dataGridView.Location = new Point(0, 108); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(851, 376); + dataGridView.TabIndex = 6; + // + // CannedName + // + CannedName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + CannedName.HeaderText = "Консерва"; + CannedName.MinimumWidth = 6; + CannedName.Name = "CannedName"; + CannedName.ReadOnly = true; + // + // Count + // + Count.HeaderText = "Количество"; + Count.MinimumWidth = 125; + Count.Name = "Count"; + Count.ReadOnly = true; + Count.Width = 170; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(438, 23); + label3.Name = "label3"; + label3.Size = new Size(113, 20); + label3.TabIndex = 7; + label3.Text = "Дата открытия:"; + // + // dateTimePicker + // + dateTimePicker.Location = new Point(557, 20); + dateTimePicker.Name = "dateTimePicker"; + dateTimePicker.Size = new Size(294, 27); + dateTimePicker.TabIndex = 8; + // + // FormShop + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(863, 568); + Controls.Add(dateTimePicker); + Controls.Add(label3); + Controls.Add(dataGridView); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxAdress); + Controls.Add(textBoxShopName); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormShop"; + Text = "Магазин"; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private TextBox textBoxShopName; + private TextBox textBoxAdress; + private Button buttonSave; + private Button buttonCancel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn CannedName; + private DataGridViewTextBoxColumn Count; + private Label label3; + private DateTimePicker dateTimePicker; + } +} \ No newline at end of file diff --git a/FishFactory/FormShop.cs b/FishFactory/FormShop.cs new file mode 100644 index 0000000..c0e3c13 --- /dev/null +++ b/FishFactory/FormShop.cs @@ -0,0 +1,30 @@ +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 FishFactory +{ + public partial class FormShop : Form + { + public FormShop() + { + InitializeComponent(); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/FishFactory/FormShop.resx b/FishFactory/FormShop.resx new file mode 100644 index 0000000..aefdb73 --- /dev/null +++ b/FishFactory/FormShop.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/FishFactory/FormShopReplenish.Designer.cs b/FishFactory/FormShopReplenish.Designer.cs new file mode 100644 index 0000000..a9e44d9 --- /dev/null +++ b/FishFactory/FormShopReplenish.Designer.cs @@ -0,0 +1,141 @@ +namespace FishFactory +{ + partial class FormShopReplenish + { + /// + /// 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() + { + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + comboBoxShopCanneds = new ComboBox(); + comboBoxCanned = new ComboBox(); + textBoxCount = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(23, 33); + label1.Name = "label1"; + label1.Size = new Size(72, 20); + label1.TabIndex = 0; + label1.Text = "Магазин:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(23, 78); + label2.Name = "label2"; + label2.Size = new Size(79, 20); + label2.TabIndex = 1; + label2.Text = "Консерва:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(23, 126); + label3.Name = "label3"; + label3.Size = new Size(93, 20); + label3.TabIndex = 2; + label3.Text = "Количество:"; + // + // comboBoxShopCanneds + // + comboBoxShopCanneds.FormattingEnabled = true; + comboBoxShopCanneds.Location = new Point(140, 33); + comboBoxShopCanneds.Name = "comboBoxShopCanneds"; + comboBoxShopCanneds.Size = new Size(383, 28); + comboBoxShopCanneds.TabIndex = 3; + // + // comboBoxCanned + // + comboBoxCanned.FormattingEnabled = true; + comboBoxCanned.Location = new Point(140, 78); + comboBoxCanned.Name = "comboBoxCanned"; + comboBoxCanned.Size = new Size(383, 28); + comboBoxCanned.TabIndex = 4; + // + // textBoxCount + // + textBoxCount.Location = new Point(140, 123); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(199, 27); + textBoxCount.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(281, 175); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(107, 34); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(407, 175); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(107, 34); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormShopReplenish + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(538, 221); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxCount); + Controls.Add(comboBoxCanned); + Controls.Add(comboBoxShopCanneds); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormShopReplenish"; + Text = "Пополнение магазина"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private ComboBox comboBoxShopCanneds; + private ComboBox comboBoxCanned; + private TextBox textBoxCount; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/FishFactory/FormShopReplenish.cs b/FishFactory/FormShopReplenish.cs new file mode 100644 index 0000000..b332189 --- /dev/null +++ b/FishFactory/FormShopReplenish.cs @@ -0,0 +1,30 @@ +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 FishFactory +{ + public partial class FormShopReplenish : Form + { + public FormShopReplenish() + { + InitializeComponent(); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/FishFactory/FormShopReplenish.resx b/FishFactory/FormShopReplenish.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FishFactory/FormShopReplenish.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/FishFactory/FormShops.Designer.cs b/FishFactory/FormShops.Designer.cs new file mode 100644 index 0000000..1b66f80 --- /dev/null +++ b/FishFactory/FormShops.Designer.cs @@ -0,0 +1,120 @@ +namespace FishFactory +{ + 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() + { + dataGridView1 = new DataGridView(); + buttonAdd = new Button(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonRef = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + SuspendLayout(); + // + // dataGridView1 + // + dataGridView1.AllowUserToAddRows = false; + dataGridView1.AllowUserToDeleteRows = false; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Location = new Point(0, 0); + dataGridView1.Name = "dataGridView1"; + dataGridView1.ReadOnly = true; + dataGridView1.RowHeadersWidth = 51; + dataGridView1.RowTemplate.Height = 29; + dataGridView1.Size = new Size(525, 673); + dataGridView1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.AccessibleRole = AccessibleRole.None; + buttonAdd.Location = new Point(565, 76); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(130, 35); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // buttonUpd + // + buttonUpd.AccessibleRole = AccessibleRole.None; + buttonUpd.Location = new Point(565, 130); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(130, 35); + buttonUpd.TabIndex = 2; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonDel + // + buttonDel.AccessibleRole = AccessibleRole.None; + buttonDel.Location = new Point(565, 186); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(130, 35); + buttonDel.TabIndex = 3; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonRef + // + buttonRef.AccessibleRole = AccessibleRole.None; + buttonRef.Location = new Point(565, 243); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(130, 35); + buttonRef.TabIndex = 4; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; + // + // FormShops + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(722, 674); + 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/FishFactory/FormShops.cs b/FishFactory/FormShops.cs new file mode 100644 index 0000000..aaa2d41 --- /dev/null +++ b/FishFactory/FormShops.cs @@ -0,0 +1,40 @@ +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 FishFactory +{ + public partial class FormShops : Form + { + public FormShops() + { + InitializeComponent(); + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + + } + + private void buttonUpd_Click(object sender, EventArgs e) + { + + } + + private void buttonDel_Click(object sender, EventArgs e) + { + + } + + private void buttonRef_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/FishFactory/FormShops.resx b/FishFactory/FormShops.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FishFactory/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 diff --git a/FishFactoryContracts/SearchModels/ShopSearchModel.cs b/FishFactoryContracts/SearchModels/ShopSearchModel.cs index 1bc6f33..6109423 100644 --- a/FishFactoryContracts/SearchModels/ShopSearchModel.cs +++ b/FishFactoryContracts/SearchModels/ShopSearchModel.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; namespace FishFactoryContracts.SearchModels { - internal class ShopSearchModel + public class ShopSearchModel { - punlic int? Id { get; set; } - public string ShopName { get; set; } + public int? Id { get; set; } + public string? ShopName { get; set; } } } diff --git a/FishFactoryContracts/StoragesContracts/IShopCannedStorage.cs b/FishFactoryContracts/StoragesContracts/IShopCannedStorage.cs deleted file mode 100644 index ae176ff..0000000 --- a/FishFactoryContracts/StoragesContracts/IShopCannedStorage.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FishFactoryContracts.StoragesContracts -{ - internal interface IShopCannedStorage - { - } -} diff --git a/FishFactoryContracts/StoragesContracts/IShopStorage.cs b/FishFactoryContracts/StoragesContracts/IShopStorage.cs index 0eb9b09..7c1dfa6 100644 --- a/FishFactoryContracts/StoragesContracts/IShopStorage.cs +++ b/FishFactoryContracts/StoragesContracts/IShopStorage.cs @@ -1,4 +1,7 @@ -using System; +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.SearchModels; +using FishFactoryContracts.ViewModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,5 +11,11 @@ namespace FishFactoryContracts.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/FishFactoryContracts/ViewModels/ShopViewModel.cs b/FishFactoryContracts/ViewModels/ShopViewModel.cs index 968df1e..bd93234 100644 --- a/FishFactoryContracts/ViewModels/ShopViewModel.cs +++ b/FishFactoryContracts/ViewModels/ShopViewModel.cs @@ -1,12 +1,23 @@ -using System; +using FishFactoryDataModel.Models; +using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FishFactoryContracts.ViewModels { - internal class ShopViewModel + public class ShopViewModel { + public int Id { get; set; } + [DisplayName("Название")] + public string ShopName { get; set; } = string.Empty; + [DisplayName("Адрес")] + public string Adress { get; set; } = string.Empty; + [DisplayName("Дата открытия")] + public DateTime OpeningDate { get; set; } + public Dictionary ShopCanneds { get; set; } = new(); + } } diff --git a/FishFactoryListImplement/DataListSingleton.cs b/FishFactoryListImplement/DataListSingleton.cs index fd86094..a2ec10e 100644 --- a/FishFactoryListImplement/DataListSingleton.cs +++ b/FishFactoryListImplement/DataListSingleton.cs @@ -13,11 +13,13 @@ namespace FishFactoryListImplement public List Components { get; set; } public List Orders { get; set; } public List Canneds { get; set; } + public List Shops { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); Canneds = new List(); + Shop = new List(); } public static DataListSingleton GetInstance() { diff --git a/FishFactoryListImplement/Implements/ShopStorage.cs b/FishFactoryListImplement/Implements/ShopStorage.cs new file mode 100644 index 0000000..9b19e79 --- /dev/null +++ b/FishFactoryListImplement/Implements/ShopStorage.cs @@ -0,0 +1,105 @@ +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.SearchModels; +using FishFactoryContracts.StoragesContracts; +using FishFactoryContracts.ViewModels; +using FishFactoryListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FishFactoryListImplement.Implements +{ + 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 (model == null || !model.Id.HasValue) + { + return result; + } + foreach (var shop in _source.Shops) + { + if (shop.Id == model.Id) + { + result.Add(shop.GetViewModel); + } + } + return result; + } + public ShopViewModel? GetElement(ShopSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + foreach (var shop in _source.Shops) + { + if (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/FishFactoryListImplement/Models/Shop.cs b/FishFactoryListImplement/Models/Shop.cs new file mode 100644 index 0000000..c5f18d2 --- /dev/null +++ b/FishFactoryListImplement/Models/Shop.cs @@ -0,0 +1,59 @@ +using FishFactoryContracts.BindingModels; +using FishFactoryDataModel.Models; +using FishFactoryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FishFactoryListImplement.Models +{ + internal class Shop : IShopModel + { + public int Id { get; private set; } + public string ShopName { get; private set; } = string.Empty; + public string Adress { get; private set; } + public DateTime OpeningDate { get; private set; } + public Dictionary ShopCanneds + { + get; + private set; + } = new Dictionary(); + + public static Shop? Create(ShopBindingModel? model) + { + if (model == null) + { + return null; + } + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Adress = model.Adress, + OpeningDate = model.OpeningDate, + ShopCanneds = model.ShopCanneds + }; + } + public void Update(ShopBindingModel? model) + { + if (model == null) + { + return; + } + ShopName = model.ShopName; + Adress = model.Adress; + OpeningDate = model.OpeningDate; + } + + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Adress = Adress, + OpeningDate = OpeningDate, + ShopCanneds = ShopCanneds + }; + } +} -- 2.25.1 From c65f7168a82a5d8009f8f1628e5a0ba12f658374 Mon Sep 17 00:00:00 2001 From: dex_moth Date: Tue, 5 Mar 2024 21:14:06 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D1=87=D0=B5=D0=BC=20=D0=B1=D1=8B=D0=BB=20?= =?UTF-8?q?=D1=81=D0=B8=D0=BB=D1=8C=D0=BD=D0=B5=D0=B9=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BB=D1=8C,=20=D1=82=D0=B5=D0=BC=20=D1=85?= =?UTF-8?q?=D0=B0=D0=BE=D1=81=20=D0=B1=D0=B5=D0=B7=D0=B3=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=87=D0=BD=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FishFactory/FormMain.Designer.cs | 26 ++- FishFactory/FormMain.cs | 21 +++ FishFactory/FormShop.Designer.cs | 16 +- FishFactory/FormShop.cs | 112 +++++++++++-- FishFactory/FormShopReplenish.cs | 83 ++++++++-- FishFactory/FormShops.Designer.cs | 32 ++-- FishFactory/FormShops.cs | 96 +++++++++-- FishFactory/Program.cs | 5 + .../BusinessLogic/CannedLogic.cs | 5 - .../BusinessLogic/ShopLogic.cs | 154 ++++++++++++++++++ ...ndingModel.cs => ReplenishBindingModel.cs} | 2 +- .../BusinessLogicsContracts/IShopLogic.cs | 7 +- FishFactoryListImplement/DataListSingleton.cs | 2 +- FishFactoryListImplement/Models/Shop.cs | 2 +- 14 files changed, 484 insertions(+), 79 deletions(-) create mode 100644 FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs rename FishFactoryContracts/BindingModels/{ShopCannedBindingModel.cs => ReplenishBindingModel.cs} (88%) diff --git a/FishFactory/FormMain.Designer.cs b/FishFactory/FormMain.Designer.cs index 73fef74..f76b064 100644 --- a/FishFactory/FormMain.Designer.cs +++ b/FishFactory/FormMain.Designer.cs @@ -33,12 +33,14 @@ toolStripDropDownButton1 = new ToolStripDropDownButton(); компонентыToolStripMenuItem = new ToolStripMenuItem(); консервыToolStripMenuItem = new ToolStripMenuItem(); + магазиныToolStripMenuItem = new ToolStripMenuItem(); buttonCreateOrder = new Button(); buttonTakeOrderInWork = new Button(); buttonOrderReady = new Button(); buttonIssuedOrder = new Button(); buttonRef = new Button(); dataGridView = new DataGridView(); + toolStripLabelReplenish = new ToolStripLabel(); toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -46,7 +48,7 @@ // toolStrip1 // toolStrip1.ImageScalingSize = new Size(20, 20); - toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1 }); + toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, toolStripLabelReplenish }); toolStrip1.Location = new Point(0, 0); toolStrip1.Name = "toolStrip1"; toolStrip1.Size = new Size(1107, 27); @@ -56,7 +58,7 @@ // toolStripDropDownButton1 // toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text; - toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, консервыToolStripMenuItem }); + toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, консервыToolStripMenuItem, магазиныToolStripMenuItem }); toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image"); toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; toolStripDropDownButton1.Name = "toolStripDropDownButton1"; @@ -66,17 +68,24 @@ // компонентыToolStripMenuItem // компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(182, 26); + компонентыToolStripMenuItem.Size = new Size(224, 26); компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; // // консервыToolStripMenuItem // консервыToolStripMenuItem.Name = "консервыToolStripMenuItem"; - консервыToolStripMenuItem.Size = new Size(182, 26); + консервы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; + // // buttonCreateOrder // buttonCreateOrder.Location = new Point(914, 75); @@ -145,6 +154,13 @@ dataGridView.Size = new Size(872, 580); dataGridView.TabIndex = 6; // + // toolStripLabelReplenish + // + toolStripLabelReplenish.Name = "toolStripLabelReplenish"; + toolStripLabelReplenish.Size = new Size(168, 24); + toolStripLabelReplenish.Text = "Пополнение магазина"; + toolStripLabelReplenish.Click += toolStripLabelReplenish_Click; + // // FormMain // AutoScaleDimensions = new SizeF(8F, 20F); @@ -180,5 +196,7 @@ private ToolStripDropDownButton toolStripDropDownButton1; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem консервыToolStripMenuItem; + private ToolStripMenuItem магазиныToolStripMenuItem; + private ToolStripLabel toolStripLabelReplenish; } } \ No newline at end of file diff --git a/FishFactory/FormMain.cs b/FishFactory/FormMain.cs index b8c0b8f..50e2296 100644 --- a/FishFactory/FormMain.cs +++ b/FishFactory/FormMain.cs @@ -65,6 +65,27 @@ namespace FishFactory.Forms form.ShowDialog(); } } + + private void магазиныToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + + if (service is FormShops form) + { + form.ShowDialog(); + } + } + + private void toolStripLabelReplenish_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShopReplenish)); + if (service is FormShopReplenish form) + { + form.ShowDialog(); + LoadData(); + } + } + private void buttonCreateOrder_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); diff --git a/FishFactory/FormShop.Designer.cs b/FishFactory/FormShop.Designer.cs index 8c47b80..2a0da5b 100644 --- a/FishFactory/FormShop.Designer.cs +++ b/FishFactory/FormShop.Designer.cs @@ -38,7 +38,7 @@ CannedName = new DataGridViewTextBoxColumn(); Count = new DataGridViewTextBoxColumn(); label3 = new Label(); - dateTimePicker = new DateTimePicker(); + openingDatePicker = new DateTimePicker(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // @@ -133,19 +133,19 @@ label3.TabIndex = 7; label3.Text = "Дата открытия:"; // - // dateTimePicker + // openingDatePicker // - dateTimePicker.Location = new Point(557, 20); - dateTimePicker.Name = "dateTimePicker"; - dateTimePicker.Size = new Size(294, 27); - dateTimePicker.TabIndex = 8; + openingDatePicker.Location = new Point(557, 20); + openingDatePicker.Name = "openingDatePicker"; + openingDatePicker.Size = new Size(294, 27); + openingDatePicker.TabIndex = 8; // // FormShop // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(863, 568); - Controls.Add(dateTimePicker); + Controls.Add(openingDatePicker); Controls.Add(label3); Controls.Add(dataGridView); Controls.Add(buttonCancel); @@ -173,6 +173,6 @@ private DataGridViewTextBoxColumn CannedName; private DataGridViewTextBoxColumn Count; private Label label3; - private DateTimePicker dateTimePicker; + private DateTimePicker openingDatePicker; } } \ No newline at end of file diff --git a/FishFactory/FormShop.cs b/FishFactory/FormShop.cs index c0e3c13..e7dcf3b 100644 --- a/FishFactory/FormShop.cs +++ b/FishFactory/FormShop.cs @@ -1,30 +1,120 @@ -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 FishFactoryContracts.BindingModels; +using FishFactoryContracts.BusinessLogicsContracts; +using FishFactoryContracts.SearchModels; +using FishFactoryDataModel.Models; +using Microsoft.Extensions.Logging; using System.Windows.Forms; namespace FishFactory { 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 _shopCanneds; + private DateTime? _openingDate = null; + + public FormShop(ILogger logger, IShopLogic logic) { InitializeComponent(); + _logger = logger; + _logic = logic; + _shopCanneds = 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) + { + textBoxShopName.Text = view.ShopName; + textBoxAdress.Text = view.Adress; + openingDatePicker.Value = view.OpeningDate; + _shopCanneds = view.ShopCanneds ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void LoadData() + { + _logger.LogInformation("Загрузка изделий в магазине"); + try + { + if (_shopCanneds != null) + { + dataGridView.Rows.Clear(); + foreach (var sr in _shopCanneds) + { + dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.CannedName, 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(textBoxShopName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxAdress.Text)) + { + MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение магазина"); + try + { + var model = new ShopBindingModel + { + Id = _id ?? 0, + ShopName = textBoxShopName.Text, + Adress = textBoxAdress.Text, + OpeningDate = openingDatePicker.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/FishFactory/FormShopReplenish.cs b/FishFactory/FormShopReplenish.cs index b332189..122d9ae 100644 --- a/FishFactory/FormShopReplenish.cs +++ b/FishFactory/FormShopReplenish.cs @@ -1,30 +1,89 @@ -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; + +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BusinessLogicsContracts; +using FishFactoryContracts.ViewModels; +using Microsoft.Extensions.Logging; namespace FishFactory { public partial class FormShopReplenish : Form { - public FormShopReplenish() + private readonly ILogger _logger; + private readonly ICannedLogic _logicP; + private readonly IShopLogic _logicS; + private List _shopList = new List(); + private List _cannedList = new List(); + + public FormShopReplenish(ILogger logger, ICannedLogic logicP, IShopLogic logicS) { InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicS = logicS; + } + + private void FormCreateReplenish_Load(object sender, EventArgs e) + { + _shopList = _logicS.ReadList(null); + _cannedList = _logicP.ReadList(null); + if (_shopList != null) + { + comboBoxShopCanneds.DisplayMember = "ShopName"; + comboBoxShopCanneds.ValueMember = "Id"; + comboBoxShopCanneds.DataSource = _shopList; + comboBoxShopCanneds.SelectedItem = null; + _logger.LogInformation("Загрузка магазинов для поставок"); + } + if (_cannedList != null) + { + comboBoxCanned.DisplayMember = "CannedName"; + comboBoxCanned.ValueMember = "Id"; + comboBoxCanned.DataSource = _cannedList; + comboBoxCanned.SelectedItem = null; + _logger.LogInformation("Загрузка консерв для поставок"); + } } private void buttonSave_Click(object sender, EventArgs e) { - + if (comboBoxShopCanneds.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxCanned.SelectedValue == null) + { + MessageBox.Show("Выберите консерву", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание поставки"); + try + { + var operationResult = _logicS.Replenish(new ReplenishBindingModel + { + ShopId = Convert.ToInt32(comboBoxShopCanneds.SelectedValue), + CannedId = Convert.ToInt32(comboBoxCanned.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/FishFactory/FormShops.Designer.cs b/FishFactory/FormShops.Designer.cs index 1b66f80..b7c0239 100644 --- a/FishFactory/FormShops.Designer.cs +++ b/FishFactory/FormShops.Designer.cs @@ -28,26 +28,26 @@ /// 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.AllowUserToAddRows = false; - dataGridView1.AllowUserToDeleteRows = false; - dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView1.Location = new Point(0, 0); - dataGridView1.Name = "dataGridView1"; - dataGridView1.ReadOnly = true; - dataGridView1.RowHeadersWidth = 51; - dataGridView1.RowTemplate.Height = 29; - dataGridView1.Size = new Size(525, 673); - dataGridView1.TabIndex = 0; + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(0, 0); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(525, 673); + dataGridView.TabIndex = 0; // // buttonAdd // @@ -102,16 +102,16 @@ Controls.Add(buttonDel); Controls.Add(buttonUpd); Controls.Add(buttonAdd); - Controls.Add(dataGridView1); + Controls.Add(dataGridView); Name = "FormShops"; Text = "Список магазинов"; - ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ((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/FishFactory/FormShops.cs b/FishFactory/FormShops.cs index aaa2d41..2d0c90f 100644 --- a/FishFactory/FormShops.cs +++ b/FishFactory/FormShops.cs @@ -1,40 +1,108 @@ -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; +using FishFactory.Forms; +using FishFactoryDataModel.Models; +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BusinessLogicsContracts; +using FishFactoryContracts.SearchModels; +using Microsoft.Extensions.Logging; namespace FishFactory { public partial class FormShops : Form { - public FormShops() + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + + public FormShops(ILogger logger, IComponentLogic 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["ShopCanneds"].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 ComponentBindingModel + { + 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/FishFactory/Program.cs b/FishFactory/Program.cs index 08c8b2d..fabfb88 100644 --- a/FishFactory/Program.cs +++ b/FishFactory/Program.cs @@ -38,9 +38,11 @@ namespace FishFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -48,6 +50,9 @@ namespace FishFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/FishFactoryBusinessLogic/BusinessLogic/CannedLogic.cs b/FishFactoryBusinessLogic/BusinessLogic/CannedLogic.cs index 4bdf067..1b6822f 100644 --- a/FishFactoryBusinessLogic/BusinessLogic/CannedLogic.cs +++ b/FishFactoryBusinessLogic/BusinessLogic/CannedLogic.cs @@ -4,11 +4,6 @@ using FishFactoryContracts.SearchModels; using FishFactoryContracts.StoragesContracts; using FishFactoryContracts.ViewModels; using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FishFactoryBusinessLogic.BusinessLogic { diff --git a/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs b/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs new file mode 100644 index 0000000..b2cbc12 --- /dev/null +++ b/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs @@ -0,0 +1,154 @@ +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BusinessLogicsContracts; +using FishFactoryContracts.SearchModels; +using FishFactoryContracts.StoragesContracts; +using FishFactoryContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace FishFactoryBusinessLogic.BusinessLogic +{ + public class ShopLogic : IShopLogic + { + private readonly ILogger _logger; + private readonly IShopStorage _shopStorage; + private readonly ICannedStorage _cannedStorage; + + public ShopLogic(ILogger logger, IShopStorage shopStorage, ICannedStorage cannedStorage) + { + _logger = logger; + _shopStorage = shopStorage; + _cannedStorage = cannedStorage; + } + 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 Replenish(ReplenishBindingModel 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.ShopCanneds.ContainsKey(model.CannedId)) + { + var oldValue = shop.ShopCanneds[model.CannedId]; + oldValue.Item2 += model.Count; + shop.ShopCanneds[model.CannedId] = oldValue; + } + else + { + var canned = _cannedStorage.GetElement(new CannedSearchModel + { + Id = model.CannedId + }); + if (canned == null) + { + throw new ArgumentException($"Поставка: Товар с id:{model.CannedId} не найденн"); + } + shop.ShopCanneds.Add(model.CannedId, (canned, 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.Adress)) + { + throw new ArgumentException("Нет адреса магазина", nameof(model.Adress)); + } + if (string.IsNullOrEmpty(model.ShopName)) + { + throw new ArgumentNullException("Нет названия компонента", nameof(model.ShopName)); + } + _logger.LogInformation("Shop. ShopName:{ShopName}.Adress:{Adress}. Id: {Id}", model.ShopName, model.Adress, model.Id); + var element = _shopStorage.GetElement(new ShopSearchModel + { + ShopName = model.ShopName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Магазин с таким названием уже есть"); + } + } + } +} diff --git a/FishFactoryContracts/BindingModels/ShopCannedBindingModel.cs b/FishFactoryContracts/BindingModels/ReplenishBindingModel.cs similarity index 88% rename from FishFactoryContracts/BindingModels/ShopCannedBindingModel.cs rename to FishFactoryContracts/BindingModels/ReplenishBindingModel.cs index e8861c6..f7210d5 100644 --- a/FishFactoryContracts/BindingModels/ShopCannedBindingModel.cs +++ b/FishFactoryContracts/BindingModels/ReplenishBindingModel.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace FishFactoryContracts.BindingModels { - public class ShopCannedBindingModel + public class ReplenishBindingModel { public int ShopId { get; set; } public int CannedId { get; set; } diff --git a/FishFactoryContracts/BusinessLogicsContracts/IShopLogic.cs b/FishFactoryContracts/BusinessLogicsContracts/IShopLogic.cs index 27854e1..8005dde 100644 --- a/FishFactoryContracts/BusinessLogicsContracts/IShopLogic.cs +++ b/FishFactoryContracts/BusinessLogicsContracts/IShopLogic.cs @@ -1,11 +1,6 @@ using FishFactoryContracts.BindingModels; using FishFactoryContracts.SearchModels; using FishFactoryContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FishFactoryContracts.BusinessLogicsContracts { @@ -16,6 +11,6 @@ namespace FishFactoryContracts.BusinessLogicsContracts bool Create(ShopBindingModel model); bool Update(ShopBindingModel model); bool Delete(ShopBindingModel model); - bool MakeSupply(ShopCannedBindingModel model); + bool Replenish(ReplenishBindingModel model); } } diff --git a/FishFactoryListImplement/DataListSingleton.cs b/FishFactoryListImplement/DataListSingleton.cs index a2ec10e..27a6009 100644 --- a/FishFactoryListImplement/DataListSingleton.cs +++ b/FishFactoryListImplement/DataListSingleton.cs @@ -19,7 +19,7 @@ namespace FishFactoryListImplement Components = new List(); Orders = new List(); Canneds = new List(); - Shop = new List(); + Shops = new List(); } public static DataListSingleton GetInstance() { diff --git a/FishFactoryListImplement/Models/Shop.cs b/FishFactoryListImplement/Models/Shop.cs index c5f18d2..b82b19c 100644 --- a/FishFactoryListImplement/Models/Shop.cs +++ b/FishFactoryListImplement/Models/Shop.cs @@ -13,7 +13,7 @@ namespace FishFactoryListImplement.Models { public int Id { get; private set; } public string ShopName { get; private set; } = string.Empty; - public string Adress { get; private set; } + public string Adress { get; private set; } = string.Empty; public DateTime OpeningDate { get; private set; } public Dictionary ShopCanneds { -- 2.25.1 From f430bc97739ee2de763dac89c0cc2723884e6799 Mon Sep 17 00:00:00 2001 From: Shtyrkin_Egor Date: Wed, 6 Mar 2024 11:01:55 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BF=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B8=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D1=80=D0=B5=D0=B4=D1=81=D1=82=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D1=8B=20=D0=B2=20=D0=BC=D0=B0=D0=B3=D0=B0=D0=B7?= =?UTF-8?q?=D0=B8=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FishFactory/FormCanneds.cs | 12 +----------- FishFactory/FormComponent.cs | 12 +----------- FishFactory/FormComponents.cs | 9 --------- FishFactory/FormMain.cs | 10 ---------- FishFactory/FormShop.Designer.cs | 3 ++- FishFactory/FormShop.cs | 3 +-- FishFactory/FormShopReplenish.Designer.cs | 3 ++- FishFactory/FormShopReplenish.cs | 7 +++---- FishFactory/FormShops.Designer.cs | 3 ++- FishFactory/FormShops.cs | 13 +++++-------- .../BusinessLogic/ShopLogic.cs | 2 +- .../BindingModels/ReplenishBindingModel.cs | 8 ++------ .../BindingModels/ShopBindingModel.cs | 9 ++------- .../SearchModels/OrderSearchModel.cs | 8 +------- FishFactoryContracts/ViewModels/ShopViewModel.cs | 1 - FishFactoryDataModels/Models/IReplenishModel.cs | 9 +++++++++ FishFactoryDataModels/Models/IShopCannedModel.cs | 15 --------------- FishFactoryDataModels/Models/IShopModel.cs | 8 +------- .../Implements/ShopStorage.cs | 13 ++++--------- FishFactoryListImplement/Models/Shop.cs | 5 ----- 20 files changed, 37 insertions(+), 116 deletions(-) create mode 100644 FishFactoryDataModels/Models/IReplenishModel.cs delete mode 100644 FishFactoryDataModels/Models/IShopCannedModel.cs diff --git a/FishFactory/FormCanneds.cs b/FishFactory/FormCanneds.cs index 6cbeb50..840349f 100644 --- a/FishFactory/FormCanneds.cs +++ b/FishFactory/FormCanneds.cs @@ -1,14 +1,4 @@ -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; -using FishFactory; -using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; diff --git a/FishFactory/FormComponent.cs b/FishFactory/FormComponent.cs index 86b613f..57f0fed 100644 --- a/FishFactory/FormComponent.cs +++ b/FishFactory/FormComponent.cs @@ -1,15 +1,5 @@ -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; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using FishFactoryContracts.BusinessLogicsContracts; -using Microsoft.VisualBasic.Logging; using FishFactoryContracts.SearchModels; using FishFactoryContracts.BindingModels; diff --git a/FishFactory/FormComponents.cs b/FishFactory/FormComponents.cs index ef3531a..925119a 100644 --- a/FishFactory/FormComponents.cs +++ b/FishFactory/FormComponents.cs @@ -1,15 +1,6 @@ using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; -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 FishFactory.Forms { diff --git a/FishFactory/FormMain.cs b/FishFactory/FormMain.cs index 50e2296..ba5fd14 100644 --- a/FishFactory/FormMain.cs +++ b/FishFactory/FormMain.cs @@ -1,15 +1,6 @@ using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; -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 FishFactory.Forms { @@ -82,7 +73,6 @@ namespace FishFactory.Forms if (service is FormShopReplenish form) { form.ShowDialog(); - LoadData(); } } diff --git a/FishFactory/FormShop.Designer.cs b/FishFactory/FormShop.Designer.cs index 2a0da5b..4724e4e 100644 --- a/FishFactory/FormShop.Designer.cs +++ b/FishFactory/FormShop.Designer.cs @@ -1,4 +1,4 @@ -namespace FishFactory +namespace FishFactory.Forms { partial class FormShop { @@ -156,6 +156,7 @@ Controls.Add(label1); Name = "FormShop"; Text = "Магазин"; + Load += FormShop_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); PerformLayout(); diff --git a/FishFactory/FormShop.cs b/FishFactory/FormShop.cs index e7dcf3b..2793743 100644 --- a/FishFactory/FormShop.cs +++ b/FishFactory/FormShop.cs @@ -3,9 +3,8 @@ using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.SearchModels; using FishFactoryDataModel.Models; using Microsoft.Extensions.Logging; -using System.Windows.Forms; -namespace FishFactory +namespace FishFactory.Forms { public partial class FormShop : Form { diff --git a/FishFactory/FormShopReplenish.Designer.cs b/FishFactory/FormShopReplenish.Designer.cs index a9e44d9..8a1f13b 100644 --- a/FishFactory/FormShopReplenish.Designer.cs +++ b/FishFactory/FormShopReplenish.Designer.cs @@ -1,4 +1,4 @@ -namespace FishFactory +namespace FishFactory.Forms { partial class FormShopReplenish { @@ -123,6 +123,7 @@ Controls.Add(label1); Name = "FormShopReplenish"; Text = "Пополнение магазина"; + Load += FormShopReplenish_Load; ResumeLayout(false); PerformLayout(); } diff --git a/FishFactory/FormShopReplenish.cs b/FishFactory/FormShopReplenish.cs index 122d9ae..19a45f3 100644 --- a/FishFactory/FormShopReplenish.cs +++ b/FishFactory/FormShopReplenish.cs @@ -1,10 +1,9 @@ - -using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.ViewModels; using Microsoft.Extensions.Logging; -namespace FishFactory +namespace FishFactory.Forms { public partial class FormShopReplenish : Form { @@ -22,7 +21,7 @@ namespace FishFactory _logicS = logicS; } - private void FormCreateReplenish_Load(object sender, EventArgs e) + private void FormShopReplenish_Load(object sender, EventArgs e) { _shopList = _logicS.ReadList(null); _cannedList = _logicP.ReadList(null); diff --git a/FishFactory/FormShops.Designer.cs b/FishFactory/FormShops.Designer.cs index b7c0239..0b6ebdd 100644 --- a/FishFactory/FormShops.Designer.cs +++ b/FishFactory/FormShops.Designer.cs @@ -1,4 +1,4 @@ -namespace FishFactory +namespace FishFactory.Forms { partial class FormShops { @@ -105,6 +105,7 @@ Controls.Add(dataGridView); Name = "FormShops"; Text = "Список магазинов"; + Load += FormShops_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } diff --git a/FishFactory/FormShops.cs b/FishFactory/FormShops.cs index 2d0c90f..46e8f15 100644 --- a/FishFactory/FormShops.cs +++ b/FishFactory/FormShops.cs @@ -1,18 +1,15 @@ -using FishFactory.Forms; -using FishFactoryDataModel.Models; -using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; -using FishFactoryContracts.SearchModels; using Microsoft.Extensions.Logging; -namespace FishFactory +namespace FishFactory.Forms { public partial class FormShops : Form { private readonly ILogger _logger; - private readonly IComponentLogic _logic; + private readonly IShopLogic _logic; - public FormShops(ILogger logger, IComponentLogic logic) + public FormShops(ILogger logger, IShopLogic logic) { InitializeComponent(); _logger = logger; @@ -82,7 +79,7 @@ namespace FishFactory _logger.LogInformation("Удаление магазина"); try { - if (!_logic.Delete(new ComponentBindingModel + if (!_logic.Delete(new ShopBindingModel { Id = id })) diff --git a/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs b/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs index b2cbc12..843fd8e 100644 --- a/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs +++ b/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs @@ -140,7 +140,7 @@ namespace FishFactoryBusinessLogic.BusinessLogic { throw new ArgumentNullException("Нет названия компонента", nameof(model.ShopName)); } - _logger.LogInformation("Shop. ShopName:{ShopName}.Adress:{Adress}. Id: {Id}", model.ShopName, model.Adress, model.Id); + _logger.LogInformation("Shop. ShopName:{ShopName}.Adress:{Adress}.OpeningDate:{OpeningDate}. Id: {Id}", model.ShopName, model.Adress, model.OpeningDate, model.Id); var element = _shopStorage.GetElement(new ShopSearchModel { ShopName = model.ShopName diff --git a/FishFactoryContracts/BindingModels/ReplenishBindingModel.cs b/FishFactoryContracts/BindingModels/ReplenishBindingModel.cs index f7210d5..f79e120 100644 --- a/FishFactoryContracts/BindingModels/ReplenishBindingModel.cs +++ b/FishFactoryContracts/BindingModels/ReplenishBindingModel.cs @@ -1,12 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using FishFactoryDataModel.Models; namespace FishFactoryContracts.BindingModels { - public class ReplenishBindingModel + public class ReplenishBindingModel : IReplenishModel { public int ShopId { get; set; } public int CannedId { get; set; } diff --git a/FishFactoryContracts/BindingModels/ShopBindingModel.cs b/FishFactoryContracts/BindingModels/ShopBindingModel.cs index 7183ee7..d89fa75 100644 --- a/FishFactoryContracts/BindingModels/ShopBindingModel.cs +++ b/FishFactoryContracts/BindingModels/ShopBindingModel.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using FishFactoryDataModel.Models; +using FishFactoryDataModel.Models; namespace FishFactoryContracts.BindingModels { - public class ShopBindingModel + public class ShopBindingModel : IShopModel { public int Id { get; set; } public string ShopName { get; set; } = string.Empty; diff --git a/FishFactoryContracts/SearchModels/OrderSearchModel.cs b/FishFactoryContracts/SearchModels/OrderSearchModel.cs index 895b7e1..4d57da6 100644 --- a/FishFactoryContracts/SearchModels/OrderSearchModel.cs +++ b/FishFactoryContracts/SearchModels/OrderSearchModel.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FishFactoryContracts.SearchModels +namespace FishFactoryContracts.SearchModels { public class OrderSearchModel { diff --git a/FishFactoryContracts/ViewModels/ShopViewModel.cs b/FishFactoryContracts/ViewModels/ShopViewModel.cs index bd93234..49058c7 100644 --- a/FishFactoryContracts/ViewModels/ShopViewModel.cs +++ b/FishFactoryContracts/ViewModels/ShopViewModel.cs @@ -18,6 +18,5 @@ namespace FishFactoryContracts.ViewModels [DisplayName("Дата открытия")] public DateTime OpeningDate { get; set; } public Dictionary ShopCanneds { get; set; } = new(); - } } diff --git a/FishFactoryDataModels/Models/IReplenishModel.cs b/FishFactoryDataModels/Models/IReplenishModel.cs new file mode 100644 index 0000000..ad1976d --- /dev/null +++ b/FishFactoryDataModels/Models/IReplenishModel.cs @@ -0,0 +1,9 @@ +namespace FishFactoryDataModel.Models +{ + public interface IReplenishModel + { + int ShopId { get; } + int CannedId { get; } + int Count { get; } + } +} diff --git a/FishFactoryDataModels/Models/IShopCannedModel.cs b/FishFactoryDataModels/Models/IShopCannedModel.cs deleted file mode 100644 index aa84a61..0000000 --- a/FishFactoryDataModels/Models/IShopCannedModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FishFactoryDataModel.Models -{ - public interface IShopCannedModel - { - int ShopId { get; } - int CannedId { get; } - int Count { get; } - } -} diff --git a/FishFactoryDataModels/Models/IShopModel.cs b/FishFactoryDataModels/Models/IShopModel.cs index 1389ba6..eb7381f 100644 --- a/FishFactoryDataModels/Models/IShopModel.cs +++ b/FishFactoryDataModels/Models/IShopModel.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FishFactoryDataModel.Models +namespace FishFactoryDataModel.Models { public interface IShopModel : IId { diff --git a/FishFactoryListImplement/Implements/ShopStorage.cs b/FishFactoryListImplement/Implements/ShopStorage.cs index 9b19e79..50007f7 100644 --- a/FishFactoryListImplement/Implements/ShopStorage.cs +++ b/FishFactoryListImplement/Implements/ShopStorage.cs @@ -3,11 +3,6 @@ using FishFactoryContracts.SearchModels; using FishFactoryContracts.StoragesContracts; using FishFactoryContracts.ViewModels; using FishFactoryListImplement.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FishFactoryListImplement.Implements { @@ -30,13 +25,13 @@ namespace FishFactoryListImplement.Implements public List GetFilteredList(ShopSearchModel model) { var result = new List(); - if (model == null || !model.Id.HasValue) + if (string.IsNullOrEmpty(model.ShopName)) { return result; } foreach (var shop in _source.Shops) { - if (shop.Id == model.Id) + if (shop.ShopName.Contains(model.ShopName)) { result.Add(shop.GetViewModel); } @@ -45,13 +40,13 @@ namespace FishFactoryListImplement.Implements } public ShopViewModel? GetElement(ShopSearchModel model) { - if (!model.Id.HasValue) + if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue) { return null; } foreach (var shop in _source.Shops) { - if (model.Id.HasValue && shop.Id == model.Id) + if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id)) { return shop.GetViewModel; } diff --git a/FishFactoryListImplement/Models/Shop.cs b/FishFactoryListImplement/Models/Shop.cs index b82b19c..78557b3 100644 --- a/FishFactoryListImplement/Models/Shop.cs +++ b/FishFactoryListImplement/Models/Shop.cs @@ -1,11 +1,6 @@ using FishFactoryContracts.BindingModels; using FishFactoryDataModel.Models; using FishFactoryContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FishFactoryListImplement.Models { -- 2.25.1 From 34338313236d96b177d3146f2d0b1706277e874f Mon Sep 17 00:00:00 2001 From: dex_moth Date: Fri, 15 Mar 2024 18:17:48 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D1=81=D0=BD=D0=B8=D0=BC=D0=B8=20=D1=81=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8F=20=D1=8D=D1=82=D1=83=20=D0=BD=D0=BE?= =?UTF-8?q?=D1=88=D1=83,=20=D0=98=D0=BA=D0=B0=D1=80=20(=D1=81)=20(=D0=B2?= =?UTF-8?q?=D1=81=D1=91=20=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FishFactory/FormCanned.Designer.cs | 52 ++++++++++++++++------------- FishFactory/FormCanneds.Designer.cs | 1 + FishFactory/FormMain.Designer.cs | 23 +++++++------ FishFactory/FormShop.cs | 2 +- FishFactory/FormShops.Designer.cs | 1 + 5 files changed, 43 insertions(+), 36 deletions(-) diff --git a/FishFactory/FormCanned.Designer.cs b/FishFactory/FormCanned.Designer.cs index db5feff..8297f20 100644 --- a/FishFactory/FormCanned.Designer.cs +++ b/FishFactory/FormCanned.Designer.cs @@ -35,14 +35,14 @@ buttonDel = new Button(); buttonRef = new Button(); dataGridView = new DataGridView(); - Number = new DataGridViewTextBoxColumn(); - Component = new DataGridViewTextBoxColumn(); - Count = new DataGridViewTextBoxColumn(); textBoxName = new TextBox(); textBoxPrice = new TextBox(); groupBox1 = new GroupBox(); buttonSave = new Button(); buttonCancel = new Button(); + Number = new DataGridViewTextBoxColumn(); + Component = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); groupBox1.SuspendLayout(); SuspendLayout(); @@ -124,27 +124,6 @@ dataGridView.Size = new Size(627, 443); dataGridView.TabIndex = 4; // - // Number - // - Number.HeaderText = "Номер"; - Number.MinimumWidth = 6; - Number.Name = "Number"; - Number.Width = 60; - // - // Component - // - Component.HeaderText = "Компонент"; - Component.MinimumWidth = 6; - Component.Name = "Component"; - Component.Width = 125; - // - // Count - // - Count.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - Count.HeaderText = "Количество"; - Count.MinimumWidth = 6; - Count.Name = "Count"; - // // textBoxName // textBoxName.Location = new Point(107, 18); @@ -201,6 +180,31 @@ buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += buttonCancel_Click; // + // Number + // + Number.HeaderText = "Номер"; + Number.MinimumWidth = 6; + Number.Name = "Number"; + Number.ReadOnly = true; + Number.Visible = false; + Number.Width = 60; + // + // Component + // + Component.HeaderText = "Компонент"; + Component.MinimumWidth = 6; + Component.Name = "Component"; + Component.ReadOnly = true; + Component.Width = 125; + // + // Count + // + Count.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + Count.HeaderText = "Количество"; + Count.MinimumWidth = 6; + Count.Name = "Count"; + Count.ReadOnly = true; + // // FormCanned // AutoScaleDimensions = new SizeF(8F, 20F); diff --git a/FishFactory/FormCanneds.Designer.cs b/FishFactory/FormCanneds.Designer.cs index 59ee6c4..3ce1fb8 100644 --- a/FishFactory/FormCanneds.Designer.cs +++ b/FishFactory/FormCanneds.Designer.cs @@ -89,6 +89,7 @@ dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 24; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView.Size = new Size(709, 568); dataGridView.TabIndex = 5; // diff --git a/FishFactory/FormMain.Designer.cs b/FishFactory/FormMain.Designer.cs index f76b064..20fcb49 100644 --- a/FishFactory/FormMain.Designer.cs +++ b/FishFactory/FormMain.Designer.cs @@ -40,7 +40,7 @@ buttonIssuedOrder = new Button(); buttonRef = new Button(); dataGridView = new DataGridView(); - toolStripLabelReplenish = new ToolStripLabel(); + toolStripLabelReplenish2 = new ToolStripLabel(); toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -48,7 +48,7 @@ // toolStrip1 // toolStrip1.ImageScalingSize = new Size(20, 20); - toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, toolStripLabelReplenish }); + toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, toolStripLabelReplenish2 }); toolStrip1.Location = new Point(0, 0); toolStrip1.Name = "toolStrip1"; toolStrip1.Size = new Size(1107, 27); @@ -68,21 +68,21 @@ // компонентыToolStripMenuItem // компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(224, 26); + компонентыToolStripMenuItem.Size = new Size(182, 26); компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; // // консервыToolStripMenuItem // консервыToolStripMenuItem.Name = "консервыToolStripMenuItem"; - консервыToolStripMenuItem.Size = new Size(224, 26); + консервыToolStripMenuItem.Size = new Size(182, 26); консервыToolStripMenuItem.Text = "Консервы"; консервыToolStripMenuItem.Click += консервыToolStripMenuItem_Click; // // магазиныToolStripMenuItem // магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; - магазиныToolStripMenuItem.Size = new Size(224, 26); + магазиныToolStripMenuItem.Size = new Size(182, 26); магазиныToolStripMenuItem.Text = "Магазины"; магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click; // @@ -154,12 +154,13 @@ dataGridView.Size = new Size(872, 580); dataGridView.TabIndex = 6; // - // toolStripLabelReplenish + // toolStripLabelReplenish2 // - toolStripLabelReplenish.Name = "toolStripLabelReplenish"; - toolStripLabelReplenish.Size = new Size(168, 24); - toolStripLabelReplenish.Text = "Пополнение магазина"; - toolStripLabelReplenish.Click += toolStripLabelReplenish_Click; + toolStripLabelReplenish2.DisplayStyle = ToolStripItemDisplayStyle.Text; + toolStripLabelReplenish2.Name = "toolStripLabelReplenish2"; + toolStripLabelReplenish2.Size = new Size(168, 24); + toolStripLabelReplenish2.Text = "Пополнение магазина"; + toolStripLabelReplenish2.Click += toolStripLabelReplenish_Click; // // FormMain // @@ -197,6 +198,6 @@ private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem консервыToolStripMenuItem; private ToolStripMenuItem магазиныToolStripMenuItem; - private ToolStripLabel toolStripLabelReplenish; + private ToolStripLabel toolStripLabelReplenish2; } } \ No newline at end of file diff --git a/FishFactory/FormShop.cs b/FishFactory/FormShop.cs index 2793743..c6d705e 100644 --- a/FishFactory/FormShop.cs +++ b/FishFactory/FormShop.cs @@ -61,7 +61,7 @@ namespace FishFactory.Forms dataGridView.Rows.Clear(); foreach (var sr in _shopCanneds) { - dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.CannedName, sr.Value.Item2 }); + dataGridView.Rows.Add(new object[] { sr.Value.Item1.CannedName, sr.Value.Item2}); } } } diff --git a/FishFactory/FormShops.Designer.cs b/FishFactory/FormShops.Designer.cs index 0b6ebdd..7e771a9 100644 --- a/FishFactory/FormShops.Designer.cs +++ b/FishFactory/FormShops.Designer.cs @@ -46,6 +46,7 @@ dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 29; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView.Size = new Size(525, 673); dataGridView.TabIndex = 0; // -- 2.25.1