From 685a8128b13d1498870309ba8e954a26f862f030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Mon, 6 Mar 2023 17:15:03 +0400 Subject: [PATCH 01/21] final --- SecuritySystem/Form1.Designer.cs | 39 --- SecuritySystem/Form1.cs | 10 - SecuritySystem/FormComponent.Designer.cs | 119 +++++++++ SecuritySystem/FormComponent.cs | 90 +++++++ .../{Form1.resx => FormComponent.resx} | 0 SecuritySystem/FormComponents.Designer.cs | 130 ++++++++++ SecuritySystem/FormComponents.cs | 114 +++++++++ SecuritySystem/FormComponents.resx | 120 +++++++++ SecuritySystem/FormCreateOrder.Designer.cs | 145 +++++++++++ SecuritySystem/FormCreateOrder.cs | 112 +++++++++ SecuritySystem/FormCreateOrder.resx | 120 +++++++++ SecuritySystem/FormMain.Designer.cs | 187 ++++++++++++++ SecuritySystem/FormMain.cs | 177 +++++++++++++ SecuritySystem/FormMain.resx | 120 +++++++++ SecuritySystem/FormManufacture.Designer.cs | 236 ++++++++++++++++++ SecuritySystem/FormManufacture.cs | 209 ++++++++++++++++ SecuritySystem/FormManufacture.resx | 120 +++++++++ .../FormManufactureComponent.Designer.cs | 119 +++++++++ SecuritySystem/FormManufactureComponent.cs | 88 +++++++ SecuritySystem/FormManufactureComponent.resx | 120 +++++++++ SecuritySystem/FormManufacturies.Designer.cs | 130 ++++++++++ SecuritySystem/FormManufacturies.cs | 107 ++++++++ SecuritySystem/FormManufacturies.resx | 120 +++++++++ SecuritySystem/Program.cs | 43 +++- SecuritySystem/SecuritySystem.csproj | 11 - SecuritySystem/SecuritySystem.sln | 26 +- SecuritySystem/SecuritySystemView.csproj | 21 ++ SecuritySystem/nlog.config | 15 ++ .../BindingModels/ComponentBindingModel.cs | 17 ++ .../BindingModels/ManufactureBindingModel.cs | 17 ++ .../BindingModels/OrderBindingModel.cs | 17 ++ .../IComponentLogic.cs | 15 ++ .../IManufactureLogic.cs | 21 ++ .../BusinessLogicsContracts/IOrderLogic.cs | 20 ++ .../SearchModels/ComponentSearchModel.cs | 14 ++ .../SearchModels/ManufactureSearchModel.cs | 14 ++ .../SearchModels/OrderSearchModel.cs | 13 + .../SecuritySystemContracts.csproj | 19 ++ .../StorageContracts/IComponentStorage.cs | 21 ++ .../StorageContracts/IManufactureStorage.cs | 21 ++ .../StorageContracts/IOrderStorage.cs | 21 ++ .../ViewModels/ComponentViewModel.cs | 19 ++ .../ViewModels/ManufactureViewModel.cs | 24 ++ .../ViewModels/OrderViewModel.cs | 32 +++ SecuritySystemDataModels/Enums/OrderStatus.cs | 17 ++ SecuritySystemDataModels/IId.cs | 13 + .../Models/IComponentModel.cs | 15 ++ .../Models/IManufactureModel.cs | 16 ++ .../Models/IOrderModel.cs | 20 ++ .../SecuritySystemDataModels.csproj | 15 ++ .../DataListSingletone.cs | 32 +++ .../Implements/ComponentStorage.cs | 104 ++++++++ .../Implements/ManufactureStorage.cs | 102 ++++++++ .../Implements/OrderStorage.cs | 115 +++++++++ .../Models/Component.cs | 47 ++++ .../Models/Manufacture.cs | 55 ++++ SecuritySystemListImplement/Models/Order.cs | 76 ++++++ .../SecuritySystemListImplement.csproj | 14 ++ SystemSecurityBusinessLogic/ComponentLogic.cs | 109 ++++++++ .../ManufactureLogic.cs | 115 +++++++++ SystemSecurityBusinessLogic/OrderLogic.cs | 112 +++++++++ .../SystemSecurityBusinessLogic.csproj | 19 ++ 62 files changed, 4086 insertions(+), 63 deletions(-) delete mode 100644 SecuritySystem/Form1.Designer.cs delete mode 100644 SecuritySystem/Form1.cs create mode 100644 SecuritySystem/FormComponent.Designer.cs create mode 100644 SecuritySystem/FormComponent.cs rename SecuritySystem/{Form1.resx => FormComponent.resx} (100%) create mode 100644 SecuritySystem/FormComponents.Designer.cs create mode 100644 SecuritySystem/FormComponents.cs create mode 100644 SecuritySystem/FormComponents.resx create mode 100644 SecuritySystem/FormCreateOrder.Designer.cs create mode 100644 SecuritySystem/FormCreateOrder.cs create mode 100644 SecuritySystem/FormCreateOrder.resx create mode 100644 SecuritySystem/FormMain.Designer.cs create mode 100644 SecuritySystem/FormMain.cs create mode 100644 SecuritySystem/FormMain.resx create mode 100644 SecuritySystem/FormManufacture.Designer.cs create mode 100644 SecuritySystem/FormManufacture.cs create mode 100644 SecuritySystem/FormManufacture.resx create mode 100644 SecuritySystem/FormManufactureComponent.Designer.cs create mode 100644 SecuritySystem/FormManufactureComponent.cs create mode 100644 SecuritySystem/FormManufactureComponent.resx create mode 100644 SecuritySystem/FormManufacturies.Designer.cs create mode 100644 SecuritySystem/FormManufacturies.cs create mode 100644 SecuritySystem/FormManufacturies.resx delete mode 100644 SecuritySystem/SecuritySystem.csproj create mode 100644 SecuritySystem/SecuritySystemView.csproj create mode 100644 SecuritySystem/nlog.config create mode 100644 SecuritySystemContracts/BindingModels/ComponentBindingModel.cs create mode 100644 SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs create mode 100644 SecuritySystemContracts/BindingModels/OrderBindingModel.cs create mode 100644 SecuritySystemContracts/BusinessLogicsContracts/IComponentLogic.cs create mode 100644 SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs create mode 100644 SecuritySystemContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 SecuritySystemContracts/SearchModels/ComponentSearchModel.cs create mode 100644 SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs create mode 100644 SecuritySystemContracts/SearchModels/OrderSearchModel.cs create mode 100644 SecuritySystemContracts/SecuritySystemContracts.csproj create mode 100644 SecuritySystemContracts/StorageContracts/IComponentStorage.cs create mode 100644 SecuritySystemContracts/StorageContracts/IManufactureStorage.cs create mode 100644 SecuritySystemContracts/StorageContracts/IOrderStorage.cs create mode 100644 SecuritySystemContracts/ViewModels/ComponentViewModel.cs create mode 100644 SecuritySystemContracts/ViewModels/ManufactureViewModel.cs create mode 100644 SecuritySystemContracts/ViewModels/OrderViewModel.cs create mode 100644 SecuritySystemDataModels/Enums/OrderStatus.cs create mode 100644 SecuritySystemDataModels/IId.cs create mode 100644 SecuritySystemDataModels/Models/IComponentModel.cs create mode 100644 SecuritySystemDataModels/Models/IManufactureModel.cs create mode 100644 SecuritySystemDataModels/Models/IOrderModel.cs create mode 100644 SecuritySystemDataModels/SecuritySystemDataModels.csproj create mode 100644 SecuritySystemListImplement/DataListSingletone.cs create mode 100644 SecuritySystemListImplement/Implements/ComponentStorage.cs create mode 100644 SecuritySystemListImplement/Implements/ManufactureStorage.cs create mode 100644 SecuritySystemListImplement/Implements/OrderStorage.cs create mode 100644 SecuritySystemListImplement/Models/Component.cs create mode 100644 SecuritySystemListImplement/Models/Manufacture.cs create mode 100644 SecuritySystemListImplement/Models/Order.cs create mode 100644 SecuritySystemListImplement/SecuritySystemListImplement.csproj create mode 100644 SystemSecurityBusinessLogic/ComponentLogic.cs create mode 100644 SystemSecurityBusinessLogic/ManufactureLogic.cs create mode 100644 SystemSecurityBusinessLogic/OrderLogic.cs create mode 100644 SystemSecurityBusinessLogic/SystemSecurityBusinessLogic.csproj diff --git a/SecuritySystem/Form1.Designer.cs b/SecuritySystem/Form1.Designer.cs deleted file mode 100644 index 241ccba..0000000 --- a/SecuritySystem/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace SecuritySystem -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/SecuritySystem/Form1.cs b/SecuritySystem/Form1.cs deleted file mode 100644 index b9d425d..0000000 --- a/SecuritySystem/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace SecuritySystem -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/SecuritySystem/FormComponent.Designer.cs b/SecuritySystem/FormComponent.Designer.cs new file mode 100644 index 0000000..280f9a6 --- /dev/null +++ b/SecuritySystem/FormComponent.Designer.cs @@ -0,0 +1,119 @@ +namespace SecuritySystemView +{ + partial class FormComponent + { + /// + /// 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.labelName = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxCost = new System.Windows.Forms.TextBox(); + this.labelCost = new System.Windows.Forms.Label(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(12, 9); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(80, 20); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название:"; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(98, 9); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(366, 27); + this.textBoxName.TabIndex = 1; + // + // textBoxCost + // + this.textBoxCost.Location = new System.Drawing.Point(98, 42); + this.textBoxCost.Name = "textBoxCost"; + this.textBoxCost.Size = new System.Drawing.Size(133, 27); + this.textBoxCost.TabIndex = 3; + // + // labelCost + // + this.labelCost.AutoSize = true; + this.labelCost.Location = new System.Drawing.Point(12, 42); + this.labelCost.Name = "labelCost"; + this.labelCost.Size = new System.Drawing.Size(45, 20); + this.labelCost.TabIndex = 2; + this.labelCost.Text = "Цена"; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(171, 90); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(130, 40); + this.buttonSave.TabIndex = 4; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(328, 90); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(136, 40); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(478, 142); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxCost); + this.Controls.Add(this.labelCost); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelName); + this.Name = "FormComponent"; + this.Text = "Компонент"; + this.Load += new System.EventHandler(this.FormComponent_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelName; + private TextBox textBoxName; + private TextBox textBoxCost; + private Label labelCost; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/SecuritySystem/FormComponent.cs b/SecuritySystem/FormComponent.cs new file mode 100644 index 0000000..bfd6ac0 --- /dev/null +++ b/SecuritySystem/FormComponent.cs @@ -0,0 +1,90 @@ +using Microsoft.Extensions.Logging; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.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 SecuritySystemView +{ + public partial class FormComponent : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + public FormComponent(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormComponent_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение компонента"); + var view = _logic.ReadElement(new ComponentSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ComponentName; + textBoxCost.Text = view.Cost.ToString(); + } + } + 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; + } + _logger.LogInformation("Сохранение компонента"); + try + { + var model = new ComponentBindingModel + { + Id = _id ?? 0, + ComponentName = textBoxName.Text, + Cost = Convert.ToDouble(textBoxCost.Text) + }; + 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/SecuritySystem/Form1.resx b/SecuritySystem/FormComponent.resx similarity index 100% rename from SecuritySystem/Form1.resx rename to SecuritySystem/FormComponent.resx diff --git a/SecuritySystem/FormComponents.Designer.cs b/SecuritySystem/FormComponents.Designer.cs new file mode 100644 index 0000000..49f0d8f --- /dev/null +++ b/SecuritySystem/FormComponents.Designer.cs @@ -0,0 +1,130 @@ +namespace SecuritySystemView +{ + partial class FormComponents + { + /// + /// 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.dataGridView = new System.Windows.Forms.DataGridView(); + 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(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.ToolsPanel.SuspendLayout(); + this.SuspendLayout(); + // + // 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 = 0; + // + // 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 = 1; + // + // 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); + // + // FormComponents + // + 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 = "FormComponents"; + this.Text = "Компоненты"; + this.Load += new System.EventHandler(this.FormComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ToolsPanel.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Panel ToolsPanel; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/SecuritySystem/FormComponents.cs b/SecuritySystem/FormComponents.cs new file mode 100644 index 0000000..f1d5cf2 --- /dev/null +++ b/SecuritySystem/FormComponents.cs @@ -0,0 +1,114 @@ +using Microsoft.Extensions.Logging; +using SecuritySystem; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.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 SecuritySystemView +{ + public partial class FormComponents : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormComponents_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["ComponentName"].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(FormComponent)); + if (service is FormComponent 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(FormComponent)); + if (service is FormComponent form) + { + form.Id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление компонента"); + try + { + if (!_logic.Delete(new ComponentBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления компонента"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/SecuritySystem/FormComponents.resx b/SecuritySystem/FormComponents.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SecuritySystem/FormComponents.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/SecuritySystem/FormCreateOrder.Designer.cs b/SecuritySystem/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..9a89b05 --- /dev/null +++ b/SecuritySystem/FormCreateOrder.Designer.cs @@ -0,0 +1,145 @@ +namespace SecuritySystemView +{ + partial class FormCreateOrder + { + /// + /// 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.labelManufacture = new System.Windows.Forms.Label(); + this.comboBoxManufacture = new System.Windows.Forms.ComboBox(); + this.labelCount = new System.Windows.Forms.Label(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.labelSum = new System.Windows.Forms.Label(); + this.textBoxSum = new System.Windows.Forms.TextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelManufacture + // + this.labelManufacture.AutoSize = true; + this.labelManufacture.Location = new System.Drawing.Point(12, 15); + this.labelManufacture.Name = "labelManufacture"; + this.labelManufacture.Size = new System.Drawing.Size(75, 20); + this.labelManufacture.TabIndex = 0; + this.labelManufacture.Text = "Изделие: "; + // + // comboBoxManufacture + // + this.comboBoxManufacture.FormattingEnabled = true; + this.comboBoxManufacture.Location = new System.Drawing.Point(115, 12); + this.comboBoxManufacture.Name = "comboBoxManufacture"; + this.comboBoxManufacture.Size = new System.Drawing.Size(358, 28); + this.comboBoxManufacture.TabIndex = 1; + this.comboBoxManufacture.SelectedIndexChanged += new System.EventHandler(this.ComboBoxManufacture_SelectedIndexChanged); + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(12, 49); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(97, 20); + this.labelCount.TabIndex = 2; + this.labelCount.Text = "Количество: "; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(115, 46); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(358, 27); + this.textBoxCount.TabIndex = 3; + this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); + // + // labelSum + // + this.labelSum.AutoSize = true; + this.labelSum.Location = new System.Drawing.Point(12, 80); + this.labelSum.Name = "labelSum"; + this.labelSum.Size = new System.Drawing.Size(62, 20); + this.labelSum.TabIndex = 4; + this.labelSum.Text = "Сумма: "; + // + // textBoxSum + // + this.textBoxSum.Location = new System.Drawing.Point(115, 80); + this.textBoxSum.Name = "textBoxSum"; + this.textBoxSum.ReadOnly = true; + this.textBoxSum.Size = new System.Drawing.Size(358, 27); + this.textBoxSum.TabIndex = 5; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(337, 113); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(110, 32); + 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(221, 113); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(110, 32); + this.buttonSave.TabIndex = 7; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // FormCreateOrder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(485, 158); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxSum); + this.Controls.Add(this.labelSum); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.comboBoxManufacture); + this.Controls.Add(this.labelManufacture); + this.Name = "FormCreateOrder"; + this.Text = "Заказ"; + this.Load += new System.EventHandler(this.FormCreateOrder_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelManufacture; + private ComboBox comboBoxManufacture; + private Label labelCount; + private TextBox textBoxCount; + private Label labelSum; + private TextBox textBoxSum; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/SecuritySystem/FormCreateOrder.cs b/SecuritySystem/FormCreateOrder.cs new file mode 100644 index 0000000..a7ce11f --- /dev/null +++ b/SecuritySystem/FormCreateOrder.cs @@ -0,0 +1,112 @@ +using Microsoft.Extensions.Logging; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; +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 SecuritySystemView +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly IManufactureLogic _logicM; + private readonly IOrderLogic _logicO; + private List? _list; + public FormCreateOrder(ILogger logger, IManufactureLogic logicM, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicM = logicM; + _logicO = logicO; + } + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _list = _logicM.ReadList(null); + if (_list != null) + { + comboBoxManufacture.DisplayMember = "ManufactureName"; + comboBoxManufacture.ValueMember = "Id"; + comboBoxManufacture.DataSource = _list; + comboBoxManufacture.SelectedItem = null; + _logger.LogInformation("Загрузка изделий для заказа"); + } + } + private void CalcSum() + { + if (comboBoxManufacture.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxManufacture.SelectedValue); + var Manufacture = _logicM.ReadElement(new ManufactureSearchModel { Id = id }); + int count = Convert.ToInt32(textBoxCount.Text); + textBoxSum.Text = Math.Round(count * (Manufacture?.Price ?? 0), 2).ToString(); + _logger.LogInformation("Расчет суммы заказа"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка расчета суммы заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void TextBoxCount_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxManufacture.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание заказа"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + ManufactureId = Convert.ToInt32(comboBoxManufacture.SelectedValue), + ManufactureName = comboBoxManufacture.Text, + Count = Convert.ToInt32(textBoxCount.Text), + Sum = Convert.ToDouble(textBoxSum.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/SecuritySystem/FormCreateOrder.resx b/SecuritySystem/FormCreateOrder.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SecuritySystem/FormCreateOrder.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/SecuritySystem/FormMain.Designer.cs b/SecuritySystem/FormMain.Designer.cs new file mode 100644 index 0000000..0558535 --- /dev/null +++ b/SecuritySystem/FormMain.Designer.cs @@ -0,0 +1,187 @@ +namespace SecuritySystemView +{ + partial class FormMain + { + /// + /// 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.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.guideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.goodsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.buttonCreateOrder = new System.Windows.Forms.Button(); + this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); + this.buttonOrderReady = new System.Windows.Forms.Button(); + this.buttonIssuedOrder = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + this.menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.guideToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2); + this.menuStrip1.Size = new System.Drawing.Size(1149, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // guideToolStripMenuItem + // + this.guideToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.componentsToolStripMenuItem, + this.goodsToolStripMenuItem}); + this.guideToolStripMenuItem.Name = "guideToolStripMenuItem"; + this.guideToolStripMenuItem.Size = new System.Drawing.Size(87, 20); + this.guideToolStripMenuItem.Text = "Справочник"; + // + // componentsToolStripMenuItem + // + this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; + this.componentsToolStripMenuItem.Size = new System.Drawing.Size(145, 22); + this.componentsToolStripMenuItem.Text = "Компоненты"; + this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); + // + // goodsToolStripMenuItem + // + this.goodsToolStripMenuItem.Name = "goodsToolStripMenuItem"; + this.goodsToolStripMenuItem.Size = new System.Drawing.Size(145, 22); + this.goodsToolStripMenuItem.Text = "Изделия"; + this.goodsToolStripMenuItem.Click += new System.EventHandler(this.GoodsToolStripMenuItem_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(10, 23); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(855, 286); + this.dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + this.buttonCreateOrder.Location = new System.Drawing.Point(898, 53); + this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCreateOrder.Name = "buttonCreateOrder"; + this.buttonCreateOrder.Size = new System.Drawing.Size(216, 22); + this.buttonCreateOrder.TabIndex = 2; + this.buttonCreateOrder.Text = "Создать заказ"; + this.buttonCreateOrder.UseVisualStyleBackColor = true; + this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); + // + // buttonTakeOrderInWork + // + this.buttonTakeOrderInWork.Location = new System.Drawing.Point(898, 92); + this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + this.buttonTakeOrderInWork.Size = new System.Drawing.Size(216, 22); + this.buttonTakeOrderInWork.TabIndex = 3; + this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; + this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; + this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + // + // buttonOrderReady + // + this.buttonOrderReady.Location = new System.Drawing.Point(898, 129); + this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonOrderReady.Name = "buttonOrderReady"; + this.buttonOrderReady.Size = new System.Drawing.Size(216, 22); + this.buttonOrderReady.TabIndex = 4; + this.buttonOrderReady.Text = "Заказ готов"; + this.buttonOrderReady.UseVisualStyleBackColor = true; + this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); + // + // buttonIssuedOrder + // + this.buttonIssuedOrder.Location = new System.Drawing.Point(898, 169); + this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonIssuedOrder.Name = "buttonIssuedOrder"; + this.buttonIssuedOrder.Size = new System.Drawing.Size(216, 22); + this.buttonIssuedOrder.TabIndex = 5; + this.buttonIssuedOrder.Text = "Заказ выдан"; + this.buttonIssuedOrder.UseVisualStyleBackColor = true; + this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(898, 210); + this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(216, 22); + this.buttonRef.TabIndex = 6; + this.buttonRef.Text = "Обновить список"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1149, 319); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonIssuedOrder); + this.Controls.Add(this.buttonOrderReady); + this.Controls.Add(this.buttonTakeOrderInWork); + this.Controls.Add(this.buttonCreateOrder); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormMain"; + this.Text = "Система Охраны"; + this.Load += new System.EventHandler(this.FormMain_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem guideToolStripMenuItem; + private ToolStripMenuItem componentsToolStripMenuItem; + private ToolStripMenuItem goodsToolStripMenuItem; + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; + private Button buttonRef; + } +} \ No newline at end of file diff --git a/SecuritySystem/FormMain.cs b/SecuritySystem/FormMain.cs new file mode 100644 index 0000000..6ce123b --- /dev/null +++ b/SecuritySystem/FormMain.cs @@ -0,0 +1,177 @@ +using SecuritySystem; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Microsoft.Extensions.Logging; +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.BindingModels; +using SecuritySystemDataModels.Enums; + +namespace SecuritySystemView +{ + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["ManufactureId"].Visible = false; + dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void GoodsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormManufacturies)); + if (service is FormManufacturies form) + { + form.ShowDialog(); + } + } + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ No {id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel + { + Id = id, + ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), + ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ No {id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel + { + Id = id, + ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), + ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + DateImplement = DateTime.Now, + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ No {id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = id, + ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), + ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + DateImplement = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateImplement"].Value.ToString()), + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ No {id} выдан", id); + 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/SecuritySystem/FormMain.resx b/SecuritySystem/FormMain.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SecuritySystem/FormMain.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/SecuritySystem/FormManufacture.Designer.cs b/SecuritySystem/FormManufacture.Designer.cs new file mode 100644 index 0000000..d4283d0 --- /dev/null +++ b/SecuritySystem/FormManufacture.Designer.cs @@ -0,0 +1,236 @@ +namespace SecuritySystemView +{ + partial class FormManufacture + { + /// + /// 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.labelName = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.labelPrice = new System.Windows.Forms.Label(); + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.groupBoxComponents = new System.Windows.Forms.GroupBox(); + 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.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.groupBoxComponents.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(16, 15); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(84, 20); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название: "; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(112, 12); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(293, 27); + this.textBoxName.TabIndex = 1; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(16, 51); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(90, 20); + this.labelPrice.TabIndex = 2; + this.labelPrice.Text = "Стоимость: "; + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(112, 51); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(171, 27); + this.textBoxPrice.TabIndex = 3; + // + // groupBoxComponents + // + this.groupBoxComponents.Controls.Add(this.buttonRef); + this.groupBoxComponents.Controls.Add(this.buttonDel); + this.groupBoxComponents.Controls.Add(this.buttonUpd); + this.groupBoxComponents.Controls.Add(this.buttonAdd); + this.groupBoxComponents.Controls.Add(this.dataGridView); + this.groupBoxComponents.Location = new System.Drawing.Point(12, 84); + this.groupBoxComponents.Name = "groupBoxComponents"; + this.groupBoxComponents.Size = new System.Drawing.Size(661, 319); + this.groupBoxComponents.TabIndex = 4; + this.groupBoxComponents.TabStop = false; + this.groupBoxComponents.Text = "Компоненты"; + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(502, 211); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(126, 34); + this.buttonRef.TabIndex = 4; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(502, 157); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(126, 34); + this.buttonDel.TabIndex = 3; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(502, 102); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(126, 34); + this.buttonUpd.TabIndex = 2; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(502, 47); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(126, 34); + this.buttonAdd.TabIndex = 1; + 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.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, + this.Component, + this.Count}); + this.dataGridView.Location = new System.Drawing.Point(6, 26); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(476, 287); + this.dataGridView.TabIndex = 0; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(514, 417); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(126, 34); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(368, 417); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(126, 34); + this.buttonSave.TabIndex = 6; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // id + // + this.id.HeaderText = "id"; + this.id.MinimumWidth = 6; + this.id.Name = "id"; + this.id.ReadOnly = true; + this.id.Visible = false; + // + // Component + // + this.Component.HeaderText = "Компонент"; + this.Component.MinimumWidth = 6; + this.Component.Name = "Component"; + this.Component.ReadOnly = true; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + this.Count.ReadOnly = true; + // + // FormManufacture + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(685, 463); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBoxComponents); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelName); + this.Name = "FormManufacture"; + this.Text = "Изделие"; + this.Load += new System.EventHandler(this.FormManufacture_Load); + this.groupBoxComponents.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelName; + private TextBox textBoxName; + private Label labelPrice; + private TextBox textBoxPrice; + private GroupBox groupBoxComponents; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Count; + private Button buttonCancel; + private Button buttonSave; + private DataGridViewTextBoxColumn id; + } +} \ No newline at end of file diff --git a/SecuritySystem/FormManufacture.cs b/SecuritySystem/FormManufacture.cs new file mode 100644 index 0000000..0a6a1a6 --- /dev/null +++ b/SecuritySystem/FormManufacture.cs @@ -0,0 +1,209 @@ +using Microsoft.Extensions.Logging; +using SecuritySystem; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.SearchModels; +using SecuritySystemDataModels.Models; +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 SecuritySystemView +{ + public partial class FormManufacture : Form + { + private readonly ILogger _logger; + private readonly IManufactureLogic _logic; + private int? _id; + private Dictionary _ManufactureComponents; + public int Id { set { _id = value; } } + public FormManufacture(ILogger logger, IManufactureLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _ManufactureComponents = new Dictionary(); + } + private void FormManufacture_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка изделия"); + try + { + var view = _logic.ReadElement(new ManufactureSearchModel { Id = _id.Value }); + if (view != null) + { + textBoxName.Text = view.ManufactureName; + textBoxPrice.Text = view.Price.ToString(); + _ManufactureComponents = view.ManufactureComponents ?? new + Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка компонент изделия"); + try + { + if (_ManufactureComponents != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _ManufactureComponents) + { + dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); + } + textBoxPrice.Text = CalcPrice().ToString(); + } + } + 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(FormManufactureComponent)); + if (service is FormManufactureComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Добавление нового компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); + if (_ManufactureComponents.ContainsKey(form.Id)) + { + _ManufactureComponents[form.Id] = (form.ComponentModel, form.Count); + } + else + { + _ManufactureComponents.Add(form.Id, (form.ComponentModel, form.Count)); + } + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); + if (service is FormManufactureComponent form) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _ManufactureComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); + _ManufactureComponents[form.Id] = (form.ComponentModel, form.Count); + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление компонента: {ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); + _ManufactureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxPrice.Text)) + { + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (_ManufactureComponents == null || _ManufactureComponents.Count == 0) + { + MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение изделия"); + try + { + var model = new ManufactureBindingModel + { + Id = _id ?? 0, + ManufactureName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + ManufactureComponents = _ManufactureComponents + }; + 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(); + } + private double CalcPrice() + { + double price = 0; + foreach (var elem in _ManufactureComponents) + { + price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); + } + } +} diff --git a/SecuritySystem/FormManufacture.resx b/SecuritySystem/FormManufacture.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SecuritySystem/FormManufacture.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/SecuritySystem/FormManufactureComponent.Designer.cs b/SecuritySystem/FormManufactureComponent.Designer.cs new file mode 100644 index 0000000..686592c --- /dev/null +++ b/SecuritySystem/FormManufactureComponent.Designer.cs @@ -0,0 +1,119 @@ +namespace SecuritySystemView +{ + partial class FormManufactureComponent + { + /// + /// 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.labelComponent = new System.Windows.Forms.Label(); + this.comboBoxComponent = 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(); + // + // labelComponent + // + this.labelComponent.AutoSize = true; + this.labelComponent.Location = new System.Drawing.Point(12, 9); + this.labelComponent.Name = "labelComponent"; + this.labelComponent.Size = new System.Drawing.Size(91, 20); + this.labelComponent.TabIndex = 0; + this.labelComponent.Text = "Компонент:"; + // + // comboBoxComponent + // + this.comboBoxComponent.FormattingEnabled = true; + this.comboBoxComponent.Location = new System.Drawing.Point(119, 9); + this.comboBoxComponent.Name = "comboBoxComponent"; + this.comboBoxComponent.Size = new System.Drawing.Size(355, 28); + this.comboBoxComponent.TabIndex = 1; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(12, 51); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(93, 20); + this.labelCount.TabIndex = 2; + this.labelCount.Text = "Количество:"; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(119, 51); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(355, 27); + this.textBoxCount.TabIndex = 3; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(317, 94); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(136, 41); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(175, 94); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(136, 41); + this.buttonSave.TabIndex = 5; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // FormManufactureComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(486, 147); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.comboBoxComponent); + this.Controls.Add(this.labelComponent); + this.Name = "FormManufactureComponent"; + this.Text = "Компонент изделия"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelComponent; + private ComboBox comboBoxComponent; + private Label labelCount; + private TextBox textBoxCount; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/SecuritySystem/FormManufactureComponent.cs b/SecuritySystem/FormManufactureComponent.cs new file mode 100644 index 0000000..cdf9c1a --- /dev/null +++ b/SecuritySystem/FormManufactureComponent.cs @@ -0,0 +1,88 @@ +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.ViewModels; +using SecuritySystemDataModels.Models; +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 SecuritySystemView +{ + public partial class FormManufactureComponent : Form + { + private readonly List? _list; + public int Id + { + get + { + return Convert.ToInt32(comboBoxComponent.SelectedValue); + } + set + { + comboBoxComponent.SelectedValue = value; + } + } + public IComponentModel? ComponentModel + { + get + { + if (_list == null) + { + return null; + } + foreach (var elem in _list) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + public int Count + { + get { return Convert.ToInt32(textBoxCount.Text); } + set { textBoxCount.Text = value.ToString(); } + } + public FormManufactureComponent(IComponentLogic logic) + { + InitializeComponent(); + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxComponent.DisplayMember = "ComponentName"; + comboBoxComponent.ValueMember = "Id"; + comboBoxComponent.DataSource = _list; + comboBoxComponent.SelectedItem = null; + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxComponent.SelectedValue == null) + { + MessageBox.Show("Выберите компонент", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + DialogResult = DialogResult.OK; + Close(); + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/SecuritySystem/FormManufactureComponent.resx b/SecuritySystem/FormManufactureComponent.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SecuritySystem/FormManufactureComponent.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/SecuritySystem/FormManufacturies.Designer.cs b/SecuritySystem/FormManufacturies.Designer.cs new file mode 100644 index 0000000..5147d93 --- /dev/null +++ b/SecuritySystem/FormManufacturies.Designer.cs @@ -0,0 +1,130 @@ +namespace SecuritySystemView +{ + partial class FormManufacturies + { + /// + /// 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; + // + // FormManufacturies + // + 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 = "FormManufacturies"; + this.Text = "Изделия"; + this.Load += new System.EventHandler(this.FormManufacturies_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/SecuritySystem/FormManufacturies.cs b/SecuritySystem/FormManufacturies.cs new file mode 100644 index 0000000..61d79fc --- /dev/null +++ b/SecuritySystem/FormManufacturies.cs @@ -0,0 +1,107 @@ +using Microsoft.Extensions.Logging; +using SecuritySystem; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.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 SecuritySystemView +{ + public partial class FormManufacturies : Form + { + private readonly ILogger _logger; + private readonly IManufactureLogic _logic; + public FormManufacturies(ILogger logger, IManufactureLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormManufacturies_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["ManufactureComponents"].Visible = false; + dataGridView.Columns["ManufactureName"].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(FormManufacture)); + if (service is FormManufacture 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(FormManufacture)); + if (service is FormManufacture 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 ManufactureBindingModel { 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/SecuritySystem/FormManufacturies.resx b/SecuritySystem/FormManufacturies.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SecuritySystem/FormManufacturies.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/SecuritySystem/Program.cs b/SecuritySystem/Program.cs index 1cae504..f6d0b1d 100644 --- a/SecuritySystem/Program.cs +++ b/SecuritySystem/Program.cs @@ -1,9 +1,23 @@ +using SecuritySystemView; +using SecuritySystemBusinessLogic.BusinessLogics; +using SecuritySystemListImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; +using OrdersShopListImplement.Implements; +using SecuritySystemBusinessLogic; +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.StoragesContracts; +using System; + namespace SecuritySystem { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// - /// The main entry point for the application. + /// The main entry point for the application. /// [STAThread] static void Main() @@ -11,7 +25,32 @@ namespace SecuritySystem // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + 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/SecuritySystem/SecuritySystem.csproj b/SecuritySystem/SecuritySystem.csproj deleted file mode 100644 index b57c89e..0000000 --- a/SecuritySystem/SecuritySystem.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - WinExe - net6.0-windows - enable - true - enable - - - \ No newline at end of file diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index 566394b..d169da1 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32922.545 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystem", "SecuritySystem.csproj", "{39A7185D-F1F5-4892-BE6F-72B1A849CA84}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemView", "SecuritySystemView.csproj", "{39A7185D-F1F5-4892-BE6F-72B1A849CA84}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemSecurityBusinessLogic", "..\SystemSecurityBusinessLogic\SystemSecurityBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemDataModels", "..\SecuritySystemDataModels\SecuritySystemDataModels.csproj", "{D12D1329-4362-472B-B6E6-D62B0FF00C63}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +23,22 @@ Global {39A7185D-F1F5-4892-BE6F-72B1A849CA84}.Debug|Any CPU.Build.0 = Debug|Any CPU {39A7185D-F1F5-4892-BE6F-72B1A849CA84}.Release|Any CPU.ActiveCfg = Release|Any CPU {39A7185D-F1F5-4892-BE6F-72B1A849CA84}.Release|Any CPU.Build.0 = Release|Any CPU + {D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}.Release|Any CPU.Build.0 = Release|Any CPU + {C1C491F5-4CB7-4B6B-92CE-41688769709A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C1C491F5-4CB7-4B6B-92CE-41688769709A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C1C491F5-4CB7-4B6B-92CE-41688769709A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C1C491F5-4CB7-4B6B-92CE-41688769709A}.Release|Any CPU.Build.0 = Release|Any CPU + {D12D1329-4362-472B-B6E6-D62B0FF00C63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D12D1329-4362-472B-B6E6-D62B0FF00C63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D12D1329-4362-472B-B6E6-D62B0FF00C63}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D12D1329-4362-472B-B6E6-D62B0FF00C63}.Release|Any CPU.Build.0 = Release|Any CPU + {A5A3381B-3592-41B6-880F-333C2502DF02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5A3381B-3592-41B6-880F-333C2502DF02}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SecuritySystem/SecuritySystemView.csproj b/SecuritySystem/SecuritySystemView.csproj new file mode 100644 index 0000000..e65dd63 --- /dev/null +++ b/SecuritySystem/SecuritySystemView.csproj @@ -0,0 +1,21 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + + + + + + + \ No newline at end of file diff --git a/SecuritySystem/nlog.config b/SecuritySystem/nlog.config new file mode 100644 index 0000000..dcd37c8 --- /dev/null +++ b/SecuritySystem/nlog.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/SecuritySystemContracts/BindingModels/ComponentBindingModel.cs b/SecuritySystemContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..715822b --- /dev/null +++ b/SecuritySystemContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SecuritySystemDataModels.Models; + +namespace SecuritySystemContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + + } +} diff --git a/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs b/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs new file mode 100644 index 0000000..408ec7a --- /dev/null +++ b/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs @@ -0,0 +1,17 @@ + +using SecuritySystemDataModels.Models; + +namespace SecuritySystemContracts.BindingModels +{ + public class ManufactureBindingModel : IManufactureModel + { + public int Id { get; set; } + public string ManufactureName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary ManufactureComponents + { + get; + set; + } = new(); + } +} diff --git a/SecuritySystemContracts/BindingModels/OrderBindingModel.cs b/SecuritySystemContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..eccc6bf --- /dev/null +++ b/SecuritySystemContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,17 @@ +using SecuritySystemDataModels.Models; +using SecuritySystemDataModels.Enums; + +namespace SecuritySystemContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int ManufactureId { get; set; } + public int Count { get; set; } + public double Sum { get; set; } + public string ManufactureName { get; set; } = string.Empty; + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime? DateImplement { get; set; } + } +} diff --git a/SecuritySystemContracts/BusinessLogicsContracts/IComponentLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..48c12b3 --- /dev/null +++ b/SecuritySystemContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,15 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; + +namespace SecuritySystemContracts.BusinessLogicsContracts +{ + public interface IComponentLogic + { + List? ReadList(ComponentSearchModel? model); + ComponentViewModel? ReadElement(ComponentSearchModel model); + bool Create(ComponentBindingModel model); + bool Update(ComponentBindingModel model); + bool Delete(ComponentBindingModel model); + } +} diff --git a/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs new file mode 100644 index 0000000..35eaabc --- /dev/null +++ b/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.BusinessLogicsContracts +{ + public interface IManufactureLogic + { + List? ReadList(ManufactureSearchModel? model); + ManufactureViewModel? ReadElement(ManufactureSearchModel model); + bool Create(ManufactureBindingModel model); + bool Update(ManufactureBindingModel model); + bool Delete(ManufactureBindingModel model); + } +} diff --git a/SecuritySystemContracts/BusinessLogicsContracts/IOrderLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..d63e239 --- /dev/null +++ b/SecuritySystemContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,20 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); + } +} diff --git a/SecuritySystemContracts/SearchModels/ComponentSearchModel.cs b/SecuritySystemContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..a5c4976 --- /dev/null +++ b/SecuritySystemContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs b/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs new file mode 100644 index 0000000..2613f72 --- /dev/null +++ b/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.SearchModels +{ + public class ManufactureSearchModel + { + public int? Id { get; set; } + public string? ManufactureName { get; set; } + } +} diff --git a/SecuritySystemContracts/SearchModels/OrderSearchModel.cs b/SecuritySystemContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..f07e85e --- /dev/null +++ b/SecuritySystemContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/SecuritySystemContracts/SecuritySystemContracts.csproj b/SecuritySystemContracts/SecuritySystemContracts.csproj new file mode 100644 index 0000000..c816b99 --- /dev/null +++ b/SecuritySystemContracts/SecuritySystemContracts.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/SecuritySystemContracts/StorageContracts/IComponentStorage.cs b/SecuritySystemContracts/StorageContracts/IComponentStorage.cs new file mode 100644 index 0000000..6bfb296 --- /dev/null +++ b/SecuritySystemContracts/StorageContracts/IComponentStorage.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.StoragesContracts +{ + public interface IComponentStorage + { + List GetFullList(); + List GetFilteredList(ComponentSearchModel model); + ComponentViewModel? GetElement(ComponentSearchModel model); + ComponentViewModel? Insert(ComponentBindingModel model); + ComponentViewModel? Update(ComponentBindingModel model); + ComponentViewModel? Delete(ComponentBindingModel model); + } +} diff --git a/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs b/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs new file mode 100644 index 0000000..dd0c521 --- /dev/null +++ b/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.StoragesContracts +{ + public interface IManufactureStorage + { + List GetFullList(); + List GetFilteredList(ManufactureSearchModel model); + ManufactureViewModel? GetElement(ManufactureSearchModel model); + ManufactureViewModel? Insert(ManufactureBindingModel model); + ManufactureViewModel? Update(ManufactureBindingModel model); + ManufactureViewModel? Delete(ManufactureBindingModel model); + } +} diff --git a/SecuritySystemContracts/StorageContracts/IOrderStorage.cs b/SecuritySystemContracts/StorageContracts/IOrderStorage.cs new file mode 100644 index 0000000..b0ed803 --- /dev/null +++ b/SecuritySystemContracts/StorageContracts/IOrderStorage.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.StoragesContracts +{ + public interface IOrderStorage + { + List GetFullList(); + List GetFilteredList(OrderSearchModel model); + OrderViewModel? GetElement(OrderSearchModel model); + OrderViewModel? Insert(OrderBindingModel model); + OrderViewModel? Update(OrderBindingModel model); + OrderViewModel? Delete(OrderBindingModel model); + } +} diff --git a/SecuritySystemContracts/ViewModels/ComponentViewModel.cs b/SecuritySystemContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..08769e5 --- /dev/null +++ b/SecuritySystemContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using SecuritySystemDataModels.Models; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + [DisplayName("Название компонента")] + public string ComponentName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Cost { get; set; } + } +} diff --git a/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs b/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs new file mode 100644 index 0000000..c8bfd3e --- /dev/null +++ b/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using SecuritySystemDataModels.Models; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.ViewModels +{ + public class ManufactureViewModel : IManufactureModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string ManufactureName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary ManufactureComponents + { + get; + set; + } = new(); + } +} diff --git a/SecuritySystemContracts/ViewModels/OrderViewModel.cs b/SecuritySystemContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..79b07cb --- /dev/null +++ b/SecuritySystemContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using SecuritySystemDataModels.Models; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SecuritySystemDataModels.Enums; + +namespace SecuritySystemContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int ManufactureId { get; set; } + [DisplayName("Изделие")] + public string ManufactureName { 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; } + + OrderStatus IOrderModel.Status => throw new NotImplementedException(); + } +} diff --git a/SecuritySystemDataModels/Enums/OrderStatus.cs b/SecuritySystemDataModels/Enums/OrderStatus.cs new file mode 100644 index 0000000..a52f920 --- /dev/null +++ b/SecuritySystemDataModels/Enums/OrderStatus.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} diff --git a/SecuritySystemDataModels/IId.cs b/SecuritySystemDataModels/IId.cs new file mode 100644 index 0000000..2a1f738 --- /dev/null +++ b/SecuritySystemDataModels/IId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/SecuritySystemDataModels/Models/IComponentModel.cs b/SecuritySystemDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..3b0c950 --- /dev/null +++ b/SecuritySystemDataModels/Models/IComponentModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/SecuritySystemDataModels/Models/IManufactureModel.cs b/SecuritySystemDataModels/Models/IManufactureModel.cs new file mode 100644 index 0000000..3499105 --- /dev/null +++ b/SecuritySystemDataModels/Models/IManufactureModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemDataModels.Models +{ + public interface IManufactureModel : IId + { + string ManufactureName { get; } + double Price { get; } + Dictionary ManufactureComponents { get; } + } +} diff --git a/SecuritySystemDataModels/Models/IOrderModel.cs b/SecuritySystemDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..13baf8c --- /dev/null +++ b/SecuritySystemDataModels/Models/IOrderModel.cs @@ -0,0 +1,20 @@ +using SecuritySystemDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemDataModels.Models +{ + public interface IOrderModel : IId + { + int ManufactureId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} diff --git a/SecuritySystemDataModels/SecuritySystemDataModels.csproj b/SecuritySystemDataModels/SecuritySystemDataModels.csproj new file mode 100644 index 0000000..17fe669 --- /dev/null +++ b/SecuritySystemDataModels/SecuritySystemDataModels.csproj @@ -0,0 +1,15 @@ + + + + net6.0 + enable + enable + + + + + + + + + diff --git a/SecuritySystemListImplement/DataListSingletone.cs b/SecuritySystemListImplement/DataListSingletone.cs new file mode 100644 index 0000000..da37d1f --- /dev/null +++ b/SecuritySystemListImplement/DataListSingletone.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SecuritySystemListImplement.Models; + +namespace SecuritySystemListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Manufactures { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Manufactures = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} \ No newline at end of file diff --git a/SecuritySystemListImplement/Implements/ComponentStorage.cs b/SecuritySystemListImplement/Implements/ComponentStorage.cs new file mode 100644 index 0000000..4d9bff8 --- /dev/null +++ b/SecuritySystemListImplement/Implements/ComponentStorage.cs @@ -0,0 +1,104 @@ + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; +using SecuritySystemListImplement.Models; + + +namespace SecuritySystemListImplement.Implements +{ + public class ComponentStorage : IComponentStorage + { + private readonly DataListSingleton _source; + public ComponentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var component in _source.Components) + { + result.Add(component.GetViewModel); + } + return result; + } + public List GetFilteredList(ComponentSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ComponentName)) + { + return result; + } + foreach (var component in _source.Components) + { + if (component.ComponentName.Contains(model.ComponentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Components) + { + if ((!string.IsNullOrEmpty(model.ComponentName) && + component.ComponentName == model.ComponentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + _source.Components.Add(newComponent); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + foreach (var component in _source.Components) + { + if (component.Id == model.Id) + { + component.Update(model); + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + for (int i = 0; i < _source.Components.Count; ++i) + { + if (_source.Components[i].Id == model.Id) + { + var element = _source.Components[i]; + _source.Components.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/SecuritySystemListImplement/Implements/ManufactureStorage.cs b/SecuritySystemListImplement/Implements/ManufactureStorage.cs new file mode 100644 index 0000000..5a8ea83 --- /dev/null +++ b/SecuritySystemListImplement/Implements/ManufactureStorage.cs @@ -0,0 +1,102 @@ +using SecuritySystemListImplement.Models; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; + + +namespace SecuritySystemListImplement.Implements +{ + public class ManufactureStorage : IManufactureStorage + { + private readonly DataListSingleton _source; + public ManufactureStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var Manufacture in _source.Manufactures) + { + result.Add(Manufacture.GetViewModel); + } + return result; + } + public List GetFilteredList(ManufactureSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ManufactureName)) + { + return result; + } + foreach (var Manufacture in _source.Manufactures) + { + if (Manufacture.ManufactureName.Contains(model.ManufactureName)) + { + result.Add(Manufacture.GetViewModel); + } + } + return result; + } + public ManufactureViewModel? GetElement(ManufactureSearchModel model) + { + if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) + { + return null; + } + foreach (var Manufacture in _source.Manufactures) + { + if ((!string.IsNullOrEmpty(model.ManufactureName) && Manufacture.ManufactureName == model.ManufactureName) || + (model.Id.HasValue && Manufacture.Id == model.Id)) + { + return Manufacture.GetViewModel; + } + } + return null; + } + public ManufactureViewModel? Insert(ManufactureBindingModel model) + { + model.Id = 1; + foreach (var Manufacture in _source.Manufactures) + { + if (model.Id <= Manufacture.Id) + { + model.Id = Manufacture.Id + 1; + } + } + var newManufacture = Manufacture.Create(model); + if (newManufacture == null) + { + return null; + } + _source.Manufactures.Add(newManufacture); + return newManufacture.GetViewModel; + } + public ManufactureViewModel? Update(ManufactureBindingModel model) + { + foreach (var Manufacture in _source.Manufactures) + { + if (Manufacture.Id == model.Id) + { + Manufacture.Update(model); + return Manufacture.GetViewModel; + } + } + return null; + } + public ManufactureViewModel? Delete(ManufactureBindingModel model) + { + for (int i = 0; i < _source.Manufactures.Count; ++i) + { + if (_source.Manufactures[i].Id == model.Id) + { + var element = _source.Manufactures[i]; + _source.Manufactures.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/SecuritySystemListImplement/Implements/OrderStorage.cs b/SecuritySystemListImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..873ed51 --- /dev/null +++ b/SecuritySystemListImplement/Implements/OrderStorage.cs @@ -0,0 +1,115 @@ +using SecuritySystemListImplement.Models; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; + +using SecuritySystemListImplement; + +namespace OrdersShopListImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataListSingleton _source; + public OrderStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var Order in _source.Orders) + { + result.Add(Order.GetViewModel); + } + return result; + } + public List GetFilteredList(OrderSearchModel model) + { + var result = new List(); + if (model == null) + { + return result; + } + foreach (var Order in _source.Orders) + { + if (Order.Id == model.Id) + { + result.Add(Order.GetViewModel); + } + } + return result; + } + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + foreach (var Order in _source.Orders) + { + if (model.Id.HasValue && Order.Id == model.Id) + { + return Order.GetViewModel; + } + } + return null; + } + public OrderViewModel? Insert(OrderBindingModel model) + { + model.Id = 1; + foreach (var Order in _source.Orders) + { + if (model.Id <= Order.Id) + { + model.Id = Order.Id + 1; + } + } + var newOrder = Order.Create(model); + if (newOrder == null) + { + return null; + } + _source.Orders.Add(newOrder); + return newOrder.GetViewModel; + } + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var Order in _source.Orders) + { + if (Order.Id == model.Id) + { + Order.Update(model); + return Order.GetViewModel; + } + } + return null; + } + public OrderViewModel? Delete(OrderBindingModel model) + { + for (int i = 0; i < _source.Orders.Count; ++i) + { + if (_source.Orders[i].Id == model.Id) + { + var element = _source.Orders[i]; + _source.Orders.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + private OrderViewModel AttachManufactureName(OrderViewModel model) + { + foreach (var manufacture in _source.Manufactures) + { + if (manufacture.Id == model.ManufactureId) + { + model.ManufactureName = manufacture.ManufactureName; + return model; + } + } + return model; + } + + } +} diff --git a/SecuritySystemListImplement/Models/Component.cs b/SecuritySystemListImplement/Models/Component.cs new file mode 100644 index 0000000..4254be1 --- /dev/null +++ b/SecuritySystemListImplement/Models/Component.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.ViewModels; +using SecuritySystemDataModels.Models; + +namespace SecuritySystemListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } +} \ No newline at end of file diff --git a/SecuritySystemListImplement/Models/Manufacture.cs b/SecuritySystemListImplement/Models/Manufacture.cs new file mode 100644 index 0000000..2e1deb9 --- /dev/null +++ b/SecuritySystemListImplement/Models/Manufacture.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.ViewModels; +using SecuritySystemDataModels.Models; + +namespace SecuritySystemListImplement.Models +{ + public class Manufacture : IManufactureModel + { + public int Id { get; private set; } + public string ManufactureName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary ManufactureComponents + { + get; + private set; + } = new Dictionary(); + public static Manufacture? Create(ManufactureBindingModel? model) + { + if (model == null) + { + return null; + } + return new Manufacture() + { + Id = model.Id, + ManufactureName = model.ManufactureName, + Price = model.Price, + ManufactureComponents = model.ManufactureComponents + }; + } + public void Update(ManufactureBindingModel? model) + { + if (model == null) + { + return; + } + ManufactureName = model.ManufactureName; + Price = model.Price; + ManufactureComponents = model.ManufactureComponents; + } + public ManufactureViewModel GetViewModel => new() + { + Id = Id, + ManufactureName = ManufactureName, + Price = Price, + ManufactureComponents = ManufactureComponents + }; + } +} diff --git a/SecuritySystemListImplement/Models/Order.cs b/SecuritySystemListImplement/Models/Order.cs new file mode 100644 index 0000000..88a2e68 --- /dev/null +++ b/SecuritySystemListImplement/Models/Order.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.ViewModels; +using SecuritySystemDataModels.Enums; +using SecuritySystemDataModels.Models; + +namespace SecuritySystemListImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + + public int ManufactureId { get; private set; } + + public string ManufactureName { get; private set; } = string.Empty; + public int Count { get; private set; } + + public double Sum { get; private set; } + + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + + public DateTime DateCreate { get; set; } = DateTime.Now; + + public DateTime? DateImplement { get; set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + ManufactureId = model.ManufactureId, + ManufactureName = model.ManufactureName, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement + }; + } + + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + ManufactureId = model.ManufactureId; + ManufactureName = model.ManufactureName; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + DateImplement = model.DateImplement; + } + public OrderViewModel GetViewModel => new() + { + Id = Id, + ManufactureId = ManufactureId, + ManufactureName = ManufactureName, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement + }; + } +} diff --git a/SecuritySystemListImplement/SecuritySystemListImplement.csproj b/SecuritySystemListImplement/SecuritySystemListImplement.csproj new file mode 100644 index 0000000..7037095 --- /dev/null +++ b/SecuritySystemListImplement/SecuritySystemListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/SystemSecurityBusinessLogic/ComponentLogic.cs b/SystemSecurityBusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..454d4c9 --- /dev/null +++ b/SystemSecurityBusinessLogic/ComponentLogic.cs @@ -0,0 +1,109 @@ + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace SecuritySystemBusinessLogic.BusinessLogics +{ + public class ComponentLogic : IComponentLogic + { + private readonly ILogger _logger; + private readonly 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); + var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ComponentViewModel? ReadElement(ComponentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id); + var element = _componentStorage.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(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ComponentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ComponentBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ComponentName)) + { + throw new ArgumentNullException("Нет названия компонента", + nameof(model.ComponentName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); + } + _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel + { + ComponentName = model.ComponentName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} \ No newline at end of file diff --git a/SystemSecurityBusinessLogic/ManufactureLogic.cs b/SystemSecurityBusinessLogic/ManufactureLogic.cs new file mode 100644 index 0000000..26b88ab --- /dev/null +++ b/SystemSecurityBusinessLogic/ManufactureLogic.cs @@ -0,0 +1,115 @@ + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace SecuritySystemBusinessLogic +{ + public class ManufactureLogic : IManufactureLogic + { + private readonly ILogger _logger; + private readonly IManufactureStorage _ManufactureStorage; + + public ManufactureLogic(ILogger logger, IManufactureStorage ManufactureStorage) + { + _logger = logger; + _ManufactureStorage = ManufactureStorage; + } + + public List? ReadList(ManufactureSearchModel? model) + { + _logger.LogInformation("ReadList. ManufactureName:{ManufactureName}.Id:{ Id}", model?.ManufactureName, model?.Id); + var list = model == null ? _ManufactureStorage.GetFullList() : _ManufactureStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public ManufactureViewModel? ReadElement(ManufactureSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ManufactureName:{ManufactureName}.Id:{ Id}", model.ManufactureName, model.Id); + var element = _ManufactureStorage.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(ManufactureBindingModel model) + { + CheckModel(model); + if (_ManufactureStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Update(ManufactureBindingModel model) + { + CheckModel(model); + if (_ManufactureStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + public bool Delete(ManufactureBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_ManufactureStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + private void CheckModel(ManufactureBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ManufactureName)) + { + throw new ArgumentNullException("Нет названия камеры", nameof(model.ManufactureName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена камеры должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Manufacture. ManufactureName:{ManufactureName}.Cost:{ Cost}. Id: { Id}", model.ManufactureName, model.Price, model.Id); + var element = _ManufactureStorage.GetElement(new ManufactureSearchModel + { + ManufactureName = model.ManufactureName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Камера с таким названием уже есть"); + } + } + } +} diff --git a/SystemSecurityBusinessLogic/OrderLogic.cs b/SystemSecurityBusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..edd9141 --- /dev/null +++ b/SystemSecurityBusinessLogic/OrderLogic.cs @@ -0,0 +1,112 @@ +using Microsoft.Extensions.Logging; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; +using SecuritySystemDataModels.Enums; + +namespace SecuritySystemBusinessLogic +{ + 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); + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (!CheckStatus(model, OrderStatus.Принят, false)) return false; + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool TakeOrderInWork(OrderBindingModel model) + { + CheckModel(model); + if (!CheckStatus(model, OrderStatus.Выполняется)) return false; + return true; + } + + public bool DeliveryOrder(OrderBindingModel model) + { + CheckModel(model); + if (!CheckStatus(model, OrderStatus.Выдан)) return false; + return true; + } + + public bool FinishOrder(OrderBindingModel model) + { + CheckModel(model); + if (!CheckStatus(model, OrderStatus.Готов)) return false; + return true; + } + + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.ManufactureId < 0) + { + throw new ArgumentNullException("Некорректный идентификатор камеры", nameof(model.ManufactureId)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество камер в заказе должно быть больше 0", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); + } + _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. ManufactureId: { ManufactureId}", model.Id, model.Sum, model.ManufactureId); + } + + private bool CheckStatus(OrderBindingModel model, OrderStatus newstatus, bool update = true) + { + if (model.Status != newstatus - 1) + { + _logger.LogWarning("Failed to change status"); + return false; + } + model.Status = newstatus; + if (!update) return true; + if (_orderStorage.Update(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; + return true; + } + + } +} diff --git a/SystemSecurityBusinessLogic/SystemSecurityBusinessLogic.csproj b/SystemSecurityBusinessLogic/SystemSecurityBusinessLogic.csproj new file mode 100644 index 0000000..cd17517 --- /dev/null +++ b/SystemSecurityBusinessLogic/SystemSecurityBusinessLogic.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + -- 2.25.1 From 6a00072ae78a53967e92cd3d10023eca4a36e4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Mon, 6 Mar 2023 17:26:18 +0400 Subject: [PATCH 02/21] final fixed --- SecuritySystem/SecuritySystem.sln | 14 ++++++++++---- .../SecuritySystemFileImplement.csproj | 9 +++++++++ SecuritySystemListImplement/Models/Order.cs | 6 ------ 3 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 SecuritySystemFileImplement/SecuritySystemFileImplement.csproj diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index d169da1..8d902d5 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -5,13 +5,15 @@ VisualStudioVersion = 17.3.32922.545 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemView", "SecuritySystemView.csproj", "{39A7185D-F1F5-4892-BE6F-72B1A849CA84}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemSecurityBusinessLogic", "..\SystemSecurityBusinessLogic\SystemSecurityBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SystemSecurityBusinessLogic", "..\SystemSecurityBusinessLogic\SystemSecurityBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemDataModels", "..\SecuritySystemDataModels\SecuritySystemDataModels.csproj", "{D12D1329-4362-472B-B6E6-D62B0FF00C63}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemDataModels", "..\SecuritySystemDataModels\SecuritySystemDataModels.csproj", "{D12D1329-4362-472B-B6E6-D62B0FF00C63}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemFileImplement", "..\SecuritySystemFileImplement\SecuritySystemFileImplement.csproj", "{7EAA8744-DD28-4007-B05B-FF2644A3D9BB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,6 +41,10 @@ Global {A5A3381B-3592-41B6-880F-333C2502DF02}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.Build.0 = Release|Any CPU + {7EAA8744-DD28-4007-B05B-FF2644A3D9BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7EAA8744-DD28-4007-B05B-FF2644A3D9BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7EAA8744-DD28-4007-B05B-FF2644A3D9BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7EAA8744-DD28-4007-B05B-FF2644A3D9BB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj b/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/SecuritySystemListImplement/Models/Order.cs b/SecuritySystemListImplement/Models/Order.cs index 88a2e68..caac226 100644 --- a/SecuritySystemListImplement/Models/Order.cs +++ b/SecuritySystemListImplement/Models/Order.cs @@ -36,13 +36,7 @@ namespace SecuritySystemListImplement.Models } return new Order() { - Id = model.Id, - ManufactureId = model.ManufactureId, - ManufactureName = model.ManufactureName, - Count = model.Count, - Sum = model.Sum, Status = model.Status, - DateCreate = model.DateCreate, DateImplement = model.DateImplement }; } -- 2.25.1 From ad16a7ca87f6261d560f26630fd71a7794f2ab0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Mon, 6 Mar 2023 18:08:23 +0400 Subject: [PATCH 03/21] Final --- SecuritySystem/Program.cs | 6 +- SecuritySystem/SecuritySystem.sln | 14 ++- SecuritySystem/SecuritySystemView.csproj | 1 + .../DataFileSingletone.cs | 54 ++++++++++ .../Implements/ComponentStorage.cs | 87 ++++++++++++++++ .../Implements/ManufactureStorage.cs | 84 ++++++++++++++++ .../Implements/OrderStorage.cs | 94 ++++++++++++++++++ .../Models/Component.cs | 65 ++++++++++++ .../Models/Manufacture.cs | 93 ++++++++++++++++++ SecuritySystemFileImplement/Models/Order.cs | 98 +++++++++++++++++++ .../SecuritySystemFileImplement.csproj | 14 +++ SecuritySystemListImplement/Models/Order.cs | 5 - 12 files changed, 602 insertions(+), 13 deletions(-) create mode 100644 SecuritySystemFileImplement/DataFileSingletone.cs create mode 100644 SecuritySystemFileImplement/Implements/ComponentStorage.cs create mode 100644 SecuritySystemFileImplement/Implements/ManufactureStorage.cs create mode 100644 SecuritySystemFileImplement/Implements/OrderStorage.cs create mode 100644 SecuritySystemFileImplement/Models/Component.cs create mode 100644 SecuritySystemFileImplement/Models/Manufacture.cs create mode 100644 SecuritySystemFileImplement/Models/Order.cs create mode 100644 SecuritySystemFileImplement/SecuritySystemFileImplement.csproj diff --git a/SecuritySystem/Program.cs b/SecuritySystem/Program.cs index f6d0b1d..5e291f3 100644 --- a/SecuritySystem/Program.cs +++ b/SecuritySystem/Program.cs @@ -1,14 +1,12 @@ using SecuritySystemView; using SecuritySystemBusinessLogic.BusinessLogics; -using SecuritySystemListImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; -using OrdersShopListImplement.Implements; +using SecuritySystemFileImplement.Implements; using SecuritySystemBusinessLogic; using SecuritySystemContracts.BusinessLogicsContracts; using SecuritySystemContracts.StoragesContracts; -using System; namespace SecuritySystem { @@ -42,9 +40,9 @@ namespace SecuritySystem services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index d169da1..14f83ce 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -5,13 +5,15 @@ VisualStudioVersion = 17.3.32922.545 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemView", "SecuritySystemView.csproj", "{39A7185D-F1F5-4892-BE6F-72B1A849CA84}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemSecurityBusinessLogic", "..\SystemSecurityBusinessLogic\SystemSecurityBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SystemSecurityBusinessLogic", "..\SystemSecurityBusinessLogic\SystemSecurityBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemDataModels", "..\SecuritySystemDataModels\SecuritySystemDataModels.csproj", "{D12D1329-4362-472B-B6E6-D62B0FF00C63}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemDataModels", "..\SecuritySystemDataModels\SecuritySystemDataModels.csproj", "{D12D1329-4362-472B-B6E6-D62B0FF00C63}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemFileImplement", "..\SecuritySystemFileImplement\SecuritySystemFileImplement.csproj", "{88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,6 +41,10 @@ Global {A5A3381B-3592-41B6-880F-333C2502DF02}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.Build.0 = Release|Any CPU + {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SecuritySystem/SecuritySystemView.csproj b/SecuritySystem/SecuritySystemView.csproj index e65dd63..ed51d3d 100644 --- a/SecuritySystem/SecuritySystemView.csproj +++ b/SecuritySystem/SecuritySystemView.csproj @@ -14,6 +14,7 @@ + diff --git a/SecuritySystemFileImplement/DataFileSingletone.cs b/SecuritySystemFileImplement/DataFileSingletone.cs new file mode 100644 index 0000000..6f66c1e --- /dev/null +++ b/SecuritySystemFileImplement/DataFileSingletone.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SecuritySystemFileImplement.Models; +using System.Xml.Linq; + +namespace SecuritySystemFileImplement +{ + public class DataFileSingleton + { + private static DataFileSingleton? instance; + private readonly string ComponentFileName = "Component.xml"; + private readonly string OrderFileName = "Order.xml"; + private readonly string ManufactureFileName = "Manufacture.xml"; + public List Components { get; private set; } + public List Orders { get; private set; } + public List Manufactures { get; private set; } + public static DataFileSingleton GetInstance() + { + if (instance == null) + { + instance = new DataFileSingleton(); + } + return instance; + } + public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement); + public void SaveManufactures() => SaveData(Manufactures, ManufactureFileName, "Manufactures", x => x.GetXElement); + public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); + private DataFileSingleton() + { + Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!; + Manufactures = LoadData(ManufactureFileName, "Manufacture", x => Manufacture.Create(x)!)!; + Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; + } + private static List? LoadData(string filename, string xmlNodeName, Func selectFunction) + { + if (File.Exists(filename)) + { + return XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList(); + } + return new List(); + } + private static void SaveData(List data, string filename, string xmlNodeName, Func selectFunction) + { + if (data != null) + { + new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename); + } + } + } +} diff --git a/SecuritySystemFileImplement/Implements/ComponentStorage.cs b/SecuritySystemFileImplement/Implements/ComponentStorage.cs new file mode 100644 index 0000000..c62adcd --- /dev/null +++ b/SecuritySystemFileImplement/Implements/ComponentStorage.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; +using SecuritySystemFileImplement.Models; +using SecuritySystemFileImplement; + +namespace SecuritySystemFileImplement.Implements +{ + public class ComponentStorage : IComponentStorage + { + private readonly DataFileSingleton source; + public ComponentStorage() + { + source = DataFileSingleton.GetInstance(); + } + public List GetFullList() + { + return source.Components + .Select(x => x.GetViewModel) + .ToList(); + } + public List GetFilteredList(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName)) + { + return new(); + } + return source.Components + .Where(x => x.ComponentName.Contains(model.ComponentName)) + .Select(x => x.GetViewModel) + .ToList(); + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + return source.Components + .FirstOrDefault(x => + (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = source.Components.Count > 0 ? source.Components.Max(x => x.Id) + 1 : 1; + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + source.Components.Add(newComponent); + source.SaveComponents(); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + var component = source.Components.FirstOrDefault(x => x.Id == model.Id); + if (component == null) + { + return null; + } + component.Update(model); + source.SaveComponents(); + return component.GetViewModel; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + var element = source.Components.FirstOrDefault(x => x.Id == model.Id); + if (element != null) + { + source.Components.Remove(element); + source.SaveComponents(); + return element.GetViewModel; + } + return null; + } + } +} \ No newline at end of file diff --git a/SecuritySystemFileImplement/Implements/ManufactureStorage.cs b/SecuritySystemFileImplement/Implements/ManufactureStorage.cs new file mode 100644 index 0000000..09c4fda --- /dev/null +++ b/SecuritySystemFileImplement/Implements/ManufactureStorage.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Numerics; +using System.Text; +using System.Threading.Tasks; + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; +using SecuritySystemFileImplement.Models; +using SecuritySystemFileImplement; + +namespace SecuritySystemFileImplement.Implements +{ + public class ManufactureStorage : IManufactureStorage + { + private readonly DataFileSingleton source; + public ManufactureStorage() + { + source = DataFileSingleton.GetInstance(); + } + public ManufactureViewModel? GetElement(ManufactureSearchModel model) + { + if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) + { + return null; + } + return source.Manufactures.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ManufactureName) && x.ManufactureName == model.ManufactureName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + } + public List GetFilteredList(ManufactureSearchModel model) + { + if (string.IsNullOrEmpty(model.ManufactureName)) + { + return new(); + } + return source.Manufactures + .Where(x => x.ManufactureName.Contains(model.ManufactureName)) + .Select(x => x.GetViewModel) + .ToList(); + } + public List GetFullList() + { + return source.Manufactures.Select(x => x.GetViewModel).ToList(); + } + public ManufactureViewModel? Insert(ManufactureBindingModel model) + { + model.Id = source.Manufactures.Count > 0 ? source.Manufactures.Max(x => x.Id) + 1 : 1; + var newManufacture = Manufacture.Create(model); + if (newManufacture == null) + { + return null; + } + source.Manufactures.Add(newManufacture); + source.SaveManufactures(); + return newManufacture.GetViewModel; + } + public ManufactureViewModel? Update(ManufactureBindingModel model) + { + var manufacture = source.Manufactures.FirstOrDefault(x => x.Id == model.Id); + if (manufacture == null) + { + return null; + } + manufacture.Update(model); + source.SaveManufactures(); + return manufacture.GetViewModel; + } + public ManufactureViewModel? Delete(ManufactureBindingModel model) + { + var manufacture = source.Manufactures.FirstOrDefault(x => x.Id == model.Id); + if (manufacture == null) + { + return null; + } + manufacture.Update(model); + source.SaveManufactures(); + return manufacture.GetViewModel; + } + + } +} diff --git a/SecuritySystemFileImplement/Implements/OrderStorage.cs b/SecuritySystemFileImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..53fd709 --- /dev/null +++ b/SecuritySystemFileImplement/Implements/OrderStorage.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; +using SecuritySystemFileImplement.Models; +using SecuritySystemFileImplement; + +namespace SecuritySystemFileImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataFileSingleton source; + public OrderStorage() + { + source = DataFileSingleton.GetInstance(); + } + public List GetFilteredList(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return new(); + } + return source.Orders + .Where(x => x.Id == model.Id) + .Select(x => GetViewModel(x)) + .ToList(); + } + public List GetFullList() + { + return source.Orders.Select(x => GetViewModel(x)).ToList(); + } + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + return source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + } + public OrderViewModel? Insert(OrderBindingModel model) + { + model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1; + var newOrder = Order.Create(model); + if (newOrder == null) + { + return null; + } + source.Orders.Add(newOrder); + source.SaveOrders(); + return GetViewModel(newOrder); + } + public OrderViewModel? Update(OrderBindingModel model) + { + var order = source.Orders.FirstOrDefault(x => x.Id == model.Id); + if (order == null) + { + return null; + } + order.Update(model); + source.SaveOrders(); + return GetViewModel(order); + } + public OrderViewModel? Delete(OrderBindingModel model) + { + var order = source.Orders.FirstOrDefault(x => x.Id == model.Id); + if (order == null) + { + return null; + } + order.Update(model); + source.SaveOrders(); + return GetViewModel(order); + } + private OrderViewModel GetViewModel(Order order) + { + var viewModel = order.GetViewModel; + foreach (var manufacture in source.Manufactures) + { + if (manufacture.Id == order.ManufactureId) + { + viewModel.ManufactureName = manufacture.ManufactureName; + break; + } + } + return viewModel; + } + } +} diff --git a/SecuritySystemFileImplement/Models/Component.cs b/SecuritySystemFileImplement/Models/Component.cs new file mode 100644 index 0000000..d345360 --- /dev/null +++ b/SecuritySystemFileImplement/Models/Component.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.ViewModels; +using SecuritySystemDataModels.Models; +using System.Xml.Linq; + +namespace SecuritySystemFileImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public static Component? Create(XElement element) + { + if (element == null) + { + return null; + } + return new Component() + { + Id = Convert.ToInt32(element.Attribute("Id")!.Value), + ComponentName = element.Element("ComponentName")!.Value, + Cost = Convert.ToDouble(element.Element("Cost")!.Value) + }; + } + public void Update(ComponentBindingModel model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + public XElement GetXElement => new("Component", + new XAttribute("Id", Id), + new XElement("ComponentName", ComponentName), + new XElement("Cost", Cost.ToString())); + } +} \ No newline at end of file diff --git a/SecuritySystemFileImplement/Models/Manufacture.cs b/SecuritySystemFileImplement/Models/Manufacture.cs new file mode 100644 index 0000000..04f48b2 --- /dev/null +++ b/SecuritySystemFileImplement/Models/Manufacture.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using System.Xml.Linq; +using SecuritySystemDataModels.Models; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.ViewModels; +using SecuritySystemFileImplement; + +namespace SecuritySystemFileImplement.Models +{ + public class Manufacture : IManufactureModel + { + public int Id { get; private set; } + public string ManufactureName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary Components { get; private set; } = new(); + private Dictionary? _manufactureComponents = null; + public Dictionary ManufactureComponents + { + get + { + if (_manufactureComponents == null) + { + var source = DataFileSingleton.GetInstance(); + _manufactureComponents = Components.ToDictionary(x => x.Key, y => + ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, y.Value)); + } + return _manufactureComponents; + } + } + public static Manufacture? Create(ManufactureBindingModel model) + { + if (model == null) + { + return null; + } + return new Manufacture() + { + Id = model.Id, + ManufactureName = model.ManufactureName, + Price = model.Price, + Components = model.ManufactureComponents.ToDictionary(x => x.Key, x => x.Value.Item2) + }; + } + public static Manufacture? Create(XElement element) + { + if (element == null) + { + return null; + } + return new Manufacture() + { + Id = Convert.ToInt32(element.Attribute("Id")!.Value), + ManufactureName = element.Element("ManufactureName")!.Value, + Price = Convert.ToDouble(element.Element("Price")!.Value), + Components = + element.Element("ManufactureComponents")!.Elements("ManufactureComponent").ToDictionary(x =>Convert.ToInt32(x.Element("Key")?.Value), + x =>Convert.ToInt32(x.Element("Value")?.Value)) + }; + } + public void Update(ManufactureBindingModel model) + { + if (model == null) + { + return; + } + ManufactureName = model.ManufactureName; + Price = model.Price; + Components = model.ManufactureComponents.ToDictionary(x => x.Key, x => x.Value.Item2); + _manufactureComponents = null; + } + public ManufactureViewModel GetViewModel => new() + { + Id = Id, + ManufactureName = ManufactureName, + Price = Price, + ManufactureComponents = ManufactureComponents + }; + public XElement GetXElement => new("Manufacture", + new XAttribute("Id", Id), + new XElement("ManufactureName", ManufactureName), + new XElement("Price", Price.ToString()), + new XElement("ManufactureComponents", Components.Select(x => + new XElement("ManufactureComponent", + new XElement("Key", x.Key), + new XElement("Value", x.Value))) + .ToArray())); + } +} diff --git a/SecuritySystemFileImplement/Models/Order.cs b/SecuritySystemFileImplement/Models/Order.cs new file mode 100644 index 0000000..b5996d8 --- /dev/null +++ b/SecuritySystemFileImplement/Models/Order.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using System.Xml.Linq; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.ViewModels; +using SecuritySystemDataModels.Enums; +using SecuritySystemDataModels.Models; + +namespace SecuritySystemFileImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + public int ManufactureId { get; private set; } + public string ManufactureName { get; private set; } = string.Empty; + public int Count { get; private set; } + public double Sum { 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) + { + return null; + } + return new Order + { + Id = model.Id, + ManufactureId = model.ManufactureId, + ManufactureName = model.ManufactureName, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement + }; + } + + public static Order? Create(XElement element) + { + if (element == null) + { + return null; + } + return new Order() + { + Id = Convert.ToInt32(element.Attribute("Id")!.Value), + ManufactureId = Convert.ToInt32(element.Element("ManufactureId")!.Value), + ManufactureName = element.Element("ManufactureName")!.Value, + Sum = Convert.ToDouble(element.Element("Sum")!.Value), + Count = Convert.ToInt32(element.Element("Count")!.Value), + Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value), + DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value), + DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null : Convert.ToDateTime(element.Element("DateImplement")!.Value) + }; + } + + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + Status = model.Status; + DateImplement = model.DateImplement; + } + + public OrderViewModel GetViewModel => new() + { + Id = Id, + ManufactureId = ManufactureId, + ManufactureName = ManufactureName, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement + }; + + public XElement GetXElement => new( + "Order", + new XAttribute("Id", Id), + new XElement("ManufactureId", ManufactureId.ToString()), + new XElement("ManufactureName", ManufactureName.ToString()), + new XElement("Count", Count.ToString()), + new XElement("Sum", Sum.ToString()), + new XElement("Status", Status.ToString()), + new XElement("DateCreate", DateCreate.ToString()), + new XElement("DateImplement", DateImplement.ToString()) + ); + } +} diff --git a/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj b/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj new file mode 100644 index 0000000..7037095 --- /dev/null +++ b/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/SecuritySystemListImplement/Models/Order.cs b/SecuritySystemListImplement/Models/Order.cs index 88a2e68..4ad41a3 100644 --- a/SecuritySystemListImplement/Models/Order.cs +++ b/SecuritySystemListImplement/Models/Order.cs @@ -53,12 +53,7 @@ namespace SecuritySystemListImplement.Models { return; } - ManufactureId = model.ManufactureId; - ManufactureName = model.ManufactureName; - Count = model.Count; - Sum = model.Sum; Status = model.Status; - DateCreate = model.DateCreate; DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() -- 2.25.1 From bf0073f63bbf5f237a23e36289eb374a4c2f20b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Mon, 6 Mar 2023 18:10:24 +0400 Subject: [PATCH 04/21] final fixed --- SecuritySystem/SecuritySystem.sln | 2 +- SecuritySystem/SecuritySystemView.csproj | 2 +- ...yBusinessLogic.csproj => SecuritySystemBusinessLogic.csproj} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename SystemSecurityBusinessLogic/{SystemSecurityBusinessLogic.csproj => SecuritySystemBusinessLogic.csproj} (100%) diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index 14f83ce..aa0dc6b 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 17.3.32922.545 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemView", "SecuritySystemView.csproj", "{39A7185D-F1F5-4892-BE6F-72B1A849CA84}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SystemSecurityBusinessLogic", "..\SystemSecurityBusinessLogic\SystemSecurityBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemBusinessLogic", "..\SystemSecurityBusinessLogic\SecuritySystemBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" EndProject diff --git a/SecuritySystem/SecuritySystemView.csproj b/SecuritySystem/SecuritySystemView.csproj index ed51d3d..371775d 100644 --- a/SecuritySystem/SecuritySystemView.csproj +++ b/SecuritySystem/SecuritySystemView.csproj @@ -16,7 +16,7 @@ - + \ No newline at end of file diff --git a/SystemSecurityBusinessLogic/SystemSecurityBusinessLogic.csproj b/SystemSecurityBusinessLogic/SecuritySystemBusinessLogic.csproj similarity index 100% rename from SystemSecurityBusinessLogic/SystemSecurityBusinessLogic.csproj rename to SystemSecurityBusinessLogic/SecuritySystemBusinessLogic.csproj -- 2.25.1 From 1dd36ca219a642a7925b875da5d9097f46f90ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Mon, 6 Mar 2023 18:11:35 +0400 Subject: [PATCH 05/21] fix name --- SecuritySystem/SecuritySystemView.csproj | 2 +- ...yBusinessLogic.csproj => SecuritySystemBusinessLogic.csproj} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename SystemSecurityBusinessLogic/{SystemSecurityBusinessLogic.csproj => SecuritySystemBusinessLogic.csproj} (100%) diff --git a/SecuritySystem/SecuritySystemView.csproj b/SecuritySystem/SecuritySystemView.csproj index e65dd63..7e4e4ef 100644 --- a/SecuritySystem/SecuritySystemView.csproj +++ b/SecuritySystem/SecuritySystemView.csproj @@ -15,7 +15,7 @@ - + \ No newline at end of file diff --git a/SystemSecurityBusinessLogic/SystemSecurityBusinessLogic.csproj b/SystemSecurityBusinessLogic/SecuritySystemBusinessLogic.csproj similarity index 100% rename from SystemSecurityBusinessLogic/SystemSecurityBusinessLogic.csproj rename to SystemSecurityBusinessLogic/SecuritySystemBusinessLogic.csproj -- 2.25.1 From 16224ce0560bdc3786fb35e52d423b2d77e95449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Mon, 6 Mar 2023 18:11:50 +0400 Subject: [PATCH 06/21] fix --- SecuritySystem/SecuritySystem.sln | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index 8d902d5..e51af08 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 17.3.32922.545 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemView", "SecuritySystemView.csproj", "{39A7185D-F1F5-4892-BE6F-72B1A849CA84}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SystemSecurityBusinessLogic", "..\SystemSecurityBusinessLogic\SystemSecurityBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemBusinessLogic", "..\SystemSecurityBusinessLogic\SecuritySystemBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" EndProject @@ -13,7 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemDataModels", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemFileImplement", "..\SecuritySystemFileImplement\SecuritySystemFileImplement.csproj", "{7EAA8744-DD28-4007-B05B-FF2644A3D9BB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemFileImplement", "..\SecuritySystemFileImplement\SecuritySystemFileImplement.csproj", "{7EAA8744-DD28-4007-B05B-FF2644A3D9BB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution -- 2.25.1 From 8352dc6bf61c3e043de3462c7514177b1ca878bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 12:47:29 +0400 Subject: [PATCH 07/21] Rename --- SecuritySystem/FormCreateOrder.Designer.cs | 40 +++--- SecuritySystem/FormCreateOrder.cs | 30 ++--- SecuritySystem/FormMain.cs | 20 +-- SecuritySystem/FormManufacturies.resx | 120 ------------------ ...ure.Designer.cs => FormSecure.Designer.cs} | 49 +++---- .../{FormManufacture.cs => FormSecure.cs} | 52 ++++---- SecuritySystem/FormSecure.resx | 60 +++++++++ ...s.Designer.cs => FormSecuries.Designer.cs} | 8 +- .../{FormManufacturies.cs => FormSecuries.cs} | 22 ++-- ...FormManufacture.resx => FormSecuries.resx} | 0 ...r.cs => FormSecuriesComponent.Designer.cs} | 2 +- ...eComponent.cs => FormSecuriesComponent.cs} | 4 +- ...ponent.resx => FormSecuriesComponent.resx} | 0 SecuritySystem/Program.cs | 10 +- .../BindingModels/OrderBindingModel.cs | 4 +- ...eBindingModel.cs => SecureBindingModel.cs} | 6 +- .../IManufactureLogic.cs | 21 --- .../BusinessLogicsContracts/ISecureLogic.cs | 21 +++ ...ureSearchModel.cs => SecureSearchModel.cs} | 4 +- .../StorageContracts/IManufactureStorage.cs | 21 --- .../StorageContracts/ISecureStorage.cs | 21 +++ .../ViewModels/OrderViewModel.cs | 4 +- ...factureViewModel.cs => SecureViewModel.cs} | 6 +- .../Models/IOrderModel.cs | 2 +- .../{IManufactureModel.cs => ISecureModel.cs} | 6 +- .../DataListSingletone.cs | 4 +- .../Implements/ManufactureStorage.cs | 102 --------------- .../Implements/OrderStorage.cs | 8 +- .../Implements/SecureStorage.cs | 102 +++++++++++++++ SecuritySystemListImplement/Models/Order.cs | 20 +-- .../Models/{Manufacture.cs => Secure.cs} | 26 ++-- SystemSecurityBusinessLogic/OrderLogic.cs | 6 +- .../{ManufactureLogic.cs => SecureLogic.cs} | 44 +++---- 33 files changed, 394 insertions(+), 451 deletions(-) delete mode 100644 SecuritySystem/FormManufacturies.resx rename SecuritySystem/{FormManufacture.Designer.cs => FormSecure.Designer.cs} (98%) rename SecuritySystem/{FormManufacture.cs => FormSecure.cs} (79%) create mode 100644 SecuritySystem/FormSecure.resx rename SecuritySystem/{FormManufacturies.Designer.cs => FormSecuries.Designer.cs} (96%) rename SecuritySystem/{FormManufacturies.cs => FormSecuries.cs} (83%) rename SecuritySystem/{FormManufacture.resx => FormSecuries.resx} (100%) rename SecuritySystem/{FormManufactureComponent.Designer.cs => FormSecuriesComponent.Designer.cs} (99%) rename SecuritySystem/{FormManufactureComponent.cs => FormSecuriesComponent.cs} (95%) rename SecuritySystem/{FormManufactureComponent.resx => FormSecuriesComponent.resx} (100%) rename SecuritySystemContracts/BindingModels/{ManufactureBindingModel.cs => SecureBindingModel.cs} (54%) delete mode 100644 SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs create mode 100644 SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs rename SecuritySystemContracts/SearchModels/{ManufactureSearchModel.cs => SecureSearchModel.cs} (70%) delete mode 100644 SecuritySystemContracts/StorageContracts/IManufactureStorage.cs create mode 100644 SecuritySystemContracts/StorageContracts/ISecureStorage.cs rename SecuritySystemContracts/ViewModels/{ManufactureViewModel.cs => SecureViewModel.cs} (70%) rename SecuritySystemDataModels/Models/{IManufactureModel.cs => ISecureModel.cs} (59%) delete mode 100644 SecuritySystemListImplement/Implements/ManufactureStorage.cs create mode 100644 SecuritySystemListImplement/Implements/SecureStorage.cs rename SecuritySystemListImplement/Models/{Manufacture.cs => Secure.cs} (54%) rename SystemSecurityBusinessLogic/{ManufactureLogic.cs => SecureLogic.cs} (59%) diff --git a/SecuritySystem/FormCreateOrder.Designer.cs b/SecuritySystem/FormCreateOrder.Designer.cs index 9a89b05..ba1b6eb 100644 --- a/SecuritySystem/FormCreateOrder.Designer.cs +++ b/SecuritySystem/FormCreateOrder.Designer.cs @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - this.labelManufacture = new System.Windows.Forms.Label(); - this.comboBoxManufacture = new System.Windows.Forms.ComboBox(); + this.labelSecure = new System.Windows.Forms.Label(); + this.comboBoxSecure = new System.Windows.Forms.ComboBox(); this.labelCount = new System.Windows.Forms.Label(); this.textBoxCount = new System.Windows.Forms.TextBox(); this.labelSum = new System.Windows.Forms.Label(); @@ -38,23 +38,23 @@ this.buttonSave = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // labelManufacture + // labelSecure // - this.labelManufacture.AutoSize = true; - this.labelManufacture.Location = new System.Drawing.Point(12, 15); - this.labelManufacture.Name = "labelManufacture"; - this.labelManufacture.Size = new System.Drawing.Size(75, 20); - this.labelManufacture.TabIndex = 0; - this.labelManufacture.Text = "Изделие: "; + this.labelSecure.AutoSize = true; + this.labelSecure.Location = new System.Drawing.Point(12, 15); + this.labelSecure.Name = "labelSecure"; + this.labelSecure.Size = new System.Drawing.Size(75, 20); + this.labelSecure.TabIndex = 0; + this.labelSecure.Text = "Изделие: "; // - // comboBoxManufacture + // comboBoxSecure // - this.comboBoxManufacture.FormattingEnabled = true; - this.comboBoxManufacture.Location = new System.Drawing.Point(115, 12); - this.comboBoxManufacture.Name = "comboBoxManufacture"; - this.comboBoxManufacture.Size = new System.Drawing.Size(358, 28); - this.comboBoxManufacture.TabIndex = 1; - this.comboBoxManufacture.SelectedIndexChanged += new System.EventHandler(this.ComboBoxManufacture_SelectedIndexChanged); + this.comboBoxSecure.FormattingEnabled = true; + this.comboBoxSecure.Location = new System.Drawing.Point(115, 12); + this.comboBoxSecure.Name = "comboBoxSecure"; + this.comboBoxSecure.Size = new System.Drawing.Size(358, 28); + this.comboBoxSecure.TabIndex = 1; + this.comboBoxSecure.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSecure_SelectedIndexChanged); // // labelCount // @@ -121,8 +121,8 @@ this.Controls.Add(this.labelSum); this.Controls.Add(this.textBoxCount); this.Controls.Add(this.labelCount); - this.Controls.Add(this.comboBoxManufacture); - this.Controls.Add(this.labelManufacture); + this.Controls.Add(this.comboBoxSecure); + this.Controls.Add(this.labelSecure); this.Name = "FormCreateOrder"; this.Text = "Заказ"; this.Load += new System.EventHandler(this.FormCreateOrder_Load); @@ -133,8 +133,8 @@ #endregion - private Label labelManufacture; - private ComboBox comboBoxManufacture; + private Label labelSecure; + private ComboBox comboBoxSecure; private Label labelCount; private TextBox textBoxCount; private Label labelSum; diff --git a/SecuritySystem/FormCreateOrder.cs b/SecuritySystem/FormCreateOrder.cs index a7ce11f..4af9c06 100644 --- a/SecuritySystem/FormCreateOrder.cs +++ b/SecuritySystem/FormCreateOrder.cs @@ -18,10 +18,10 @@ namespace SecuritySystemView public partial class FormCreateOrder : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logicM; + private readonly ISecureLogic _logicM; private readonly IOrderLogic _logicO; - private List? _list; - public FormCreateOrder(ILogger logger, IManufactureLogic logicM, IOrderLogic logicO) + private List? _list; + public FormCreateOrder(ILogger logger, ISecureLogic logicM, IOrderLogic logicO) { InitializeComponent(); _logger = logger; @@ -33,23 +33,23 @@ namespace SecuritySystemView _list = _logicM.ReadList(null); if (_list != null) { - comboBoxManufacture.DisplayMember = "ManufactureName"; - comboBoxManufacture.ValueMember = "Id"; - comboBoxManufacture.DataSource = _list; - comboBoxManufacture.SelectedItem = null; + comboBoxSecure.DisplayMember = "SecureName"; + comboBoxSecure.ValueMember = "Id"; + comboBoxSecure.DataSource = _list; + comboBoxSecure.SelectedItem = null; _logger.LogInformation("Загрузка изделий для заказа"); } } private void CalcSum() { - if (comboBoxManufacture.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + if (comboBoxSecure.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) { try { - int id = Convert.ToInt32(comboBoxManufacture.SelectedValue); - var Manufacture = _logicM.ReadElement(new ManufactureSearchModel { Id = id }); + int id = Convert.ToInt32(comboBoxSecure.SelectedValue); + var Secure = _logicM.ReadElement(new SecureSearchModel { Id = id }); int count = Convert.ToInt32(textBoxCount.Text); - textBoxSum.Text = Math.Round(count * (Manufacture?.Price ?? 0), 2).ToString(); + textBoxSum.Text = Math.Round(count * (Secure?.Price ?? 0), 2).ToString(); _logger.LogInformation("Расчет суммы заказа"); } catch (Exception ex) @@ -63,7 +63,7 @@ namespace SecuritySystemView { CalcSum(); } - private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e) + private void ComboBoxSecure_SelectedIndexChanged(object sender, EventArgs e) { CalcSum(); } @@ -74,7 +74,7 @@ namespace SecuritySystemView MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (comboBoxManufacture.SelectedValue == null) + if (comboBoxSecure.SelectedValue == null) { MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -84,8 +84,8 @@ namespace SecuritySystemView { var operationResult = _logicO.CreateOrder(new OrderBindingModel { - ManufactureId = Convert.ToInt32(comboBoxManufacture.SelectedValue), - ManufactureName = comboBoxManufacture.Text, + SecureId = Convert.ToInt32(comboBoxSecure.SelectedValue), + SecureName = comboBoxSecure.Text, Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); diff --git a/SecuritySystem/FormMain.cs b/SecuritySystem/FormMain.cs index 6ce123b..2537a2f 100644 --- a/SecuritySystem/FormMain.cs +++ b/SecuritySystem/FormMain.cs @@ -37,8 +37,8 @@ namespace SecuritySystemView if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["ManufactureId"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["SecureId"].Visible = false; + dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } @@ -58,8 +58,8 @@ namespace SecuritySystemView } private void GoodsToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacturies)); - if (service is FormManufacturies form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuries)); + if (service is FormSecuries form) { form.ShowDialog(); } @@ -84,8 +84,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -115,8 +115,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -147,8 +147,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), diff --git a/SecuritySystem/FormManufacturies.resx b/SecuritySystem/FormManufacturies.resx deleted file mode 100644 index 1af7de1..0000000 --- a/SecuritySystem/FormManufacturies.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/SecuritySystem/FormManufacture.Designer.cs b/SecuritySystem/FormSecure.Designer.cs similarity index 98% rename from SecuritySystem/FormManufacture.Designer.cs rename to SecuritySystem/FormSecure.Designer.cs index d4283d0..934e2e7 100644 --- a/SecuritySystem/FormManufacture.Designer.cs +++ b/SecuritySystem/FormSecure.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufacture + partial class FormSecure { /// /// Required designer variable. @@ -38,11 +38,11 @@ this.buttonUpd = new System.Windows.Forms.Button(); this.buttonAdd = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonSave = new System.Windows.Forms.Button(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); this.groupBoxComponents.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -76,6 +76,7 @@ // this.textBoxPrice.Location = new System.Drawing.Point(112, 51); this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.ReadOnly = true; this.textBoxPrice.Size = new System.Drawing.Size(171, 27); this.textBoxPrice.TabIndex = 3; // @@ -151,26 +152,6 @@ this.dataGridView.Size = new System.Drawing.Size(476, 287); this.dataGridView.TabIndex = 0; // - // buttonCancel - // - this.buttonCancel.Location = new System.Drawing.Point(514, 417); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(126, 34); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "Отмена"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); - // - // buttonSave - // - this.buttonSave.Location = new System.Drawing.Point(368, 417); - this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(126, 34); - this.buttonSave.TabIndex = 6; - this.buttonSave.Text = "Сохранить"; - this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); - // // id // this.id.HeaderText = "id"; @@ -193,6 +174,26 @@ this.Count.Name = "Count"; this.Count.ReadOnly = true; // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(514, 417); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(126, 34); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(368, 417); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(126, 34); + this.buttonSave.TabIndex = 6; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // // FormManufacture // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); @@ -207,7 +208,7 @@ this.Controls.Add(this.labelName); this.Name = "FormManufacture"; this.Text = "Изделие"; - this.Load += new System.EventHandler(this.FormManufacture_Load); + this.Load += new System.EventHandler(this.FormSecure_Load); this.groupBoxComponents.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/SecuritySystem/FormManufacture.cs b/SecuritySystem/FormSecure.cs similarity index 79% rename from SecuritySystem/FormManufacture.cs rename to SecuritySystem/FormSecure.cs index 0a6a1a6..f328329 100644 --- a/SecuritySystem/FormManufacture.cs +++ b/SecuritySystem/FormSecure.cs @@ -16,33 +16,33 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufacture : Form + public partial class FormSecure : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logic; + private readonly ISecureLogic _logic; private int? _id; - private Dictionary _ManufactureComponents; + private Dictionary _SecureComponents; public int Id { set { _id = value; } } - public FormManufacture(ILogger logger, IManufactureLogic logic) + public FormSecure(ILogger logger, ISecureLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; - _ManufactureComponents = new Dictionary(); + _SecureComponents = new Dictionary(); } - private void FormManufacture_Load(object sender, EventArgs e) + private void FormSecure_Load(object sender, EventArgs e) { if (_id.HasValue) { _logger.LogInformation("Загрузка изделия"); try { - var view = _logic.ReadElement(new ManufactureSearchModel { Id = _id.Value }); + var view = _logic.ReadElement(new SecureSearchModel { Id = _id.Value }); if (view != null) { - textBoxName.Text = view.ManufactureName; + textBoxName.Text = view.SecureName; textBoxPrice.Text = view.Price.ToString(); - _ManufactureComponents = view.ManufactureComponents ?? new + _SecureComponents = view.SecureComponents ?? new Dictionary(); LoadData(); } @@ -60,10 +60,10 @@ namespace SecuritySystemView _logger.LogInformation("Загрузка компонент изделия"); try { - if (_ManufactureComponents != null) + if (_SecureComponents != null) { dataGridView.Rows.Clear(); - foreach (var pc in _ManufactureComponents) + foreach (var pc in _SecureComponents) { dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); } @@ -79,8 +79,8 @@ namespace SecuritySystemView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); - if (service is FormManufactureComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuriesComponent)); + if (service is FormSecuriesComponent form) { if (form.ShowDialog() == DialogResult.OK) { @@ -89,13 +89,13 @@ namespace SecuritySystemView return; } _logger.LogInformation("Добавление нового компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); - if (_ManufactureComponents.ContainsKey(form.Id)) + if (_SecureComponents.ContainsKey(form.Id)) { - _ManufactureComponents[form.Id] = (form.ComponentModel, form.Count); + _SecureComponents[form.Id] = (form.ComponentModel, form.Count); } else { - _ManufactureComponents.Add(form.Id, (form.ComponentModel, form.Count)); + _SecureComponents.Add(form.Id, (form.ComponentModel, form.Count)); } LoadData(); } @@ -105,12 +105,12 @@ namespace SecuritySystemView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); - if (service is FormManufactureComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuriesComponent)); + if (service is FormSecuriesComponent form) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; - form.Count = _ManufactureComponents[id].Item2; + form.Count = _SecureComponents[id].Item2; if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) @@ -118,7 +118,7 @@ namespace SecuritySystemView return; } _logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); - _ManufactureComponents[form.Id] = (form.ComponentModel, form.Count); + _SecureComponents[form.Id] = (form.ComponentModel, form.Count); LoadData(); } } @@ -134,7 +134,7 @@ namespace SecuritySystemView try { _logger.LogInformation("Удаление компонента: {ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); - _ManufactureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _SecureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { @@ -161,7 +161,7 @@ namespace SecuritySystemView MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (_ManufactureComponents == null || _ManufactureComponents.Count == 0) + if (_SecureComponents == null || _SecureComponents.Count == 0) { MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -169,12 +169,12 @@ namespace SecuritySystemView _logger.LogInformation("Сохранение изделия"); try { - var model = new ManufactureBindingModel + var model = new SecureBindingModel { Id = _id ?? 0, - ManufactureName = textBoxName.Text, + SecureName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - ManufactureComponents = _ManufactureComponents + SecureComponents = _SecureComponents }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) @@ -199,7 +199,7 @@ namespace SecuritySystemView private double CalcPrice() { double price = 0; - foreach (var elem in _ManufactureComponents) + foreach (var elem in _SecureComponents) { price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); } diff --git a/SecuritySystem/FormSecure.resx b/SecuritySystem/FormSecure.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SecuritySystem/FormSecure.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/SecuritySystem/FormManufacturies.Designer.cs b/SecuritySystem/FormSecuries.Designer.cs similarity index 96% rename from SecuritySystem/FormManufacturies.Designer.cs rename to SecuritySystem/FormSecuries.Designer.cs index 5147d93..718eb7d 100644 --- a/SecuritySystem/FormManufacturies.Designer.cs +++ b/SecuritySystem/FormSecuries.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufacturies + partial class FormSecuries { /// /// Required designer variable. @@ -102,16 +102,16 @@ this.dataGridView.Size = new System.Drawing.Size(590, 426); this.dataGridView.TabIndex = 2; // - // FormManufacturies + // FormSecure // 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 = "FormManufacturies"; + this.Name = "FormSecuries"; this.Text = "Изделия"; - this.Load += new System.EventHandler(this.FormManufacturies_Load); + this.Load += new System.EventHandler(this.FormSecuries_Load); this.ToolsPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/SecuritySystem/FormManufacturies.cs b/SecuritySystem/FormSecuries.cs similarity index 83% rename from SecuritySystem/FormManufacturies.cs rename to SecuritySystem/FormSecuries.cs index 61d79fc..acd9911 100644 --- a/SecuritySystem/FormManufacturies.cs +++ b/SecuritySystem/FormSecuries.cs @@ -14,17 +14,17 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufacturies : Form + public partial class FormSecuries : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logic; - public FormManufacturies(ILogger logger, IManufactureLogic logic) + private readonly ISecureLogic _logic; + public FormSecuries(ILogger logger, ISecureLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - private void FormManufacturies_Load(object sender, EventArgs e) + private void FormSecuries_Load(object sender, EventArgs e) { LoadData(); } @@ -37,8 +37,8 @@ namespace SecuritySystemView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ManufactureComponents"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = + dataGridView.Columns["SecureComponents"].Visible = false; + dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка изделий"); @@ -51,8 +51,8 @@ namespace SecuritySystemView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); - if (service is FormManufacture form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecure)); + if (service is FormSecure form) { if (form.ShowDialog() == DialogResult.OK) { @@ -64,8 +64,8 @@ namespace SecuritySystemView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); - if (service is FormManufacture form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecure)); + if (service is FormSecure form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) @@ -85,7 +85,7 @@ namespace SecuritySystemView _logger.LogInformation("Удаление изделия"); try { - if (!_logic.Delete(new ManufactureBindingModel { Id = id })) + if (!_logic.Delete(new SecureBindingModel { Id = id })) { throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); } diff --git a/SecuritySystem/FormManufacture.resx b/SecuritySystem/FormSecuries.resx similarity index 100% rename from SecuritySystem/FormManufacture.resx rename to SecuritySystem/FormSecuries.resx diff --git a/SecuritySystem/FormManufactureComponent.Designer.cs b/SecuritySystem/FormSecuriesComponent.Designer.cs similarity index 99% rename from SecuritySystem/FormManufactureComponent.Designer.cs rename to SecuritySystem/FormSecuriesComponent.Designer.cs index 686592c..bb2b8c6 100644 --- a/SecuritySystem/FormManufactureComponent.Designer.cs +++ b/SecuritySystem/FormSecuriesComponent.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufactureComponent + partial class FormSecuriesComponent { /// /// Required designer variable. diff --git a/SecuritySystem/FormManufactureComponent.cs b/SecuritySystem/FormSecuriesComponent.cs similarity index 95% rename from SecuritySystem/FormManufactureComponent.cs rename to SecuritySystem/FormSecuriesComponent.cs index cdf9c1a..ad94391 100644 --- a/SecuritySystem/FormManufactureComponent.cs +++ b/SecuritySystem/FormSecuriesComponent.cs @@ -13,7 +13,7 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufactureComponent : Form + public partial class FormSecuriesComponent : Form { private readonly List? _list; public int Id @@ -50,7 +50,7 @@ namespace SecuritySystemView get { return Convert.ToInt32(textBoxCount.Text); } set { textBoxCount.Text = value.ToString(); } } - public FormManufactureComponent(IComponentLogic logic) + public FormSecuriesComponent(IComponentLogic logic) { InitializeComponent(); _list = logic.ReadList(null); diff --git a/SecuritySystem/FormManufactureComponent.resx b/SecuritySystem/FormSecuriesComponent.resx similarity index 100% rename from SecuritySystem/FormManufactureComponent.resx rename to SecuritySystem/FormSecuriesComponent.resx diff --git a/SecuritySystem/Program.cs b/SecuritySystem/Program.cs index f6d0b1d..e49e574 100644 --- a/SecuritySystem/Program.cs +++ b/SecuritySystem/Program.cs @@ -40,17 +40,17 @@ namespace SecuritySystem services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); 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/SecuritySystemContracts/BindingModels/OrderBindingModel.cs b/SecuritySystemContracts/BindingModels/OrderBindingModel.cs index eccc6bf..ae51c4c 100644 --- a/SecuritySystemContracts/BindingModels/OrderBindingModel.cs +++ b/SecuritySystemContracts/BindingModels/OrderBindingModel.cs @@ -6,10 +6,10 @@ namespace SecuritySystemContracts.BindingModels public class OrderBindingModel : IOrderModel { public int Id { get; set; } - public int ManufactureId { get; set; } + public int SecureId { get; set; } public int Count { get; set; } public double Sum { get; set; } - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateImplement { get; set; } diff --git a/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs b/SecuritySystemContracts/BindingModels/SecureBindingModel.cs similarity index 54% rename from SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs rename to SecuritySystemContracts/BindingModels/SecureBindingModel.cs index 408ec7a..2a24bee 100644 --- a/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs +++ b/SecuritySystemContracts/BindingModels/SecureBindingModel.cs @@ -3,12 +3,12 @@ using SecuritySystemDataModels.Models; namespace SecuritySystemContracts.BindingModels { - public class ManufactureBindingModel : IManufactureModel + public class SecureBindingModel : ISecureModel { public int Id { get; set; } - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; public double Price { get; set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; set; diff --git a/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs deleted file mode 100644 index 35eaabc..0000000 --- a/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs +++ /dev/null @@ -1,21 +0,0 @@ -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.ViewModels; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SecuritySystemContracts.BusinessLogicsContracts -{ - public interface IManufactureLogic - { - List? ReadList(ManufactureSearchModel? model); - ManufactureViewModel? ReadElement(ManufactureSearchModel model); - bool Create(ManufactureBindingModel model); - bool Update(ManufactureBindingModel model); - bool Delete(ManufactureBindingModel model); - } -} diff --git a/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs new file mode 100644 index 0000000..58f0398 --- /dev/null +++ b/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.BusinessLogicsContracts +{ + public interface ISecureLogic + { + List? ReadList(SecureSearchModel? model); + SecureViewModel? ReadElement(SecureSearchModel model); + bool Create(SecureBindingModel model); + bool Update(SecureBindingModel model); + bool Delete(SecureBindingModel model); + } +} diff --git a/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs similarity index 70% rename from SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs rename to SecuritySystemContracts/SearchModels/SecureSearchModel.cs index 2613f72..ea906d3 100644 --- a/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs +++ b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; namespace SecuritySystemContracts.SearchModels { - public class ManufactureSearchModel + public class SecureSearchModel { public int? Id { get; set; } - public string? ManufactureName { get; set; } + public string? SecureName { get; set; } } } diff --git a/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs b/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs deleted file mode 100644 index dd0c521..0000000 --- a/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs +++ /dev/null @@ -1,21 +0,0 @@ -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SecuritySystemContracts.StoragesContracts -{ - public interface IManufactureStorage - { - List GetFullList(); - List GetFilteredList(ManufactureSearchModel model); - ManufactureViewModel? GetElement(ManufactureSearchModel model); - ManufactureViewModel? Insert(ManufactureBindingModel model); - ManufactureViewModel? Update(ManufactureBindingModel model); - ManufactureViewModel? Delete(ManufactureBindingModel model); - } -} diff --git a/SecuritySystemContracts/StorageContracts/ISecureStorage.cs b/SecuritySystemContracts/StorageContracts/ISecureStorage.cs new file mode 100644 index 0000000..7dc62cc --- /dev/null +++ b/SecuritySystemContracts/StorageContracts/ISecureStorage.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.StoragesContracts +{ + public interface ISecureStorage + { + List GetFullList(); + List GetFilteredList(SecureSearchModel model); + SecureViewModel? GetElement(SecureSearchModel model); + SecureViewModel? Insert(SecureBindingModel model); + SecureViewModel? Update(SecureBindingModel model); + SecureViewModel? Delete(SecureBindingModel model); + } +} diff --git a/SecuritySystemContracts/ViewModels/OrderViewModel.cs b/SecuritySystemContracts/ViewModels/OrderViewModel.cs index 79b07cb..498fcbf 100644 --- a/SecuritySystemContracts/ViewModels/OrderViewModel.cs +++ b/SecuritySystemContracts/ViewModels/OrderViewModel.cs @@ -13,9 +13,9 @@ namespace SecuritySystemContracts.ViewModels { [DisplayName("Номер")] public int Id { get; set; } - public int ManufactureId { get; set; } + public int SecureId { get; set; } [DisplayName("Изделие")] - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } [DisplayName("Сумма")] diff --git a/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs b/SecuritySystemContracts/ViewModels/SecureViewModel.cs similarity index 70% rename from SecuritySystemContracts/ViewModels/ManufactureViewModel.cs rename to SecuritySystemContracts/ViewModels/SecureViewModel.cs index c8bfd3e..4480475 100644 --- a/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs +++ b/SecuritySystemContracts/ViewModels/SecureViewModel.cs @@ -8,14 +8,14 @@ using System.Threading.Tasks; namespace SecuritySystemContracts.ViewModels { - public class ManufactureViewModel : IManufactureModel + public class SecureViewModel : ISecureModel { public int Id { get; set; } [DisplayName("Название изделия")] - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; [DisplayName("Цена")] public double Price { get; set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; set; diff --git a/SecuritySystemDataModels/Models/IOrderModel.cs b/SecuritySystemDataModels/Models/IOrderModel.cs index 13baf8c..1f705ee 100644 --- a/SecuritySystemDataModels/Models/IOrderModel.cs +++ b/SecuritySystemDataModels/Models/IOrderModel.cs @@ -10,7 +10,7 @@ namespace SecuritySystemDataModels.Models { public interface IOrderModel : IId { - int ManufactureId { get; } + int SecureId { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/SecuritySystemDataModels/Models/IManufactureModel.cs b/SecuritySystemDataModels/Models/ISecureModel.cs similarity index 59% rename from SecuritySystemDataModels/Models/IManufactureModel.cs rename to SecuritySystemDataModels/Models/ISecureModel.cs index 3499105..f675b0f 100644 --- a/SecuritySystemDataModels/Models/IManufactureModel.cs +++ b/SecuritySystemDataModels/Models/ISecureModel.cs @@ -7,10 +7,10 @@ using System.Threading.Tasks; namespace SecuritySystemDataModels.Models { - public interface IManufactureModel : IId + public interface ISecureModel : IId { - string ManufactureName { get; } + string SecureName { get; } double Price { get; } - Dictionary ManufactureComponents { get; } + Dictionary SecureComponents { get; } } } diff --git a/SecuritySystemListImplement/DataListSingletone.cs b/SecuritySystemListImplement/DataListSingletone.cs index da37d1f..7a9a84a 100644 --- a/SecuritySystemListImplement/DataListSingletone.cs +++ b/SecuritySystemListImplement/DataListSingletone.cs @@ -13,12 +13,12 @@ namespace SecuritySystemListImplement private static DataListSingleton? _instance; public List Components { get; set; } public List Orders { get; set; } - public List Manufactures { get; set; } + public List Securies { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); - Manufactures = new List(); + Securies = new List(); } public static DataListSingleton GetInstance() { diff --git a/SecuritySystemListImplement/Implements/ManufactureStorage.cs b/SecuritySystemListImplement/Implements/ManufactureStorage.cs deleted file mode 100644 index 5a8ea83..0000000 --- a/SecuritySystemListImplement/Implements/ManufactureStorage.cs +++ /dev/null @@ -1,102 +0,0 @@ -using SecuritySystemListImplement.Models; -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.StoragesContracts; -using SecuritySystemContracts.ViewModels; - - -namespace SecuritySystemListImplement.Implements -{ - public class ManufactureStorage : IManufactureStorage - { - private readonly DataListSingleton _source; - public ManufactureStorage() - { - _source = DataListSingleton.GetInstance(); - } - public List GetFullList() - { - var result = new List(); - foreach (var Manufacture in _source.Manufactures) - { - result.Add(Manufacture.GetViewModel); - } - return result; - } - public List GetFilteredList(ManufactureSearchModel model) - { - var result = new List(); - if (string.IsNullOrEmpty(model.ManufactureName)) - { - return result; - } - foreach (var Manufacture in _source.Manufactures) - { - if (Manufacture.ManufactureName.Contains(model.ManufactureName)) - { - result.Add(Manufacture.GetViewModel); - } - } - return result; - } - public ManufactureViewModel? GetElement(ManufactureSearchModel model) - { - if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) - { - return null; - } - foreach (var Manufacture in _source.Manufactures) - { - if ((!string.IsNullOrEmpty(model.ManufactureName) && Manufacture.ManufactureName == model.ManufactureName) || - (model.Id.HasValue && Manufacture.Id == model.Id)) - { - return Manufacture.GetViewModel; - } - } - return null; - } - public ManufactureViewModel? Insert(ManufactureBindingModel model) - { - model.Id = 1; - foreach (var Manufacture in _source.Manufactures) - { - if (model.Id <= Manufacture.Id) - { - model.Id = Manufacture.Id + 1; - } - } - var newManufacture = Manufacture.Create(model); - if (newManufacture == null) - { - return null; - } - _source.Manufactures.Add(newManufacture); - return newManufacture.GetViewModel; - } - public ManufactureViewModel? Update(ManufactureBindingModel model) - { - foreach (var Manufacture in _source.Manufactures) - { - if (Manufacture.Id == model.Id) - { - Manufacture.Update(model); - return Manufacture.GetViewModel; - } - } - return null; - } - public ManufactureViewModel? Delete(ManufactureBindingModel model) - { - for (int i = 0; i < _source.Manufactures.Count; ++i) - { - if (_source.Manufactures[i].Id == model.Id) - { - var element = _source.Manufactures[i]; - _source.Manufactures.RemoveAt(i); - return element.GetViewModel; - } - } - return null; - } - } -} diff --git a/SecuritySystemListImplement/Implements/OrderStorage.cs b/SecuritySystemListImplement/Implements/OrderStorage.cs index 873ed51..706ee4b 100644 --- a/SecuritySystemListImplement/Implements/OrderStorage.cs +++ b/SecuritySystemListImplement/Implements/OrderStorage.cs @@ -98,13 +98,13 @@ namespace OrdersShopListImplement.Implements } return null; } - private OrderViewModel AttachManufactureName(OrderViewModel model) + private OrderViewModel AttachSecureName(OrderViewModel model) { - foreach (var manufacture in _source.Manufactures) + foreach (var secure in _source.Securies) { - if (manufacture.Id == model.ManufactureId) + if (secure.Id == model.SecureId) { - model.ManufactureName = manufacture.ManufactureName; + model.SecureName = secure.SecureName; return model; } } diff --git a/SecuritySystemListImplement/Implements/SecureStorage.cs b/SecuritySystemListImplement/Implements/SecureStorage.cs new file mode 100644 index 0000000..a01cbf9 --- /dev/null +++ b/SecuritySystemListImplement/Implements/SecureStorage.cs @@ -0,0 +1,102 @@ +using SecuritySystemListImplement.Models; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; + + +namespace SecuritySystemListImplement.Implements +{ + public class SecureStorage : ISecureStorage + { + private readonly DataListSingleton _source; + public SecureStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var Secure in _source.Securies) + { + result.Add(Secure.GetViewModel); + } + return result; + } + public List GetFilteredList(SecureSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.SecureName)) + { + return result; + } + foreach (var Secure in _source.Securies) + { + if (Secure.SecureName.Contains(model.SecureName)) + { + result.Add(Secure.GetViewModel); + } + } + return result; + } + public SecureViewModel? GetElement(SecureSearchModel model) + { + if (string.IsNullOrEmpty(model.SecureName) && !model.Id.HasValue) + { + return null; + } + foreach (var Secure in _source.Securies) + { + if ((!string.IsNullOrEmpty(model.SecureName) && Secure.SecureName == model.SecureName) || + (model.Id.HasValue && Secure.Id == model.Id)) + { + return Secure.GetViewModel; + } + } + return null; + } + public SecureViewModel? Insert(SecureBindingModel model) + { + model.Id = 1; + foreach (var Secure in _source.Securies) + { + if (model.Id <= Secure.Id) + { + model.Id = Secure.Id + 1; + } + } + var newSecure = Secure.Create(model); + if (newSecure == null) + { + return null; + } + _source.Securies.Add(newSecure); + return newSecure.GetViewModel; + } + public SecureViewModel? Update(SecureBindingModel model) + { + foreach (var Secure in _source.Securies) + { + if (Secure.Id == model.Id) + { + Secure.Update(model); + return Secure.GetViewModel; + } + } + return null; + } + public SecureViewModel? Delete(SecureBindingModel model) + { + for (int i = 0; i < _source.Securies.Count; ++i) + { + if (_source.Securies[i].Id == model.Id) + { + var element = _source.Securies[i]; + _source.Securies.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/SecuritySystemListImplement/Models/Order.cs b/SecuritySystemListImplement/Models/Order.cs index caac226..2fd9e3c 100644 --- a/SecuritySystemListImplement/Models/Order.cs +++ b/SecuritySystemListImplement/Models/Order.cs @@ -15,9 +15,9 @@ namespace SecuritySystemListImplement.Models { public int Id { get; private set; } - public int ManufactureId { get; private set; } + public int SecureId { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; + public string SecureName { get; private set; } = string.Empty; public int Count { get; private set; } public double Sum { get; private set; } @@ -36,7 +36,13 @@ namespace SecuritySystemListImplement.Models } return new Order() { + Id = model.Id, + SecureId = model.SecureId, + SecureName = model.SecureName, + Count = model.Count, + Sum = model.Sum, Status = model.Status, + DateCreate = model.DateCreate, DateImplement = model.DateImplement }; } @@ -47,19 +53,15 @@ namespace SecuritySystemListImplement.Models { return; } - ManufactureId = model.ManufactureId; - ManufactureName = model.ManufactureName; - Count = model.Count; - Sum = model.Sum; + Status = model.Status; - DateCreate = model.DateCreate; DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() { Id = Id, - ManufactureId = ManufactureId, - ManufactureName = ManufactureName, + SecureId = SecureId, + SecureName = SecureName, Count = Count, Sum = Sum, Status = Status, diff --git a/SecuritySystemListImplement/Models/Manufacture.cs b/SecuritySystemListImplement/Models/Secure.cs similarity index 54% rename from SecuritySystemListImplement/Models/Manufacture.cs rename to SecuritySystemListImplement/Models/Secure.cs index 2e1deb9..28e0c76 100644 --- a/SecuritySystemListImplement/Models/Manufacture.cs +++ b/SecuritySystemListImplement/Models/Secure.cs @@ -10,46 +10,46 @@ using SecuritySystemDataModels.Models; namespace SecuritySystemListImplement.Models { - public class Manufacture : IManufactureModel + public class Secure : ISecureModel { public int Id { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; + public string SecureName { get; private set; } = string.Empty; public double Price { get; private set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; private set; } = new Dictionary(); - public static Manufacture? Create(ManufactureBindingModel? model) + public static Secure? Create(SecureBindingModel? model) { if (model == null) { return null; } - return new Manufacture() + return new Secure() { Id = model.Id, - ManufactureName = model.ManufactureName, + SecureName = model.SecureName, Price = model.Price, - ManufactureComponents = model.ManufactureComponents + SecureComponents = model.SecureComponents }; } - public void Update(ManufactureBindingModel? model) + public void Update(SecureBindingModel? model) { if (model == null) { return; } - ManufactureName = model.ManufactureName; + SecureName = model.SecureName; Price = model.Price; - ManufactureComponents = model.ManufactureComponents; + SecureComponents = model.SecureComponents; } - public ManufactureViewModel GetViewModel => new() + public SecureViewModel GetViewModel => new() { Id = Id, - ManufactureName = ManufactureName, + SecureName = SecureName, Price = Price, - ManufactureComponents = ManufactureComponents + SecureComponents = SecureComponents }; } } diff --git a/SystemSecurityBusinessLogic/OrderLogic.cs b/SystemSecurityBusinessLogic/OrderLogic.cs index edd9141..41cc69a 100644 --- a/SystemSecurityBusinessLogic/OrderLogic.cs +++ b/SystemSecurityBusinessLogic/OrderLogic.cs @@ -75,9 +75,9 @@ namespace SecuritySystemBusinessLogic { return; } - if (model.ManufactureId < 0) + if (model.SecureId < 0) { - throw new ArgumentNullException("Некорректный идентификатор камеры", nameof(model.ManufactureId)); + throw new ArgumentNullException("Некорректный идентификатор камеры", nameof(model.SecureId)); } if (model.Count <= 0) { @@ -87,7 +87,7 @@ namespace SecuritySystemBusinessLogic { throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); } - _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. ManufactureId: { ManufactureId}", model.Id, model.Sum, model.ManufactureId); + _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. SecureId: { SecureId}", model.Id, model.Sum, model.SecureId); } private bool CheckStatus(OrderBindingModel model, OrderStatus newstatus, bool update = true) diff --git a/SystemSecurityBusinessLogic/ManufactureLogic.cs b/SystemSecurityBusinessLogic/SecureLogic.cs similarity index 59% rename from SystemSecurityBusinessLogic/ManufactureLogic.cs rename to SystemSecurityBusinessLogic/SecureLogic.cs index 26b88ab..78f5cc0 100644 --- a/SystemSecurityBusinessLogic/ManufactureLogic.cs +++ b/SystemSecurityBusinessLogic/SecureLogic.cs @@ -8,21 +8,21 @@ using Microsoft.Extensions.Logging; namespace SecuritySystemBusinessLogic { - public class ManufactureLogic : IManufactureLogic + public class SecureLogic : ISecureLogic { private readonly ILogger _logger; - private readonly IManufactureStorage _ManufactureStorage; + private readonly ISecureStorage _SecureStorage; - public ManufactureLogic(ILogger logger, IManufactureStorage ManufactureStorage) + public SecureLogic(ILogger logger, ISecureStorage SecureStorage) { _logger = logger; - _ManufactureStorage = ManufactureStorage; + _SecureStorage = SecureStorage; } - public List? ReadList(ManufactureSearchModel? model) + public List? ReadList(SecureSearchModel? model) { - _logger.LogInformation("ReadList. ManufactureName:{ManufactureName}.Id:{ Id}", model?.ManufactureName, model?.Id); - var list = model == null ? _ManufactureStorage.GetFullList() : _ManufactureStorage.GetFilteredList(model); + _logger.LogInformation("ReadList. SecureName:{SecureName}.Id:{ Id}", model?.SecureName, model?.Id); + var list = model == null ? _SecureStorage.GetFullList() : _SecureStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -32,14 +32,14 @@ namespace SecuritySystemBusinessLogic return list; } - public ManufactureViewModel? ReadElement(ManufactureSearchModel model) + public SecureViewModel? ReadElement(SecureSearchModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. ManufactureName:{ManufactureName}.Id:{ Id}", model.ManufactureName, model.Id); - var element = _ManufactureStorage.GetElement(model); + _logger.LogInformation("ReadElement. SecureName:{SecureName}.Id:{ Id}", model.SecureName, model.Id); + var element = _SecureStorage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement element not found"); @@ -49,10 +49,10 @@ namespace SecuritySystemBusinessLogic return element; } - public bool Create(ManufactureBindingModel model) + public bool Create(SecureBindingModel model) { CheckModel(model); - if (_ManufactureStorage.Insert(model) == null) + if (_SecureStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; @@ -60,10 +60,10 @@ namespace SecuritySystemBusinessLogic return true; } - public bool Update(ManufactureBindingModel model) + public bool Update(SecureBindingModel model) { CheckModel(model); - if (_ManufactureStorage.Update(model) == null) + if (_SecureStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); return false; @@ -71,11 +71,11 @@ namespace SecuritySystemBusinessLogic return true; } - public bool Delete(ManufactureBindingModel model) + public bool Delete(SecureBindingModel model) { CheckModel(model, false); _logger.LogInformation("Delete. Id:{Id}", model.Id); - if (_ManufactureStorage.Delete(model) == null) + if (_SecureStorage.Delete(model) == null) { _logger.LogWarning("Delete operation failed"); return false; @@ -83,7 +83,7 @@ namespace SecuritySystemBusinessLogic return true; } - private void CheckModel(ManufactureBindingModel model, bool withParams = true) + private void CheckModel(SecureBindingModel model, bool withParams = true) { if (model == null) { @@ -93,18 +93,18 @@ namespace SecuritySystemBusinessLogic { return; } - if (string.IsNullOrEmpty(model.ManufactureName)) + if (string.IsNullOrEmpty(model.SecureName)) { - throw new ArgumentNullException("Нет названия камеры", nameof(model.ManufactureName)); + throw new ArgumentNullException("Нет названия камеры", nameof(model.SecureName)); } if (model.Price <= 0) { throw new ArgumentNullException("Цена камеры должна быть больше 0", nameof(model.Price)); } - _logger.LogInformation("Manufacture. ManufactureName:{ManufactureName}.Cost:{ Cost}. Id: { Id}", model.ManufactureName, model.Price, model.Id); - var element = _ManufactureStorage.GetElement(new ManufactureSearchModel + _logger.LogInformation("Secure. SecureName:{SecureName}.Cost:{ Cost}. Id: { Id}", model.SecureName, model.Price, model.Id); + var element = _SecureStorage.GetElement(new SecureSearchModel { - ManufactureName = model.ManufactureName + SecureName = model.SecureName }); if (element != null && element.Id != model.Id) { -- 2.25.1 From 5ddd734aa6829eb7f3be6f396d7d11d7036e3945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 12:56:54 +0400 Subject: [PATCH 08/21] rename --- .../Implements/SecureStorage.cs | 102 ++++++++++++++++++ SecuritySystemListImplement/Models/Secure.cs | 55 ++++++++++ 2 files changed, 157 insertions(+) create mode 100644 SecuritySystemListImplement/Implements/SecureStorage.cs create mode 100644 SecuritySystemListImplement/Models/Secure.cs diff --git a/SecuritySystemListImplement/Implements/SecureStorage.cs b/SecuritySystemListImplement/Implements/SecureStorage.cs new file mode 100644 index 0000000..d278cad --- /dev/null +++ b/SecuritySystemListImplement/Implements/SecureStorage.cs @@ -0,0 +1,102 @@ +using SecuritySystemListImplement.Models; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; + + +namespace SecuritySystemListImplement.Implements +{ + public class SecureStorage : IManufactureStorage + { + private readonly DataListSingleton _source; + public SecureStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var Manufacture in _source.Manufactures) + { + result.Add(Manufacture.GetViewModel); + } + return result; + } + public List GetFilteredList(ManufactureSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ManufactureName)) + { + return result; + } + foreach (var Manufacture in _source.Manufactures) + { + if (Manufacture.ManufactureName.Contains(model.ManufactureName)) + { + result.Add(Manufacture.GetViewModel); + } + } + return result; + } + public ManufactureViewModel? GetElement(ManufactureSearchModel model) + { + if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) + { + return null; + } + foreach (var Manufacture in _source.Manufactures) + { + if ((!string.IsNullOrEmpty(model.ManufactureName) && Manufacture.ManufactureName == model.ManufactureName) || + (model.Id.HasValue && Manufacture.Id == model.Id)) + { + return Manufacture.GetViewModel; + } + } + return null; + } + public ManufactureViewModel? Insert(ManufactureBindingModel model) + { + model.Id = 1; + foreach (var Manufacture in _source.Manufactures) + { + if (model.Id <= Manufacture.Id) + { + model.Id = Manufacture.Id + 1; + } + } + var newManufacture = Secure.Create(model); + if (newManufacture == null) + { + return null; + } + _source.Manufactures.Add(newManufacture); + return newManufacture.GetViewModel; + } + public ManufactureViewModel? Update(ManufactureBindingModel model) + { + foreach (var Manufacture in _source.Manufactures) + { + if (Manufacture.Id == model.Id) + { + Manufacture.Update(model); + return Manufacture.GetViewModel; + } + } + return null; + } + public ManufactureViewModel? Delete(ManufactureBindingModel model) + { + for (int i = 0; i < _source.Manufactures.Count; ++i) + { + if (_source.Manufactures[i].Id == model.Id) + { + var element = _source.Manufactures[i]; + _source.Manufactures.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/SecuritySystemListImplement/Models/Secure.cs b/SecuritySystemListImplement/Models/Secure.cs new file mode 100644 index 0000000..a7bc67d --- /dev/null +++ b/SecuritySystemListImplement/Models/Secure.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.ViewModels; +using SecuritySystemDataModels.Models; + +namespace SecuritySystemListImplement.Models +{ + public class Secure : IManufactureModel + { + public int Id { get; private set; } + public string ManufactureName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary ManufactureComponents + { + get; + private set; + } = new Dictionary(); + public static Secure? Create(ManufactureBindingModel? model) + { + if (model == null) + { + return null; + } + return new Secure() + { + Id = model.Id, + ManufactureName = model.ManufactureName, + Price = model.Price, + ManufactureComponents = model.ManufactureComponents + }; + } + public void Update(ManufactureBindingModel? model) + { + if (model == null) + { + return; + } + ManufactureName = model.ManufactureName; + Price = model.Price; + ManufactureComponents = model.ManufactureComponents; + } + public ManufactureViewModel GetViewModel => new() + { + Id = Id, + ManufactureName = ManufactureName, + Price = Price, + ManufactureComponents = ManufactureComponents + }; + } +} -- 2.25.1 From ba933bf7f3d3fd75e897915284b2618b05484d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Mon, 6 Mar 2023 17:26:18 +0400 Subject: [PATCH 09/21] final fixed --- SecuritySystemListImplement/Models/Order.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/SecuritySystemListImplement/Models/Order.cs b/SecuritySystemListImplement/Models/Order.cs index 4ad41a3..9cb0cfa 100644 --- a/SecuritySystemListImplement/Models/Order.cs +++ b/SecuritySystemListImplement/Models/Order.cs @@ -36,13 +36,7 @@ namespace SecuritySystemListImplement.Models } return new Order() { - Id = model.Id, - ManufactureId = model.ManufactureId, - ManufactureName = model.ManufactureName, - Count = model.Count, - Sum = model.Sum, Status = model.Status, - DateCreate = model.DateCreate, DateImplement = model.DateImplement }; } -- 2.25.1 From 21274bfbf0eea8fc476acec2f905a9e985a0b1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 12:47:29 +0400 Subject: [PATCH 10/21] Rename --- SecuritySystem/FormCreateOrder.Designer.cs | 40 +++--- SecuritySystem/FormCreateOrder.cs | 30 ++--- SecuritySystem/FormMain.cs | 20 +-- SecuritySystem/FormManufacturies.resx | 120 ------------------ ...ure.Designer.cs => FormSecure.Designer.cs} | 49 +++---- .../{FormManufacture.cs => FormSecure.cs} | 52 ++++---- SecuritySystem/FormSecure.resx | 60 +++++++++ ...s.Designer.cs => FormSecuries.Designer.cs} | 8 +- .../{FormManufacturies.cs => FormSecuries.cs} | 22 ++-- ...FormManufacture.resx => FormSecuries.resx} | 0 ...r.cs => FormSecuriesComponent.Designer.cs} | 2 +- ...eComponent.cs => FormSecuriesComponent.cs} | 4 +- ...ponent.resx => FormSecuriesComponent.resx} | 0 SecuritySystem/Program.cs | 11 +- .../BindingModels/OrderBindingModel.cs | 4 +- ...eBindingModel.cs => SecureBindingModel.cs} | 6 +- .../IManufactureLogic.cs | 21 --- .../BusinessLogicsContracts/ISecureLogic.cs | 21 +++ ...ureSearchModel.cs => SecureSearchModel.cs} | 4 +- .../StorageContracts/IManufactureStorage.cs | 21 --- .../StorageContracts/ISecureStorage.cs | 21 +++ .../ViewModels/OrderViewModel.cs | 4 +- ...factureViewModel.cs => SecureViewModel.cs} | 6 +- .../Models/IOrderModel.cs | 2 +- .../{IManufactureModel.cs => ISecureModel.cs} | 6 +- .../DataListSingletone.cs | 4 +- .../Implements/ManufactureStorage.cs | 102 --------------- .../Implements/OrderStorage.cs | 8 +- .../Implements/SecureStorage.cs | 70 +++++----- .../Models/Manufacture.cs | 55 -------- SecuritySystemListImplement/Models/Order.cs | 15 ++- SecuritySystemListImplement/Models/Secure.cs | 24 ++-- SystemSecurityBusinessLogic/OrderLogic.cs | 6 +- .../{ManufactureLogic.cs => SecureLogic.cs} | 44 +++---- 34 files changed, 326 insertions(+), 536 deletions(-) delete mode 100644 SecuritySystem/FormManufacturies.resx rename SecuritySystem/{FormManufacture.Designer.cs => FormSecure.Designer.cs} (98%) rename SecuritySystem/{FormManufacture.cs => FormSecure.cs} (79%) create mode 100644 SecuritySystem/FormSecure.resx rename SecuritySystem/{FormManufacturies.Designer.cs => FormSecuries.Designer.cs} (96%) rename SecuritySystem/{FormManufacturies.cs => FormSecuries.cs} (83%) rename SecuritySystem/{FormManufacture.resx => FormSecuries.resx} (100%) rename SecuritySystem/{FormManufactureComponent.Designer.cs => FormSecuriesComponent.Designer.cs} (99%) rename SecuritySystem/{FormManufactureComponent.cs => FormSecuriesComponent.cs} (95%) rename SecuritySystem/{FormManufactureComponent.resx => FormSecuriesComponent.resx} (100%) rename SecuritySystemContracts/BindingModels/{ManufactureBindingModel.cs => SecureBindingModel.cs} (54%) delete mode 100644 SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs create mode 100644 SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs rename SecuritySystemContracts/SearchModels/{ManufactureSearchModel.cs => SecureSearchModel.cs} (70%) delete mode 100644 SecuritySystemContracts/StorageContracts/IManufactureStorage.cs create mode 100644 SecuritySystemContracts/StorageContracts/ISecureStorage.cs rename SecuritySystemContracts/ViewModels/{ManufactureViewModel.cs => SecureViewModel.cs} (70%) rename SecuritySystemDataModels/Models/{IManufactureModel.cs => ISecureModel.cs} (59%) delete mode 100644 SecuritySystemListImplement/Implements/ManufactureStorage.cs delete mode 100644 SecuritySystemListImplement/Models/Manufacture.cs rename SystemSecurityBusinessLogic/{ManufactureLogic.cs => SecureLogic.cs} (59%) diff --git a/SecuritySystem/FormCreateOrder.Designer.cs b/SecuritySystem/FormCreateOrder.Designer.cs index 9a89b05..ba1b6eb 100644 --- a/SecuritySystem/FormCreateOrder.Designer.cs +++ b/SecuritySystem/FormCreateOrder.Designer.cs @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - this.labelManufacture = new System.Windows.Forms.Label(); - this.comboBoxManufacture = new System.Windows.Forms.ComboBox(); + this.labelSecure = new System.Windows.Forms.Label(); + this.comboBoxSecure = new System.Windows.Forms.ComboBox(); this.labelCount = new System.Windows.Forms.Label(); this.textBoxCount = new System.Windows.Forms.TextBox(); this.labelSum = new System.Windows.Forms.Label(); @@ -38,23 +38,23 @@ this.buttonSave = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // labelManufacture + // labelSecure // - this.labelManufacture.AutoSize = true; - this.labelManufacture.Location = new System.Drawing.Point(12, 15); - this.labelManufacture.Name = "labelManufacture"; - this.labelManufacture.Size = new System.Drawing.Size(75, 20); - this.labelManufacture.TabIndex = 0; - this.labelManufacture.Text = "Изделие: "; + this.labelSecure.AutoSize = true; + this.labelSecure.Location = new System.Drawing.Point(12, 15); + this.labelSecure.Name = "labelSecure"; + this.labelSecure.Size = new System.Drawing.Size(75, 20); + this.labelSecure.TabIndex = 0; + this.labelSecure.Text = "Изделие: "; // - // comboBoxManufacture + // comboBoxSecure // - this.comboBoxManufacture.FormattingEnabled = true; - this.comboBoxManufacture.Location = new System.Drawing.Point(115, 12); - this.comboBoxManufacture.Name = "comboBoxManufacture"; - this.comboBoxManufacture.Size = new System.Drawing.Size(358, 28); - this.comboBoxManufacture.TabIndex = 1; - this.comboBoxManufacture.SelectedIndexChanged += new System.EventHandler(this.ComboBoxManufacture_SelectedIndexChanged); + this.comboBoxSecure.FormattingEnabled = true; + this.comboBoxSecure.Location = new System.Drawing.Point(115, 12); + this.comboBoxSecure.Name = "comboBoxSecure"; + this.comboBoxSecure.Size = new System.Drawing.Size(358, 28); + this.comboBoxSecure.TabIndex = 1; + this.comboBoxSecure.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSecure_SelectedIndexChanged); // // labelCount // @@ -121,8 +121,8 @@ this.Controls.Add(this.labelSum); this.Controls.Add(this.textBoxCount); this.Controls.Add(this.labelCount); - this.Controls.Add(this.comboBoxManufacture); - this.Controls.Add(this.labelManufacture); + this.Controls.Add(this.comboBoxSecure); + this.Controls.Add(this.labelSecure); this.Name = "FormCreateOrder"; this.Text = "Заказ"; this.Load += new System.EventHandler(this.FormCreateOrder_Load); @@ -133,8 +133,8 @@ #endregion - private Label labelManufacture; - private ComboBox comboBoxManufacture; + private Label labelSecure; + private ComboBox comboBoxSecure; private Label labelCount; private TextBox textBoxCount; private Label labelSum; diff --git a/SecuritySystem/FormCreateOrder.cs b/SecuritySystem/FormCreateOrder.cs index a7ce11f..4af9c06 100644 --- a/SecuritySystem/FormCreateOrder.cs +++ b/SecuritySystem/FormCreateOrder.cs @@ -18,10 +18,10 @@ namespace SecuritySystemView public partial class FormCreateOrder : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logicM; + private readonly ISecureLogic _logicM; private readonly IOrderLogic _logicO; - private List? _list; - public FormCreateOrder(ILogger logger, IManufactureLogic logicM, IOrderLogic logicO) + private List? _list; + public FormCreateOrder(ILogger logger, ISecureLogic logicM, IOrderLogic logicO) { InitializeComponent(); _logger = logger; @@ -33,23 +33,23 @@ namespace SecuritySystemView _list = _logicM.ReadList(null); if (_list != null) { - comboBoxManufacture.DisplayMember = "ManufactureName"; - comboBoxManufacture.ValueMember = "Id"; - comboBoxManufacture.DataSource = _list; - comboBoxManufacture.SelectedItem = null; + comboBoxSecure.DisplayMember = "SecureName"; + comboBoxSecure.ValueMember = "Id"; + comboBoxSecure.DataSource = _list; + comboBoxSecure.SelectedItem = null; _logger.LogInformation("Загрузка изделий для заказа"); } } private void CalcSum() { - if (comboBoxManufacture.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + if (comboBoxSecure.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) { try { - int id = Convert.ToInt32(comboBoxManufacture.SelectedValue); - var Manufacture = _logicM.ReadElement(new ManufactureSearchModel { Id = id }); + int id = Convert.ToInt32(comboBoxSecure.SelectedValue); + var Secure = _logicM.ReadElement(new SecureSearchModel { Id = id }); int count = Convert.ToInt32(textBoxCount.Text); - textBoxSum.Text = Math.Round(count * (Manufacture?.Price ?? 0), 2).ToString(); + textBoxSum.Text = Math.Round(count * (Secure?.Price ?? 0), 2).ToString(); _logger.LogInformation("Расчет суммы заказа"); } catch (Exception ex) @@ -63,7 +63,7 @@ namespace SecuritySystemView { CalcSum(); } - private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e) + private void ComboBoxSecure_SelectedIndexChanged(object sender, EventArgs e) { CalcSum(); } @@ -74,7 +74,7 @@ namespace SecuritySystemView MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (comboBoxManufacture.SelectedValue == null) + if (comboBoxSecure.SelectedValue == null) { MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -84,8 +84,8 @@ namespace SecuritySystemView { var operationResult = _logicO.CreateOrder(new OrderBindingModel { - ManufactureId = Convert.ToInt32(comboBoxManufacture.SelectedValue), - ManufactureName = comboBoxManufacture.Text, + SecureId = Convert.ToInt32(comboBoxSecure.SelectedValue), + SecureName = comboBoxSecure.Text, Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); diff --git a/SecuritySystem/FormMain.cs b/SecuritySystem/FormMain.cs index 6ce123b..2537a2f 100644 --- a/SecuritySystem/FormMain.cs +++ b/SecuritySystem/FormMain.cs @@ -37,8 +37,8 @@ namespace SecuritySystemView if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["ManufactureId"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["SecureId"].Visible = false; + dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } @@ -58,8 +58,8 @@ namespace SecuritySystemView } private void GoodsToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacturies)); - if (service is FormManufacturies form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuries)); + if (service is FormSecuries form) { form.ShowDialog(); } @@ -84,8 +84,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -115,8 +115,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -147,8 +147,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), diff --git a/SecuritySystem/FormManufacturies.resx b/SecuritySystem/FormManufacturies.resx deleted file mode 100644 index 1af7de1..0000000 --- a/SecuritySystem/FormManufacturies.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/SecuritySystem/FormManufacture.Designer.cs b/SecuritySystem/FormSecure.Designer.cs similarity index 98% rename from SecuritySystem/FormManufacture.Designer.cs rename to SecuritySystem/FormSecure.Designer.cs index d4283d0..934e2e7 100644 --- a/SecuritySystem/FormManufacture.Designer.cs +++ b/SecuritySystem/FormSecure.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufacture + partial class FormSecure { /// /// Required designer variable. @@ -38,11 +38,11 @@ this.buttonUpd = new System.Windows.Forms.Button(); this.buttonAdd = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonSave = new System.Windows.Forms.Button(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); this.groupBoxComponents.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -76,6 +76,7 @@ // this.textBoxPrice.Location = new System.Drawing.Point(112, 51); this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.ReadOnly = true; this.textBoxPrice.Size = new System.Drawing.Size(171, 27); this.textBoxPrice.TabIndex = 3; // @@ -151,26 +152,6 @@ this.dataGridView.Size = new System.Drawing.Size(476, 287); this.dataGridView.TabIndex = 0; // - // buttonCancel - // - this.buttonCancel.Location = new System.Drawing.Point(514, 417); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(126, 34); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "Отмена"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); - // - // buttonSave - // - this.buttonSave.Location = new System.Drawing.Point(368, 417); - this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(126, 34); - this.buttonSave.TabIndex = 6; - this.buttonSave.Text = "Сохранить"; - this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); - // // id // this.id.HeaderText = "id"; @@ -193,6 +174,26 @@ this.Count.Name = "Count"; this.Count.ReadOnly = true; // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(514, 417); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(126, 34); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(368, 417); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(126, 34); + this.buttonSave.TabIndex = 6; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // // FormManufacture // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); @@ -207,7 +208,7 @@ this.Controls.Add(this.labelName); this.Name = "FormManufacture"; this.Text = "Изделие"; - this.Load += new System.EventHandler(this.FormManufacture_Load); + this.Load += new System.EventHandler(this.FormSecure_Load); this.groupBoxComponents.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/SecuritySystem/FormManufacture.cs b/SecuritySystem/FormSecure.cs similarity index 79% rename from SecuritySystem/FormManufacture.cs rename to SecuritySystem/FormSecure.cs index 0a6a1a6..f328329 100644 --- a/SecuritySystem/FormManufacture.cs +++ b/SecuritySystem/FormSecure.cs @@ -16,33 +16,33 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufacture : Form + public partial class FormSecure : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logic; + private readonly ISecureLogic _logic; private int? _id; - private Dictionary _ManufactureComponents; + private Dictionary _SecureComponents; public int Id { set { _id = value; } } - public FormManufacture(ILogger logger, IManufactureLogic logic) + public FormSecure(ILogger logger, ISecureLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; - _ManufactureComponents = new Dictionary(); + _SecureComponents = new Dictionary(); } - private void FormManufacture_Load(object sender, EventArgs e) + private void FormSecure_Load(object sender, EventArgs e) { if (_id.HasValue) { _logger.LogInformation("Загрузка изделия"); try { - var view = _logic.ReadElement(new ManufactureSearchModel { Id = _id.Value }); + var view = _logic.ReadElement(new SecureSearchModel { Id = _id.Value }); if (view != null) { - textBoxName.Text = view.ManufactureName; + textBoxName.Text = view.SecureName; textBoxPrice.Text = view.Price.ToString(); - _ManufactureComponents = view.ManufactureComponents ?? new + _SecureComponents = view.SecureComponents ?? new Dictionary(); LoadData(); } @@ -60,10 +60,10 @@ namespace SecuritySystemView _logger.LogInformation("Загрузка компонент изделия"); try { - if (_ManufactureComponents != null) + if (_SecureComponents != null) { dataGridView.Rows.Clear(); - foreach (var pc in _ManufactureComponents) + foreach (var pc in _SecureComponents) { dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); } @@ -79,8 +79,8 @@ namespace SecuritySystemView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); - if (service is FormManufactureComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuriesComponent)); + if (service is FormSecuriesComponent form) { if (form.ShowDialog() == DialogResult.OK) { @@ -89,13 +89,13 @@ namespace SecuritySystemView return; } _logger.LogInformation("Добавление нового компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); - if (_ManufactureComponents.ContainsKey(form.Id)) + if (_SecureComponents.ContainsKey(form.Id)) { - _ManufactureComponents[form.Id] = (form.ComponentModel, form.Count); + _SecureComponents[form.Id] = (form.ComponentModel, form.Count); } else { - _ManufactureComponents.Add(form.Id, (form.ComponentModel, form.Count)); + _SecureComponents.Add(form.Id, (form.ComponentModel, form.Count)); } LoadData(); } @@ -105,12 +105,12 @@ namespace SecuritySystemView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); - if (service is FormManufactureComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuriesComponent)); + if (service is FormSecuriesComponent form) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; - form.Count = _ManufactureComponents[id].Item2; + form.Count = _SecureComponents[id].Item2; if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) @@ -118,7 +118,7 @@ namespace SecuritySystemView return; } _logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); - _ManufactureComponents[form.Id] = (form.ComponentModel, form.Count); + _SecureComponents[form.Id] = (form.ComponentModel, form.Count); LoadData(); } } @@ -134,7 +134,7 @@ namespace SecuritySystemView try { _logger.LogInformation("Удаление компонента: {ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); - _ManufactureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _SecureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { @@ -161,7 +161,7 @@ namespace SecuritySystemView MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (_ManufactureComponents == null || _ManufactureComponents.Count == 0) + if (_SecureComponents == null || _SecureComponents.Count == 0) { MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -169,12 +169,12 @@ namespace SecuritySystemView _logger.LogInformation("Сохранение изделия"); try { - var model = new ManufactureBindingModel + var model = new SecureBindingModel { Id = _id ?? 0, - ManufactureName = textBoxName.Text, + SecureName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - ManufactureComponents = _ManufactureComponents + SecureComponents = _SecureComponents }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) @@ -199,7 +199,7 @@ namespace SecuritySystemView private double CalcPrice() { double price = 0; - foreach (var elem in _ManufactureComponents) + foreach (var elem in _SecureComponents) { price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); } diff --git a/SecuritySystem/FormSecure.resx b/SecuritySystem/FormSecure.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SecuritySystem/FormSecure.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/SecuritySystem/FormManufacturies.Designer.cs b/SecuritySystem/FormSecuries.Designer.cs similarity index 96% rename from SecuritySystem/FormManufacturies.Designer.cs rename to SecuritySystem/FormSecuries.Designer.cs index 5147d93..718eb7d 100644 --- a/SecuritySystem/FormManufacturies.Designer.cs +++ b/SecuritySystem/FormSecuries.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufacturies + partial class FormSecuries { /// /// Required designer variable. @@ -102,16 +102,16 @@ this.dataGridView.Size = new System.Drawing.Size(590, 426); this.dataGridView.TabIndex = 2; // - // FormManufacturies + // FormSecure // 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 = "FormManufacturies"; + this.Name = "FormSecuries"; this.Text = "Изделия"; - this.Load += new System.EventHandler(this.FormManufacturies_Load); + this.Load += new System.EventHandler(this.FormSecuries_Load); this.ToolsPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/SecuritySystem/FormManufacturies.cs b/SecuritySystem/FormSecuries.cs similarity index 83% rename from SecuritySystem/FormManufacturies.cs rename to SecuritySystem/FormSecuries.cs index 61d79fc..acd9911 100644 --- a/SecuritySystem/FormManufacturies.cs +++ b/SecuritySystem/FormSecuries.cs @@ -14,17 +14,17 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufacturies : Form + public partial class FormSecuries : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logic; - public FormManufacturies(ILogger logger, IManufactureLogic logic) + private readonly ISecureLogic _logic; + public FormSecuries(ILogger logger, ISecureLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - private void FormManufacturies_Load(object sender, EventArgs e) + private void FormSecuries_Load(object sender, EventArgs e) { LoadData(); } @@ -37,8 +37,8 @@ namespace SecuritySystemView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ManufactureComponents"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = + dataGridView.Columns["SecureComponents"].Visible = false; + dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка изделий"); @@ -51,8 +51,8 @@ namespace SecuritySystemView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); - if (service is FormManufacture form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecure)); + if (service is FormSecure form) { if (form.ShowDialog() == DialogResult.OK) { @@ -64,8 +64,8 @@ namespace SecuritySystemView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); - if (service is FormManufacture form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecure)); + if (service is FormSecure form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) @@ -85,7 +85,7 @@ namespace SecuritySystemView _logger.LogInformation("Удаление изделия"); try { - if (!_logic.Delete(new ManufactureBindingModel { Id = id })) + if (!_logic.Delete(new SecureBindingModel { Id = id })) { throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); } diff --git a/SecuritySystem/FormManufacture.resx b/SecuritySystem/FormSecuries.resx similarity index 100% rename from SecuritySystem/FormManufacture.resx rename to SecuritySystem/FormSecuries.resx diff --git a/SecuritySystem/FormManufactureComponent.Designer.cs b/SecuritySystem/FormSecuriesComponent.Designer.cs similarity index 99% rename from SecuritySystem/FormManufactureComponent.Designer.cs rename to SecuritySystem/FormSecuriesComponent.Designer.cs index 686592c..bb2b8c6 100644 --- a/SecuritySystem/FormManufactureComponent.Designer.cs +++ b/SecuritySystem/FormSecuriesComponent.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufactureComponent + partial class FormSecuriesComponent { /// /// Required designer variable. diff --git a/SecuritySystem/FormManufactureComponent.cs b/SecuritySystem/FormSecuriesComponent.cs similarity index 95% rename from SecuritySystem/FormManufactureComponent.cs rename to SecuritySystem/FormSecuriesComponent.cs index cdf9c1a..ad94391 100644 --- a/SecuritySystem/FormManufactureComponent.cs +++ b/SecuritySystem/FormSecuriesComponent.cs @@ -13,7 +13,7 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufactureComponent : Form + public partial class FormSecuriesComponent : Form { private readonly List? _list; public int Id @@ -50,7 +50,7 @@ namespace SecuritySystemView get { return Convert.ToInt32(textBoxCount.Text); } set { textBoxCount.Text = value.ToString(); } } - public FormManufactureComponent(IComponentLogic logic) + public FormSecuriesComponent(IComponentLogic logic) { InitializeComponent(); _list = logic.ReadList(null); diff --git a/SecuritySystem/FormManufactureComponent.resx b/SecuritySystem/FormSecuriesComponent.resx similarity index 100% rename from SecuritySystem/FormManufactureComponent.resx rename to SecuritySystem/FormSecuriesComponent.resx diff --git a/SecuritySystem/Program.cs b/SecuritySystem/Program.cs index 5e291f3..d50ea8f 100644 --- a/SecuritySystem/Program.cs +++ b/SecuritySystem/Program.cs @@ -38,17 +38,16 @@ namespace SecuritySystem services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); 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/SecuritySystemContracts/BindingModels/OrderBindingModel.cs b/SecuritySystemContracts/BindingModels/OrderBindingModel.cs index eccc6bf..ae51c4c 100644 --- a/SecuritySystemContracts/BindingModels/OrderBindingModel.cs +++ b/SecuritySystemContracts/BindingModels/OrderBindingModel.cs @@ -6,10 +6,10 @@ namespace SecuritySystemContracts.BindingModels public class OrderBindingModel : IOrderModel { public int Id { get; set; } - public int ManufactureId { get; set; } + public int SecureId { get; set; } public int Count { get; set; } public double Sum { get; set; } - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateImplement { get; set; } diff --git a/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs b/SecuritySystemContracts/BindingModels/SecureBindingModel.cs similarity index 54% rename from SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs rename to SecuritySystemContracts/BindingModels/SecureBindingModel.cs index 408ec7a..2a24bee 100644 --- a/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs +++ b/SecuritySystemContracts/BindingModels/SecureBindingModel.cs @@ -3,12 +3,12 @@ using SecuritySystemDataModels.Models; namespace SecuritySystemContracts.BindingModels { - public class ManufactureBindingModel : IManufactureModel + public class SecureBindingModel : ISecureModel { public int Id { get; set; } - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; public double Price { get; set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; set; diff --git a/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs deleted file mode 100644 index 35eaabc..0000000 --- a/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs +++ /dev/null @@ -1,21 +0,0 @@ -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.ViewModels; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SecuritySystemContracts.BusinessLogicsContracts -{ - public interface IManufactureLogic - { - List? ReadList(ManufactureSearchModel? model); - ManufactureViewModel? ReadElement(ManufactureSearchModel model); - bool Create(ManufactureBindingModel model); - bool Update(ManufactureBindingModel model); - bool Delete(ManufactureBindingModel model); - } -} diff --git a/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs new file mode 100644 index 0000000..58f0398 --- /dev/null +++ b/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.BusinessLogicsContracts +{ + public interface ISecureLogic + { + List? ReadList(SecureSearchModel? model); + SecureViewModel? ReadElement(SecureSearchModel model); + bool Create(SecureBindingModel model); + bool Update(SecureBindingModel model); + bool Delete(SecureBindingModel model); + } +} diff --git a/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs similarity index 70% rename from SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs rename to SecuritySystemContracts/SearchModels/SecureSearchModel.cs index 2613f72..ea906d3 100644 --- a/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs +++ b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; namespace SecuritySystemContracts.SearchModels { - public class ManufactureSearchModel + public class SecureSearchModel { public int? Id { get; set; } - public string? ManufactureName { get; set; } + public string? SecureName { get; set; } } } diff --git a/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs b/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs deleted file mode 100644 index dd0c521..0000000 --- a/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs +++ /dev/null @@ -1,21 +0,0 @@ -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SecuritySystemContracts.StoragesContracts -{ - public interface IManufactureStorage - { - List GetFullList(); - List GetFilteredList(ManufactureSearchModel model); - ManufactureViewModel? GetElement(ManufactureSearchModel model); - ManufactureViewModel? Insert(ManufactureBindingModel model); - ManufactureViewModel? Update(ManufactureBindingModel model); - ManufactureViewModel? Delete(ManufactureBindingModel model); - } -} diff --git a/SecuritySystemContracts/StorageContracts/ISecureStorage.cs b/SecuritySystemContracts/StorageContracts/ISecureStorage.cs new file mode 100644 index 0000000..7dc62cc --- /dev/null +++ b/SecuritySystemContracts/StorageContracts/ISecureStorage.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.StoragesContracts +{ + public interface ISecureStorage + { + List GetFullList(); + List GetFilteredList(SecureSearchModel model); + SecureViewModel? GetElement(SecureSearchModel model); + SecureViewModel? Insert(SecureBindingModel model); + SecureViewModel? Update(SecureBindingModel model); + SecureViewModel? Delete(SecureBindingModel model); + } +} diff --git a/SecuritySystemContracts/ViewModels/OrderViewModel.cs b/SecuritySystemContracts/ViewModels/OrderViewModel.cs index 79b07cb..498fcbf 100644 --- a/SecuritySystemContracts/ViewModels/OrderViewModel.cs +++ b/SecuritySystemContracts/ViewModels/OrderViewModel.cs @@ -13,9 +13,9 @@ namespace SecuritySystemContracts.ViewModels { [DisplayName("Номер")] public int Id { get; set; } - public int ManufactureId { get; set; } + public int SecureId { get; set; } [DisplayName("Изделие")] - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } [DisplayName("Сумма")] diff --git a/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs b/SecuritySystemContracts/ViewModels/SecureViewModel.cs similarity index 70% rename from SecuritySystemContracts/ViewModels/ManufactureViewModel.cs rename to SecuritySystemContracts/ViewModels/SecureViewModel.cs index c8bfd3e..4480475 100644 --- a/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs +++ b/SecuritySystemContracts/ViewModels/SecureViewModel.cs @@ -8,14 +8,14 @@ using System.Threading.Tasks; namespace SecuritySystemContracts.ViewModels { - public class ManufactureViewModel : IManufactureModel + public class SecureViewModel : ISecureModel { public int Id { get; set; } [DisplayName("Название изделия")] - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; [DisplayName("Цена")] public double Price { get; set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; set; diff --git a/SecuritySystemDataModels/Models/IOrderModel.cs b/SecuritySystemDataModels/Models/IOrderModel.cs index 13baf8c..1f705ee 100644 --- a/SecuritySystemDataModels/Models/IOrderModel.cs +++ b/SecuritySystemDataModels/Models/IOrderModel.cs @@ -10,7 +10,7 @@ namespace SecuritySystemDataModels.Models { public interface IOrderModel : IId { - int ManufactureId { get; } + int SecureId { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/SecuritySystemDataModels/Models/IManufactureModel.cs b/SecuritySystemDataModels/Models/ISecureModel.cs similarity index 59% rename from SecuritySystemDataModels/Models/IManufactureModel.cs rename to SecuritySystemDataModels/Models/ISecureModel.cs index 3499105..f675b0f 100644 --- a/SecuritySystemDataModels/Models/IManufactureModel.cs +++ b/SecuritySystemDataModels/Models/ISecureModel.cs @@ -7,10 +7,10 @@ using System.Threading.Tasks; namespace SecuritySystemDataModels.Models { - public interface IManufactureModel : IId + public interface ISecureModel : IId { - string ManufactureName { get; } + string SecureName { get; } double Price { get; } - Dictionary ManufactureComponents { get; } + Dictionary SecureComponents { get; } } } diff --git a/SecuritySystemListImplement/DataListSingletone.cs b/SecuritySystemListImplement/DataListSingletone.cs index da37d1f..7a9a84a 100644 --- a/SecuritySystemListImplement/DataListSingletone.cs +++ b/SecuritySystemListImplement/DataListSingletone.cs @@ -13,12 +13,12 @@ namespace SecuritySystemListImplement private static DataListSingleton? _instance; public List Components { get; set; } public List Orders { get; set; } - public List Manufactures { get; set; } + public List Securies { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); - Manufactures = new List(); + Securies = new List(); } public static DataListSingleton GetInstance() { diff --git a/SecuritySystemListImplement/Implements/ManufactureStorage.cs b/SecuritySystemListImplement/Implements/ManufactureStorage.cs deleted file mode 100644 index 5a8ea83..0000000 --- a/SecuritySystemListImplement/Implements/ManufactureStorage.cs +++ /dev/null @@ -1,102 +0,0 @@ -using SecuritySystemListImplement.Models; -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.StoragesContracts; -using SecuritySystemContracts.ViewModels; - - -namespace SecuritySystemListImplement.Implements -{ - public class ManufactureStorage : IManufactureStorage - { - private readonly DataListSingleton _source; - public ManufactureStorage() - { - _source = DataListSingleton.GetInstance(); - } - public List GetFullList() - { - var result = new List(); - foreach (var Manufacture in _source.Manufactures) - { - result.Add(Manufacture.GetViewModel); - } - return result; - } - public List GetFilteredList(ManufactureSearchModel model) - { - var result = new List(); - if (string.IsNullOrEmpty(model.ManufactureName)) - { - return result; - } - foreach (var Manufacture in _source.Manufactures) - { - if (Manufacture.ManufactureName.Contains(model.ManufactureName)) - { - result.Add(Manufacture.GetViewModel); - } - } - return result; - } - public ManufactureViewModel? GetElement(ManufactureSearchModel model) - { - if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) - { - return null; - } - foreach (var Manufacture in _source.Manufactures) - { - if ((!string.IsNullOrEmpty(model.ManufactureName) && Manufacture.ManufactureName == model.ManufactureName) || - (model.Id.HasValue && Manufacture.Id == model.Id)) - { - return Manufacture.GetViewModel; - } - } - return null; - } - public ManufactureViewModel? Insert(ManufactureBindingModel model) - { - model.Id = 1; - foreach (var Manufacture in _source.Manufactures) - { - if (model.Id <= Manufacture.Id) - { - model.Id = Manufacture.Id + 1; - } - } - var newManufacture = Manufacture.Create(model); - if (newManufacture == null) - { - return null; - } - _source.Manufactures.Add(newManufacture); - return newManufacture.GetViewModel; - } - public ManufactureViewModel? Update(ManufactureBindingModel model) - { - foreach (var Manufacture in _source.Manufactures) - { - if (Manufacture.Id == model.Id) - { - Manufacture.Update(model); - return Manufacture.GetViewModel; - } - } - return null; - } - public ManufactureViewModel? Delete(ManufactureBindingModel model) - { - for (int i = 0; i < _source.Manufactures.Count; ++i) - { - if (_source.Manufactures[i].Id == model.Id) - { - var element = _source.Manufactures[i]; - _source.Manufactures.RemoveAt(i); - return element.GetViewModel; - } - } - return null; - } - } -} diff --git a/SecuritySystemListImplement/Implements/OrderStorage.cs b/SecuritySystemListImplement/Implements/OrderStorage.cs index 873ed51..706ee4b 100644 --- a/SecuritySystemListImplement/Implements/OrderStorage.cs +++ b/SecuritySystemListImplement/Implements/OrderStorage.cs @@ -98,13 +98,13 @@ namespace OrdersShopListImplement.Implements } return null; } - private OrderViewModel AttachManufactureName(OrderViewModel model) + private OrderViewModel AttachSecureName(OrderViewModel model) { - foreach (var manufacture in _source.Manufactures) + foreach (var secure in _source.Securies) { - if (manufacture.Id == model.ManufactureId) + if (secure.Id == model.SecureId) { - model.ManufactureName = manufacture.ManufactureName; + model.SecureName = secure.SecureName; return model; } } diff --git a/SecuritySystemListImplement/Implements/SecureStorage.cs b/SecuritySystemListImplement/Implements/SecureStorage.cs index d278cad..a01cbf9 100644 --- a/SecuritySystemListImplement/Implements/SecureStorage.cs +++ b/SecuritySystemListImplement/Implements/SecureStorage.cs @@ -7,92 +7,92 @@ using SecuritySystemContracts.ViewModels; namespace SecuritySystemListImplement.Implements { - public class SecureStorage : IManufactureStorage + public class SecureStorage : ISecureStorage { private readonly DataListSingleton _source; public SecureStorage() { _source = DataListSingleton.GetInstance(); } - public List GetFullList() + public List GetFullList() { - var result = new List(); - foreach (var Manufacture in _source.Manufactures) + var result = new List(); + foreach (var Secure in _source.Securies) { - result.Add(Manufacture.GetViewModel); + result.Add(Secure.GetViewModel); } return result; } - public List GetFilteredList(ManufactureSearchModel model) + public List GetFilteredList(SecureSearchModel model) { - var result = new List(); - if (string.IsNullOrEmpty(model.ManufactureName)) + var result = new List(); + if (string.IsNullOrEmpty(model.SecureName)) { return result; } - foreach (var Manufacture in _source.Manufactures) + foreach (var Secure in _source.Securies) { - if (Manufacture.ManufactureName.Contains(model.ManufactureName)) + if (Secure.SecureName.Contains(model.SecureName)) { - result.Add(Manufacture.GetViewModel); + result.Add(Secure.GetViewModel); } } return result; } - public ManufactureViewModel? GetElement(ManufactureSearchModel model) + public SecureViewModel? GetElement(SecureSearchModel model) { - if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) + if (string.IsNullOrEmpty(model.SecureName) && !model.Id.HasValue) { return null; } - foreach (var Manufacture in _source.Manufactures) + foreach (var Secure in _source.Securies) { - if ((!string.IsNullOrEmpty(model.ManufactureName) && Manufacture.ManufactureName == model.ManufactureName) || - (model.Id.HasValue && Manufacture.Id == model.Id)) + if ((!string.IsNullOrEmpty(model.SecureName) && Secure.SecureName == model.SecureName) || + (model.Id.HasValue && Secure.Id == model.Id)) { - return Manufacture.GetViewModel; + return Secure.GetViewModel; } } return null; } - public ManufactureViewModel? Insert(ManufactureBindingModel model) + public SecureViewModel? Insert(SecureBindingModel model) { model.Id = 1; - foreach (var Manufacture in _source.Manufactures) + foreach (var Secure in _source.Securies) { - if (model.Id <= Manufacture.Id) + if (model.Id <= Secure.Id) { - model.Id = Manufacture.Id + 1; + model.Id = Secure.Id + 1; } } - var newManufacture = Secure.Create(model); - if (newManufacture == null) + var newSecure = Secure.Create(model); + if (newSecure == null) { return null; } - _source.Manufactures.Add(newManufacture); - return newManufacture.GetViewModel; + _source.Securies.Add(newSecure); + return newSecure.GetViewModel; } - public ManufactureViewModel? Update(ManufactureBindingModel model) + public SecureViewModel? Update(SecureBindingModel model) { - foreach (var Manufacture in _source.Manufactures) + foreach (var Secure in _source.Securies) { - if (Manufacture.Id == model.Id) + if (Secure.Id == model.Id) { - Manufacture.Update(model); - return Manufacture.GetViewModel; + Secure.Update(model); + return Secure.GetViewModel; } } return null; } - public ManufactureViewModel? Delete(ManufactureBindingModel model) + public SecureViewModel? Delete(SecureBindingModel model) { - for (int i = 0; i < _source.Manufactures.Count; ++i) + for (int i = 0; i < _source.Securies.Count; ++i) { - if (_source.Manufactures[i].Id == model.Id) + if (_source.Securies[i].Id == model.Id) { - var element = _source.Manufactures[i]; - _source.Manufactures.RemoveAt(i); + var element = _source.Securies[i]; + _source.Securies.RemoveAt(i); return element.GetViewModel; } } diff --git a/SecuritySystemListImplement/Models/Manufacture.cs b/SecuritySystemListImplement/Models/Manufacture.cs deleted file mode 100644 index 2e1deb9..0000000 --- a/SecuritySystemListImplement/Models/Manufacture.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.ViewModels; -using SecuritySystemDataModels.Models; - -namespace SecuritySystemListImplement.Models -{ - public class Manufacture : IManufactureModel - { - public int Id { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; - public double Price { get; private set; } - public Dictionary ManufactureComponents - { - get; - private set; - } = new Dictionary(); - public static Manufacture? Create(ManufactureBindingModel? model) - { - if (model == null) - { - return null; - } - return new Manufacture() - { - Id = model.Id, - ManufactureName = model.ManufactureName, - Price = model.Price, - ManufactureComponents = model.ManufactureComponents - }; - } - public void Update(ManufactureBindingModel? model) - { - if (model == null) - { - return; - } - ManufactureName = model.ManufactureName; - Price = model.Price; - ManufactureComponents = model.ManufactureComponents; - } - public ManufactureViewModel GetViewModel => new() - { - Id = Id, - ManufactureName = ManufactureName, - Price = Price, - ManufactureComponents = ManufactureComponents - }; - } -} diff --git a/SecuritySystemListImplement/Models/Order.cs b/SecuritySystemListImplement/Models/Order.cs index 9cb0cfa..2fd9e3c 100644 --- a/SecuritySystemListImplement/Models/Order.cs +++ b/SecuritySystemListImplement/Models/Order.cs @@ -15,9 +15,9 @@ namespace SecuritySystemListImplement.Models { public int Id { get; private set; } - public int ManufactureId { get; private set; } + public int SecureId { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; + public string SecureName { get; private set; } = string.Empty; public int Count { get; private set; } public double Sum { get; private set; } @@ -36,7 +36,13 @@ namespace SecuritySystemListImplement.Models } return new Order() { + Id = model.Id, + SecureId = model.SecureId, + SecureName = model.SecureName, + Count = model.Count, + Sum = model.Sum, Status = model.Status, + DateCreate = model.DateCreate, DateImplement = model.DateImplement }; } @@ -47,14 +53,15 @@ namespace SecuritySystemListImplement.Models { return; } + Status = model.Status; DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() { Id = Id, - ManufactureId = ManufactureId, - ManufactureName = ManufactureName, + SecureId = SecureId, + SecureName = SecureName, Count = Count, Sum = Sum, Status = Status, diff --git a/SecuritySystemListImplement/Models/Secure.cs b/SecuritySystemListImplement/Models/Secure.cs index a7bc67d..28e0c76 100644 --- a/SecuritySystemListImplement/Models/Secure.cs +++ b/SecuritySystemListImplement/Models/Secure.cs @@ -10,17 +10,17 @@ using SecuritySystemDataModels.Models; namespace SecuritySystemListImplement.Models { - public class Secure : IManufactureModel + public class Secure : ISecureModel { public int Id { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; + public string SecureName { get; private set; } = string.Empty; public double Price { get; private set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; private set; } = new Dictionary(); - public static Secure? Create(ManufactureBindingModel? model) + public static Secure? Create(SecureBindingModel? model) { if (model == null) { @@ -29,27 +29,27 @@ namespace SecuritySystemListImplement.Models return new Secure() { Id = model.Id, - ManufactureName = model.ManufactureName, + SecureName = model.SecureName, Price = model.Price, - ManufactureComponents = model.ManufactureComponents + SecureComponents = model.SecureComponents }; } - public void Update(ManufactureBindingModel? model) + public void Update(SecureBindingModel? model) { if (model == null) { return; } - ManufactureName = model.ManufactureName; + SecureName = model.SecureName; Price = model.Price; - ManufactureComponents = model.ManufactureComponents; + SecureComponents = model.SecureComponents; } - public ManufactureViewModel GetViewModel => new() + public SecureViewModel GetViewModel => new() { Id = Id, - ManufactureName = ManufactureName, + SecureName = SecureName, Price = Price, - ManufactureComponents = ManufactureComponents + SecureComponents = SecureComponents }; } } diff --git a/SystemSecurityBusinessLogic/OrderLogic.cs b/SystemSecurityBusinessLogic/OrderLogic.cs index edd9141..41cc69a 100644 --- a/SystemSecurityBusinessLogic/OrderLogic.cs +++ b/SystemSecurityBusinessLogic/OrderLogic.cs @@ -75,9 +75,9 @@ namespace SecuritySystemBusinessLogic { return; } - if (model.ManufactureId < 0) + if (model.SecureId < 0) { - throw new ArgumentNullException("Некорректный идентификатор камеры", nameof(model.ManufactureId)); + throw new ArgumentNullException("Некорректный идентификатор камеры", nameof(model.SecureId)); } if (model.Count <= 0) { @@ -87,7 +87,7 @@ namespace SecuritySystemBusinessLogic { throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); } - _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. ManufactureId: { ManufactureId}", model.Id, model.Sum, model.ManufactureId); + _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. SecureId: { SecureId}", model.Id, model.Sum, model.SecureId); } private bool CheckStatus(OrderBindingModel model, OrderStatus newstatus, bool update = true) diff --git a/SystemSecurityBusinessLogic/ManufactureLogic.cs b/SystemSecurityBusinessLogic/SecureLogic.cs similarity index 59% rename from SystemSecurityBusinessLogic/ManufactureLogic.cs rename to SystemSecurityBusinessLogic/SecureLogic.cs index 26b88ab..78f5cc0 100644 --- a/SystemSecurityBusinessLogic/ManufactureLogic.cs +++ b/SystemSecurityBusinessLogic/SecureLogic.cs @@ -8,21 +8,21 @@ using Microsoft.Extensions.Logging; namespace SecuritySystemBusinessLogic { - public class ManufactureLogic : IManufactureLogic + public class SecureLogic : ISecureLogic { private readonly ILogger _logger; - private readonly IManufactureStorage _ManufactureStorage; + private readonly ISecureStorage _SecureStorage; - public ManufactureLogic(ILogger logger, IManufactureStorage ManufactureStorage) + public SecureLogic(ILogger logger, ISecureStorage SecureStorage) { _logger = logger; - _ManufactureStorage = ManufactureStorage; + _SecureStorage = SecureStorage; } - public List? ReadList(ManufactureSearchModel? model) + public List? ReadList(SecureSearchModel? model) { - _logger.LogInformation("ReadList. ManufactureName:{ManufactureName}.Id:{ Id}", model?.ManufactureName, model?.Id); - var list = model == null ? _ManufactureStorage.GetFullList() : _ManufactureStorage.GetFilteredList(model); + _logger.LogInformation("ReadList. SecureName:{SecureName}.Id:{ Id}", model?.SecureName, model?.Id); + var list = model == null ? _SecureStorage.GetFullList() : _SecureStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -32,14 +32,14 @@ namespace SecuritySystemBusinessLogic return list; } - public ManufactureViewModel? ReadElement(ManufactureSearchModel model) + public SecureViewModel? ReadElement(SecureSearchModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. ManufactureName:{ManufactureName}.Id:{ Id}", model.ManufactureName, model.Id); - var element = _ManufactureStorage.GetElement(model); + _logger.LogInformation("ReadElement. SecureName:{SecureName}.Id:{ Id}", model.SecureName, model.Id); + var element = _SecureStorage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement element not found"); @@ -49,10 +49,10 @@ namespace SecuritySystemBusinessLogic return element; } - public bool Create(ManufactureBindingModel model) + public bool Create(SecureBindingModel model) { CheckModel(model); - if (_ManufactureStorage.Insert(model) == null) + if (_SecureStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; @@ -60,10 +60,10 @@ namespace SecuritySystemBusinessLogic return true; } - public bool Update(ManufactureBindingModel model) + public bool Update(SecureBindingModel model) { CheckModel(model); - if (_ManufactureStorage.Update(model) == null) + if (_SecureStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); return false; @@ -71,11 +71,11 @@ namespace SecuritySystemBusinessLogic return true; } - public bool Delete(ManufactureBindingModel model) + public bool Delete(SecureBindingModel model) { CheckModel(model, false); _logger.LogInformation("Delete. Id:{Id}", model.Id); - if (_ManufactureStorage.Delete(model) == null) + if (_SecureStorage.Delete(model) == null) { _logger.LogWarning("Delete operation failed"); return false; @@ -83,7 +83,7 @@ namespace SecuritySystemBusinessLogic return true; } - private void CheckModel(ManufactureBindingModel model, bool withParams = true) + private void CheckModel(SecureBindingModel model, bool withParams = true) { if (model == null) { @@ -93,18 +93,18 @@ namespace SecuritySystemBusinessLogic { return; } - if (string.IsNullOrEmpty(model.ManufactureName)) + if (string.IsNullOrEmpty(model.SecureName)) { - throw new ArgumentNullException("Нет названия камеры", nameof(model.ManufactureName)); + throw new ArgumentNullException("Нет названия камеры", nameof(model.SecureName)); } if (model.Price <= 0) { throw new ArgumentNullException("Цена камеры должна быть больше 0", nameof(model.Price)); } - _logger.LogInformation("Manufacture. ManufactureName:{ManufactureName}.Cost:{ Cost}. Id: { Id}", model.ManufactureName, model.Price, model.Id); - var element = _ManufactureStorage.GetElement(new ManufactureSearchModel + _logger.LogInformation("Secure. SecureName:{SecureName}.Cost:{ Cost}. Id: { Id}", model.SecureName, model.Price, model.Id); + var element = _SecureStorage.GetElement(new SecureSearchModel { - ManufactureName = model.ManufactureName + SecureName = model.SecureName }); if (element != null && element.Id != model.Id) { -- 2.25.1 From c9c3ccd75692437c70ea223d24220a45484ce044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 13:23:43 +0400 Subject: [PATCH 11/21] Fix --- SecuritySystem/Program.cs | 4 +++- SecuritySystem/SecuritySystem.sln | 6 ------ SecuritySystem/SecuritySystemView.csproj | 1 - SecuritySystemListImplement/Implements/OrderStorage.cs | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/SecuritySystem/Program.cs b/SecuritySystem/Program.cs index d50ea8f..8e29998 100644 --- a/SecuritySystem/Program.cs +++ b/SecuritySystem/Program.cs @@ -3,7 +3,7 @@ using SecuritySystemBusinessLogic.BusinessLogics; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; -using SecuritySystemFileImplement.Implements; +using SecuritySystemListImplement.Implements; using SecuritySystemBusinessLogic; using SecuritySystemContracts.BusinessLogicsContracts; using SecuritySystemContracts.StoragesContracts; @@ -39,6 +39,7 @@ namespace SecuritySystem services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -48,6 +49,7 @@ namespace SecuritySystem services.AddTransient(); services.AddTransient(); services.AddTransient(); + } } } \ No newline at end of file diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index aa0dc6b..f9f4bdb 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -13,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemDataModels", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemFileImplement", "..\SecuritySystemFileImplement\SecuritySystemFileImplement.csproj", "{88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,10 +39,6 @@ Global {A5A3381B-3592-41B6-880F-333C2502DF02}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.Build.0 = Release|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SecuritySystem/SecuritySystemView.csproj b/SecuritySystem/SecuritySystemView.csproj index 371775d..7e4e4ef 100644 --- a/SecuritySystem/SecuritySystemView.csproj +++ b/SecuritySystem/SecuritySystemView.csproj @@ -14,7 +14,6 @@ - diff --git a/SecuritySystemListImplement/Implements/OrderStorage.cs b/SecuritySystemListImplement/Implements/OrderStorage.cs index 706ee4b..a35d05f 100644 --- a/SecuritySystemListImplement/Implements/OrderStorage.cs +++ b/SecuritySystemListImplement/Implements/OrderStorage.cs @@ -6,7 +6,7 @@ using SecuritySystemContracts.ViewModels; using SecuritySystemListImplement; -namespace OrdersShopListImplement.Implements +namespace SecuritySystemListImplement.Implements { public class OrderStorage : IOrderStorage { -- 2.25.1 From 4d3559581fd8fc76848f11f7839a2d25cd2e3dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Mon, 6 Mar 2023 17:26:18 +0400 Subject: [PATCH 12/21] final fixed --- SecuritySystemListImplement/Models/Order.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/SecuritySystemListImplement/Models/Order.cs b/SecuritySystemListImplement/Models/Order.cs index 4ad41a3..9cb0cfa 100644 --- a/SecuritySystemListImplement/Models/Order.cs +++ b/SecuritySystemListImplement/Models/Order.cs @@ -36,13 +36,7 @@ namespace SecuritySystemListImplement.Models } return new Order() { - Id = model.Id, - ManufactureId = model.ManufactureId, - ManufactureName = model.ManufactureName, - Count = model.Count, - Sum = model.Sum, Status = model.Status, - DateCreate = model.DateCreate, DateImplement = model.DateImplement }; } -- 2.25.1 From f047644598c66ef9eda9fa182724f2fe67c63334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 12:47:29 +0400 Subject: [PATCH 13/21] Rename --- SecuritySystem/FormCreateOrder.Designer.cs | 40 +++--- SecuritySystem/FormCreateOrder.cs | 30 ++--- SecuritySystem/FormMain.cs | 20 +-- SecuritySystem/FormManufacturies.resx | 120 ------------------ ...ure.Designer.cs => FormSecure.Designer.cs} | 49 +++---- .../{FormManufacture.cs => FormSecure.cs} | 52 ++++---- SecuritySystem/FormSecure.resx | 60 +++++++++ ...s.Designer.cs => FormSecuries.Designer.cs} | 8 +- .../{FormManufacturies.cs => FormSecuries.cs} | 22 ++-- ...FormManufacture.resx => FormSecuries.resx} | 0 ...r.cs => FormSecuriesComponent.Designer.cs} | 2 +- ...eComponent.cs => FormSecuriesComponent.cs} | 4 +- ...ponent.resx => FormSecuriesComponent.resx} | 0 SecuritySystem/Program.cs | 11 +- .../BindingModels/OrderBindingModel.cs | 4 +- ...eBindingModel.cs => SecureBindingModel.cs} | 6 +- .../IManufactureLogic.cs | 21 --- .../BusinessLogicsContracts/ISecureLogic.cs | 21 +++ ...ureSearchModel.cs => SecureSearchModel.cs} | 4 +- .../StorageContracts/IManufactureStorage.cs | 21 --- .../StorageContracts/ISecureStorage.cs | 21 +++ .../ViewModels/OrderViewModel.cs | 4 +- ...factureViewModel.cs => SecureViewModel.cs} | 6 +- .../Models/IOrderModel.cs | 2 +- .../{IManufactureModel.cs => ISecureModel.cs} | 6 +- .../DataListSingletone.cs | 4 +- .../Implements/ManufactureStorage.cs | 102 --------------- .../Implements/OrderStorage.cs | 8 +- .../Implements/SecureStorage.cs | 70 +++++----- .../Models/Manufacture.cs | 55 -------- SecuritySystemListImplement/Models/Order.cs | 15 ++- SecuritySystemListImplement/Models/Secure.cs | 24 ++-- SystemSecurityBusinessLogic/OrderLogic.cs | 6 +- .../{ManufactureLogic.cs => SecureLogic.cs} | 44 +++---- 34 files changed, 326 insertions(+), 536 deletions(-) delete mode 100644 SecuritySystem/FormManufacturies.resx rename SecuritySystem/{FormManufacture.Designer.cs => FormSecure.Designer.cs} (98%) rename SecuritySystem/{FormManufacture.cs => FormSecure.cs} (79%) create mode 100644 SecuritySystem/FormSecure.resx rename SecuritySystem/{FormManufacturies.Designer.cs => FormSecuries.Designer.cs} (96%) rename SecuritySystem/{FormManufacturies.cs => FormSecuries.cs} (83%) rename SecuritySystem/{FormManufacture.resx => FormSecuries.resx} (100%) rename SecuritySystem/{FormManufactureComponent.Designer.cs => FormSecuriesComponent.Designer.cs} (99%) rename SecuritySystem/{FormManufactureComponent.cs => FormSecuriesComponent.cs} (95%) rename SecuritySystem/{FormManufactureComponent.resx => FormSecuriesComponent.resx} (100%) rename SecuritySystemContracts/BindingModels/{ManufactureBindingModel.cs => SecureBindingModel.cs} (54%) delete mode 100644 SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs create mode 100644 SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs rename SecuritySystemContracts/SearchModels/{ManufactureSearchModel.cs => SecureSearchModel.cs} (70%) delete mode 100644 SecuritySystemContracts/StorageContracts/IManufactureStorage.cs create mode 100644 SecuritySystemContracts/StorageContracts/ISecureStorage.cs rename SecuritySystemContracts/ViewModels/{ManufactureViewModel.cs => SecureViewModel.cs} (70%) rename SecuritySystemDataModels/Models/{IManufactureModel.cs => ISecureModel.cs} (59%) delete mode 100644 SecuritySystemListImplement/Implements/ManufactureStorage.cs delete mode 100644 SecuritySystemListImplement/Models/Manufacture.cs rename SystemSecurityBusinessLogic/{ManufactureLogic.cs => SecureLogic.cs} (59%) diff --git a/SecuritySystem/FormCreateOrder.Designer.cs b/SecuritySystem/FormCreateOrder.Designer.cs index 9a89b05..ba1b6eb 100644 --- a/SecuritySystem/FormCreateOrder.Designer.cs +++ b/SecuritySystem/FormCreateOrder.Designer.cs @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - this.labelManufacture = new System.Windows.Forms.Label(); - this.comboBoxManufacture = new System.Windows.Forms.ComboBox(); + this.labelSecure = new System.Windows.Forms.Label(); + this.comboBoxSecure = new System.Windows.Forms.ComboBox(); this.labelCount = new System.Windows.Forms.Label(); this.textBoxCount = new System.Windows.Forms.TextBox(); this.labelSum = new System.Windows.Forms.Label(); @@ -38,23 +38,23 @@ this.buttonSave = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // labelManufacture + // labelSecure // - this.labelManufacture.AutoSize = true; - this.labelManufacture.Location = new System.Drawing.Point(12, 15); - this.labelManufacture.Name = "labelManufacture"; - this.labelManufacture.Size = new System.Drawing.Size(75, 20); - this.labelManufacture.TabIndex = 0; - this.labelManufacture.Text = "Изделие: "; + this.labelSecure.AutoSize = true; + this.labelSecure.Location = new System.Drawing.Point(12, 15); + this.labelSecure.Name = "labelSecure"; + this.labelSecure.Size = new System.Drawing.Size(75, 20); + this.labelSecure.TabIndex = 0; + this.labelSecure.Text = "Изделие: "; // - // comboBoxManufacture + // comboBoxSecure // - this.comboBoxManufacture.FormattingEnabled = true; - this.comboBoxManufacture.Location = new System.Drawing.Point(115, 12); - this.comboBoxManufacture.Name = "comboBoxManufacture"; - this.comboBoxManufacture.Size = new System.Drawing.Size(358, 28); - this.comboBoxManufacture.TabIndex = 1; - this.comboBoxManufacture.SelectedIndexChanged += new System.EventHandler(this.ComboBoxManufacture_SelectedIndexChanged); + this.comboBoxSecure.FormattingEnabled = true; + this.comboBoxSecure.Location = new System.Drawing.Point(115, 12); + this.comboBoxSecure.Name = "comboBoxSecure"; + this.comboBoxSecure.Size = new System.Drawing.Size(358, 28); + this.comboBoxSecure.TabIndex = 1; + this.comboBoxSecure.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSecure_SelectedIndexChanged); // // labelCount // @@ -121,8 +121,8 @@ this.Controls.Add(this.labelSum); this.Controls.Add(this.textBoxCount); this.Controls.Add(this.labelCount); - this.Controls.Add(this.comboBoxManufacture); - this.Controls.Add(this.labelManufacture); + this.Controls.Add(this.comboBoxSecure); + this.Controls.Add(this.labelSecure); this.Name = "FormCreateOrder"; this.Text = "Заказ"; this.Load += new System.EventHandler(this.FormCreateOrder_Load); @@ -133,8 +133,8 @@ #endregion - private Label labelManufacture; - private ComboBox comboBoxManufacture; + private Label labelSecure; + private ComboBox comboBoxSecure; private Label labelCount; private TextBox textBoxCount; private Label labelSum; diff --git a/SecuritySystem/FormCreateOrder.cs b/SecuritySystem/FormCreateOrder.cs index a7ce11f..4af9c06 100644 --- a/SecuritySystem/FormCreateOrder.cs +++ b/SecuritySystem/FormCreateOrder.cs @@ -18,10 +18,10 @@ namespace SecuritySystemView public partial class FormCreateOrder : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logicM; + private readonly ISecureLogic _logicM; private readonly IOrderLogic _logicO; - private List? _list; - public FormCreateOrder(ILogger logger, IManufactureLogic logicM, IOrderLogic logicO) + private List? _list; + public FormCreateOrder(ILogger logger, ISecureLogic logicM, IOrderLogic logicO) { InitializeComponent(); _logger = logger; @@ -33,23 +33,23 @@ namespace SecuritySystemView _list = _logicM.ReadList(null); if (_list != null) { - comboBoxManufacture.DisplayMember = "ManufactureName"; - comboBoxManufacture.ValueMember = "Id"; - comboBoxManufacture.DataSource = _list; - comboBoxManufacture.SelectedItem = null; + comboBoxSecure.DisplayMember = "SecureName"; + comboBoxSecure.ValueMember = "Id"; + comboBoxSecure.DataSource = _list; + comboBoxSecure.SelectedItem = null; _logger.LogInformation("Загрузка изделий для заказа"); } } private void CalcSum() { - if (comboBoxManufacture.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + if (comboBoxSecure.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) { try { - int id = Convert.ToInt32(comboBoxManufacture.SelectedValue); - var Manufacture = _logicM.ReadElement(new ManufactureSearchModel { Id = id }); + int id = Convert.ToInt32(comboBoxSecure.SelectedValue); + var Secure = _logicM.ReadElement(new SecureSearchModel { Id = id }); int count = Convert.ToInt32(textBoxCount.Text); - textBoxSum.Text = Math.Round(count * (Manufacture?.Price ?? 0), 2).ToString(); + textBoxSum.Text = Math.Round(count * (Secure?.Price ?? 0), 2).ToString(); _logger.LogInformation("Расчет суммы заказа"); } catch (Exception ex) @@ -63,7 +63,7 @@ namespace SecuritySystemView { CalcSum(); } - private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e) + private void ComboBoxSecure_SelectedIndexChanged(object sender, EventArgs e) { CalcSum(); } @@ -74,7 +74,7 @@ namespace SecuritySystemView MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (comboBoxManufacture.SelectedValue == null) + if (comboBoxSecure.SelectedValue == null) { MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -84,8 +84,8 @@ namespace SecuritySystemView { var operationResult = _logicO.CreateOrder(new OrderBindingModel { - ManufactureId = Convert.ToInt32(comboBoxManufacture.SelectedValue), - ManufactureName = comboBoxManufacture.Text, + SecureId = Convert.ToInt32(comboBoxSecure.SelectedValue), + SecureName = comboBoxSecure.Text, Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); diff --git a/SecuritySystem/FormMain.cs b/SecuritySystem/FormMain.cs index 6ce123b..2537a2f 100644 --- a/SecuritySystem/FormMain.cs +++ b/SecuritySystem/FormMain.cs @@ -37,8 +37,8 @@ namespace SecuritySystemView if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["ManufactureId"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["SecureId"].Visible = false; + dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } @@ -58,8 +58,8 @@ namespace SecuritySystemView } private void GoodsToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacturies)); - if (service is FormManufacturies form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuries)); + if (service is FormSecuries form) { form.ShowDialog(); } @@ -84,8 +84,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -115,8 +115,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -147,8 +147,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), diff --git a/SecuritySystem/FormManufacturies.resx b/SecuritySystem/FormManufacturies.resx deleted file mode 100644 index 1af7de1..0000000 --- a/SecuritySystem/FormManufacturies.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/SecuritySystem/FormManufacture.Designer.cs b/SecuritySystem/FormSecure.Designer.cs similarity index 98% rename from SecuritySystem/FormManufacture.Designer.cs rename to SecuritySystem/FormSecure.Designer.cs index d4283d0..934e2e7 100644 --- a/SecuritySystem/FormManufacture.Designer.cs +++ b/SecuritySystem/FormSecure.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufacture + partial class FormSecure { /// /// Required designer variable. @@ -38,11 +38,11 @@ this.buttonUpd = new System.Windows.Forms.Button(); this.buttonAdd = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonSave = new System.Windows.Forms.Button(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); this.groupBoxComponents.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -76,6 +76,7 @@ // this.textBoxPrice.Location = new System.Drawing.Point(112, 51); this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.ReadOnly = true; this.textBoxPrice.Size = new System.Drawing.Size(171, 27); this.textBoxPrice.TabIndex = 3; // @@ -151,26 +152,6 @@ this.dataGridView.Size = new System.Drawing.Size(476, 287); this.dataGridView.TabIndex = 0; // - // buttonCancel - // - this.buttonCancel.Location = new System.Drawing.Point(514, 417); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(126, 34); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "Отмена"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); - // - // buttonSave - // - this.buttonSave.Location = new System.Drawing.Point(368, 417); - this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(126, 34); - this.buttonSave.TabIndex = 6; - this.buttonSave.Text = "Сохранить"; - this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); - // // id // this.id.HeaderText = "id"; @@ -193,6 +174,26 @@ this.Count.Name = "Count"; this.Count.ReadOnly = true; // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(514, 417); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(126, 34); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(368, 417); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(126, 34); + this.buttonSave.TabIndex = 6; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // // FormManufacture // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); @@ -207,7 +208,7 @@ this.Controls.Add(this.labelName); this.Name = "FormManufacture"; this.Text = "Изделие"; - this.Load += new System.EventHandler(this.FormManufacture_Load); + this.Load += new System.EventHandler(this.FormSecure_Load); this.groupBoxComponents.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/SecuritySystem/FormManufacture.cs b/SecuritySystem/FormSecure.cs similarity index 79% rename from SecuritySystem/FormManufacture.cs rename to SecuritySystem/FormSecure.cs index 0a6a1a6..f328329 100644 --- a/SecuritySystem/FormManufacture.cs +++ b/SecuritySystem/FormSecure.cs @@ -16,33 +16,33 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufacture : Form + public partial class FormSecure : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logic; + private readonly ISecureLogic _logic; private int? _id; - private Dictionary _ManufactureComponents; + private Dictionary _SecureComponents; public int Id { set { _id = value; } } - public FormManufacture(ILogger logger, IManufactureLogic logic) + public FormSecure(ILogger logger, ISecureLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; - _ManufactureComponents = new Dictionary(); + _SecureComponents = new Dictionary(); } - private void FormManufacture_Load(object sender, EventArgs e) + private void FormSecure_Load(object sender, EventArgs e) { if (_id.HasValue) { _logger.LogInformation("Загрузка изделия"); try { - var view = _logic.ReadElement(new ManufactureSearchModel { Id = _id.Value }); + var view = _logic.ReadElement(new SecureSearchModel { Id = _id.Value }); if (view != null) { - textBoxName.Text = view.ManufactureName; + textBoxName.Text = view.SecureName; textBoxPrice.Text = view.Price.ToString(); - _ManufactureComponents = view.ManufactureComponents ?? new + _SecureComponents = view.SecureComponents ?? new Dictionary(); LoadData(); } @@ -60,10 +60,10 @@ namespace SecuritySystemView _logger.LogInformation("Загрузка компонент изделия"); try { - if (_ManufactureComponents != null) + if (_SecureComponents != null) { dataGridView.Rows.Clear(); - foreach (var pc in _ManufactureComponents) + foreach (var pc in _SecureComponents) { dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); } @@ -79,8 +79,8 @@ namespace SecuritySystemView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); - if (service is FormManufactureComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuriesComponent)); + if (service is FormSecuriesComponent form) { if (form.ShowDialog() == DialogResult.OK) { @@ -89,13 +89,13 @@ namespace SecuritySystemView return; } _logger.LogInformation("Добавление нового компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); - if (_ManufactureComponents.ContainsKey(form.Id)) + if (_SecureComponents.ContainsKey(form.Id)) { - _ManufactureComponents[form.Id] = (form.ComponentModel, form.Count); + _SecureComponents[form.Id] = (form.ComponentModel, form.Count); } else { - _ManufactureComponents.Add(form.Id, (form.ComponentModel, form.Count)); + _SecureComponents.Add(form.Id, (form.ComponentModel, form.Count)); } LoadData(); } @@ -105,12 +105,12 @@ namespace SecuritySystemView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); - if (service is FormManufactureComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuriesComponent)); + if (service is FormSecuriesComponent form) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; - form.Count = _ManufactureComponents[id].Item2; + form.Count = _SecureComponents[id].Item2; if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) @@ -118,7 +118,7 @@ namespace SecuritySystemView return; } _logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); - _ManufactureComponents[form.Id] = (form.ComponentModel, form.Count); + _SecureComponents[form.Id] = (form.ComponentModel, form.Count); LoadData(); } } @@ -134,7 +134,7 @@ namespace SecuritySystemView try { _logger.LogInformation("Удаление компонента: {ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); - _ManufactureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _SecureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { @@ -161,7 +161,7 @@ namespace SecuritySystemView MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (_ManufactureComponents == null || _ManufactureComponents.Count == 0) + if (_SecureComponents == null || _SecureComponents.Count == 0) { MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -169,12 +169,12 @@ namespace SecuritySystemView _logger.LogInformation("Сохранение изделия"); try { - var model = new ManufactureBindingModel + var model = new SecureBindingModel { Id = _id ?? 0, - ManufactureName = textBoxName.Text, + SecureName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - ManufactureComponents = _ManufactureComponents + SecureComponents = _SecureComponents }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) @@ -199,7 +199,7 @@ namespace SecuritySystemView private double CalcPrice() { double price = 0; - foreach (var elem in _ManufactureComponents) + foreach (var elem in _SecureComponents) { price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); } diff --git a/SecuritySystem/FormSecure.resx b/SecuritySystem/FormSecure.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SecuritySystem/FormSecure.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/SecuritySystem/FormManufacturies.Designer.cs b/SecuritySystem/FormSecuries.Designer.cs similarity index 96% rename from SecuritySystem/FormManufacturies.Designer.cs rename to SecuritySystem/FormSecuries.Designer.cs index 5147d93..718eb7d 100644 --- a/SecuritySystem/FormManufacturies.Designer.cs +++ b/SecuritySystem/FormSecuries.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufacturies + partial class FormSecuries { /// /// Required designer variable. @@ -102,16 +102,16 @@ this.dataGridView.Size = new System.Drawing.Size(590, 426); this.dataGridView.TabIndex = 2; // - // FormManufacturies + // FormSecure // 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 = "FormManufacturies"; + this.Name = "FormSecuries"; this.Text = "Изделия"; - this.Load += new System.EventHandler(this.FormManufacturies_Load); + this.Load += new System.EventHandler(this.FormSecuries_Load); this.ToolsPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/SecuritySystem/FormManufacturies.cs b/SecuritySystem/FormSecuries.cs similarity index 83% rename from SecuritySystem/FormManufacturies.cs rename to SecuritySystem/FormSecuries.cs index 61d79fc..acd9911 100644 --- a/SecuritySystem/FormManufacturies.cs +++ b/SecuritySystem/FormSecuries.cs @@ -14,17 +14,17 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufacturies : Form + public partial class FormSecuries : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logic; - public FormManufacturies(ILogger logger, IManufactureLogic logic) + private readonly ISecureLogic _logic; + public FormSecuries(ILogger logger, ISecureLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - private void FormManufacturies_Load(object sender, EventArgs e) + private void FormSecuries_Load(object sender, EventArgs e) { LoadData(); } @@ -37,8 +37,8 @@ namespace SecuritySystemView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ManufactureComponents"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = + dataGridView.Columns["SecureComponents"].Visible = false; + dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка изделий"); @@ -51,8 +51,8 @@ namespace SecuritySystemView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); - if (service is FormManufacture form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecure)); + if (service is FormSecure form) { if (form.ShowDialog() == DialogResult.OK) { @@ -64,8 +64,8 @@ namespace SecuritySystemView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); - if (service is FormManufacture form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecure)); + if (service is FormSecure form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) @@ -85,7 +85,7 @@ namespace SecuritySystemView _logger.LogInformation("Удаление изделия"); try { - if (!_logic.Delete(new ManufactureBindingModel { Id = id })) + if (!_logic.Delete(new SecureBindingModel { Id = id })) { throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); } diff --git a/SecuritySystem/FormManufacture.resx b/SecuritySystem/FormSecuries.resx similarity index 100% rename from SecuritySystem/FormManufacture.resx rename to SecuritySystem/FormSecuries.resx diff --git a/SecuritySystem/FormManufactureComponent.Designer.cs b/SecuritySystem/FormSecuriesComponent.Designer.cs similarity index 99% rename from SecuritySystem/FormManufactureComponent.Designer.cs rename to SecuritySystem/FormSecuriesComponent.Designer.cs index 686592c..bb2b8c6 100644 --- a/SecuritySystem/FormManufactureComponent.Designer.cs +++ b/SecuritySystem/FormSecuriesComponent.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufactureComponent + partial class FormSecuriesComponent { /// /// Required designer variable. diff --git a/SecuritySystem/FormManufactureComponent.cs b/SecuritySystem/FormSecuriesComponent.cs similarity index 95% rename from SecuritySystem/FormManufactureComponent.cs rename to SecuritySystem/FormSecuriesComponent.cs index cdf9c1a..ad94391 100644 --- a/SecuritySystem/FormManufactureComponent.cs +++ b/SecuritySystem/FormSecuriesComponent.cs @@ -13,7 +13,7 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufactureComponent : Form + public partial class FormSecuriesComponent : Form { private readonly List? _list; public int Id @@ -50,7 +50,7 @@ namespace SecuritySystemView get { return Convert.ToInt32(textBoxCount.Text); } set { textBoxCount.Text = value.ToString(); } } - public FormManufactureComponent(IComponentLogic logic) + public FormSecuriesComponent(IComponentLogic logic) { InitializeComponent(); _list = logic.ReadList(null); diff --git a/SecuritySystem/FormManufactureComponent.resx b/SecuritySystem/FormSecuriesComponent.resx similarity index 100% rename from SecuritySystem/FormManufactureComponent.resx rename to SecuritySystem/FormSecuriesComponent.resx diff --git a/SecuritySystem/Program.cs b/SecuritySystem/Program.cs index 5e291f3..d50ea8f 100644 --- a/SecuritySystem/Program.cs +++ b/SecuritySystem/Program.cs @@ -38,17 +38,16 @@ namespace SecuritySystem services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); 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/SecuritySystemContracts/BindingModels/OrderBindingModel.cs b/SecuritySystemContracts/BindingModels/OrderBindingModel.cs index eccc6bf..ae51c4c 100644 --- a/SecuritySystemContracts/BindingModels/OrderBindingModel.cs +++ b/SecuritySystemContracts/BindingModels/OrderBindingModel.cs @@ -6,10 +6,10 @@ namespace SecuritySystemContracts.BindingModels public class OrderBindingModel : IOrderModel { public int Id { get; set; } - public int ManufactureId { get; set; } + public int SecureId { get; set; } public int Count { get; set; } public double Sum { get; set; } - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateImplement { get; set; } diff --git a/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs b/SecuritySystemContracts/BindingModels/SecureBindingModel.cs similarity index 54% rename from SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs rename to SecuritySystemContracts/BindingModels/SecureBindingModel.cs index 408ec7a..2a24bee 100644 --- a/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs +++ b/SecuritySystemContracts/BindingModels/SecureBindingModel.cs @@ -3,12 +3,12 @@ using SecuritySystemDataModels.Models; namespace SecuritySystemContracts.BindingModels { - public class ManufactureBindingModel : IManufactureModel + public class SecureBindingModel : ISecureModel { public int Id { get; set; } - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; public double Price { get; set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; set; diff --git a/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs deleted file mode 100644 index 35eaabc..0000000 --- a/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs +++ /dev/null @@ -1,21 +0,0 @@ -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.ViewModels; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SecuritySystemContracts.BusinessLogicsContracts -{ - public interface IManufactureLogic - { - List? ReadList(ManufactureSearchModel? model); - ManufactureViewModel? ReadElement(ManufactureSearchModel model); - bool Create(ManufactureBindingModel model); - bool Update(ManufactureBindingModel model); - bool Delete(ManufactureBindingModel model); - } -} diff --git a/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs new file mode 100644 index 0000000..58f0398 --- /dev/null +++ b/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.BusinessLogicsContracts +{ + public interface ISecureLogic + { + List? ReadList(SecureSearchModel? model); + SecureViewModel? ReadElement(SecureSearchModel model); + bool Create(SecureBindingModel model); + bool Update(SecureBindingModel model); + bool Delete(SecureBindingModel model); + } +} diff --git a/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs similarity index 70% rename from SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs rename to SecuritySystemContracts/SearchModels/SecureSearchModel.cs index 2613f72..ea906d3 100644 --- a/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs +++ b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; namespace SecuritySystemContracts.SearchModels { - public class ManufactureSearchModel + public class SecureSearchModel { public int? Id { get; set; } - public string? ManufactureName { get; set; } + public string? SecureName { get; set; } } } diff --git a/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs b/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs deleted file mode 100644 index dd0c521..0000000 --- a/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs +++ /dev/null @@ -1,21 +0,0 @@ -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SecuritySystemContracts.StoragesContracts -{ - public interface IManufactureStorage - { - List GetFullList(); - List GetFilteredList(ManufactureSearchModel model); - ManufactureViewModel? GetElement(ManufactureSearchModel model); - ManufactureViewModel? Insert(ManufactureBindingModel model); - ManufactureViewModel? Update(ManufactureBindingModel model); - ManufactureViewModel? Delete(ManufactureBindingModel model); - } -} diff --git a/SecuritySystemContracts/StorageContracts/ISecureStorage.cs b/SecuritySystemContracts/StorageContracts/ISecureStorage.cs new file mode 100644 index 0000000..7dc62cc --- /dev/null +++ b/SecuritySystemContracts/StorageContracts/ISecureStorage.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.StoragesContracts +{ + public interface ISecureStorage + { + List GetFullList(); + List GetFilteredList(SecureSearchModel model); + SecureViewModel? GetElement(SecureSearchModel model); + SecureViewModel? Insert(SecureBindingModel model); + SecureViewModel? Update(SecureBindingModel model); + SecureViewModel? Delete(SecureBindingModel model); + } +} diff --git a/SecuritySystemContracts/ViewModels/OrderViewModel.cs b/SecuritySystemContracts/ViewModels/OrderViewModel.cs index 79b07cb..498fcbf 100644 --- a/SecuritySystemContracts/ViewModels/OrderViewModel.cs +++ b/SecuritySystemContracts/ViewModels/OrderViewModel.cs @@ -13,9 +13,9 @@ namespace SecuritySystemContracts.ViewModels { [DisplayName("Номер")] public int Id { get; set; } - public int ManufactureId { get; set; } + public int SecureId { get; set; } [DisplayName("Изделие")] - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } [DisplayName("Сумма")] diff --git a/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs b/SecuritySystemContracts/ViewModels/SecureViewModel.cs similarity index 70% rename from SecuritySystemContracts/ViewModels/ManufactureViewModel.cs rename to SecuritySystemContracts/ViewModels/SecureViewModel.cs index c8bfd3e..4480475 100644 --- a/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs +++ b/SecuritySystemContracts/ViewModels/SecureViewModel.cs @@ -8,14 +8,14 @@ using System.Threading.Tasks; namespace SecuritySystemContracts.ViewModels { - public class ManufactureViewModel : IManufactureModel + public class SecureViewModel : ISecureModel { public int Id { get; set; } [DisplayName("Название изделия")] - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; [DisplayName("Цена")] public double Price { get; set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; set; diff --git a/SecuritySystemDataModels/Models/IOrderModel.cs b/SecuritySystemDataModels/Models/IOrderModel.cs index 13baf8c..1f705ee 100644 --- a/SecuritySystemDataModels/Models/IOrderModel.cs +++ b/SecuritySystemDataModels/Models/IOrderModel.cs @@ -10,7 +10,7 @@ namespace SecuritySystemDataModels.Models { public interface IOrderModel : IId { - int ManufactureId { get; } + int SecureId { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/SecuritySystemDataModels/Models/IManufactureModel.cs b/SecuritySystemDataModels/Models/ISecureModel.cs similarity index 59% rename from SecuritySystemDataModels/Models/IManufactureModel.cs rename to SecuritySystemDataModels/Models/ISecureModel.cs index 3499105..f675b0f 100644 --- a/SecuritySystemDataModels/Models/IManufactureModel.cs +++ b/SecuritySystemDataModels/Models/ISecureModel.cs @@ -7,10 +7,10 @@ using System.Threading.Tasks; namespace SecuritySystemDataModels.Models { - public interface IManufactureModel : IId + public interface ISecureModel : IId { - string ManufactureName { get; } + string SecureName { get; } double Price { get; } - Dictionary ManufactureComponents { get; } + Dictionary SecureComponents { get; } } } diff --git a/SecuritySystemListImplement/DataListSingletone.cs b/SecuritySystemListImplement/DataListSingletone.cs index da37d1f..7a9a84a 100644 --- a/SecuritySystemListImplement/DataListSingletone.cs +++ b/SecuritySystemListImplement/DataListSingletone.cs @@ -13,12 +13,12 @@ namespace SecuritySystemListImplement private static DataListSingleton? _instance; public List Components { get; set; } public List Orders { get; set; } - public List Manufactures { get; set; } + public List Securies { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); - Manufactures = new List(); + Securies = new List(); } public static DataListSingleton GetInstance() { diff --git a/SecuritySystemListImplement/Implements/ManufactureStorage.cs b/SecuritySystemListImplement/Implements/ManufactureStorage.cs deleted file mode 100644 index 5a8ea83..0000000 --- a/SecuritySystemListImplement/Implements/ManufactureStorage.cs +++ /dev/null @@ -1,102 +0,0 @@ -using SecuritySystemListImplement.Models; -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.StoragesContracts; -using SecuritySystemContracts.ViewModels; - - -namespace SecuritySystemListImplement.Implements -{ - public class ManufactureStorage : IManufactureStorage - { - private readonly DataListSingleton _source; - public ManufactureStorage() - { - _source = DataListSingleton.GetInstance(); - } - public List GetFullList() - { - var result = new List(); - foreach (var Manufacture in _source.Manufactures) - { - result.Add(Manufacture.GetViewModel); - } - return result; - } - public List GetFilteredList(ManufactureSearchModel model) - { - var result = new List(); - if (string.IsNullOrEmpty(model.ManufactureName)) - { - return result; - } - foreach (var Manufacture in _source.Manufactures) - { - if (Manufacture.ManufactureName.Contains(model.ManufactureName)) - { - result.Add(Manufacture.GetViewModel); - } - } - return result; - } - public ManufactureViewModel? GetElement(ManufactureSearchModel model) - { - if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) - { - return null; - } - foreach (var Manufacture in _source.Manufactures) - { - if ((!string.IsNullOrEmpty(model.ManufactureName) && Manufacture.ManufactureName == model.ManufactureName) || - (model.Id.HasValue && Manufacture.Id == model.Id)) - { - return Manufacture.GetViewModel; - } - } - return null; - } - public ManufactureViewModel? Insert(ManufactureBindingModel model) - { - model.Id = 1; - foreach (var Manufacture in _source.Manufactures) - { - if (model.Id <= Manufacture.Id) - { - model.Id = Manufacture.Id + 1; - } - } - var newManufacture = Manufacture.Create(model); - if (newManufacture == null) - { - return null; - } - _source.Manufactures.Add(newManufacture); - return newManufacture.GetViewModel; - } - public ManufactureViewModel? Update(ManufactureBindingModel model) - { - foreach (var Manufacture in _source.Manufactures) - { - if (Manufacture.Id == model.Id) - { - Manufacture.Update(model); - return Manufacture.GetViewModel; - } - } - return null; - } - public ManufactureViewModel? Delete(ManufactureBindingModel model) - { - for (int i = 0; i < _source.Manufactures.Count; ++i) - { - if (_source.Manufactures[i].Id == model.Id) - { - var element = _source.Manufactures[i]; - _source.Manufactures.RemoveAt(i); - return element.GetViewModel; - } - } - return null; - } - } -} diff --git a/SecuritySystemListImplement/Implements/OrderStorage.cs b/SecuritySystemListImplement/Implements/OrderStorage.cs index 873ed51..706ee4b 100644 --- a/SecuritySystemListImplement/Implements/OrderStorage.cs +++ b/SecuritySystemListImplement/Implements/OrderStorage.cs @@ -98,13 +98,13 @@ namespace OrdersShopListImplement.Implements } return null; } - private OrderViewModel AttachManufactureName(OrderViewModel model) + private OrderViewModel AttachSecureName(OrderViewModel model) { - foreach (var manufacture in _source.Manufactures) + foreach (var secure in _source.Securies) { - if (manufacture.Id == model.ManufactureId) + if (secure.Id == model.SecureId) { - model.ManufactureName = manufacture.ManufactureName; + model.SecureName = secure.SecureName; return model; } } diff --git a/SecuritySystemListImplement/Implements/SecureStorage.cs b/SecuritySystemListImplement/Implements/SecureStorage.cs index d278cad..a01cbf9 100644 --- a/SecuritySystemListImplement/Implements/SecureStorage.cs +++ b/SecuritySystemListImplement/Implements/SecureStorage.cs @@ -7,92 +7,92 @@ using SecuritySystemContracts.ViewModels; namespace SecuritySystemListImplement.Implements { - public class SecureStorage : IManufactureStorage + public class SecureStorage : ISecureStorage { private readonly DataListSingleton _source; public SecureStorage() { _source = DataListSingleton.GetInstance(); } - public List GetFullList() + public List GetFullList() { - var result = new List(); - foreach (var Manufacture in _source.Manufactures) + var result = new List(); + foreach (var Secure in _source.Securies) { - result.Add(Manufacture.GetViewModel); + result.Add(Secure.GetViewModel); } return result; } - public List GetFilteredList(ManufactureSearchModel model) + public List GetFilteredList(SecureSearchModel model) { - var result = new List(); - if (string.IsNullOrEmpty(model.ManufactureName)) + var result = new List(); + if (string.IsNullOrEmpty(model.SecureName)) { return result; } - foreach (var Manufacture in _source.Manufactures) + foreach (var Secure in _source.Securies) { - if (Manufacture.ManufactureName.Contains(model.ManufactureName)) + if (Secure.SecureName.Contains(model.SecureName)) { - result.Add(Manufacture.GetViewModel); + result.Add(Secure.GetViewModel); } } return result; } - public ManufactureViewModel? GetElement(ManufactureSearchModel model) + public SecureViewModel? GetElement(SecureSearchModel model) { - if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) + if (string.IsNullOrEmpty(model.SecureName) && !model.Id.HasValue) { return null; } - foreach (var Manufacture in _source.Manufactures) + foreach (var Secure in _source.Securies) { - if ((!string.IsNullOrEmpty(model.ManufactureName) && Manufacture.ManufactureName == model.ManufactureName) || - (model.Id.HasValue && Manufacture.Id == model.Id)) + if ((!string.IsNullOrEmpty(model.SecureName) && Secure.SecureName == model.SecureName) || + (model.Id.HasValue && Secure.Id == model.Id)) { - return Manufacture.GetViewModel; + return Secure.GetViewModel; } } return null; } - public ManufactureViewModel? Insert(ManufactureBindingModel model) + public SecureViewModel? Insert(SecureBindingModel model) { model.Id = 1; - foreach (var Manufacture in _source.Manufactures) + foreach (var Secure in _source.Securies) { - if (model.Id <= Manufacture.Id) + if (model.Id <= Secure.Id) { - model.Id = Manufacture.Id + 1; + model.Id = Secure.Id + 1; } } - var newManufacture = Secure.Create(model); - if (newManufacture == null) + var newSecure = Secure.Create(model); + if (newSecure == null) { return null; } - _source.Manufactures.Add(newManufacture); - return newManufacture.GetViewModel; + _source.Securies.Add(newSecure); + return newSecure.GetViewModel; } - public ManufactureViewModel? Update(ManufactureBindingModel model) + public SecureViewModel? Update(SecureBindingModel model) { - foreach (var Manufacture in _source.Manufactures) + foreach (var Secure in _source.Securies) { - if (Manufacture.Id == model.Id) + if (Secure.Id == model.Id) { - Manufacture.Update(model); - return Manufacture.GetViewModel; + Secure.Update(model); + return Secure.GetViewModel; } } return null; } - public ManufactureViewModel? Delete(ManufactureBindingModel model) + public SecureViewModel? Delete(SecureBindingModel model) { - for (int i = 0; i < _source.Manufactures.Count; ++i) + for (int i = 0; i < _source.Securies.Count; ++i) { - if (_source.Manufactures[i].Id == model.Id) + if (_source.Securies[i].Id == model.Id) { - var element = _source.Manufactures[i]; - _source.Manufactures.RemoveAt(i); + var element = _source.Securies[i]; + _source.Securies.RemoveAt(i); return element.GetViewModel; } } diff --git a/SecuritySystemListImplement/Models/Manufacture.cs b/SecuritySystemListImplement/Models/Manufacture.cs deleted file mode 100644 index 2e1deb9..0000000 --- a/SecuritySystemListImplement/Models/Manufacture.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.ViewModels; -using SecuritySystemDataModels.Models; - -namespace SecuritySystemListImplement.Models -{ - public class Manufacture : IManufactureModel - { - public int Id { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; - public double Price { get; private set; } - public Dictionary ManufactureComponents - { - get; - private set; - } = new Dictionary(); - public static Manufacture? Create(ManufactureBindingModel? model) - { - if (model == null) - { - return null; - } - return new Manufacture() - { - Id = model.Id, - ManufactureName = model.ManufactureName, - Price = model.Price, - ManufactureComponents = model.ManufactureComponents - }; - } - public void Update(ManufactureBindingModel? model) - { - if (model == null) - { - return; - } - ManufactureName = model.ManufactureName; - Price = model.Price; - ManufactureComponents = model.ManufactureComponents; - } - public ManufactureViewModel GetViewModel => new() - { - Id = Id, - ManufactureName = ManufactureName, - Price = Price, - ManufactureComponents = ManufactureComponents - }; - } -} diff --git a/SecuritySystemListImplement/Models/Order.cs b/SecuritySystemListImplement/Models/Order.cs index 9cb0cfa..2fd9e3c 100644 --- a/SecuritySystemListImplement/Models/Order.cs +++ b/SecuritySystemListImplement/Models/Order.cs @@ -15,9 +15,9 @@ namespace SecuritySystemListImplement.Models { public int Id { get; private set; } - public int ManufactureId { get; private set; } + public int SecureId { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; + public string SecureName { get; private set; } = string.Empty; public int Count { get; private set; } public double Sum { get; private set; } @@ -36,7 +36,13 @@ namespace SecuritySystemListImplement.Models } return new Order() { + Id = model.Id, + SecureId = model.SecureId, + SecureName = model.SecureName, + Count = model.Count, + Sum = model.Sum, Status = model.Status, + DateCreate = model.DateCreate, DateImplement = model.DateImplement }; } @@ -47,14 +53,15 @@ namespace SecuritySystemListImplement.Models { return; } + Status = model.Status; DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() { Id = Id, - ManufactureId = ManufactureId, - ManufactureName = ManufactureName, + SecureId = SecureId, + SecureName = SecureName, Count = Count, Sum = Sum, Status = Status, diff --git a/SecuritySystemListImplement/Models/Secure.cs b/SecuritySystemListImplement/Models/Secure.cs index a7bc67d..28e0c76 100644 --- a/SecuritySystemListImplement/Models/Secure.cs +++ b/SecuritySystemListImplement/Models/Secure.cs @@ -10,17 +10,17 @@ using SecuritySystemDataModels.Models; namespace SecuritySystemListImplement.Models { - public class Secure : IManufactureModel + public class Secure : ISecureModel { public int Id { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; + public string SecureName { get; private set; } = string.Empty; public double Price { get; private set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; private set; } = new Dictionary(); - public static Secure? Create(ManufactureBindingModel? model) + public static Secure? Create(SecureBindingModel? model) { if (model == null) { @@ -29,27 +29,27 @@ namespace SecuritySystemListImplement.Models return new Secure() { Id = model.Id, - ManufactureName = model.ManufactureName, + SecureName = model.SecureName, Price = model.Price, - ManufactureComponents = model.ManufactureComponents + SecureComponents = model.SecureComponents }; } - public void Update(ManufactureBindingModel? model) + public void Update(SecureBindingModel? model) { if (model == null) { return; } - ManufactureName = model.ManufactureName; + SecureName = model.SecureName; Price = model.Price; - ManufactureComponents = model.ManufactureComponents; + SecureComponents = model.SecureComponents; } - public ManufactureViewModel GetViewModel => new() + public SecureViewModel GetViewModel => new() { Id = Id, - ManufactureName = ManufactureName, + SecureName = SecureName, Price = Price, - ManufactureComponents = ManufactureComponents + SecureComponents = SecureComponents }; } } diff --git a/SystemSecurityBusinessLogic/OrderLogic.cs b/SystemSecurityBusinessLogic/OrderLogic.cs index edd9141..41cc69a 100644 --- a/SystemSecurityBusinessLogic/OrderLogic.cs +++ b/SystemSecurityBusinessLogic/OrderLogic.cs @@ -75,9 +75,9 @@ namespace SecuritySystemBusinessLogic { return; } - if (model.ManufactureId < 0) + if (model.SecureId < 0) { - throw new ArgumentNullException("Некорректный идентификатор камеры", nameof(model.ManufactureId)); + throw new ArgumentNullException("Некорректный идентификатор камеры", nameof(model.SecureId)); } if (model.Count <= 0) { @@ -87,7 +87,7 @@ namespace SecuritySystemBusinessLogic { throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); } - _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. ManufactureId: { ManufactureId}", model.Id, model.Sum, model.ManufactureId); + _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. SecureId: { SecureId}", model.Id, model.Sum, model.SecureId); } private bool CheckStatus(OrderBindingModel model, OrderStatus newstatus, bool update = true) diff --git a/SystemSecurityBusinessLogic/ManufactureLogic.cs b/SystemSecurityBusinessLogic/SecureLogic.cs similarity index 59% rename from SystemSecurityBusinessLogic/ManufactureLogic.cs rename to SystemSecurityBusinessLogic/SecureLogic.cs index 26b88ab..78f5cc0 100644 --- a/SystemSecurityBusinessLogic/ManufactureLogic.cs +++ b/SystemSecurityBusinessLogic/SecureLogic.cs @@ -8,21 +8,21 @@ using Microsoft.Extensions.Logging; namespace SecuritySystemBusinessLogic { - public class ManufactureLogic : IManufactureLogic + public class SecureLogic : ISecureLogic { private readonly ILogger _logger; - private readonly IManufactureStorage _ManufactureStorage; + private readonly ISecureStorage _SecureStorage; - public ManufactureLogic(ILogger logger, IManufactureStorage ManufactureStorage) + public SecureLogic(ILogger logger, ISecureStorage SecureStorage) { _logger = logger; - _ManufactureStorage = ManufactureStorage; + _SecureStorage = SecureStorage; } - public List? ReadList(ManufactureSearchModel? model) + public List? ReadList(SecureSearchModel? model) { - _logger.LogInformation("ReadList. ManufactureName:{ManufactureName}.Id:{ Id}", model?.ManufactureName, model?.Id); - var list = model == null ? _ManufactureStorage.GetFullList() : _ManufactureStorage.GetFilteredList(model); + _logger.LogInformation("ReadList. SecureName:{SecureName}.Id:{ Id}", model?.SecureName, model?.Id); + var list = model == null ? _SecureStorage.GetFullList() : _SecureStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -32,14 +32,14 @@ namespace SecuritySystemBusinessLogic return list; } - public ManufactureViewModel? ReadElement(ManufactureSearchModel model) + public SecureViewModel? ReadElement(SecureSearchModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. ManufactureName:{ManufactureName}.Id:{ Id}", model.ManufactureName, model.Id); - var element = _ManufactureStorage.GetElement(model); + _logger.LogInformation("ReadElement. SecureName:{SecureName}.Id:{ Id}", model.SecureName, model.Id); + var element = _SecureStorage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement element not found"); @@ -49,10 +49,10 @@ namespace SecuritySystemBusinessLogic return element; } - public bool Create(ManufactureBindingModel model) + public bool Create(SecureBindingModel model) { CheckModel(model); - if (_ManufactureStorage.Insert(model) == null) + if (_SecureStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; @@ -60,10 +60,10 @@ namespace SecuritySystemBusinessLogic return true; } - public bool Update(ManufactureBindingModel model) + public bool Update(SecureBindingModel model) { CheckModel(model); - if (_ManufactureStorage.Update(model) == null) + if (_SecureStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); return false; @@ -71,11 +71,11 @@ namespace SecuritySystemBusinessLogic return true; } - public bool Delete(ManufactureBindingModel model) + public bool Delete(SecureBindingModel model) { CheckModel(model, false); _logger.LogInformation("Delete. Id:{Id}", model.Id); - if (_ManufactureStorage.Delete(model) == null) + if (_SecureStorage.Delete(model) == null) { _logger.LogWarning("Delete operation failed"); return false; @@ -83,7 +83,7 @@ namespace SecuritySystemBusinessLogic return true; } - private void CheckModel(ManufactureBindingModel model, bool withParams = true) + private void CheckModel(SecureBindingModel model, bool withParams = true) { if (model == null) { @@ -93,18 +93,18 @@ namespace SecuritySystemBusinessLogic { return; } - if (string.IsNullOrEmpty(model.ManufactureName)) + if (string.IsNullOrEmpty(model.SecureName)) { - throw new ArgumentNullException("Нет названия камеры", nameof(model.ManufactureName)); + throw new ArgumentNullException("Нет названия камеры", nameof(model.SecureName)); } if (model.Price <= 0) { throw new ArgumentNullException("Цена камеры должна быть больше 0", nameof(model.Price)); } - _logger.LogInformation("Manufacture. ManufactureName:{ManufactureName}.Cost:{ Cost}. Id: { Id}", model.ManufactureName, model.Price, model.Id); - var element = _ManufactureStorage.GetElement(new ManufactureSearchModel + _logger.LogInformation("Secure. SecureName:{SecureName}.Cost:{ Cost}. Id: { Id}", model.SecureName, model.Price, model.Id); + var element = _SecureStorage.GetElement(new SecureSearchModel { - ManufactureName = model.ManufactureName + SecureName = model.SecureName }); if (element != null && element.Id != model.Id) { -- 2.25.1 From cc5c7c4e82b2e93a8d6126749d2686f17f4af94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 13:23:43 +0400 Subject: [PATCH 14/21] Fix --- SecuritySystem/Program.cs | 4 +++- SecuritySystem/SecuritySystem.sln | 6 ------ SecuritySystem/SecuritySystemView.csproj | 1 - SecuritySystemListImplement/Implements/OrderStorage.cs | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/SecuritySystem/Program.cs b/SecuritySystem/Program.cs index d50ea8f..8e29998 100644 --- a/SecuritySystem/Program.cs +++ b/SecuritySystem/Program.cs @@ -3,7 +3,7 @@ using SecuritySystemBusinessLogic.BusinessLogics; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; -using SecuritySystemFileImplement.Implements; +using SecuritySystemListImplement.Implements; using SecuritySystemBusinessLogic; using SecuritySystemContracts.BusinessLogicsContracts; using SecuritySystemContracts.StoragesContracts; @@ -39,6 +39,7 @@ namespace SecuritySystem services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -48,6 +49,7 @@ namespace SecuritySystem services.AddTransient(); services.AddTransient(); services.AddTransient(); + } } } \ No newline at end of file diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index aa0dc6b..f9f4bdb 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -13,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemDataModels", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemFileImplement", "..\SecuritySystemFileImplement\SecuritySystemFileImplement.csproj", "{88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,10 +39,6 @@ Global {A5A3381B-3592-41B6-880F-333C2502DF02}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.Build.0 = Release|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SecuritySystem/SecuritySystemView.csproj b/SecuritySystem/SecuritySystemView.csproj index 371775d..7e4e4ef 100644 --- a/SecuritySystem/SecuritySystemView.csproj +++ b/SecuritySystem/SecuritySystemView.csproj @@ -14,7 +14,6 @@ - diff --git a/SecuritySystemListImplement/Implements/OrderStorage.cs b/SecuritySystemListImplement/Implements/OrderStorage.cs index 706ee4b..a35d05f 100644 --- a/SecuritySystemListImplement/Implements/OrderStorage.cs +++ b/SecuritySystemListImplement/Implements/OrderStorage.cs @@ -6,7 +6,7 @@ using SecuritySystemContracts.ViewModels; using SecuritySystemListImplement; -namespace OrdersShopListImplement.Implements +namespace SecuritySystemListImplement.Implements { public class OrderStorage : IOrderStorage { -- 2.25.1 From 33a1d14f71d95552fd86bb241b4213caf331f61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 12:47:29 +0400 Subject: [PATCH 15/21] Rename --- SecuritySystem/FormManufacture.resx | 120 ++++++++++++++++++ SecuritySystem/FormManufactureComponent.resx | 120 ++++++++++++++++++ .../SearchModels/ManufactureSearchModel.cs | 14 ++ .../SearchModels/SecureSearchModel.cs | 7 + 4 files changed, 261 insertions(+) create mode 100644 SecuritySystem/FormManufacture.resx create mode 100644 SecuritySystem/FormManufactureComponent.resx create mode 100644 SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs diff --git a/SecuritySystem/FormManufacture.resx b/SecuritySystem/FormManufacture.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SecuritySystem/FormManufacture.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/SecuritySystem/FormManufactureComponent.resx b/SecuritySystem/FormManufactureComponent.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SecuritySystem/FormManufactureComponent.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/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs b/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs new file mode 100644 index 0000000..2613f72 --- /dev/null +++ b/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.SearchModels +{ + public class ManufactureSearchModel + { + public int? Id { get; set; } + public string? ManufactureName { get; set; } + } +} diff --git a/SecuritySystemContracts/SearchModels/SecureSearchModel.cs b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs index ea906d3..1778cfb 100644 --- a/SecuritySystemContracts/SearchModels/SecureSearchModel.cs +++ b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs @@ -6,9 +6,16 @@ using System.Threading.Tasks; namespace SecuritySystemContracts.SearchModels { +<<<<<<< HEAD:SecuritySystemContracts/SearchModels/ComponentSearchModel.cs + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } +======= public class SecureSearchModel { public int? Id { get; set; } public string? SecureName { get; set; } +>>>>>>> Rename:SecuritySystemContracts/SearchModels/SecureSearchModel.cs } } -- 2.25.1 From 6c2ef9c8bbce823cd6e866d303214cb4663cdb13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 13:33:47 +0400 Subject: [PATCH 16/21] rename --- SecuritySystem/FormManufacture.resx | 120 ------------------- SecuritySystem/FormManufactureComponent.resx | 120 ------------------- 2 files changed, 240 deletions(-) delete mode 100644 SecuritySystem/FormManufacture.resx delete mode 100644 SecuritySystem/FormManufactureComponent.resx diff --git a/SecuritySystem/FormManufacture.resx b/SecuritySystem/FormManufacture.resx deleted file mode 100644 index 1af7de1..0000000 --- a/SecuritySystem/FormManufacture.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/SecuritySystem/FormManufactureComponent.resx b/SecuritySystem/FormManufactureComponent.resx deleted file mode 100644 index 1af7de1..0000000 --- a/SecuritySystem/FormManufactureComponent.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file -- 2.25.1 From c04d4e829f96d47436dfb21e716418137ee56e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 13:42:43 +0400 Subject: [PATCH 17/21] fix --- SecuritySystem/SecuritySystem.sln | 6 ------ 1 file changed, 6 deletions(-) diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index e51af08..f9f4bdb 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -13,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemDataModels", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemFileImplement", "..\SecuritySystemFileImplement\SecuritySystemFileImplement.csproj", "{7EAA8744-DD28-4007-B05B-FF2644A3D9BB}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,10 +39,6 @@ Global {A5A3381B-3592-41B6-880F-333C2502DF02}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.Build.0 = Release|Any CPU - {7EAA8744-DD28-4007-B05B-FF2644A3D9BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7EAA8744-DD28-4007-B05B-FF2644A3D9BB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7EAA8744-DD28-4007-B05B-FF2644A3D9BB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7EAA8744-DD28-4007-B05B-FF2644A3D9BB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE -- 2.25.1 From 268fd1fe70574d08087ed55995022b8234795f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 13:56:05 +0400 Subject: [PATCH 18/21] fix --- SystemSecurityBusinessLogic/ComponentLogic.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SystemSecurityBusinessLogic/ComponentLogic.cs b/SystemSecurityBusinessLogic/ComponentLogic.cs index 454d4c9..3b74f22 100644 --- a/SystemSecurityBusinessLogic/ComponentLogic.cs +++ b/SystemSecurityBusinessLogic/ComponentLogic.cs @@ -17,6 +17,7 @@ namespace SecuritySystemBusinessLogic.BusinessLogics _logger = logger; _componentStorage = componentStorage; } + public List? ReadList(ComponentSearchModel? model) { _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id); -- 2.25.1 From 3190a9da85aa27f90b1a7bfd5bf1f8d8330936ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 13:58:15 +0400 Subject: [PATCH 19/21] Revert "Final" This reverts commit ad16a7ca87f6261d560f26630fd71a7794f2ab0c. --- SecuritySystem/Program.cs | 6 +- SecuritySystem/SecuritySystem.sln | 14 +-- SecuritySystem/SecuritySystemView.csproj | 1 - .../DataFileSingletone.cs | 54 ---------- .../Implements/ComponentStorage.cs | 87 ---------------- .../Implements/ManufactureStorage.cs | 84 ---------------- .../Implements/OrderStorage.cs | 94 ------------------ .../Models/Component.cs | 65 ------------ .../Models/Manufacture.cs | 93 ------------------ SecuritySystemFileImplement/Models/Order.cs | 98 ------------------- .../SecuritySystemFileImplement.csproj | 14 --- SecuritySystemListImplement/Models/Order.cs | 5 + 12 files changed, 13 insertions(+), 602 deletions(-) delete mode 100644 SecuritySystemFileImplement/DataFileSingletone.cs delete mode 100644 SecuritySystemFileImplement/Implements/ComponentStorage.cs delete mode 100644 SecuritySystemFileImplement/Implements/ManufactureStorage.cs delete mode 100644 SecuritySystemFileImplement/Implements/OrderStorage.cs delete mode 100644 SecuritySystemFileImplement/Models/Component.cs delete mode 100644 SecuritySystemFileImplement/Models/Manufacture.cs delete mode 100644 SecuritySystemFileImplement/Models/Order.cs delete mode 100644 SecuritySystemFileImplement/SecuritySystemFileImplement.csproj diff --git a/SecuritySystem/Program.cs b/SecuritySystem/Program.cs index 5e291f3..f6d0b1d 100644 --- a/SecuritySystem/Program.cs +++ b/SecuritySystem/Program.cs @@ -1,12 +1,14 @@ using SecuritySystemView; using SecuritySystemBusinessLogic.BusinessLogics; +using SecuritySystemListImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; -using SecuritySystemFileImplement.Implements; +using OrdersShopListImplement.Implements; using SecuritySystemBusinessLogic; using SecuritySystemContracts.BusinessLogicsContracts; using SecuritySystemContracts.StoragesContracts; +using System; namespace SecuritySystem { @@ -40,9 +42,9 @@ namespace SecuritySystem services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index 14f83ce..d169da1 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -5,15 +5,13 @@ VisualStudioVersion = 17.3.32922.545 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemView", "SecuritySystemView.csproj", "{39A7185D-F1F5-4892-BE6F-72B1A849CA84}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SystemSecurityBusinessLogic", "..\SystemSecurityBusinessLogic\SystemSecurityBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemSecurityBusinessLogic", "..\SystemSecurityBusinessLogic\SystemSecurityBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemDataModels", "..\SecuritySystemDataModels\SecuritySystemDataModels.csproj", "{D12D1329-4362-472B-B6E6-D62B0FF00C63}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemDataModels", "..\SecuritySystemDataModels\SecuritySystemDataModels.csproj", "{D12D1329-4362-472B-B6E6-D62B0FF00C63}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemFileImplement", "..\SecuritySystemFileImplement\SecuritySystemFileImplement.csproj", "{88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -41,10 +39,6 @@ Global {A5A3381B-3592-41B6-880F-333C2502DF02}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.Build.0 = Release|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {88EDB793-0A3D-4B04-BE39-DB9C317ADEE6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SecuritySystem/SecuritySystemView.csproj b/SecuritySystem/SecuritySystemView.csproj index ed51d3d..e65dd63 100644 --- a/SecuritySystem/SecuritySystemView.csproj +++ b/SecuritySystem/SecuritySystemView.csproj @@ -14,7 +14,6 @@ - diff --git a/SecuritySystemFileImplement/DataFileSingletone.cs b/SecuritySystemFileImplement/DataFileSingletone.cs deleted file mode 100644 index 6f66c1e..0000000 --- a/SecuritySystemFileImplement/DataFileSingletone.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using SecuritySystemFileImplement.Models; -using System.Xml.Linq; - -namespace SecuritySystemFileImplement -{ - public class DataFileSingleton - { - private static DataFileSingleton? instance; - private readonly string ComponentFileName = "Component.xml"; - private readonly string OrderFileName = "Order.xml"; - private readonly string ManufactureFileName = "Manufacture.xml"; - public List Components { get; private set; } - public List Orders { get; private set; } - public List Manufactures { get; private set; } - public static DataFileSingleton GetInstance() - { - if (instance == null) - { - instance = new DataFileSingleton(); - } - return instance; - } - public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement); - public void SaveManufactures() => SaveData(Manufactures, ManufactureFileName, "Manufactures", x => x.GetXElement); - public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); - private DataFileSingleton() - { - Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!; - Manufactures = LoadData(ManufactureFileName, "Manufacture", x => Manufacture.Create(x)!)!; - Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; - } - private static List? LoadData(string filename, string xmlNodeName, Func selectFunction) - { - if (File.Exists(filename)) - { - return XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList(); - } - return new List(); - } - private static void SaveData(List data, string filename, string xmlNodeName, Func selectFunction) - { - if (data != null) - { - new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename); - } - } - } -} diff --git a/SecuritySystemFileImplement/Implements/ComponentStorage.cs b/SecuritySystemFileImplement/Implements/ComponentStorage.cs deleted file mode 100644 index c62adcd..0000000 --- a/SecuritySystemFileImplement/Implements/ComponentStorage.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.StoragesContracts; -using SecuritySystemContracts.ViewModels; -using SecuritySystemFileImplement.Models; -using SecuritySystemFileImplement; - -namespace SecuritySystemFileImplement.Implements -{ - public class ComponentStorage : IComponentStorage - { - private readonly DataFileSingleton source; - public ComponentStorage() - { - source = DataFileSingleton.GetInstance(); - } - public List GetFullList() - { - return source.Components - .Select(x => x.GetViewModel) - .ToList(); - } - public List GetFilteredList(ComponentSearchModel model) - { - if (string.IsNullOrEmpty(model.ComponentName)) - { - return new(); - } - return source.Components - .Where(x => x.ComponentName.Contains(model.ComponentName)) - .Select(x => x.GetViewModel) - .ToList(); - } - public ComponentViewModel? GetElement(ComponentSearchModel model) - { - if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) - { - return null; - } - return source.Components - .FirstOrDefault(x => - (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) || - (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; - } - public ComponentViewModel? Insert(ComponentBindingModel model) - { - model.Id = source.Components.Count > 0 ? source.Components.Max(x => x.Id) + 1 : 1; - var newComponent = Component.Create(model); - if (newComponent == null) - { - return null; - } - source.Components.Add(newComponent); - source.SaveComponents(); - return newComponent.GetViewModel; - } - public ComponentViewModel? Update(ComponentBindingModel model) - { - var component = source.Components.FirstOrDefault(x => x.Id == model.Id); - if (component == null) - { - return null; - } - component.Update(model); - source.SaveComponents(); - return component.GetViewModel; - } - public ComponentViewModel? Delete(ComponentBindingModel model) - { - var element = source.Components.FirstOrDefault(x => x.Id == model.Id); - if (element != null) - { - source.Components.Remove(element); - source.SaveComponents(); - return element.GetViewModel; - } - return null; - } - } -} \ No newline at end of file diff --git a/SecuritySystemFileImplement/Implements/ManufactureStorage.cs b/SecuritySystemFileImplement/Implements/ManufactureStorage.cs deleted file mode 100644 index 09c4fda..0000000 --- a/SecuritySystemFileImplement/Implements/ManufactureStorage.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; - -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.StoragesContracts; -using SecuritySystemContracts.ViewModels; -using SecuritySystemFileImplement.Models; -using SecuritySystemFileImplement; - -namespace SecuritySystemFileImplement.Implements -{ - public class ManufactureStorage : IManufactureStorage - { - private readonly DataFileSingleton source; - public ManufactureStorage() - { - source = DataFileSingleton.GetInstance(); - } - public ManufactureViewModel? GetElement(ManufactureSearchModel model) - { - if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) - { - return null; - } - return source.Manufactures.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ManufactureName) && x.ManufactureName == model.ManufactureName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; - } - public List GetFilteredList(ManufactureSearchModel model) - { - if (string.IsNullOrEmpty(model.ManufactureName)) - { - return new(); - } - return source.Manufactures - .Where(x => x.ManufactureName.Contains(model.ManufactureName)) - .Select(x => x.GetViewModel) - .ToList(); - } - public List GetFullList() - { - return source.Manufactures.Select(x => x.GetViewModel).ToList(); - } - public ManufactureViewModel? Insert(ManufactureBindingModel model) - { - model.Id = source.Manufactures.Count > 0 ? source.Manufactures.Max(x => x.Id) + 1 : 1; - var newManufacture = Manufacture.Create(model); - if (newManufacture == null) - { - return null; - } - source.Manufactures.Add(newManufacture); - source.SaveManufactures(); - return newManufacture.GetViewModel; - } - public ManufactureViewModel? Update(ManufactureBindingModel model) - { - var manufacture = source.Manufactures.FirstOrDefault(x => x.Id == model.Id); - if (manufacture == null) - { - return null; - } - manufacture.Update(model); - source.SaveManufactures(); - return manufacture.GetViewModel; - } - public ManufactureViewModel? Delete(ManufactureBindingModel model) - { - var manufacture = source.Manufactures.FirstOrDefault(x => x.Id == model.Id); - if (manufacture == null) - { - return null; - } - manufacture.Update(model); - source.SaveManufactures(); - return manufacture.GetViewModel; - } - - } -} diff --git a/SecuritySystemFileImplement/Implements/OrderStorage.cs b/SecuritySystemFileImplement/Implements/OrderStorage.cs deleted file mode 100644 index 53fd709..0000000 --- a/SecuritySystemFileImplement/Implements/OrderStorage.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.StoragesContracts; -using SecuritySystemContracts.ViewModels; -using SecuritySystemFileImplement.Models; -using SecuritySystemFileImplement; - -namespace SecuritySystemFileImplement.Implements -{ - public class OrderStorage : IOrderStorage - { - private readonly DataFileSingleton source; - public OrderStorage() - { - source = DataFileSingleton.GetInstance(); - } - public List GetFilteredList(OrderSearchModel model) - { - if (!model.Id.HasValue) - { - return new(); - } - return source.Orders - .Where(x => x.Id == model.Id) - .Select(x => GetViewModel(x)) - .ToList(); - } - public List GetFullList() - { - return source.Orders.Select(x => GetViewModel(x)).ToList(); - } - public OrderViewModel? GetElement(OrderSearchModel model) - { - if (!model.Id.HasValue) - { - return null; - } - return source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; - } - public OrderViewModel? Insert(OrderBindingModel model) - { - model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1; - var newOrder = Order.Create(model); - if (newOrder == null) - { - return null; - } - source.Orders.Add(newOrder); - source.SaveOrders(); - return GetViewModel(newOrder); - } - public OrderViewModel? Update(OrderBindingModel model) - { - var order = source.Orders.FirstOrDefault(x => x.Id == model.Id); - if (order == null) - { - return null; - } - order.Update(model); - source.SaveOrders(); - return GetViewModel(order); - } - public OrderViewModel? Delete(OrderBindingModel model) - { - var order = source.Orders.FirstOrDefault(x => x.Id == model.Id); - if (order == null) - { - return null; - } - order.Update(model); - source.SaveOrders(); - return GetViewModel(order); - } - private OrderViewModel GetViewModel(Order order) - { - var viewModel = order.GetViewModel; - foreach (var manufacture in source.Manufactures) - { - if (manufacture.Id == order.ManufactureId) - { - viewModel.ManufactureName = manufacture.ManufactureName; - break; - } - } - return viewModel; - } - } -} diff --git a/SecuritySystemFileImplement/Models/Component.cs b/SecuritySystemFileImplement/Models/Component.cs deleted file mode 100644 index d345360..0000000 --- a/SecuritySystemFileImplement/Models/Component.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.ViewModels; -using SecuritySystemDataModels.Models; -using System.Xml.Linq; - -namespace SecuritySystemFileImplement.Models -{ - public class Component : IComponentModel - { - public int Id { get; private set; } - public string ComponentName { get; private set; } = string.Empty; - public double Cost { get; set; } - public static Component? Create(ComponentBindingModel model) - { - if (model == null) - { - return null; - } - return new Component() - { - Id = model.Id, - ComponentName = model.ComponentName, - Cost = model.Cost - }; - } - public static Component? Create(XElement element) - { - if (element == null) - { - return null; - } - return new Component() - { - Id = Convert.ToInt32(element.Attribute("Id")!.Value), - ComponentName = element.Element("ComponentName")!.Value, - Cost = Convert.ToDouble(element.Element("Cost")!.Value) - }; - } - public void Update(ComponentBindingModel model) - { - if (model == null) - { - return; - } - ComponentName = model.ComponentName; - Cost = model.Cost; - } - public ComponentViewModel GetViewModel => new() - { - Id = Id, - ComponentName = ComponentName, - Cost = Cost - }; - public XElement GetXElement => new("Component", - new XAttribute("Id", Id), - new XElement("ComponentName", ComponentName), - new XElement("Cost", Cost.ToString())); - } -} \ No newline at end of file diff --git a/SecuritySystemFileImplement/Models/Manufacture.cs b/SecuritySystemFileImplement/Models/Manufacture.cs deleted file mode 100644 index 04f48b2..0000000 --- a/SecuritySystemFileImplement/Models/Manufacture.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using System.Xml.Linq; -using SecuritySystemDataModels.Models; -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.ViewModels; -using SecuritySystemFileImplement; - -namespace SecuritySystemFileImplement.Models -{ - public class Manufacture : IManufactureModel - { - public int Id { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; - public double Price { get; private set; } - public Dictionary Components { get; private set; } = new(); - private Dictionary? _manufactureComponents = null; - public Dictionary ManufactureComponents - { - get - { - if (_manufactureComponents == null) - { - var source = DataFileSingleton.GetInstance(); - _manufactureComponents = Components.ToDictionary(x => x.Key, y => - ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, y.Value)); - } - return _manufactureComponents; - } - } - public static Manufacture? Create(ManufactureBindingModel model) - { - if (model == null) - { - return null; - } - return new Manufacture() - { - Id = model.Id, - ManufactureName = model.ManufactureName, - Price = model.Price, - Components = model.ManufactureComponents.ToDictionary(x => x.Key, x => x.Value.Item2) - }; - } - public static Manufacture? Create(XElement element) - { - if (element == null) - { - return null; - } - return new Manufacture() - { - Id = Convert.ToInt32(element.Attribute("Id")!.Value), - ManufactureName = element.Element("ManufactureName")!.Value, - Price = Convert.ToDouble(element.Element("Price")!.Value), - Components = - element.Element("ManufactureComponents")!.Elements("ManufactureComponent").ToDictionary(x =>Convert.ToInt32(x.Element("Key")?.Value), - x =>Convert.ToInt32(x.Element("Value")?.Value)) - }; - } - public void Update(ManufactureBindingModel model) - { - if (model == null) - { - return; - } - ManufactureName = model.ManufactureName; - Price = model.Price; - Components = model.ManufactureComponents.ToDictionary(x => x.Key, x => x.Value.Item2); - _manufactureComponents = null; - } - public ManufactureViewModel GetViewModel => new() - { - Id = Id, - ManufactureName = ManufactureName, - Price = Price, - ManufactureComponents = ManufactureComponents - }; - public XElement GetXElement => new("Manufacture", - new XAttribute("Id", Id), - new XElement("ManufactureName", ManufactureName), - new XElement("Price", Price.ToString()), - new XElement("ManufactureComponents", Components.Select(x => - new XElement("ManufactureComponent", - new XElement("Key", x.Key), - new XElement("Value", x.Value))) - .ToArray())); - } -} diff --git a/SecuritySystemFileImplement/Models/Order.cs b/SecuritySystemFileImplement/Models/Order.cs deleted file mode 100644 index b5996d8..0000000 --- a/SecuritySystemFileImplement/Models/Order.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using System.Xml.Linq; -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.ViewModels; -using SecuritySystemDataModels.Enums; -using SecuritySystemDataModels.Models; - -namespace SecuritySystemFileImplement.Models -{ - public class Order : IOrderModel - { - public int Id { get; private set; } - public int ManufactureId { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; - public int Count { get; private set; } - public double Sum { 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) - { - return null; - } - return new Order - { - Id = model.Id, - ManufactureId = model.ManufactureId, - ManufactureName = model.ManufactureName, - Count = model.Count, - Sum = model.Sum, - Status = model.Status, - DateCreate = model.DateCreate, - DateImplement = model.DateImplement - }; - } - - public static Order? Create(XElement element) - { - if (element == null) - { - return null; - } - return new Order() - { - Id = Convert.ToInt32(element.Attribute("Id")!.Value), - ManufactureId = Convert.ToInt32(element.Element("ManufactureId")!.Value), - ManufactureName = element.Element("ManufactureName")!.Value, - Sum = Convert.ToDouble(element.Element("Sum")!.Value), - Count = Convert.ToInt32(element.Element("Count")!.Value), - Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value), - DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value), - DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null : Convert.ToDateTime(element.Element("DateImplement")!.Value) - }; - } - - public void Update(OrderBindingModel? model) - { - if (model == null) - { - return; - } - Status = model.Status; - DateImplement = model.DateImplement; - } - - public OrderViewModel GetViewModel => new() - { - Id = Id, - ManufactureId = ManufactureId, - ManufactureName = ManufactureName, - Count = Count, - Sum = Sum, - Status = Status, - DateCreate = DateCreate, - DateImplement = DateImplement - }; - - public XElement GetXElement => new( - "Order", - new XAttribute("Id", Id), - new XElement("ManufactureId", ManufactureId.ToString()), - new XElement("ManufactureName", ManufactureName.ToString()), - new XElement("Count", Count.ToString()), - new XElement("Sum", Sum.ToString()), - new XElement("Status", Status.ToString()), - new XElement("DateCreate", DateCreate.ToString()), - new XElement("DateImplement", DateImplement.ToString()) - ); - } -} diff --git a/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj b/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj deleted file mode 100644 index 7037095..0000000 --- a/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - diff --git a/SecuritySystemListImplement/Models/Order.cs b/SecuritySystemListImplement/Models/Order.cs index 4ad41a3..88a2e68 100644 --- a/SecuritySystemListImplement/Models/Order.cs +++ b/SecuritySystemListImplement/Models/Order.cs @@ -53,7 +53,12 @@ namespace SecuritySystemListImplement.Models { return; } + ManufactureId = model.ManufactureId; + ManufactureName = model.ManufactureName; + Count = model.Count; + Sum = model.Sum; Status = model.Status; + DateCreate = model.DateCreate; DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() -- 2.25.1 From 6c25c1a3a9bd1a25ddab03709a89f41e705473c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 14:04:23 +0400 Subject: [PATCH 20/21] fix --- SecuritySystemContracts/SearchModels/SecureSearchModel.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/SecuritySystemContracts/SearchModels/SecureSearchModel.cs b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs index 1778cfb..8547e9f 100644 --- a/SecuritySystemContracts/SearchModels/SecureSearchModel.cs +++ b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs @@ -6,16 +6,10 @@ using System.Threading.Tasks; namespace SecuritySystemContracts.SearchModels { -<<<<<<< HEAD:SecuritySystemContracts/SearchModels/ComponentSearchModel.cs - public class ComponentSearchModel - { - public int? Id { get; set; } - public string? ComponentName { get; set; } -======= public class SecureSearchModel { public int? Id { get; set; } public string? SecureName { get; set; } ->>>>>>> Rename:SecuritySystemContracts/SearchModels/SecureSearchModel.cs + } } -- 2.25.1 From beeb41756adc434c6bc4b455aac3350c5b8cecbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 7 Mar 2023 14:10:53 +0400 Subject: [PATCH 21/21] fix --- SecuritySystem/SecuritySystem.sln | 16 ++++++++-------- SecuritySystem/SecuritySystemView.csproj | 2 +- .../ComponentLogic.cs | 0 .../OrderLogic.cs | 0 .../SecureLogic.cs | 0 .../SecuritySystemBusinessLogic.csproj | 0 6 files changed, 9 insertions(+), 9 deletions(-) rename {SystemSecurityBusinessLogic => SecuritySystemBusinessLogic}/ComponentLogic.cs (100%) rename {SystemSecurityBusinessLogic => SecuritySystemBusinessLogic}/OrderLogic.cs (100%) rename {SystemSecurityBusinessLogic => SecuritySystemBusinessLogic}/SecureLogic.cs (100%) rename {SystemSecurityBusinessLogic => SecuritySystemBusinessLogic}/SecuritySystemBusinessLogic.csproj (100%) diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index d169da1..74c4eb3 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -5,13 +5,13 @@ VisualStudioVersion = 17.3.32922.545 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemView", "SecuritySystemView.csproj", "{39A7185D-F1F5-4892-BE6F-72B1A849CA84}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemSecurityBusinessLogic", "..\SystemSecurityBusinessLogic\SystemSecurityBusinessLogic.csproj", "{D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemContracts", "..\SecuritySystemContracts\SecuritySystemContracts.csproj", "{C1C491F5-4CB7-4B6B-92CE-41688769709A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemDataModels", "..\SecuritySystemDataModels\SecuritySystemDataModels.csproj", "{D12D1329-4362-472B-B6E6-D62B0FF00C63}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemDataModels", "..\SecuritySystemDataModels\SecuritySystemDataModels.csproj", "{D12D1329-4362-472B-B6E6-D62B0FF00C63}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemListImplement", "..\SecuritySystemListImplement\SecuritySystemListImplement.csproj", "{A5A3381B-3592-41B6-880F-333C2502DF02}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemBusinessLogic", "..\SecuritySystemBusinessLogic\SecuritySystemBusinessLogic.csproj", "{EF5F4167-954D-4414-8F76-372410029641}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -23,10 +23,6 @@ Global {39A7185D-F1F5-4892-BE6F-72B1A849CA84}.Debug|Any CPU.Build.0 = Debug|Any CPU {39A7185D-F1F5-4892-BE6F-72B1A849CA84}.Release|Any CPU.ActiveCfg = Release|Any CPU {39A7185D-F1F5-4892-BE6F-72B1A849CA84}.Release|Any CPU.Build.0 = Release|Any CPU - {D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D8EF10A4-F934-461B-BE3C-BCCCF266B8D9}.Release|Any CPU.Build.0 = Release|Any CPU {C1C491F5-4CB7-4B6B-92CE-41688769709A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C1C491F5-4CB7-4B6B-92CE-41688769709A}.Debug|Any CPU.Build.0 = Debug|Any CPU {C1C491F5-4CB7-4B6B-92CE-41688769709A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -39,6 +35,10 @@ Global {A5A3381B-3592-41B6-880F-333C2502DF02}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5A3381B-3592-41B6-880F-333C2502DF02}.Release|Any CPU.Build.0 = Release|Any CPU + {EF5F4167-954D-4414-8F76-372410029641}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF5F4167-954D-4414-8F76-372410029641}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF5F4167-954D-4414-8F76-372410029641}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF5F4167-954D-4414-8F76-372410029641}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SecuritySystem/SecuritySystemView.csproj b/SecuritySystem/SecuritySystemView.csproj index 7e4e4ef..d92a318 100644 --- a/SecuritySystem/SecuritySystemView.csproj +++ b/SecuritySystem/SecuritySystemView.csproj @@ -15,7 +15,7 @@ - + \ No newline at end of file diff --git a/SystemSecurityBusinessLogic/ComponentLogic.cs b/SecuritySystemBusinessLogic/ComponentLogic.cs similarity index 100% rename from SystemSecurityBusinessLogic/ComponentLogic.cs rename to SecuritySystemBusinessLogic/ComponentLogic.cs diff --git a/SystemSecurityBusinessLogic/OrderLogic.cs b/SecuritySystemBusinessLogic/OrderLogic.cs similarity index 100% rename from SystemSecurityBusinessLogic/OrderLogic.cs rename to SecuritySystemBusinessLogic/OrderLogic.cs diff --git a/SystemSecurityBusinessLogic/SecureLogic.cs b/SecuritySystemBusinessLogic/SecureLogic.cs similarity index 100% rename from SystemSecurityBusinessLogic/SecureLogic.cs rename to SecuritySystemBusinessLogic/SecureLogic.cs diff --git a/SystemSecurityBusinessLogic/SecuritySystemBusinessLogic.csproj b/SecuritySystemBusinessLogic/SecuritySystemBusinessLogic.csproj similarity index 100% rename from SystemSecurityBusinessLogic/SecuritySystemBusinessLogic.csproj rename to SecuritySystemBusinessLogic/SecuritySystemBusinessLogic.csproj -- 2.25.1