From fe793c7943bfdb7ea765a92ca621bb0e96805c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=9A=D1=83=D0=BA?= =?UTF-8?q?=D0=BB=D0=B5=D0=B2?= Date: Sun, 7 Apr 2024 17:51:29 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormComponent.Designer.cs | 24 +-- SoftwareInstallation/FormComponent.cs | 10 +- SoftwareInstallation/FormComponent.resx | 2 +- .../FormComponents.Designer.cs | 47 +++-- SoftwareInstallation/FormComponents.cs | 12 +- SoftwareInstallation/FormComponents.resx | 2 +- .../FormCreateOrder.Designer.cs | 34 +-- SoftwareInstallation/FormCreateOrder.cs | 6 +- SoftwareInstallation/FormCreateOrder.resx | 2 +- .../FormCreateSupply.Designer.cs | 143 +++++++++++++ SoftwareInstallation/FormCreateSupply.cs | 99 +++++++++ SoftwareInstallation/FormCreateSupply.resx | 120 +++++++++++ SoftwareInstallation/FormMain.Designer.cs | 93 ++++++--- SoftwareInstallation/FormMain.cs | 22 +- SoftwareInstallation/FormMain.resx | 2 +- SoftwareInstallation/FormPackage.Designer.cs | 132 ++++++------ SoftwareInstallation/FormPackage.cs | 24 +-- SoftwareInstallation/FormPackage.resx | 2 +- .../FormPackageComponent.Designer.cs | 37 ++-- SoftwareInstallation/FormPackageComponent.cs | 4 +- .../FormPackageComponent.resx | 2 +- SoftwareInstallation/FormPackages.Designer.cs | 58 ++++-- SoftwareInstallation/FormPackages.cs | 12 +- SoftwareInstallation/FormPackages.resx | 2 +- SoftwareInstallation/FormShop.Designer.cs | 196 ++++++++++++++++++ SoftwareInstallation/FormShop.cs | 128 ++++++++++++ SoftwareInstallation/FormShop.resx | 120 +++++++++++ SoftwareInstallation/FormShops.Designer.cs | 130 ++++++++++++ SoftwareInstallation/FormShops.cs | 117 +++++++++++ SoftwareInstallation/FormShops.resx | 120 +++++++++++ SoftwareInstallation/Program.cs | 11 +- .../ComponentLogic.cs | 26 ++- .../OrderLogic.cs | 104 ++++------ .../PackageLogic.cs | 30 ++- .../BusinessLogics/ShopLogic.cs | 160 ++++++++++++++ .../BindingModels/ComponentBindingModel.cs | 2 +- .../BindingModels/OrderBindingModel.cs | 4 +- .../BindingModels/PackageBindingModel.cs | 2 +- .../BindingModels/ShopBindingModel.cs | 18 ++ .../BindingModels/SupplyBindingModel.cs | 16 ++ .../IComponentLogic.cs | 1 - .../BusinessLogicsContracts/IOrderLogic.cs | 10 - .../BusinessLogicsContracts/IShopLogic.cs | 21 ++ .../SearchModels/ComponentSearchModel.cs | 2 +- .../SearchModels/OrderSearchModel.cs | 2 +- .../SearchModels/PackageSearchModel.cs | 2 +- .../SearchModels/ShopSearchModel.cs | 14 ++ .../StoragesContracts/IComponentStorage.cs | 1 - .../StoragesContracts/IShopStorage.cs | 21 ++ .../ViewModels/ComponentViewModel.cs | 4 +- .../ViewModels/OrderViewModel.cs | 14 +- .../ViewModels/PackageViewModel.cs | 10 +- .../ViewModels/ShopViewModel.cs | 22 ++ .../Enums/OrderStatus.cs | 10 +- SoftwareInstallationDataModels/IId.cs | 2 +- .../Models/IComponentModel.cs | 8 +- .../Models/IOrderModel.cs | 7 +- .../Models/IPackageModel.cs | 20 +- .../Models/IShopModel.cs | 18 ++ .../Models/ISupplyModel.cs | 15 ++ .../DataListSingleton.cs | 6 +- .../Implements/ComponentStorage.cs | 13 +- .../Implements/OrderStorage.cs | 6 +- .../Implements/PackageStorage.cs | 156 +++++++------- .../Implements/ShopStorage.cs | 113 ++++++++++ .../Models/Component.cs | 10 +- .../Models/Order.cs | 14 +- .../Models/Package.cs | 14 +- .../Models/Shop.cs | 55 +++++ 69 files changed, 2218 insertions(+), 448 deletions(-) create mode 100644 SoftwareInstallation/FormCreateSupply.Designer.cs create mode 100644 SoftwareInstallation/FormCreateSupply.cs create mode 100644 SoftwareInstallation/FormCreateSupply.resx create mode 100644 SoftwareInstallation/FormShop.Designer.cs create mode 100644 SoftwareInstallation/FormShop.cs create mode 100644 SoftwareInstallation/FormShop.resx create mode 100644 SoftwareInstallation/FormShops.Designer.cs create mode 100644 SoftwareInstallation/FormShops.cs create mode 100644 SoftwareInstallation/FormShops.resx rename SoftwareInstallationBusinessLogic/{BusinessLogic => BusinessLogics}/ComponentLogic.cs (87%) rename SoftwareInstallationBusinessLogic/{BusinessLogic => BusinessLogics}/OrderLogic.cs (60%) rename SoftwareInstallationBusinessLogic/{BusinessLogic => BusinessLogics}/PackageLogic.cs (79%) create mode 100644 SoftwareInstallationBusinessLogic/BusinessLogics/ShopLogic.cs create mode 100644 SoftwareInstallationContracts/BindingModels/ShopBindingModel.cs create mode 100644 SoftwareInstallationContracts/BindingModels/SupplyBindingModel.cs create mode 100644 SoftwareInstallationContracts/BusinessLogicsContracts/IShopLogic.cs create mode 100644 SoftwareInstallationContracts/SearchModels/ShopSearchModel.cs create mode 100644 SoftwareInstallationContracts/StoragesContracts/IShopStorage.cs create mode 100644 SoftwareInstallationContracts/ViewModels/ShopViewModel.cs create mode 100644 SoftwareInstallationDataModels/Models/IShopModel.cs create mode 100644 SoftwareInstallationDataModels/Models/ISupplyModel.cs create mode 100644 SoftwareInstallationListImplement/Implements/ShopStorage.cs create mode 100644 SoftwareInstallationListImplement/Models/Shop.cs diff --git a/SoftwareInstallation/FormComponent.Designer.cs b/SoftwareInstallation/FormComponent.Designer.cs index 9f6e489..f727627 100644 --- a/SoftwareInstallation/FormComponent.Designer.cs +++ b/SoftwareInstallation/FormComponent.Designer.cs @@ -1,4 +1,4 @@ -namespace SoftwareInstallationView +namespace PizzeriaView { partial class FormComponent { @@ -39,7 +39,7 @@ // labelName // labelName.AutoSize = true; - labelName.Location = new Point(21, 22); + labelName.Location = new Point(10, 7); labelName.Name = "labelName"; labelName.Size = new Size(62, 15); labelName.TabIndex = 0; @@ -47,24 +47,24 @@ // // textBoxName // - textBoxName.Location = new Point(103, 20); + textBoxName.Location = new Point(86, 7); textBoxName.Margin = new Padding(3, 2, 3, 2); textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(267, 23); + textBoxName.Size = new Size(321, 23); textBoxName.TabIndex = 1; // // textBoxCost // - textBoxCost.Location = new Point(103, 49); + textBoxCost.Location = new Point(86, 32); textBoxCost.Margin = new Padding(3, 2, 3, 2); textBoxCost.Name = "textBoxCost"; - textBoxCost.Size = new Size(163, 23); + textBoxCost.Size = new Size(117, 23); textBoxCost.TabIndex = 3; // // labelCost // labelCost.AutoSize = true; - labelCost.Location = new Point(21, 52); + labelCost.Location = new Point(10, 32); labelCost.Name = "labelCost"; labelCost.Size = new Size(35, 15); labelCost.TabIndex = 2; @@ -72,10 +72,10 @@ // // buttonSave // - buttonSave.Location = new Point(190, 89); + buttonSave.Location = new Point(150, 68); buttonSave.Margin = new Padding(3, 2, 3, 2); buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(86, 26); + buttonSave.Size = new Size(114, 30); buttonSave.TabIndex = 4; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; @@ -83,10 +83,10 @@ // // buttonCancel // - buttonCancel.Location = new Point(284, 89); + buttonCancel.Location = new Point(287, 68); buttonCancel.Margin = new Padding(3, 2, 3, 2); buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(86, 26); + buttonCancel.Size = new Size(119, 30); buttonCancel.TabIndex = 5; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; @@ -96,7 +96,7 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(404, 130); + ClientSize = new Size(418, 106); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(textBoxCost); diff --git a/SoftwareInstallation/FormComponent.cs b/SoftwareInstallation/FormComponent.cs index c62d9d5..a42680f 100644 --- a/SoftwareInstallation/FormComponent.cs +++ b/SoftwareInstallation/FormComponent.cs @@ -12,7 +12,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace SoftwareInstallationView +namespace PizzeriaView { public partial class FormComponent : Form { @@ -34,7 +34,7 @@ namespace SoftwareInstallationView { try { - _logger.LogInformation("Получение ингридиента"); + _logger.LogInformation("Получение компонента"); var view = _logic.ReadElement(new ComponentSearchModel { Id = _id.Value @@ -47,7 +47,7 @@ namespace SoftwareInstallationView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения ингридиента"); + _logger.LogError(ex, "Ошибка получения компонента"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -60,7 +60,7 @@ namespace SoftwareInstallationView MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - _logger.LogInformation("Сохранение ингридиента"); + _logger.LogInformation("Сохранение компонента"); try { var model = new ComponentBindingModel @@ -80,7 +80,7 @@ namespace SoftwareInstallationView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка сохранения ингридиента"); + _logger.LogError(ex, "Ошибка сохранения компонента"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/SoftwareInstallation/FormComponent.resx b/SoftwareInstallation/FormComponent.resx index af32865..a395bff 100644 --- a/SoftwareInstallation/FormComponent.resx +++ b/SoftwareInstallation/FormComponent.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/SoftwareInstallation/FormComponents.Designer.cs b/SoftwareInstallation/FormComponents.Designer.cs index b0ebeec..4f59470 100644 --- a/SoftwareInstallation/FormComponents.Designer.cs +++ b/SoftwareInstallation/FormComponents.Designer.cs @@ -1,4 +1,4 @@ -namespace SoftwareInstallationView +namespace PizzeriaView { partial class FormComponents { @@ -29,11 +29,13 @@ private void InitializeComponent() { dataGridView = new DataGridView(); + ToolsPanel = new Panel(); buttonUpdate = new Button(); buttonDelete = new Button(); buttonEdit = new Button(); buttonAdd = new Button(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ToolsPanel.SuspendLayout(); SuspendLayout(); // // dataGridView @@ -41,21 +43,33 @@ dataGridView.AllowUserToAddRows = false; dataGridView.AllowUserToDeleteRows = false; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(-1, -2); + dataGridView.Location = new Point(10, 9); dataGridView.Margin = new Padding(3, 2, 3, 2); dataGridView.Name = "dataGridView"; dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(437, 426); + dataGridView.Size = new Size(516, 320); dataGridView.TabIndex = 0; // + // ToolsPanel + // + ToolsPanel.Controls.Add(buttonUpdate); + ToolsPanel.Controls.Add(buttonDelete); + ToolsPanel.Controls.Add(buttonEdit); + ToolsPanel.Controls.Add(buttonAdd); + ToolsPanel.Location = new Point(532, 9); + ToolsPanel.Margin = new Padding(3, 2, 3, 2); + ToolsPanel.Name = "ToolsPanel"; + ToolsPanel.Size = new Size(158, 320); + ToolsPanel.TabIndex = 1; + // // buttonUpdate // - buttonUpdate.Location = new Point(459, 151); + buttonUpdate.Location = new Point(27, 154); buttonUpdate.Margin = new Padding(3, 2, 3, 2); buttonUpdate.Name = "buttonUpdate"; - buttonUpdate.Size = new Size(109, 26); + buttonUpdate.Size = new Size(110, 27); buttonUpdate.TabIndex = 3; buttonUpdate.Text = "Обновить"; buttonUpdate.UseVisualStyleBackColor = true; @@ -63,10 +77,10 @@ // // buttonDelete // - buttonDelete.Location = new Point(459, 112); + buttonDelete.Location = new Point(27, 106); buttonDelete.Margin = new Padding(3, 2, 3, 2); buttonDelete.Name = "buttonDelete"; - buttonDelete.Size = new Size(109, 26); + buttonDelete.Size = new Size(110, 27); buttonDelete.TabIndex = 2; buttonDelete.Text = "Удалить"; buttonDelete.UseVisualStyleBackColor = true; @@ -74,10 +88,10 @@ // // buttonEdit // - buttonEdit.Location = new Point(459, 74); + buttonEdit.Location = new Point(27, 57); buttonEdit.Margin = new Padding(3, 2, 3, 2); buttonEdit.Name = "buttonEdit"; - buttonEdit.Size = new Size(109, 26); + buttonEdit.Size = new Size(110, 27); buttonEdit.TabIndex = 1; buttonEdit.Text = "Изменить"; buttonEdit.UseVisualStyleBackColor = true; @@ -85,10 +99,10 @@ // // buttonAdd // - buttonAdd.Location = new Point(459, 36); + buttonAdd.Location = new Point(27, 12); buttonAdd.Margin = new Padding(3, 2, 3, 2); buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(109, 26); + buttonAdd.Size = new Size(110, 27); buttonAdd.TabIndex = 0; buttonAdd.Text = "Добавить"; buttonAdd.UseVisualStyleBackColor = true; @@ -98,23 +112,22 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(592, 422); - Controls.Add(buttonUpdate); - Controls.Add(buttonDelete); + ClientSize = new Size(700, 338); + Controls.Add(ToolsPanel); Controls.Add(dataGridView); - Controls.Add(buttonEdit); - Controls.Add(buttonAdd); Margin = new Padding(3, 2, 3, 2); Name = "FormComponents"; - Text = "Список компонентов"; + Text = "Компоненты"; Load += FormComponents_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ToolsPanel.ResumeLayout(false); ResumeLayout(false); } #endregion private DataGridView dataGridView; + private Panel ToolsPanel; private Button buttonUpdate; private Button buttonDelete; private Button buttonEdit; diff --git a/SoftwareInstallation/FormComponents.cs b/SoftwareInstallation/FormComponents.cs index ad09b43..c85923c 100644 --- a/SoftwareInstallation/FormComponents.cs +++ b/SoftwareInstallation/FormComponents.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.Logging; -using SoftwareInstallation; +using Pizzeria; using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.BusinessLogicsContracts; -namespace SoftwareInstallationView +namespace PizzeriaView { public partial class FormComponents : Form { @@ -34,11 +34,11 @@ namespace SoftwareInstallationView dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } - _logger.LogInformation("Загрузка ингридиентов"); + _logger.LogInformation("Загрузка компонентов"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки ингридиентов"); + _logger.LogError(ex, "Ошибка загрузки компонентов"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -82,7 +82,7 @@ namespace SoftwareInstallationView { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Удаление ингридиента"); + _logger.LogInformation("Удаление компонента"); try { if (!_logic.Delete(new ComponentBindingModel @@ -96,7 +96,7 @@ namespace SoftwareInstallationView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка удаления ингридиента"); + _logger.LogError(ex, "Ошибка удаления компонента"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } diff --git a/SoftwareInstallation/FormComponents.resx b/SoftwareInstallation/FormComponents.resx index af32865..a395bff 100644 --- a/SoftwareInstallation/FormComponents.resx +++ b/SoftwareInstallation/FormComponents.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/SoftwareInstallation/FormCreateOrder.Designer.cs b/SoftwareInstallation/FormCreateOrder.Designer.cs index 3b8cb40..08c021f 100644 --- a/SoftwareInstallation/FormCreateOrder.Designer.cs +++ b/SoftwareInstallation/FormCreateOrder.Designer.cs @@ -1,4 +1,4 @@ -namespace SoftwareInstallationView +namespace PizzeriaView { partial class FormCreateOrder { @@ -41,26 +41,26 @@ // labelPackage // labelPackage.AutoSize = true; - labelPackage.Location = new Point(19, 12); + labelPackage.Location = new Point(10, 11); labelPackage.Name = "labelPackage"; - labelPackage.Size = new Size(56, 15); + labelPackage.Size = new Size(39, 15); labelPackage.TabIndex = 0; - labelPackage.Text = "Изделие:"; + labelPackage.Text = "Пакет"; // // comboBoxPackage // comboBoxPackage.FormattingEnabled = true; - comboBoxPackage.Location = new Point(103, 10); + comboBoxPackage.Location = new Point(101, 9); comboBoxPackage.Margin = new Padding(3, 2, 3, 2); comboBoxPackage.Name = "comboBoxPackage"; - comboBoxPackage.Size = new Size(246, 23); + comboBoxPackage.Size = new Size(314, 23); comboBoxPackage.TabIndex = 1; comboBoxPackage.SelectedIndexChanged += ComboBoxPackage_SelectedIndexChanged; // // labelCount // labelCount.AutoSize = true; - labelCount.Location = new Point(19, 44); + labelCount.Location = new Point(10, 37); labelCount.Name = "labelCount"; labelCount.Size = new Size(78, 15); labelCount.TabIndex = 2; @@ -68,17 +68,17 @@ // // textBoxCount // - textBoxCount.Location = new Point(103, 41); + textBoxCount.Location = new Point(101, 34); textBoxCount.Margin = new Padding(3, 2, 3, 2); textBoxCount.Name = "textBoxCount"; - textBoxCount.Size = new Size(246, 23); + textBoxCount.Size = new Size(314, 23); textBoxCount.TabIndex = 3; textBoxCount.TextChanged += TextBoxCount_TextChanged; // // labelSum // labelSum.AutoSize = true; - labelSum.Location = new Point(19, 70); + labelSum.Location = new Point(10, 60); labelSum.Name = "labelSum"; labelSum.Size = new Size(51, 15); labelSum.TabIndex = 4; @@ -86,19 +86,19 @@ // // textBoxSum // - textBoxSum.Location = new Point(103, 70); + textBoxSum.Location = new Point(101, 60); textBoxSum.Margin = new Padding(3, 2, 3, 2); textBoxSum.Name = "textBoxSum"; textBoxSum.ReadOnly = true; - textBoxSum.Size = new Size(246, 23); + textBoxSum.Size = new Size(314, 23); textBoxSum.TabIndex = 5; // // buttonCancel // - buttonCancel.Location = new Point(249, 101); + buttonCancel.Location = new Point(295, 85); buttonCancel.Margin = new Padding(3, 2, 3, 2); buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(94, 26); + buttonCancel.Size = new Size(96, 24); buttonCancel.TabIndex = 6; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; @@ -106,10 +106,10 @@ // // buttonSave // - buttonSave.Location = new Point(150, 101); + buttonSave.Location = new Point(193, 85); buttonSave.Margin = new Padding(3, 2, 3, 2); buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(94, 26); + buttonSave.Size = new Size(96, 24); buttonSave.TabIndex = 7; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; @@ -119,7 +119,7 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(374, 136); + ClientSize = new Size(424, 118); Controls.Add(buttonSave); Controls.Add(buttonCancel); Controls.Add(textBoxSum); diff --git a/SoftwareInstallation/FormCreateOrder.cs b/SoftwareInstallation/FormCreateOrder.cs index c44aed2..19fb972 100644 --- a/SoftwareInstallation/FormCreateOrder.cs +++ b/SoftwareInstallation/FormCreateOrder.cs @@ -13,7 +13,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace SoftwareInstallationView +namespace PizzeriaView { public partial class FormCreateOrder : Form { @@ -39,7 +39,7 @@ namespace SoftwareInstallationView comboBoxPackage.ValueMember = "Id"; comboBoxPackage.DataSource = _list; comboBoxPackage.SelectedItem = null; - _logger.LogInformation("Загрузка пиццы для заказа"); + _logger.LogInformation("Загрузка пакета для заказа"); } } @@ -85,7 +85,7 @@ namespace SoftwareInstallationView } if (comboBoxPackage.SelectedValue == null) { - MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Выберите пакет", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _logger.LogInformation("Создание заказа"); diff --git a/SoftwareInstallation/FormCreateOrder.resx b/SoftwareInstallation/FormCreateOrder.resx index af32865..a395bff 100644 --- a/SoftwareInstallation/FormCreateOrder.resx +++ b/SoftwareInstallation/FormCreateOrder.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/SoftwareInstallation/FormCreateSupply.Designer.cs b/SoftwareInstallation/FormCreateSupply.Designer.cs new file mode 100644 index 0000000..2bf6c39 --- /dev/null +++ b/SoftwareInstallation/FormCreateSupply.Designer.cs @@ -0,0 +1,143 @@ +namespace PizzeriaView +{ + 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.comboBoxShop = new System.Windows.Forms.ComboBox(); + this.labelShop = new System.Windows.Forms.Label(); + this.labelPackage = new System.Windows.Forms.Label(); + this.comboBoxPackage = new System.Windows.Forms.ComboBox(); + this.labelCount = new System.Windows.Forms.Label(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // comboBoxShop + // + this.comboBoxShop.FormattingEnabled = true; + this.comboBoxShop.Location = new System.Drawing.Point(115, 12); + this.comboBoxShop.Name = "comboBoxShop"; + this.comboBoxShop.Size = new System.Drawing.Size(344, 28); + this.comboBoxShop.TabIndex = 0; + // + // labelShop + // + this.labelShop.AutoSize = true; + this.labelShop.Location = new System.Drawing.Point(12, 15); + this.labelShop.Name = "labelShop"; + this.labelShop.Size = new System.Drawing.Size(76, 20); + this.labelShop.TabIndex = 1; + this.labelShop.Text = "Магазин: "; + // + // labelPackage + // + this.labelPackage.AutoSize = true; + this.labelPackage.Location = new System.Drawing.Point(12, 49); + this.labelPackage.Name = "labelPackage"; + this.labelPackage.Size = new System.Drawing.Size(75, 20); + this.labelPackage.TabIndex = 2; + this.labelPackage.Text = "Изделие: "; + // + // comboBoxPackage + // + this.comboBoxPackage.FormattingEnabled = true; + this.comboBoxPackage.Location = new System.Drawing.Point(115, 46); + this.comboBoxPackage.Name = "comboBoxPackage"; + this.comboBoxPackage.Size = new System.Drawing.Size(344, 28); + this.comboBoxPackage.TabIndex = 3; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(12, 83); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(97, 20); + this.labelCount.TabIndex = 4; + this.labelCount.Text = "Количество: "; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(115, 80); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(344, 27); + this.textBoxCount.TabIndex = 5; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(300, 113); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(116, 39); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(168, 113); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(116, 39); + this.buttonSave.TabIndex = 7; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // FormCreateSupply + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(471, 164); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.comboBoxPackage); + this.Controls.Add(this.labelPackage); + this.Controls.Add(this.labelShop); + this.Controls.Add(this.comboBoxShop); + this.Name = "FormCreateSupply"; + this.Text = "Создание поставки"; + this.Load += new System.EventHandler(this.FormCreateSupply_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private ComboBox comboBoxShop; + private Label labelShop; + private Label labelPackage; + private ComboBox comboBoxPackage; + private Label labelCount; + private TextBox textBoxCount; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/FormCreateSupply.cs b/SoftwareInstallation/FormCreateSupply.cs new file mode 100644 index 0000000..34ab37e --- /dev/null +++ b/SoftwareInstallation/FormCreateSupply.cs @@ -0,0 +1,99 @@ +using Microsoft.Extensions.Logging; +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.ViewModels; +using System; +using System.Collections; +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 static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace PizzeriaView +{ + public partial class FormCreateSupply : Form + { + private readonly ILogger _logger; + private readonly IPackageLogic _logicP; + private readonly IShopLogic _logicS; + private List _shopList = new List(); + private List _packageList = new List(); + + public FormCreateSupply(ILogger logger, IPackageLogic logicP, IShopLogic logicS) + { + InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicS = logicS; + } + + private void FormCreateSupply_Load(object sender, EventArgs e) + { + _shopList = _logicS.ReadList(null); + _packageList = _logicP.ReadList(null); + if (_shopList != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = _shopList; + comboBoxShop.SelectedItem = null; + _logger.LogInformation("Загрузка магазинов для поставок"); + } + if (_packageList != null) + { + comboBoxPackage.DisplayMember = "PackageName"; + comboBoxPackage.ValueMember = "Id"; + comboBoxPackage.DataSource = _packageList; + comboBoxPackage.SelectedItem = null; + _logger.LogInformation("Загрузка пакетов для поставок"); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxPackage.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание поставки"); + try + { + var operationResult = _logicS.MakeSupply(new SupplyBindingModel + { + ShopId = Convert.ToInt32(comboBoxShop.SelectedValue), + PackageId = Convert.ToInt32(comboBoxPackage.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/SoftwareInstallation/FormCreateSupply.resx b/SoftwareInstallation/FormCreateSupply.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SoftwareInstallation/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/SoftwareInstallation/FormMain.Designer.cs b/SoftwareInstallation/FormMain.Designer.cs index 2bb45a9..4b75f74 100644 --- a/SoftwareInstallation/FormMain.Designer.cs +++ b/SoftwareInstallation/FormMain.Designer.cs @@ -1,4 +1,4 @@ -namespace SoftwareInstallationView +namespace PizzeriaView { partial class FormMain { @@ -30,8 +30,10 @@ { menuStrip1 = new MenuStrip(); bookToolStripMenuItem = new ToolStripMenuItem(); - компонентыToolStripMenuItem = new ToolStripMenuItem(); - pizzasToolStripMenuItem = new ToolStripMenuItem(); + ingridientsToolStripMenuItem = new ToolStripMenuItem(); + packagesToolStripMenuItem = new ToolStripMenuItem(); + shopsToolStripMenuItem = new ToolStripMenuItem(); + transactionToolStripMenuItem = new ToolStripMenuItem(); dataGridView = new DataGridView(); buttonCreateOrder = new Button(); buttonTakeOrderInWork = new Button(); @@ -48,49 +50,65 @@ menuStrip1.Items.AddRange(new ToolStripItem[] { bookToolStripMenuItem }); menuStrip1.Location = new Point(0, 0); menuStrip1.Name = "menuStrip1"; - menuStrip1.Padding = new Padding(6, 3, 0, 3); - menuStrip1.Size = new Size(1107, 30); + menuStrip1.Padding = new Padding(5, 2, 0, 2); + menuStrip1.Size = new Size(1149, 24); menuStrip1.TabIndex = 0; menuStrip1.Text = "menuStrip1"; // // bookToolStripMenuItem // - bookToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, pizzasToolStripMenuItem }); + bookToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ingridientsToolStripMenuItem, packagesToolStripMenuItem, shopsToolStripMenuItem, transactionToolStripMenuItem }); bookToolStripMenuItem.Name = "bookToolStripMenuItem"; - bookToolStripMenuItem.Size = new Size(108, 24); + bookToolStripMenuItem.Size = new Size(87, 20); bookToolStripMenuItem.Text = "Справочник"; // - // компонентыToolStripMenuItem + // ingridientsToolStripMenuItem // - компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(224, 26); - компонентыToolStripMenuItem.Text = "Компоненты"; - компонентыToolStripMenuItem.Click += IngridentsToolStripMenuItem_Click; + ingridientsToolStripMenuItem.Name = "ingridientsToolStripMenuItem"; + ingridientsToolStripMenuItem.Size = new Size(180, 22); + ingridientsToolStripMenuItem.Text = "Компоненты"; + ingridientsToolStripMenuItem.Click += IngridentsToolStripMenuItem_Click; // - // pizzasToolStripMenuItem + // packagesToolStripMenuItem // - pizzasToolStripMenuItem.Name = "pizzasToolStripMenuItem"; - pizzasToolStripMenuItem.Size = new Size(224, 26); - pizzasToolStripMenuItem.Text = "ПО"; - pizzasToolStripMenuItem.Click += PackagesToolStripMenuItem_Click; + packagesToolStripMenuItem.Name = "packagesToolStripMenuItem"; + packagesToolStripMenuItem.Size = new Size(180, 22); + packagesToolStripMenuItem.Text = "Пакеты"; + packagesToolStripMenuItem.Click += PackagesToolStripMenuItem_Click; + // + // shopsToolStripMenuItem + // + shopsToolStripMenuItem.Name = "shopsToolStripMenuItem"; + shopsToolStripMenuItem.Size = new Size(180, 22); + shopsToolStripMenuItem.Text = "Магазины"; + shopsToolStripMenuItem.Click += shopsToolStripMenuItem_Click; + // + // transactionToolStripMenuItem + // + transactionToolStripMenuItem.Name = "transactionToolStripMenuItem"; + transactionToolStripMenuItem.Size = new Size(180, 22); + transactionToolStripMenuItem.Text = "Поставки"; + transactionToolStripMenuItem.Click += transactionToolStripMenuItem_Click; // // dataGridView // dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 35); + dataGridView.Location = new Point(10, 23); + dataGridView.Margin = new Padding(3, 2, 3, 2); dataGridView.Name = "dataGridView"; dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 29; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(872, 580); + dataGridView.Size = new Size(855, 286); dataGridView.TabIndex = 1; // // buttonCreateOrder // - buttonCreateOrder.Location = new Point(914, 75); + buttonCreateOrder.Location = new Point(898, 53); + buttonCreateOrder.Margin = new Padding(3, 2, 3, 2); buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(161, 32); + buttonCreateOrder.Size = new Size(216, 22); buttonCreateOrder.TabIndex = 2; buttonCreateOrder.Text = "Создать заказ"; buttonCreateOrder.UseVisualStyleBackColor = true; @@ -98,9 +116,10 @@ // // buttonTakeOrderInWork // - buttonTakeOrderInWork.Location = new Point(914, 133); + buttonTakeOrderInWork.Location = new Point(898, 92); + buttonTakeOrderInWork.Margin = new Padding(3, 2, 3, 2); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(161, 32); + buttonTakeOrderInWork.Size = new Size(216, 22); buttonTakeOrderInWork.TabIndex = 3; buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonTakeOrderInWork.UseVisualStyleBackColor = true; @@ -108,9 +127,10 @@ // // buttonOrderReady // - buttonOrderReady.Location = new Point(914, 189); + buttonOrderReady.Location = new Point(898, 129); + buttonOrderReady.Margin = new Padding(3, 2, 3, 2); buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(161, 32); + buttonOrderReady.Size = new Size(216, 22); buttonOrderReady.TabIndex = 4; buttonOrderReady.Text = "Заказ готов"; buttonOrderReady.UseVisualStyleBackColor = true; @@ -118,9 +138,10 @@ // // buttonIssuedOrder // - buttonIssuedOrder.Location = new Point(914, 241); + buttonIssuedOrder.Location = new Point(898, 169); + buttonIssuedOrder.Margin = new Padding(3, 2, 3, 2); buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(161, 32); + buttonIssuedOrder.Size = new Size(216, 22); buttonIssuedOrder.TabIndex = 5; buttonIssuedOrder.Text = "Заказ выдан"; buttonIssuedOrder.UseVisualStyleBackColor = true; @@ -128,9 +149,10 @@ // // buttonRef // - buttonRef.Location = new Point(914, 296); + buttonRef.Location = new Point(898, 210); + buttonRef.Margin = new Padding(3, 2, 3, 2); buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(161, 32); + buttonRef.Size = new Size(216, 22); buttonRef.TabIndex = 6; buttonRef.Text = "Обновить список"; buttonRef.UseVisualStyleBackColor = true; @@ -138,9 +160,9 @@ // // FormMain // - AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1107, 615); + ClientSize = new Size(1149, 319); Controls.Add(buttonRef); Controls.Add(buttonIssuedOrder); Controls.Add(buttonOrderReady); @@ -149,8 +171,9 @@ Controls.Add(dataGridView); Controls.Add(menuStrip1); MainMenuStrip = menuStrip1; + Margin = new Padding(3, 2, 3, 2); Name = "FormMain"; - Text = "ПО"; + Text = "Уставновка ПО"; Load += FormMain_Load; menuStrip1.ResumeLayout(false); menuStrip1.PerformLayout(); @@ -163,13 +186,15 @@ private MenuStrip menuStrip1; private ToolStripMenuItem bookToolStripMenuItem; - private ToolStripMenuItem компонентыToolStripMenuItem; - private ToolStripMenuItem pizzasToolStripMenuItem; + private ToolStripMenuItem ingridientsToolStripMenuItem; + private ToolStripMenuItem packagesToolStripMenuItem; private DataGridView dataGridView; private Button buttonCreateOrder; private Button buttonTakeOrderInWork; private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonRef; + private ToolStripMenuItem shopsToolStripMenuItem; + private ToolStripMenuItem transactionToolStripMenuItem; } } \ No newline at end of file diff --git a/SoftwareInstallation/FormMain.cs b/SoftwareInstallation/FormMain.cs index 28564b1..8005060 100644 --- a/SoftwareInstallation/FormMain.cs +++ b/SoftwareInstallation/FormMain.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.Logging; -using SoftwareInstallation; +using Pizzeria; using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.BusinessLogicsContracts; -namespace SoftwareInstallationView +namespace PizzeriaView { public partial class FormMain : Form { @@ -154,5 +154,23 @@ namespace SoftwareInstallationView { LoadData(); } + + private void shopsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) + { + form.ShowDialog(); + } + } + + private void transactionToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply)); + if (service is FormCreateSupply form) + { + form.ShowDialog(); + } + } } } diff --git a/SoftwareInstallation/FormMain.resx b/SoftwareInstallation/FormMain.resx index a0623c8..5203d24 100644 --- a/SoftwareInstallation/FormMain.resx +++ b/SoftwareInstallation/FormMain.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/SoftwareInstallation/FormPackage.Designer.cs b/SoftwareInstallation/FormPackage.Designer.cs index 2971c3f..1d79765 100644 --- a/SoftwareInstallation/FormPackage.Designer.cs +++ b/SoftwareInstallation/FormPackage.Designer.cs @@ -1,4 +1,4 @@ -namespace SoftwareInstallationView +namespace PizzeriaView { partial class FormPackage { @@ -38,11 +38,11 @@ buttonUpd = new Button(); buttonAdd = new Button(); dataGridView = new DataGridView(); - Number = new DataGridViewTextBoxColumn(); - Component = new DataGridViewTextBoxColumn(); - Count = new DataGridViewTextBoxColumn(); buttonCancel = new Button(); buttonSave = new Button(); + id = new DataGridViewTextBoxColumn(); + Component = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); groupBoxComponents.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -50,36 +50,37 @@ // labelName // labelName.AutoSize = true; - labelName.Location = new Point(18, 20); + labelName.Location = new Point(14, 11); labelName.Name = "labelName"; - labelName.Size = new Size(84, 20); + labelName.Size = new Size(65, 15); labelName.TabIndex = 0; labelName.Text = "Название: "; // // textBoxName // - textBoxName.Location = new Point(107, 19); + textBoxName.Location = new Point(98, 9); + textBoxName.Margin = new Padding(3, 2, 3, 2); textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(281, 27); + textBoxName.Size = new Size(257, 23); textBoxName.TabIndex = 1; // // labelPrice // labelPrice.AutoSize = true; - labelPrice.Location = new Point(18, 55); + labelPrice.Location = new Point(14, 38); labelPrice.Name = "labelPrice"; - labelPrice.Size = new Size(90, 20); + labelPrice.Size = new Size(73, 15); labelPrice.TabIndex = 2; labelPrice.Text = "Стоимость: "; // // textBoxPrice // - textBoxPrice.Location = new Point(107, 52); + textBoxPrice.Location = new Point(98, 38); + textBoxPrice.Margin = new Padding(3, 2, 3, 2); textBoxPrice.Name = "textBoxPrice"; textBoxPrice.ReadOnly = true; - textBoxPrice.Size = new Size(97, 27); + textBoxPrice.Size = new Size(150, 23); textBoxPrice.TabIndex = 3; - textBoxPrice.TabStop = false; // // groupBoxComponents // @@ -88,18 +89,21 @@ groupBoxComponents.Controls.Add(buttonUpd); groupBoxComponents.Controls.Add(buttonAdd); groupBoxComponents.Controls.Add(dataGridView); - groupBoxComponents.Location = new Point(16, 95); + groupBoxComponents.Location = new Point(10, 63); + groupBoxComponents.Margin = new Padding(3, 2, 3, 2); groupBoxComponents.Name = "groupBoxComponents"; - groupBoxComponents.Size = new Size(787, 489); + groupBoxComponents.Padding = new Padding(3, 2, 3, 2); + groupBoxComponents.Size = new Size(578, 239); groupBoxComponents.TabIndex = 4; groupBoxComponents.TabStop = false; - groupBoxComponents.Text = "Компоненты"; + groupBoxComponents.Text = "Ингредиенты"; // // buttonRef // - buttonRef.Location = new Point(656, 231); + buttonRef.Location = new Point(439, 158); + buttonRef.Margin = new Padding(3, 2, 3, 2); buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(111, 37); + buttonRef.Size = new Size(110, 26); buttonRef.TabIndex = 4; buttonRef.Text = "Обновить"; buttonRef.UseVisualStyleBackColor = true; @@ -107,9 +111,10 @@ // // buttonDel // - buttonDel.Location = new Point(656, 179); + buttonDel.Location = new Point(439, 118); + buttonDel.Margin = new Padding(3, 2, 3, 2); buttonDel.Name = "buttonDel"; - buttonDel.Size = new Size(111, 37); + buttonDel.Size = new Size(110, 26); buttonDel.TabIndex = 3; buttonDel.Text = "Удалить"; buttonDel.UseVisualStyleBackColor = true; @@ -117,9 +122,10 @@ // // buttonUpd // - buttonUpd.Location = new Point(656, 120); + buttonUpd.Location = new Point(439, 76); + buttonUpd.Margin = new Padding(3, 2, 3, 2); buttonUpd.Name = "buttonUpd"; - buttonUpd.Size = new Size(111, 37); + buttonUpd.Size = new Size(110, 26); buttonUpd.TabIndex = 2; buttonUpd.Text = "Изменить"; buttonUpd.UseVisualStyleBackColor = true; @@ -127,9 +133,10 @@ // // buttonAdd // - buttonAdd.Location = new Point(656, 59); + buttonAdd.Location = new Point(439, 35); + buttonAdd.Margin = new Padding(3, 2, 3, 2); buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(111, 37); + buttonAdd.Size = new Size(110, 26); buttonAdd.TabIndex = 1; buttonAdd.Text = "Добавить"; buttonAdd.UseVisualStyleBackColor = true; @@ -137,47 +144,26 @@ // // dataGridView // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { Number, Component, Count }); - dataGridView.Location = new Point(0, 27); + dataGridView.Columns.AddRange(new DataGridViewColumn[] { id, Component, Count }); + dataGridView.Location = new Point(5, 20); + dataGridView.Margin = new Padding(3, 2, 3, 2); dataGridView.Name = "dataGridView"; dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 29; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.ShowEditingIcon = false; - dataGridView.Size = new Size(627, 443); + dataGridView.Size = new Size(416, 215); dataGridView.TabIndex = 0; // - // Number - // - Number.HeaderText = "Номер"; - Number.MinimumWidth = 6; - Number.Name = "Number"; - Number.ReadOnly = true; - 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; - // // buttonCancel // - buttonCancel.Location = new Point(609, 605); + buttonCancel.Location = new Point(450, 313); + buttonCancel.Margin = new Padding(3, 2, 3, 2); buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(130, 37); + buttonCancel.Size = new Size(110, 26); buttonCancel.TabIndex = 5; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; @@ -185,19 +171,42 @@ // // buttonSave // - buttonSave.Location = new Point(454, 605); + buttonSave.Location = new Point(322, 313); + buttonSave.Margin = new Padding(3, 2, 3, 2); buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(130, 37); + buttonSave.Size = new Size(110, 26); buttonSave.TabIndex = 6; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; buttonSave.Click += ButtonSave_Click; // + // id + // + id.HeaderText = "id"; + id.MinimumWidth = 6; + id.Name = "id"; + id.ReadOnly = true; + id.Visible = false; + // + // Component + // + Component.HeaderText = "Компоненты"; + Component.MinimumWidth = 6; + Component.Name = "Component"; + Component.ReadOnly = true; + // + // Count + // + Count.HeaderText = "Количество"; + Count.MinimumWidth = 6; + Count.Name = "Count"; + Count.ReadOnly = true; + // // FormPackage // - AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(813, 663); + ClientSize = new Size(599, 347); Controls.Add(buttonSave); Controls.Add(buttonCancel); Controls.Add(groupBoxComponents); @@ -205,8 +214,9 @@ Controls.Add(labelPrice); Controls.Add(textBoxName); Controls.Add(labelName); + Margin = new Padding(3, 2, 3, 2); Name = "FormPackage"; - Text = "ПО"; + Text = "Пакеты"; Load += FormPackage_Load; groupBoxComponents.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); @@ -229,7 +239,7 @@ private DataGridView dataGridView; private Button buttonCancel; private Button buttonSave; - private DataGridViewTextBoxColumn Number; + private DataGridViewTextBoxColumn id; private DataGridViewTextBoxColumn Component; private DataGridViewTextBoxColumn Count; } diff --git a/SoftwareInstallation/FormPackage.cs b/SoftwareInstallation/FormPackage.cs index 30ddf42..aeb09c5 100644 --- a/SoftwareInstallation/FormPackage.cs +++ b/SoftwareInstallation/FormPackage.cs @@ -1,11 +1,11 @@ using Microsoft.Extensions.Logging; -using SoftwareInstallation; +using Pizzeria; using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.BusinessLogicsContracts; using SoftwareInstallationContracts.SearchModels; using SoftwareInstallationDataModels.Models; -namespace SoftwareInstallationView +namespace PizzeriaView { public partial class FormPackage : Form { @@ -27,7 +27,7 @@ namespace SoftwareInstallationView { if (_id.HasValue) { - _logger.LogInformation("Загрузка пиццы"); + _logger.LogInformation("Загрузка пакета"); try { var view = _logic.ReadElement(new PackageSearchModel @@ -45,7 +45,7 @@ namespace SoftwareInstallationView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки пиццы"); + _logger.LogError(ex, "Ошибка загрузки пакета"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -54,7 +54,7 @@ namespace SoftwareInstallationView private void LoadData() { - _logger.LogInformation("Загрузка ингредиент пиццы"); + _logger.LogInformation("Загрузка компонента пакета"); try { if (_PackageComponents != null) @@ -69,7 +69,7 @@ namespace SoftwareInstallationView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки ингредиента пиццы"); + _logger.LogError(ex, "Ошибка загрузки компонента пакета"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -86,7 +86,7 @@ namespace SoftwareInstallationView { return; } - _logger.LogInformation("Добавление нового ингредиента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); + _logger.LogInformation("Добавление нового компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); if (_PackageComponents.ContainsKey(form.Id)) { _PackageComponents[form.Id] = (form.ComponentModel, @@ -118,7 +118,7 @@ namespace SoftwareInstallationView { return; } - _logger.LogInformation("Изменение ингредиента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); + _logger.LogInformation("Изменение компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); _PackageComponents[form.Id] = (form.ComponentModel, form.Count); LoadData(); } @@ -134,7 +134,7 @@ namespace SoftwareInstallationView { try { - _logger.LogInformation("Удаление ингредиента:{ ComponentName}-{ Count}", dataGridView.SelectedRows[0].Cells[1].Value); + _logger.LogInformation("Удаление компонента:{ ComponentName}-{ Count}", dataGridView.SelectedRows[0].Cells[1].Value); _PackageComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) @@ -166,10 +166,10 @@ namespace SoftwareInstallationView } if (_PackageComponents == null || _PackageComponents.Count == 0) { - MessageBox.Show("Заполните ингредиенты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - _logger.LogInformation("Сохранение пиццы"); + _logger.LogInformation("Сохранение пакета"); try { var model = new PackageBindingModel @@ -191,7 +191,7 @@ namespace SoftwareInstallationView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка сохранения пиццы"); + _logger.LogError(ex, "Ошибка сохранения пакета"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/SoftwareInstallation/FormPackage.resx b/SoftwareInstallation/FormPackage.resx index af32865..a395bff 100644 --- a/SoftwareInstallation/FormPackage.resx +++ b/SoftwareInstallation/FormPackage.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/SoftwareInstallation/FormPackageComponent.Designer.cs b/SoftwareInstallation/FormPackageComponent.Designer.cs index 6218708..2a5ff7b 100644 --- a/SoftwareInstallation/FormPackageComponent.Designer.cs +++ b/SoftwareInstallation/FormPackageComponent.Designer.cs @@ -1,4 +1,4 @@ -namespace SoftwareInstallationView +namespace PizzeriaView { partial class FormPackageComponent { @@ -39,41 +39,44 @@ // labelComponent // labelComponent.AutoSize = true; - labelComponent.Location = new Point(14, 19); + labelComponent.Location = new Point(10, 7); labelComponent.Name = "labelComponent"; - labelComponent.Size = new Size(91, 20); + labelComponent.Size = new Size(72, 15); labelComponent.TabIndex = 0; labelComponent.Text = "Компонент:"; // // comboBoxComponent // comboBoxComponent.FormattingEnabled = true; - comboBoxComponent.Location = new Point(121, 12); + comboBoxComponent.Location = new Point(104, 7); + comboBoxComponent.Margin = new Padding(3, 2, 3, 2); comboBoxComponent.Name = "comboBoxComponent"; - comboBoxComponent.Size = new Size(285, 28); + comboBoxComponent.Size = new Size(311, 23); comboBoxComponent.TabIndex = 1; // // labelCount // labelCount.AutoSize = true; - labelCount.Location = new Point(14, 59); + labelCount.Location = new Point(10, 38); labelCount.Name = "labelCount"; - labelCount.Size = new Size(93, 20); + labelCount.Size = new Size(75, 15); labelCount.TabIndex = 2; labelCount.Text = "Количество:"; // // textBoxCount // - textBoxCount.Location = new Point(121, 59); + textBoxCount.Location = new Point(104, 38); + textBoxCount.Margin = new Padding(3, 2, 3, 2); textBoxCount.Name = "textBoxCount"; - textBoxCount.Size = new Size(285, 27); + textBoxCount.Size = new Size(311, 23); textBoxCount.TabIndex = 3; // // buttonCancel // - buttonCancel.Location = new Point(309, 100); + buttonCancel.Location = new Point(277, 70); + buttonCancel.Margin = new Padding(3, 2, 3, 2); buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(98, 36); + buttonCancel.Size = new Size(119, 31); buttonCancel.TabIndex = 4; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; @@ -81,9 +84,10 @@ // // buttonSave // - buttonSave.Location = new Point(199, 100); + buttonSave.Location = new Point(153, 70); + buttonSave.Margin = new Padding(3, 2, 3, 2); buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(98, 36); + buttonSave.Size = new Size(119, 31); buttonSave.TabIndex = 5; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; @@ -91,17 +95,18 @@ // // FormPackageComponent // - AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(426, 149); + ClientSize = new Size(425, 110); Controls.Add(buttonSave); Controls.Add(buttonCancel); Controls.Add(textBoxCount); Controls.Add(labelCount); Controls.Add(comboBoxComponent); Controls.Add(labelComponent); + Margin = new Padding(3, 2, 3, 2); Name = "FormPackageComponent"; - Text = "ПО"; + Text = "Компоненты пакета"; ResumeLayout(false); PerformLayout(); } diff --git a/SoftwareInstallation/FormPackageComponent.cs b/SoftwareInstallation/FormPackageComponent.cs index e6a2b6a..5a6595a 100644 --- a/SoftwareInstallation/FormPackageComponent.cs +++ b/SoftwareInstallation/FormPackageComponent.cs @@ -11,7 +11,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace SoftwareInstallationView +namespace PizzeriaView { public partial class FormPackageComponent : Form { @@ -73,7 +73,7 @@ namespace SoftwareInstallationView } if (comboBoxComponent.SelectedValue == null) { - MessageBox.Show("Выберите ингредиент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult = DialogResult.OK; diff --git a/SoftwareInstallation/FormPackageComponent.resx b/SoftwareInstallation/FormPackageComponent.resx index af32865..a395bff 100644 --- a/SoftwareInstallation/FormPackageComponent.resx +++ b/SoftwareInstallation/FormPackageComponent.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/SoftwareInstallation/FormPackages.Designer.cs b/SoftwareInstallation/FormPackages.Designer.cs index 68bfac9..89e0da0 100644 --- a/SoftwareInstallation/FormPackages.Designer.cs +++ b/SoftwareInstallation/FormPackages.Designer.cs @@ -1,4 +1,4 @@ -namespace SoftwareInstallationView +namespace PizzeriaView { partial class FormPackages { @@ -28,19 +28,34 @@ /// private void InitializeComponent() { + ToolsPanel = new Panel(); buttonRef = new Button(); buttonDel = new Button(); buttonUpd = new Button(); buttonAdd = new Button(); dataGridView = new DataGridView(); + ToolsPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // + // ToolsPanel + // + ToolsPanel.Controls.Add(buttonRef); + ToolsPanel.Controls.Add(buttonDel); + ToolsPanel.Controls.Add(buttonUpd); + ToolsPanel.Controls.Add(buttonAdd); + ToolsPanel.Location = new Point(532, 9); + ToolsPanel.Margin = new Padding(3, 2, 3, 2); + ToolsPanel.Name = "ToolsPanel"; + ToolsPanel.Size = new Size(158, 320); + ToolsPanel.TabIndex = 3; + // // buttonRef // - buttonRef.Location = new Point(741, 180); + buttonRef.Location = new Point(27, 154); + buttonRef.Margin = new Padding(3, 2, 3, 2); buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(128, 35); + buttonRef.Size = new Size(110, 27); buttonRef.TabIndex = 3; buttonRef.Text = "Обновить"; buttonRef.UseVisualStyleBackColor = true; @@ -48,9 +63,10 @@ // // buttonDel // - buttonDel.Location = new Point(741, 129); + buttonDel.Location = new Point(27, 106); + buttonDel.Margin = new Padding(3, 2, 3, 2); buttonDel.Name = "buttonDel"; - buttonDel.Size = new Size(128, 35); + buttonDel.Size = new Size(110, 27); buttonDel.TabIndex = 2; buttonDel.Text = "Удалить"; buttonDel.UseVisualStyleBackColor = true; @@ -58,9 +74,10 @@ // // buttonUpd // - buttonUpd.Location = new Point(741, 77); + buttonUpd.Location = new Point(27, 57); + buttonUpd.Margin = new Padding(3, 2, 3, 2); buttonUpd.Name = "buttonUpd"; - buttonUpd.Size = new Size(128, 35); + buttonUpd.Size = new Size(110, 27); buttonUpd.TabIndex = 1; buttonUpd.Text = "Изменить"; buttonUpd.UseVisualStyleBackColor = true; @@ -68,9 +85,10 @@ // // buttonAdd // - buttonAdd.Location = new Point(741, 27); + buttonAdd.Location = new Point(27, 12); + buttonAdd.Margin = new Padding(3, 2, 3, 2); buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(128, 35); + buttonAdd.Size = new Size(110, 27); buttonAdd.TabIndex = 0; buttonAdd.Text = "Добавить"; buttonAdd.UseVisualStyleBackColor = true; @@ -78,33 +96,37 @@ // // dataGridView // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(-1, 0); + dataGridView.Location = new Point(10, 9); + dataGridView.Margin = new Padding(3, 2, 3, 2); dataGridView.Name = "dataGridView"; dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(709, 568); + dataGridView.Size = new Size(516, 320); dataGridView.TabIndex = 2; // // FormPackages // - AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(895, 571); - Controls.Add(buttonRef); - Controls.Add(buttonDel); + ClientSize = new Size(700, 338); + Controls.Add(ToolsPanel); Controls.Add(dataGridView); - Controls.Add(buttonUpd); - Controls.Add(buttonAdd); + Margin = new Padding(3, 2, 3, 2); Name = "FormPackages"; - Text = "Список ПО"; + Text = "Пакет"; Load += FormPackage_Load; + ToolsPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } #endregion + + private Panel ToolsPanel; private Button buttonRef; private Button buttonDel; private Button buttonUpd; diff --git a/SoftwareInstallation/FormPackages.cs b/SoftwareInstallation/FormPackages.cs index 437f6bb..3800a72 100644 --- a/SoftwareInstallation/FormPackages.cs +++ b/SoftwareInstallation/FormPackages.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.Logging; -using SoftwareInstallation; +using Pizzeria; using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.BusinessLogicsContracts; -namespace SoftwareInstallationView +namespace PizzeriaView { public partial class FormPackages : Form { @@ -35,11 +35,11 @@ namespace SoftwareInstallationView dataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } - _logger.LogInformation("Загрузка пиццы"); + _logger.LogInformation("Загрузка пакета"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки пиццы"); + _logger.LogError(ex, "Ошибка загрузки пакета"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -79,7 +79,7 @@ namespace SoftwareInstallationView if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Удаление пиццы"); + _logger.LogInformation("Удаление пакета"); try { if (!_logic.Delete(new PackageBindingModel @@ -93,7 +93,7 @@ namespace SoftwareInstallationView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка удаления пиццы"); + _logger.LogError(ex, "Ошибка удаления пакета"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/SoftwareInstallation/FormPackages.resx b/SoftwareInstallation/FormPackages.resx index af32865..a395bff 100644 --- a/SoftwareInstallation/FormPackages.resx +++ b/SoftwareInstallation/FormPackages.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/SoftwareInstallation/FormShop.Designer.cs b/SoftwareInstallation/FormShop.Designer.cs new file mode 100644 index 0000000..77e2913 --- /dev/null +++ b/SoftwareInstallation/FormShop.Designer.cs @@ -0,0 +1,196 @@ +namespace PizzeriaView +{ + 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() + { + labelName = new Label(); + textBoxName = new TextBox(); + textBoxAdress = new TextBox(); + labelAdress = new Label(); + buttonCancel = new Button(); + buttonSave = new Button(); + dataGridView = new DataGridView(); + label1 = new Label(); + dateTimeOpen = new DateTimePicker(); + id = new DataGridViewTextBoxColumn(); + PackageName = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(10, 11); + labelName.Name = "labelName"; + labelName.Size = new Size(65, 15); + labelName.TabIndex = 0; + labelName.Text = "Название: "; + // + // textBoxName + // + textBoxName.Location = new Point(89, 9); + textBoxName.Margin = new Padding(3, 2, 3, 2); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(242, 23); + textBoxName.TabIndex = 1; + // + // textBoxAdress + // + textBoxAdress.Location = new Point(89, 44); + textBoxAdress.Margin = new Padding(3, 2, 3, 2); + textBoxAdress.Name = "textBoxAdress"; + textBoxAdress.Size = new Size(374, 23); + textBoxAdress.TabIndex = 3; + // + // labelAdress + // + labelAdress.AutoSize = true; + labelAdress.Location = new Point(10, 46); + labelAdress.Name = "labelAdress"; + labelAdress.Size = new Size(46, 15); + labelAdress.TabIndex = 2; + labelAdress.Text = "Адрес: "; + // + // buttonCancel + // + buttonCancel.Location = new Point(395, 343); + buttonCancel.Margin = new Padding(3, 2, 3, 2); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(114, 33); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(276, 343); + buttonSave.Margin = new Padding(3, 2, 3, 2); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(114, 33); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { id, PackageName, Count }); + dataGridView.Location = new Point(10, 108); + dataGridView.Margin = new Padding(3, 2, 3, 2); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; + dataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(498, 230); + dataGridView.TabIndex = 7; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(10, 77); + label1.Name = "label1"; + label1.Size = new Size(87, 15); + label1.TabIndex = 8; + label1.Text = "Дата открытия"; + // + // dateTimeOpen + // + dateTimeOpen.Location = new Point(112, 77); + dateTimeOpen.Margin = new Padding(3, 2, 3, 2); + dateTimeOpen.Name = "dateTimeOpen"; + dateTimeOpen.Size = new Size(351, 23); + dateTimeOpen.TabIndex = 9; + // + // id + // + id.HeaderText = "id"; + id.MinimumWidth = 6; + id.Name = "id"; + id.ReadOnly = true; + id.Visible = false; + // + // PackageName + // + PackageName.HeaderText = "Пакет"; + PackageName.MinimumWidth = 6; + PackageName.Name = "PackageName"; + PackageName.ReadOnly = true; + // + // Count + // + Count.HeaderText = "Количество"; + Count.MinimumWidth = 6; + Count.Name = "Count"; + Count.ReadOnly = true; + // + // FormShop + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(519, 385); + Controls.Add(dateTimeOpen); + Controls.Add(label1); + Controls.Add(dataGridView); + Controls.Add(buttonSave); + Controls.Add(buttonCancel); + Controls.Add(textBoxAdress); + Controls.Add(labelAdress); + Controls.Add(textBoxName); + Controls.Add(labelName); + Margin = new Padding(3, 2, 3, 2); + Name = "FormShop"; + Text = "Магазин"; + Load += FormShop_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private TextBox textBoxName; + private TextBox textBoxAdress; + private Label labelAdress; + private Button buttonCancel; + private Button buttonSave; + private DataGridView dataGridView; + private Label label1; + private DateTimePicker dateTimeOpen; + private DataGridViewTextBoxColumn id; + private DataGridViewTextBoxColumn PackageName; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/FormShop.cs b/SoftwareInstallation/FormShop.cs new file mode 100644 index 0000000..b13f73b --- /dev/null +++ b/SoftwareInstallation/FormShop.cs @@ -0,0 +1,128 @@ +using SoftwareInstallationDataModels.Models; +using Microsoft.Extensions.Logging; +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.SearchModels; +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 PizzeriaView +{ + public partial class FormShop : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + private Dictionary _ShopPackages; + private DateTime? _openingDate = null; + + public FormShop(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _ShopPackages = 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; + textBoxAdress.Text = view.Adress; + dateTimeOpen.Value = view.OpeningDate; + _ShopPackages = view.ShopPackages ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void LoadData() + { + _logger.LogInformation("Загрузка изделий в магазине"); + try + { + if (_ShopPackages != null) + { + dataGridView.Rows.Clear(); + foreach (var sr in _ShopPackages) + { + dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.PackageName, 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(textBoxAdress.Text)) + { + MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение магазина"); + try + { + var model = new ShopBindingModel + { + Id = _id ?? 0, + ShopName = textBoxName.Text, + Adress = textBoxAdress.Text, + OpeningDate = dateTimeOpen.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/SoftwareInstallation/FormShop.resx b/SoftwareInstallation/FormShop.resx new file mode 100644 index 0000000..a395bff --- /dev/null +++ b/SoftwareInstallation/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/SoftwareInstallation/FormShops.Designer.cs b/SoftwareInstallation/FormShops.Designer.cs new file mode 100644 index 0000000..3af7c45 --- /dev/null +++ b/SoftwareInstallation/FormShops.Designer.cs @@ -0,0 +1,130 @@ +namespace PizzeriaView +{ + 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.ToolsPanel = new System.Windows.Forms.Panel(); + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ToolsPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // ToolsPanel + // + this.ToolsPanel.Controls.Add(this.buttonRef); + this.ToolsPanel.Controls.Add(this.buttonDel); + this.ToolsPanel.Controls.Add(this.buttonUpd); + this.ToolsPanel.Controls.Add(this.buttonAdd); + this.ToolsPanel.Location = new System.Drawing.Point(608, 12); + this.ToolsPanel.Name = "ToolsPanel"; + this.ToolsPanel.Size = new System.Drawing.Size(180, 426); + this.ToolsPanel.TabIndex = 3; + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(31, 206); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(126, 36); + this.buttonRef.TabIndex = 3; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(31, 142); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(126, 36); + this.buttonDel.TabIndex = 2; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(31, 76); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(126, 36); + this.buttonUpd.TabIndex = 1; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(31, 16); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(126, 36); + this.buttonAdd.TabIndex = 0; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(590, 426); + this.dataGridView.TabIndex = 2; + // + // FormShops + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.ToolsPanel); + this.Controls.Add(this.dataGridView); + this.Name = "FormShops"; + this.Text = "Магазины"; + this.Load += new System.EventHandler(this.FormShops_Load); + this.ToolsPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel ToolsPanel; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/FormShops.cs b/SoftwareInstallation/FormShops.cs new file mode 100644 index 0000000..d1f19de --- /dev/null +++ b/SoftwareInstallation/FormShops.cs @@ -0,0 +1,117 @@ +using Microsoft.Extensions.Logging; +using Pizzeria; +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +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 PizzeriaView +{ + public partial class FormShops : Form + { + 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["ShopPackages"].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/SoftwareInstallation/FormShops.resx b/SoftwareInstallation/FormShops.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SoftwareInstallation/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/SoftwareInstallation/Program.cs b/SoftwareInstallation/Program.cs index 8bfbcc7..d867576 100644 --- a/SoftwareInstallation/Program.cs +++ b/SoftwareInstallation/Program.cs @@ -1,13 +1,13 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; -using SoftwareInstallationBusinessLogic.BusinessLogic; +using SoftwareInstallationBusinessLogic.BusinessLogics; using SoftwareInstallationContracts.BusinessLogicsContracts; using SoftwareInstallationContracts.StoragesContracts; using SoftwareInstallationListImplement.Implements; -using SoftwareInstallationView; +using PizzeriaView; -namespace SoftwareInstallation +namespace Pizzeria { internal static class Program { @@ -49,6 +49,11 @@ namespace SoftwareInstallation services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/SoftwareInstallationBusinessLogic/BusinessLogic/ComponentLogic.cs b/SoftwareInstallationBusinessLogic/BusinessLogics/ComponentLogic.cs similarity index 87% rename from SoftwareInstallationBusinessLogic/BusinessLogic/ComponentLogic.cs rename to SoftwareInstallationBusinessLogic/BusinessLogics/ComponentLogic.cs index 261d831..5b41f52 100644 --- a/SoftwareInstallationBusinessLogic/BusinessLogic/ComponentLogic.cs +++ b/SoftwareInstallationBusinessLogic/BusinessLogics/ComponentLogic.cs @@ -1,25 +1,31 @@ -using SoftwareInstallationContracts.BindingModels; +using Microsoft.Extensions.Logging; +using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.BusinessLogicsContracts; using SoftwareInstallationContracts.SearchModels; using SoftwareInstallationContracts.StoragesContracts; using SoftwareInstallationContracts.ViewModels; -using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; -namespace SoftwareInstallationBusinessLogic.BusinessLogic +namespace SoftwareInstallationBusinessLogic.BusinessLogics { public class ComponentLogic : IComponentLogic { private readonly ILogger _logger; private readonly IComponentStorage _componentStorage; - public ComponentLogic(ILogger logger, IComponentStorage - componentStorage) + + public ComponentLogic(ILogger logger, IComponentStorage componentStorage) { _logger = logger; _componentStorage = componentStorage; } + public List? ReadList(ComponentSearchModel? model) { - _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{Id}", model?.ComponentName, model?.Id); + _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id); var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model); if (list == null) { @@ -36,7 +42,7 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{Id}", model.ComponentName, model.Id); + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id); var element = _componentStorage.GetElement(model); if (element == null) { @@ -99,10 +105,10 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic { throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); } - _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{Cost}. Id: {Id}", model.ComponentName, model.Cost, model.Id); + _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}.Id: { Id}", model.ComponentName, model.Cost, model.Id); var element = _componentStorage.GetElement(new ComponentSearchModel { - ComponentName = model.ComponentName + ComponentName = model.ComponentName }); if (element != null && element.Id != model.Id) { @@ -110,4 +116,4 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic } } } -} \ No newline at end of file +} diff --git a/SoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs b/SoftwareInstallationBusinessLogic/BusinessLogics/OrderLogic.cs similarity index 60% rename from SoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs rename to SoftwareInstallationBusinessLogic/BusinessLogics/OrderLogic.cs index a09428d..88d6466 100644 --- a/SoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/SoftwareInstallationBusinessLogic/BusinessLogics/OrderLogic.cs @@ -1,33 +1,27 @@ -using SoftwareInstallationContracts.BindingModels; +using Microsoft.Extensions.Logging; +using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.BusinessLogicsContracts; using SoftwareInstallationContracts.SearchModels; using SoftwareInstallationContracts.StoragesContracts; using SoftwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Enums; -using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace SoftwareInstallationBusinessLogic.BusinessLogic +namespace SoftwareInstallationBusinessLogic.BusinessLogics { public class OrderLogic : IOrderLogic { - //Класс с логикой для заказов будет отвечать за получение списка заказов, - //создания заказа и смены его статусов. Следует учитывать, что у заказа можно - //менять статус на новый, если его текущий статус предшествует новому - private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; - public OrderLogic(ILogger logger, IOrderStorage orderStorage) { _logger = logger; _orderStorage = orderStorage; } - public List? ReadList(OrderSearchModel? model) { _logger.LogInformation("ReadList. OrderId:{Id}", model?.Id); @@ -40,18 +34,14 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic _logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; } - public bool CreateOrder(OrderBindingModel model) { CheckModel(model); - if (model.Status != OrderStatus.Неизвестен) return false; model.Status = OrderStatus.Принят; - if (_orderStorage.Insert(model) == null) { - model.Status = OrderStatus.Неизвестен; _logger.LogWarning("Insert operation failed"); return false; } @@ -60,57 +50,17 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic public bool TakeOrderInWork(OrderBindingModel model) { - return ToNextStatus(model, OrderStatus.Выполняется); + return ChangeStatus(model, OrderStatus.Выполняется); } public bool FinishOrder(OrderBindingModel model) { - return ToNextStatus(model, OrderStatus.Готов); + return ChangeStatus(model, OrderStatus.Готов); } public bool DeliveryOrder(OrderBindingModel model) { - return ToNextStatus(model, OrderStatus.Выдан); - } - - public bool ToNextStatus(OrderBindingModel model, OrderStatus orderStatus) - { - CheckModel(model, false); - var element = _orderStorage.GetElement(new OrderSearchModel() - { - Id = model.Id - }); - if (element == null) - { - throw new ArgumentNullException(nameof(element)); - } - - model.PackageId = element.PackageId; - model.DateCreate = element.DateCreate; - model.DateImplement = element.DateImplement; - model.Status = element.Status; - model.Count = element.Count; - model.Sum = element.Sum; - - if (model.Status != orderStatus - 1) - { - _logger.LogWarning("Status update to " + orderStatus + " operation failed"); - return false; - } - model.Status = orderStatus; - - if (model.Status == OrderStatus.Выдан) - { - model.DateImplement = DateTime.Now; - } - - if (_orderStorage.Update(model) == null) - { - model.Status--; - _logger.LogWarning("Changing status operation faled"); - return false; - } - return true; + return ChangeStatus(model, OrderStatus.Выдан); } private void CheckModel(OrderBindingModel model, bool withParams = true) @@ -125,17 +75,51 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic } if (model.Count <= 0) { - throw new ArgumentNullException("Количество изделий должно быть больше 0", nameof(model.Count)); + throw new ArgumentException("Колличество пакетов в заказе не может быть меньше 1", nameof(model.Count)); } if (model.Sum <= 0) { - throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum)); + throw new ArgumentException("Стоимость заказа на может быть меньше 1", nameof(model.Sum)); } if (model.DateImplement.HasValue && model.DateImplement < model.DateCreate) { - throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} должна быть позже даты его создания {model.DateCreate}"); + throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}"); } - _logger.LogInformation("Package. PackageId:{PackageId}.Count:{Count}.Sum:{Sum}Id:{Id}", model.PackageId, model.Count, model.Sum, model.Id); + _logger.LogInformation("Package. PackageId:{PackageId}.Count:{Count}.Sum:{Sum}Id:{Id}", + model.PackageId, model.Count, model.Sum, model.Id); + } + + private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) + { + CheckModel(model, false); + var element = _orderStorage.GetElement(new OrderSearchModel() + { + Id = model.Id + }); + if (element == null) + { + throw new ArgumentNullException(nameof(element)); + } + model.DateCreate = element.DateCreate; + model.PackageId = element.PackageId; + model.DateImplement = element.DateImplement; + model.Status = element.Status; + model.Count = element.Count; + model.Sum = element.Sum; + if (requiredStatus - model.Status == 1) + { + model.Status = requiredStatus; + if (model.Status == OrderStatus.Выдан) + model.DateImplement = DateTime.Now; + if (_orderStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + _logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus); + throw new ArgumentException($"Невозможно присвоить статус {requiredStatus} заказу с текущим статусом {model.Status}"); } } } diff --git a/SoftwareInstallationBusinessLogic/BusinessLogic/PackageLogic.cs b/SoftwareInstallationBusinessLogic/BusinessLogics/PackageLogic.cs similarity index 79% rename from SoftwareInstallationBusinessLogic/BusinessLogic/PackageLogic.cs rename to SoftwareInstallationBusinessLogic/BusinessLogics/PackageLogic.cs index ea87d3b..aafba47 100644 --- a/SoftwareInstallationBusinessLogic/BusinessLogic/PackageLogic.cs +++ b/SoftwareInstallationBusinessLogic/BusinessLogics/PackageLogic.cs @@ -1,30 +1,29 @@ -using SoftwareInstallationContracts.BindingModels; +using Microsoft.Extensions.Logging; +using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.BusinessLogicsContracts; using SoftwareInstallationContracts.SearchModels; using SoftwareInstallationContracts.StoragesContracts; using SoftwareInstallationContracts.ViewModels; -using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace SoftwareInstallationBusinessLogic.BusinessLogic +namespace SoftwareInstallationBusinessLogic.BusinessLogics { public class PackageLogic : IPackageLogic { private readonly ILogger _logger; private readonly IPackageStorage _PackageStorage; - public PackageLogic(ILogger logger, IPackageStorage - PackageStorage) + public PackageLogic(ILogger logger, IPackageStorage PackageStorage) { _logger = logger; _PackageStorage = PackageStorage; } public List? ReadList(PackageSearchModel? model) { - _logger.LogInformation("ReadList. PackageName:{PackageName}.Id:{Id}", model?.PackageName, model?.Id); + _logger.LogInformation("ReadList. PackageName:{PackageName}.Id:{ Id}", model?.PackageName, model?.Id); var list = model == null ? _PackageStorage.GetFullList() : _PackageStorage.GetFilteredList(model); if (list == null) { @@ -34,14 +33,13 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic _logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; } - public PackageViewModel? ReadElement(PackageSearchModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. PackageName:{PackageName}.Id:{Id}", model.PackageName, model.Id); + _logger.LogInformation("ReadElement. PackageName:{PackageName}.Id:{ Id}", model.PackageName, model.Id); var element = _PackageStorage.GetElement(model); if (element == null) { @@ -51,7 +49,6 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); return element; } - public bool Create(PackageBindingModel model) { CheckModel(model); @@ -62,7 +59,6 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic } return true; } - public bool Update(PackageBindingModel model) { CheckModel(model); @@ -73,7 +69,6 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic } return true; } - public bool Delete(PackageBindingModel model) { CheckModel(model, false); @@ -85,7 +80,6 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic } return true; } - private void CheckModel(PackageBindingModel model, bool withParams = true) { if (model == null) @@ -98,20 +92,24 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogic } if (string.IsNullOrEmpty(model.PackageName)) { - throw new ArgumentNullException("Нет названия изделия", nameof(model.PackageName)); + throw new ArgumentNullException("Нет названия пакета", nameof(model.PackageName)); } if (model.Price <= 0) { - throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price)); + throw new ArgumentNullException("Цена пакета должна быть больше 0", nameof(model.Price)); } - _logger.LogInformation("Package. PackageName:{PackageName}.Price:{Cost}. Id: {Id}", model.PackageName, model.Price, model.Id); + if (model.PackageComponents == null || model.PackageComponents.Count == 0) + { + throw new ArgumentNullException("Перечень компонентов не может быть пустым", nameof(model.PackageComponents)); + } + _logger.LogInformation("Package. PackageName:{PackageName}.Price:{Price}.Id: { Id}", model.PackageName, model.Price, model.Id); var element = _PackageStorage.GetElement(new PackageSearchModel { PackageName = model.PackageName }); if (element != null && element.Id != model.Id) { - throw new InvalidOperationException("Изделие с таким названием уже есть"); + throw new InvalidOperationException("Пакет с таким названием уже есть"); } } } diff --git a/SoftwareInstallationBusinessLogic/BusinessLogics/ShopLogic.cs b/SoftwareInstallationBusinessLogic/BusinessLogics/ShopLogic.cs new file mode 100644 index 0000000..0d17271 --- /dev/null +++ b/SoftwareInstallationBusinessLogic/BusinessLogics/ShopLogic.cs @@ -0,0 +1,160 @@ +using Microsoft.Extensions.Logging; +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.StoragesContracts; +using SoftwareInstallationContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationBusinessLogic.BusinessLogics +{ + public class ShopLogic : IShopLogic + { + private readonly ILogger _logger; + private readonly IShopStorage _shopStorage; + private readonly IPackageStorage _packageStorage; + + public ShopLogic(ILogger logger, IShopStorage shopStorage, IPackageStorage packageStorage) + { + _logger = logger; + _shopStorage = shopStorage; + _packageStorage = packageStorage; + } + + 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.ShopPackages.ContainsKey(model.PackageId)) + { + var oldValue = shop.ShopPackages[model.PackageId]; + oldValue.Item2 += model.Count; + shop.ShopPackages[model.PackageId] = oldValue; + } + else + { + var pizza = _packageStorage.GetElement(new PackageSearchModel + { + Id = model.PackageId + }); + if (pizza == null) + { + throw new ArgumentException($"Поставка: Товар с id:{model.PackageId} не найденн"); + } + shop.ShopPackages.Add(model.PackageId, (pizza, 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 ArgumentException("Название магазина должно быть заполнено", nameof(model.ShopName)); + } + _logger.LogInformation("Shop. ShopName:{ShopName}.Adres:{Adres}.OpeningDate:{OpeningDate}.Id:{ Id}", model.ShopName, model.Adress, 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/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs b/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs index f1da9cf..2d1912d 100644 --- a/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs +++ b/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs @@ -13,4 +13,4 @@ namespace SoftwareInstallationContracts.BindingModels public string ComponentName { get; set; } = string.Empty; public double Cost { get; set; } } -} +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs b/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs index d53ff55..779cd14 100644 --- a/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs +++ b/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs @@ -13,9 +13,9 @@ namespace SoftwareInstallationContracts.BindingModels public int Id { get; set; } public int PackageId { get; set; } public int Count { get; set; } - public double Sum { get; set; } + public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateImplement { get; set; } } -} +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs b/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs index 4650e41..49a174b 100644 --- a/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs +++ b/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs @@ -14,4 +14,4 @@ namespace SoftwareInstallationContracts.BindingModels public double Price { get; set; } public Dictionary PackageComponents { get; set; } = new(); } -} +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/BindingModels/ShopBindingModel.cs b/SoftwareInstallationContracts/BindingModels/ShopBindingModel.cs new file mode 100644 index 0000000..f7774b6 --- /dev/null +++ b/SoftwareInstallationContracts/BindingModels/ShopBindingModel.cs @@ -0,0 +1,18 @@ +using SoftwareInstallationDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationContracts.BindingModels +{ + public class ShopBindingModel : IShopModel + { + 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 ShopPackages { get; set; } = new(); + } +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/BindingModels/SupplyBindingModel.cs b/SoftwareInstallationContracts/BindingModels/SupplyBindingModel.cs new file mode 100644 index 0000000..7e61624 --- /dev/null +++ b/SoftwareInstallationContracts/BindingModels/SupplyBindingModel.cs @@ -0,0 +1,16 @@ +using SoftwareInstallationDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationContracts.BindingModels +{ + public class SupplyBindingModel : ISupplyModel + { + public int ShopId { get; set; } + public int PackageId { get; set; } + public int Count { get; set; } + } +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/BusinessLogicsContracts/IComponentLogic.cs b/SoftwareInstallationContracts/BusinessLogicsContracts/IComponentLogic.cs index 94d4a7d..f4d7d10 100644 --- a/SoftwareInstallationContracts/BusinessLogicsContracts/IComponentLogic.cs +++ b/SoftwareInstallationContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -3,7 +3,6 @@ using SoftwareInstallationContracts.SearchModels; using SoftwareInstallationContracts.ViewModels; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs b/SoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs index c589fe2..41bc7f7 100644 --- a/SoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/SoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -14,17 +14,7 @@ namespace SoftwareInstallationContracts.BusinessLogicsContracts List? ReadList(OrderSearchModel? model); bool CreateOrder(OrderBindingModel model); bool TakeOrderInWork(OrderBindingModel model); - /// - /// Готов - /// - /// - /// bool FinishOrder(OrderBindingModel model); - /// - /// Доставлен - /// - /// - /// bool DeliveryOrder(OrderBindingModel model); } } diff --git a/SoftwareInstallationContracts/BusinessLogicsContracts/IShopLogic.cs b/SoftwareInstallationContracts/BusinessLogicsContracts/IShopLogic.cs new file mode 100644 index 0000000..77e32cd --- /dev/null +++ b/SoftwareInstallationContracts/BusinessLogicsContracts/IShopLogic.cs @@ -0,0 +1,21 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationContracts.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); + } +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs b/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs index c15aff8..daf4ae4 100644 --- a/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs +++ b/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs @@ -11,4 +11,4 @@ namespace SoftwareInstallationContracts.SearchModels public int? Id { get; set; } public string? ComponentName { get; set; } } -} +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs b/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs index b2831f6..1b8352b 100644 --- a/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs +++ b/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs @@ -10,4 +10,4 @@ namespace SoftwareInstallationContracts.SearchModels { public int? Id { get; set; } } -} +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs b/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs index 43c90d4..7f28726 100644 --- a/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs +++ b/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs @@ -11,4 +11,4 @@ namespace SoftwareInstallationContracts.SearchModels public int? Id { get; set; } public string? PackageName { get; set; } } -} +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/SearchModels/ShopSearchModel.cs b/SoftwareInstallationContracts/SearchModels/ShopSearchModel.cs new file mode 100644 index 0000000..4613740 --- /dev/null +++ b/SoftwareInstallationContracts/SearchModels/ShopSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationContracts.SearchModels +{ + public class ShopSearchModel + { + public int? Id { get; set; } + public string? ShopName { get; set; } + } +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs b/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs index b07927d..6e6115e 100644 --- a/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs +++ b/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs @@ -17,6 +17,5 @@ namespace SoftwareInstallationContracts.StoragesContracts ComponentViewModel? Insert(ComponentBindingModel model); ComponentViewModel? Update(ComponentBindingModel model); ComponentViewModel? Delete(ComponentBindingModel model); - } } diff --git a/SoftwareInstallationContracts/StoragesContracts/IShopStorage.cs b/SoftwareInstallationContracts/StoragesContracts/IShopStorage.cs new file mode 100644 index 0000000..b7db259 --- /dev/null +++ b/SoftwareInstallationContracts/StoragesContracts/IShopStorage.cs @@ -0,0 +1,21 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationContracts.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); + } +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs b/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs index 083b3c3..02c5d5e 100644 --- a/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs +++ b/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs @@ -11,9 +11,11 @@ namespace SoftwareInstallationContracts.ViewModels public class ComponentViewModel : IComponentModel { public int Id { get; set; } + [DisplayName("Название компонента")] public string ComponentName { get; set; } = string.Empty; + [DisplayName("Цена")] public double Cost { get; set; } } -} +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs b/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs index e4c9a67..f460218 100644 --- a/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs +++ b/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs @@ -1,4 +1,5 @@ using SoftwareInstallationDataModels.Enums; +using SoftwareInstallationDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -8,22 +9,29 @@ using System.Threading.Tasks; namespace SoftwareInstallationContracts.ViewModels { - public class OrderViewModel + public class OrderViewModel : IOrderModel { [DisplayName("Номер")] public int Id { get; set; } + public int PackageId { get; set; } - [DisplayName("Изделие")] + + [DisplayName("Пакет")] public string PackageName { get; set; } = string.Empty; + [DisplayName("Количество")] public int Count { get; set; } + [DisplayName("Сумма")] public double Sum { get; set; } + [DisplayName("Статус")] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + [DisplayName("Дата создания")] public DateTime DateCreate { get; set; } = DateTime.Now; + [DisplayName("Дата выполнения")] public DateTime? DateImplement { get; set; } } -} +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs b/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs index 12a29dc..99fda72 100644 --- a/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs +++ b/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs @@ -11,11 +11,13 @@ namespace SoftwareInstallationContracts.ViewModels public class PackageViewModel : IPackageModel { public int Id { get; set; } - [DisplayName("Название изделия")] - public string PackageName { get; set; } + + [DisplayName("Название пакета")] + public string PackageName { get; set; } = string.Empty; + [DisplayName("Цена")] public double Price { get; set; } - public Dictionary PackageComponents { get; set; } = new(); + public Dictionary PackageComponents { get; set; } = new(); } -} +} \ No newline at end of file diff --git a/SoftwareInstallationContracts/ViewModels/ShopViewModel.cs b/SoftwareInstallationContracts/ViewModels/ShopViewModel.cs new file mode 100644 index 0000000..8befd07 --- /dev/null +++ b/SoftwareInstallationContracts/ViewModels/ShopViewModel.cs @@ -0,0 +1,22 @@ +using SoftwareInstallationDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationContracts.ViewModels +{ + public class ShopViewModel : IShopModel + { + 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 ShopPackages { get; set; } = new(); + } +} \ No newline at end of file diff --git a/SoftwareInstallationDataModels/Enums/OrderStatus.cs b/SoftwareInstallationDataModels/Enums/OrderStatus.cs index 13c4efe..83360ae 100644 --- a/SoftwareInstallationDataModels/Enums/OrderStatus.cs +++ b/SoftwareInstallationDataModels/Enums/OrderStatus.cs @@ -1,4 +1,10 @@ -namespace SoftwareInstallationDataModels.Enums +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationDataModels.Enums { public enum OrderStatus { @@ -6,6 +12,6 @@ Принят = 0, Выполняется = 1, Готов = 2, - Выдан = 3, + Выдан = 3 } } \ No newline at end of file diff --git a/SoftwareInstallationDataModels/IId.cs b/SoftwareInstallationDataModels/IId.cs index 4c444f5..da727f0 100644 --- a/SoftwareInstallationDataModels/IId.cs +++ b/SoftwareInstallationDataModels/IId.cs @@ -10,4 +10,4 @@ namespace SoftwareInstallationDataModels { int Id { get; } } -} +} \ No newline at end of file diff --git a/SoftwareInstallationDataModels/Models/IComponentModel.cs b/SoftwareInstallationDataModels/Models/IComponentModel.cs index 5d18120..0441f68 100644 --- a/SoftwareInstallationDataModels/Models/IComponentModel.cs +++ b/SoftwareInstallationDataModels/Models/IComponentModel.cs @@ -1,3 +1,9 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + namespace SoftwareInstallationDataModels.Models { public interface IComponentModel : IId @@ -5,4 +11,4 @@ namespace SoftwareInstallationDataModels.Models string ComponentName { get; } double Cost { get; } } -} +} \ No newline at end of file diff --git a/SoftwareInstallationDataModels/Models/IOrderModel.cs b/SoftwareInstallationDataModels/Models/IOrderModel.cs index 95ae88f..46e35ee 100644 --- a/SoftwareInstallationDataModels/Models/IOrderModel.cs +++ b/SoftwareInstallationDataModels/Models/IOrderModel.cs @@ -1,4 +1,9 @@ -using SoftwareInstallationDataModels.Enums; +using SoftwareInstallationDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace SoftwareInstallationDataModels.Models { diff --git a/SoftwareInstallationDataModels/Models/IPackageModel.cs b/SoftwareInstallationDataModels/Models/IPackageModel.cs index 6d2a4f9..2b70758 100644 --- a/SoftwareInstallationDataModels/Models/IPackageModel.cs +++ b/SoftwareInstallationDataModels/Models/IPackageModel.cs @@ -1,9 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + namespace SoftwareInstallationDataModels.Models { - public interface IPackageModel : IId - { - string PackageName { get; } - double Price { get; } - Dictionary PackageComponents { get; } - } -} + public interface IPackageModel : IId + { + string PackageName { get; } + double Price { get; } + Dictionary PackageComponents { get; } + } +} \ No newline at end of file diff --git a/SoftwareInstallationDataModels/Models/IShopModel.cs b/SoftwareInstallationDataModels/Models/IShopModel.cs new file mode 100644 index 0000000..f70018c --- /dev/null +++ b/SoftwareInstallationDataModels/Models/IShopModel.cs @@ -0,0 +1,18 @@ +using SoftwareInstallationDataModels; +using SoftwareInstallationDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationDataModels.Models +{ + public interface IShopModel : IId + { + string ShopName { get; } + string Adress { get; } + DateTime OpeningDate { get; } + Dictionary ShopPackages { get; } + } +} \ No newline at end of file diff --git a/SoftwareInstallationDataModels/Models/ISupplyModel.cs b/SoftwareInstallationDataModels/Models/ISupplyModel.cs new file mode 100644 index 0000000..34f1546 --- /dev/null +++ b/SoftwareInstallationDataModels/Models/ISupplyModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationDataModels.Models +{ + public interface ISupplyModel + { + int ShopId { get; } + int PackageId { get; } + int Count { get; } + } +} \ No newline at end of file diff --git a/SoftwareInstallationListImplement/DataListSingleton.cs b/SoftwareInstallationListImplement/DataListSingleton.cs index 76fc819..341f6c4 100644 --- a/SoftwareInstallationListImplement/DataListSingleton.cs +++ b/SoftwareInstallationListImplement/DataListSingleton.cs @@ -7,18 +7,22 @@ using System.Threading.Tasks; namespace SoftwareInstallationListImplement { - internal class DataListSingleton + public class DataListSingleton { private static DataListSingleton? _instance; public List Components { get; set; } public List Orders { get; set; } public List Packages { get; set; } + public List Shops { get; set; } + private DataListSingleton() { Components = new List(); Orders = new List(); Packages = new List(); + Shops = new List(); } + public static DataListSingleton GetInstance() { if (_instance == null) diff --git a/SoftwareInstallationListImplement/Implements/ComponentStorage.cs b/SoftwareInstallationListImplement/Implements/ComponentStorage.cs index 9c26614..24725d9 100644 --- a/SoftwareInstallationListImplement/Implements/ComponentStorage.cs +++ b/SoftwareInstallationListImplement/Implements/ComponentStorage.cs @@ -1,6 +1,6 @@ -using SoftwareInstallationContracts.StoragesContracts; -using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.StoragesContracts; using SoftwareInstallationContracts.ViewModels; using SoftwareInstallationListImplement.Models; using System; @@ -14,10 +14,12 @@ namespace SoftwareInstallationListImplement.Implements public class ComponentStorage : IComponentStorage { private readonly DataListSingleton _source; + public ComponentStorage() { _source = DataListSingleton.GetInstance(); } + public List GetFullList() { var result = new List(); @@ -27,6 +29,7 @@ namespace SoftwareInstallationListImplement.Implements } return result; } + public List GetFilteredList(ComponentSearchModel model) { var result = new List(); @@ -43,6 +46,7 @@ namespace SoftwareInstallationListImplement.Implements } return result; } + public ComponentViewModel? GetElement(ComponentSearchModel model) { if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) @@ -52,13 +56,14 @@ namespace SoftwareInstallationListImplement.Implements foreach (var component in _source.Components) { if ((!string.IsNullOrEmpty(model.ComponentName) && component.ComponentName == model.ComponentName) || - (model.Id.HasValue && component.Id == model.Id)) + (model.Id.HasValue && component.Id == model.Id)) { return component.GetViewModel; } } return null; } + public ComponentViewModel? Insert(ComponentBindingModel model) { model.Id = 1; @@ -77,6 +82,7 @@ namespace SoftwareInstallationListImplement.Implements _source.Components.Add(newComponent); return newComponent.GetViewModel; } + public ComponentViewModel? Update(ComponentBindingModel model) { foreach (var component in _source.Components) @@ -89,6 +95,7 @@ namespace SoftwareInstallationListImplement.Implements } return null; } + public ComponentViewModel? Delete(ComponentBindingModel model) { for (int i = 0; i < _source.Components.Count; ++i) diff --git a/SoftwareInstallationListImplement/Implements/OrderStorage.cs b/SoftwareInstallationListImplement/Implements/OrderStorage.cs index a3afef2..480635a 100644 --- a/SoftwareInstallationListImplement/Implements/OrderStorage.cs +++ b/SoftwareInstallationListImplement/Implements/OrderStorage.cs @@ -111,11 +111,11 @@ namespace SoftwareInstallationListImplement.Implements private OrderViewModel AttachPackageName(OrderViewModel model) { - foreach (var Package in _source.Packages) + foreach (var package in _source.Packages) { - if (Package.Id == model.PackageId) + if (package.Id == model.PackageId) { - model.PackageName = Package.PackageName; + model.PackageName = package.PackageName; return model; } } diff --git a/SoftwareInstallationListImplement/Implements/PackageStorage.cs b/SoftwareInstallationListImplement/Implements/PackageStorage.cs index 97a39fb..3037469 100644 --- a/SoftwareInstallationListImplement/Implements/PackageStorage.cs +++ b/SoftwareInstallationListImplement/Implements/PackageStorage.cs @@ -11,13 +11,91 @@ using System.Threading.Tasks; namespace SoftwareInstallationListImplement.Implements { - public class PackageStorage : IPackageStorage { + public class PackageStorage : IPackageStorage + { private readonly DataListSingleton _source; + public PackageStorage() { _source = DataListSingleton.GetInstance(); } + public List GetFullList() + { + var result = new List(); + foreach (var packages in _source.Packages) + { + result.Add(packages.GetViewModel); + } + return result; + } + + public List GetFilteredList(PackageSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.PackageName)) + { + return result; + } + foreach (var packages in _source.Packages) + { + if (packages.PackageName.Contains(model.PackageName)) + { + result.Add(packages.GetViewModel); + } + } + return result; + } + + public PackageViewModel? GetElement(PackageSearchModel model) + { + if (string.IsNullOrEmpty(model.PackageName) && !model.Id.HasValue) + { + return null; + } + foreach (var packages in _source.Packages) + { + if ((!string.IsNullOrEmpty(model.PackageName) && packages.PackageName == model.PackageName) || + (model.Id.HasValue && packages.Id == model.Id)) + { + return packages.GetViewModel; + } + } + return null; + } + + public PackageViewModel? Insert(PackageBindingModel model) + { + model.Id = 1; + foreach (var packages in _source.Packages) + { + if (model.Id <= packages.Id) + { + model.Id = packages.Id + 1; + } + } + var newPackages = Package.Create(model); + if (newPackages == null) + { + return null; + } + _source.Packages.Add(newPackages); + return newPackages.GetViewModel; + } + + public PackageViewModel? Update(PackageBindingModel model) + { + foreach (var packages in _source.Packages) + { + if (packages.Id == model.Id) + { + packages.Update(model); + return packages.GetViewModel; + } + } + return null; + } + public PackageViewModel? Delete(PackageBindingModel model) { for (int i = 0; i < _source.Packages.Count; ++i) @@ -31,81 +109,5 @@ namespace SoftwareInstallationListImplement.Implements } return null; } - - public PackageViewModel? GetElement(PackageSearchModel model) - { - if (string.IsNullOrEmpty(model.PackageName) && !model.Id.HasValue) - { - return null; - } - foreach (var Package in _source.Packages) - { - if ((!string.IsNullOrEmpty(model.PackageName) && Package.PackageName == model.PackageName) || - (model.Id.HasValue && Package.Id == model.Id)) - { - return Package.GetViewModel; - } - } - return null; - } - - public List GetFilteredList(PackageSearchModel model) - { - var result = new List(); - if (string.IsNullOrEmpty(model.PackageName)) - { - return result; - } - foreach (var Package in _source.Packages) - { - if (Package.PackageName.Contains(model.PackageName)) - { - result.Add(Package.GetViewModel); - } - } - return result; - } - - public List GetFullList() - { - var result = new List(); - foreach (var Package in _source.Packages) - { - result.Add(Package.GetViewModel); - } - return result; - } - - public PackageViewModel? Insert(PackageBindingModel model) - { - model.Id = 1; - foreach (var Package in _source.Packages) - { - if (model.Id <= Package.Id) - { - model.Id = Package.Id + 1; - } - } - var newPackage = Package.Create(model); - if (newPackage == null) - { - return null; - } - _source.Packages.Add(newPackage); - return newPackage.GetViewModel; - } - - public PackageViewModel? Update(PackageBindingModel model) - { - foreach (var Package in _source.Packages) - { - if (Package.Id == model.Id) - { - Package.Update(model); - return Package.GetViewModel; - } - } - return null; - } } } diff --git a/SoftwareInstallationListImplement/Implements/ShopStorage.cs b/SoftwareInstallationListImplement/Implements/ShopStorage.cs new file mode 100644 index 0000000..a569908 --- /dev/null +++ b/SoftwareInstallationListImplement/Implements/ShopStorage.cs @@ -0,0 +1,113 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.StoragesContracts; +using SoftwareInstallationContracts.ViewModels; +using SoftwareInstallationListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationListImplement.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 (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; + } + } +} \ No newline at end of file diff --git a/SoftwareInstallationListImplement/Models/Component.cs b/SoftwareInstallationListImplement/Models/Component.cs index 4a114fb..90247de 100644 --- a/SoftwareInstallationListImplement/Models/Component.cs +++ b/SoftwareInstallationListImplement/Models/Component.cs @@ -1,6 +1,11 @@ using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace SoftwareInstallationListImplement.Models { @@ -8,7 +13,8 @@ namespace SoftwareInstallationListImplement.Models { public int Id { get; private set; } public string ComponentName { get; private set; } = string.Empty; - public double Cost { get; set; } + public double Cost { get; private set; } + public static Component? Create(ComponentBindingModel? model) { if (model == null) @@ -38,4 +44,4 @@ namespace SoftwareInstallationListImplement.Models Cost = Cost }; } -} \ No newline at end of file +} diff --git a/SoftwareInstallationListImplement/Models/Order.cs b/SoftwareInstallationListImplement/Models/Order.cs index fe7cccd..95f298a 100644 --- a/SoftwareInstallationListImplement/Models/Order.cs +++ b/SoftwareInstallationListImplement/Models/Order.cs @@ -5,7 +5,6 @@ using SoftwareInstallationDataModels.Models; using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -17,9 +16,10 @@ namespace SoftwareInstallationListImplement.Models public int PackageId { get; private set; } public int Count { get; private set; } public double Sum { get; private set; } - public OrderStatus Status { get; private set; } - public DateTime DateCreate { get; private set; } + public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; private set; } = DateTime.Now; public DateTime? DateImplement { get; private set; } + public static Order? Create(OrderBindingModel? model) { if (model == null) @@ -37,19 +37,17 @@ namespace SoftwareInstallationListImplement.Models DateImplement = model.DateImplement, }; } + public void Update(OrderBindingModel? model) { if (model == null) { return; } - PackageId = model.PackageId; - Count = model.Count; - Sum = model.Sum; Status = model.Status; - DateCreate = model.DateCreate; - DateImplement = model.DateImplement; + if (model.Status == OrderStatus.Выдан) DateImplement = model.DateImplement; } + public OrderViewModel GetViewModel => new() { Id = Id, diff --git a/SoftwareInstallationListImplement/Models/Package.cs b/SoftwareInstallationListImplement/Models/Package.cs index 3d51572..9e55215 100644 --- a/SoftwareInstallationListImplement/Models/Package.cs +++ b/SoftwareInstallationListImplement/Models/Package.cs @@ -9,16 +9,13 @@ using System.Threading.Tasks; namespace SoftwareInstallationListImplement.Models { - internal class Package : IPackageModel + public class Package : IPackageModel { public int Id { get; private set; } public string PackageName { get; private set; } = string.Empty; public double Price { get; private set; } - public Dictionary PackageComponents - { - get; - private set; - } = new Dictionary(); + public Dictionary PackageComponents { get; private set; } = new Dictionary(); + public static Package? Create(PackageBindingModel? model) { if (model == null) @@ -30,9 +27,10 @@ namespace SoftwareInstallationListImplement.Models Id = model.Id, PackageName = model.PackageName, Price = model.Price, - PackageComponents = model.PackageComponents + PackageComponents = model.PackageComponents, }; } + public void Update(PackageBindingModel? model) { if (model == null) @@ -43,6 +41,7 @@ namespace SoftwareInstallationListImplement.Models Price = model.Price; PackageComponents = model.PackageComponents; } + public PackageViewModel GetViewModel => new() { Id = Id, @@ -50,6 +49,5 @@ namespace SoftwareInstallationListImplement.Models Price = Price, PackageComponents = PackageComponents }; - } } diff --git a/SoftwareInstallationListImplement/Models/Shop.cs b/SoftwareInstallationListImplement/Models/Shop.cs new file mode 100644 index 0000000..d05feae --- /dev/null +++ b/SoftwareInstallationListImplement/Models/Shop.cs @@ -0,0 +1,55 @@ +using SoftwareInstallationDataModels.Models; +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftwareInstallationListImplement.Models +{ + public class Shop : IShopModel + { + public int Id { get; private set; } + public string ShopName { get; private set; } = string.Empty; + public string Adress { get; private set; } = string.Empty; + public DateTime OpeningDate { get; private set; } + public Dictionary ShopPackages { get; private set; } = new(); + + 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 + }; + } + + 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, + ShopPackages = ShopPackages + }; + } +} \ No newline at end of file -- 2.25.1