From 8e4ebbaa2fc98c5b1f69fd0ca43b0edb77266297 Mon Sep 17 00:00:00 2001 From: aleksandr chegodaev Date: Sat, 11 May 2024 00:42:33 +0400 Subject: [PATCH 1/2] lab1_hard --- LawFirm/LawFirm/FormComponent.Designer.cs | 149 +++++----- LawFirm/LawFirm/FormComponent.cs | 29 +- LawFirm/LawFirm/FormComponent.resx | 62 +--- LawFirm/LawFirm/FormComponents.Designer.cs | 119 ++++---- LawFirm/LawFirm/FormComponents.cs | 33 ++- LawFirm/LawFirm/FormComponents.resx | 62 +--- LawFirm/LawFirm/FormCreateOrder.Designer.cs | 175 ++++++------ LawFirm/LawFirm/FormCreateOrder.cs | 73 +++-- LawFirm/LawFirm/FormCreateOrder.resx | 62 +--- LawFirm/LawFirm/FormDocument.Designer.cs | 226 +++++++++++++++ .../LawFirm/{FormLaw.cs => FormDocument.cs} | 121 +++++--- LawFirm/LawFirm/FormDocument.resx | 78 ++++++ .../LawFirm/FormDocumentComponent.Designer.cs | 119 ++++++++ ...wComponent.cs => FormDocumentComponent.cs} | 22 +- LawFirm/LawFirm/FormDocumentComponent.resx | 60 ++++ LawFirm/LawFirm/FormDocuments.Designer.cs | 114 ++++++++ .../LawFirm/{FormLaws.cs => FormDocuments.cs} | 49 ++-- LawFirm/LawFirm/FormDocuments.resx | 60 ++++ LawFirm/LawFirm/FormLaw.Designer.cs | 235 ---------------- LawFirm/LawFirm/FormLaw.resx | 129 --------- LawFirm/LawFirm/FormLawComponent.Designer.cs | 118 -------- LawFirm/LawFirm/FormLawComponent.resx | 120 -------- LawFirm/LawFirm/FormLaws.Designer.cs | 116 -------- LawFirm/LawFirm/FormLaws.resx | 120 -------- LawFirm/LawFirm/FormMain.Designer.cs | 264 ++++++++++-------- LawFirm/LawFirm/FormMain.cs | 95 +++++-- LawFirm/LawFirm/FormMain.resx | 82 +----- LawFirm/LawFirm/FormShop.Designer.cs | 182 ++++++++++++ LawFirm/LawFirm/FormShop.cs | 134 +++++++++ LawFirm/LawFirm/FormShop.resx | 69 +++++ LawFirm/LawFirm/FormShopSupply.Designer.cs | 143 ++++++++++ LawFirm/LawFirm/FormShopSupply.cs | 125 +++++++++ LawFirm/LawFirm/FormShopSupply.resx | 60 ++++ LawFirm/LawFirm/FormShops.Designer.cs | 114 ++++++++ LawFirm/LawFirm/FormShops.cs | 122 ++++++++ LawFirm/LawFirm/FormShops.resx | 60 ++++ LawFirm/LawFirm/Program.cs | 23 +- LawFirm/LawFirm/nlog.config | 15 - .../BusinessLogic/ComponentLogic.cs | 31 +- .../{LawLogic.cs => DocumentLogic.cs} | 56 ++-- .../BusinessLogic/OrderLogic.cs | 94 +++---- .../BusinessLogic/ShopLogic.cs | 162 +++++++++++ .../BindingModels/ComponentBindingModel.cs | 2 +- ...indingModel.cs => DocumentBindingModel.cs} | 6 +- .../BindingModels/OrderBindingModel.cs | 4 +- .../BindingModels/ShopBindingModel.cs | 26 ++ .../IComponentLogic.cs | 3 +- .../BusinessLogicsContracts/IDocumentLogic.cs | 20 ++ .../BusinessLogicsContracts/ILawLogic.cs | 20 -- .../BusinessLogicsContracts/IOrderLogic.cs | 10 - .../BusinessLogicsContracts/IShopLogic.cs | 22 ++ .../SearchModels/DocumentSearchModel.cs | 14 + .../{LawSearchModel.cs => ShopSearchModel.cs} | 4 +- .../StoragesContracts/IComponentStorage.cs | 3 +- .../StoragesContracts/IDocumentStorage.cs | 21 ++ .../StoragesContracts/ILawStorage.cs | 21 -- .../StoragesContracts/IShopStorage.cs | 21 ++ .../{LawViewModel.cs => DocumentViewModel.cs} | 12 +- .../ViewModels/OrderViewModel.cs | 9 +- .../ViewModels/ShopViewModel.cs | 29 ++ .../LawFirmDataModels/Enums/OrderStatus.cs | 12 +- .../Models/IComponentModel.cs | 10 +- .../Models/IDocumentModel.cs | 16 ++ LawFirm/LawFirmDataModels/Models/ILawModel.cs | 9 - .../LawFirmDataModels/Models/IOrderModel.cs | 11 +- .../LawFirmDataModels/Models/IShopModel.cs | 16 ++ .../LawFirmListImplement/DataListSingleton.cs | 8 +- .../Implements/ComponentStorage.cs | 18 +- .../Implements/DocumentStorage.cs | 109 ++++++++ .../Implements/LawStorage.cs | 112 -------- .../Implements/OrderStorage.cs | 37 +-- .../Implements/ShopStorage.cs | 118 ++++++++ .../LawFirmListImplement/Models/Component.cs | 10 +- .../Models/{Law.cs => Document.cs} | 28 +- LawFirm/LawFirmListImplement/Models/Order.cs | 11 +- LawFirm/LawFirmListImplement/Models/Shop.cs | 60 ++++ 76 files changed, 3130 insertions(+), 1984 deletions(-) create mode 100644 LawFirm/LawFirm/FormDocument.Designer.cs rename LawFirm/LawFirm/{FormLaw.cs => FormDocument.cs} (61%) create mode 100644 LawFirm/LawFirm/FormDocument.resx create mode 100644 LawFirm/LawFirm/FormDocumentComponent.Designer.cs rename LawFirm/LawFirm/{FormLawComponent.cs => FormDocumentComponent.cs} (82%) create mode 100644 LawFirm/LawFirm/FormDocumentComponent.resx create mode 100644 LawFirm/LawFirm/FormDocuments.Designer.cs rename LawFirm/LawFirm/{FormLaws.cs => FormDocuments.cs} (69%) create mode 100644 LawFirm/LawFirm/FormDocuments.resx delete mode 100644 LawFirm/LawFirm/FormLaw.Designer.cs delete mode 100644 LawFirm/LawFirm/FormLaw.resx delete mode 100644 LawFirm/LawFirm/FormLawComponent.Designer.cs delete mode 100644 LawFirm/LawFirm/FormLawComponent.resx delete mode 100644 LawFirm/LawFirm/FormLaws.Designer.cs delete mode 100644 LawFirm/LawFirm/FormLaws.resx create mode 100644 LawFirm/LawFirm/FormShop.Designer.cs create mode 100644 LawFirm/LawFirm/FormShop.cs create mode 100644 LawFirm/LawFirm/FormShop.resx create mode 100644 LawFirm/LawFirm/FormShopSupply.Designer.cs create mode 100644 LawFirm/LawFirm/FormShopSupply.cs create mode 100644 LawFirm/LawFirm/FormShopSupply.resx create mode 100644 LawFirm/LawFirm/FormShops.Designer.cs create mode 100644 LawFirm/LawFirm/FormShops.cs create mode 100644 LawFirm/LawFirm/FormShops.resx delete mode 100644 LawFirm/LawFirm/nlog.config rename LawFirm/LawFirmBusinessLogic/BusinessLogic/{LawLogic.cs => DocumentLogic.cs} (54%) create mode 100644 LawFirm/LawFirmBusinessLogic/BusinessLogic/ShopLogic.cs rename LawFirm/LawFirmContracts/BindingModels/{LawBindingModel.cs => DocumentBindingModel.cs} (56%) create mode 100644 LawFirm/LawFirmContracts/BindingModels/ShopBindingModel.cs create mode 100644 LawFirm/LawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs delete mode 100644 LawFirm/LawFirmContracts/BusinessLogicsContracts/ILawLogic.cs create mode 100644 LawFirm/LawFirmContracts/BusinessLogicsContracts/IShopLogic.cs create mode 100644 LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs rename LawFirm/LawFirmContracts/SearchModels/{LawSearchModel.cs => ShopSearchModel.cs} (72%) create mode 100644 LawFirm/LawFirmContracts/StoragesContracts/IDocumentStorage.cs delete mode 100644 LawFirm/LawFirmContracts/StoragesContracts/ILawStorage.cs create mode 100644 LawFirm/LawFirmContracts/StoragesContracts/IShopStorage.cs rename LawFirm/LawFirmContracts/ViewModels/{LawViewModel.cs => DocumentViewModel.cs} (51%) create mode 100644 LawFirm/LawFirmContracts/ViewModels/ShopViewModel.cs create mode 100644 LawFirm/LawFirmDataModels/Models/IDocumentModel.cs delete mode 100644 LawFirm/LawFirmDataModels/Models/ILawModel.cs create mode 100644 LawFirm/LawFirmDataModels/Models/IShopModel.cs create mode 100644 LawFirm/LawFirmListImplement/Implements/DocumentStorage.cs delete mode 100644 LawFirm/LawFirmListImplement/Implements/LawStorage.cs create mode 100644 LawFirm/LawFirmListImplement/Implements/ShopStorage.cs rename LawFirm/LawFirmListImplement/Models/{Law.cs => Document.cs} (55%) create mode 100644 LawFirm/LawFirmListImplement/Models/Shop.cs diff --git a/LawFirm/LawFirm/FormComponent.Designer.cs b/LawFirm/LawFirm/FormComponent.Designer.cs index 7e400c3..2704664 100644 --- a/LawFirm/LawFirm/FormComponent.Designer.cs +++ b/LawFirm/LawFirm/FormComponent.Designer.cs @@ -1,4 +1,4 @@ -namespace LawFirm.Forms +namespace LawFirmView { partial class FormComponent { @@ -28,95 +28,92 @@ /// private void InitializeComponent() { - buttonSave = new Button(); - buttonCancel = new Button(); - label1 = new Label(); - label2 = new Label(); - textBoxName = new TextBox(); - textBoxCost = new TextBox(); - SuspendLayout(); - // - // buttonSave - // - buttonSave.Location = new Point(217, 119); - buttonSave.Margin = new Padding(3, 4, 3, 4); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(98, 34); - buttonSave.TabIndex = 0; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += buttonSave_Click; - // - // buttonCancel - // - buttonCancel.Location = new Point(325, 119); - buttonCancel.Margin = new Padding(3, 4, 3, 4); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(98, 34); - buttonCancel.TabIndex = 1; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += buttonCancel_Click; - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(24, 30); - label1.Name = "label1"; - label1.Size = new Size(80, 20); - label1.TabIndex = 2; - label1.Text = "Название:"; - // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(24, 69); - label2.Name = "label2"; - label2.Size = new Size(48, 20); - label2.TabIndex = 3; - label2.Text = "Цена:"; + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxCost = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); // // textBoxName // - textBoxName.Location = new Point(118, 26); - textBoxName.Margin = new Padding(3, 4, 3, 4); - textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(305, 27); - textBoxName.TabIndex = 4; + this.textBoxName.Location = new System.Drawing.Point(72, 12); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(267, 23); + this.textBoxName.TabIndex = 0; // // textBoxCost // - textBoxCost.Location = new Point(118, 65); - textBoxCost.Margin = new Padding(3, 4, 3, 4); - textBoxCost.Name = "textBoxCost"; - textBoxCost.Size = new Size(186, 27); - textBoxCost.TabIndex = 5; + this.textBoxCost.Location = new System.Drawing.Point(72, 55); + this.textBoxCost.Name = "textBoxCost"; + this.textBoxCost.Size = new System.Drawing.Size(143, 23); + this.textBoxCost.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(2, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(62, 15); + this.label1.TabIndex = 2; + this.label1.Text = "Название:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 55); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(38, 15); + this.label2.TabIndex = 3; + this.label2.Text = "Цена:"; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(159, 101); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + 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(264, 101); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); // // FormComponent // - AutoScaleDimensions = new SizeF(8F, 20F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(462, 174); - Controls.Add(textBoxCost); - Controls.Add(textBoxName); - Controls.Add(label2); - Controls.Add(label1); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Margin = new Padding(3, 4, 3, 4); - Name = "FormComponent"; - Text = "Компонент"; - ResumeLayout(false); - PerformLayout(); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(456, 139); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.textBoxCost); + this.Controls.Add(this.textBoxName); + this.Name = "FormComponent"; + this.Text = "Компонент"; + this.Load += new System.EventHandler(this.FormComponent_Load); + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion - private Button buttonSave; - private Button buttonCancel; - private Label label1; - private Label label2; private TextBox textBoxName; private TextBox textBoxCost; + private Label label1; + private Label label2; + private Button buttonSave; + private Button buttonCancel; } } \ No newline at end of file diff --git a/LawFirm/LawFirm/FormComponent.cs b/LawFirm/LawFirm/FormComponent.cs index 69213f3..9346757 100644 --- a/LawFirm/LawFirm/FormComponent.cs +++ b/LawFirm/LawFirm/FormComponent.cs @@ -1,4 +1,8 @@ -using System; +using LawFirmContracts.BindingModels.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -7,13 +11,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using Microsoft.Extensions.Logging; -using LawFirmContracts.BusinessLogicsContracts; -using Microsoft.VisualBasic.Logging; -using LawFirmContracts.SearchModels; -using LawFirmContracts.BindingModels; -namespace LawFirm.Forms +namespace LawFirmView { public partial class FormComponent : Form { @@ -37,7 +36,8 @@ namespace LawFirm.Forms _logger.LogInformation("Получение компонента"); var view = _logic.ReadElement(new ComponentSearchModel { - Id = _id.Value + Id = + _id.Value }); if (view != null) { @@ -58,7 +58,8 @@ namespace LawFirm.Forms { if (string.IsNullOrEmpty(textBoxName.Text)) { - MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _logger.LogInformation("Сохранение компонента"); @@ -70,20 +71,24 @@ namespace LawFirm.Forms ComponentName = textBoxName.Text, Cost = Convert.ToDouble(textBoxCost.Text) }; - var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { _logger.LogError(ex, "Ошибка сохранения компонента"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } + } private void buttonCancel_Click(object sender, EventArgs e) diff --git a/LawFirm/LawFirm/FormComponent.resx b/LawFirm/LawFirm/FormComponent.resx index af32865..f298a7b 100644 --- a/LawFirm/LawFirm/FormComponent.resx +++ b/LawFirm/LawFirm/FormComponent.resx @@ -1,64 +1,4 @@ - - - + diff --git a/LawFirm/LawFirm/FormComponents.Designer.cs b/LawFirm/LawFirm/FormComponents.Designer.cs index 4ddb726..5c5db9f 100644 --- a/LawFirm/LawFirm/FormComponents.Designer.cs +++ b/LawFirm/LawFirm/FormComponents.Designer.cs @@ -1,4 +1,4 @@ -namespace LawFirm.Forms +namespace LawFirmView { partial class FormComponents { @@ -28,86 +28,79 @@ /// private void InitializeComponent() { - dataGridView = new DataGridView(); - buttonAdd = new Button(); - buttonUpd = new Button(); - buttonDel = new Button(); - buttonRef = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); // // dataGridView // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(-1, -2); - dataGridView.Margin = new Padding(3, 4, 3, 4); - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 24; - dataGridView.Size = new Size(499, 568); - dataGridView.TabIndex = 0; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(439, 442); + this.dataGridView.TabIndex = 0; // // buttonAdd // - buttonAdd.Location = new Point(525, 48); - buttonAdd.Margin = new Padding(3, 4, 3, 4); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(125, 35); - buttonAdd.TabIndex = 1; - buttonAdd.Text = "Добавить"; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += buttonAdd_Click; + this.buttonAdd.Location = new System.Drawing.Point(486, 12); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(102, 40); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); // // buttonUpd // - buttonUpd.Location = new Point(525, 98); - buttonUpd.Margin = new Padding(3, 4, 3, 4); - buttonUpd.Name = "buttonUpd"; - buttonUpd.Size = new Size(125, 35); - buttonUpd.TabIndex = 2; - buttonUpd.Text = "Изменить"; - buttonUpd.UseVisualStyleBackColor = true; - buttonUpd.Click += buttonUpd_Click; + this.buttonUpd.Location = new System.Drawing.Point(486, 58); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(102, 41); + this.buttonUpd.TabIndex = 2; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click); // // buttonDel // - buttonDel.Location = new Point(525, 150); - buttonDel.Margin = new Padding(3, 4, 3, 4); - buttonDel.Name = "buttonDel"; - buttonDel.Size = new Size(125, 35); - buttonDel.TabIndex = 3; - buttonDel.Text = "Удалить"; - buttonDel.UseVisualStyleBackColor = true; - buttonDel.Click += buttonDel_Click; + this.buttonDel.Location = new System.Drawing.Point(486, 105); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(102, 42); + this.buttonDel.TabIndex = 3; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click); // // buttonRef // - buttonRef.Location = new Point(525, 201); - buttonRef.Margin = new Padding(3, 4, 3, 4); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(125, 35); - buttonRef.TabIndex = 4; - buttonRef.Text = "Обновить"; - buttonRef.UseVisualStyleBackColor = true; - buttonRef.Click += buttonRef_Click; + this.buttonRef.Location = new System.Drawing.Point(486, 153); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(102, 39); + this.buttonRef.TabIndex = 4; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click); // // FormComponents // - AutoScaleDimensions = new SizeF(8F, 20F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(676, 562); - Controls.Add(buttonRef); - Controls.Add(buttonDel); - Controls.Add(buttonUpd); - Controls.Add(buttonAdd); - Controls.Add(dataGridView); - Margin = new Padding(3, 4, 3, 4); - Name = "FormComponents"; - Text = "Список компонентов"; - Load += FormComponents_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(632, 443); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.dataGridView); + this.Name = "FormComponents"; + this.Text = "FormComponents"; + this.Load += new System.EventHandler(this.FormComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + } #endregion diff --git a/LawFirm/LawFirm/FormComponents.cs b/LawFirm/LawFirm/FormComponents.cs index 72a40fb..8d63a50 100644 --- a/LawFirm/LawFirm/FormComponents.cs +++ b/LawFirm/LawFirm/FormComponents.cs @@ -1,6 +1,7 @@ -using LawFirmContracts.BindingModels; +using LawFirmContracts.BindingModels.BindingModels; using LawFirmContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; +using Microsoft.VisualBasic.Logging; using System; using System.Collections.Generic; using System.ComponentModel; @@ -11,7 +12,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace LawFirm.Forms +namespace LawFirmView { public partial class FormComponents : Form { @@ -23,12 +24,11 @@ namespace LawFirm.Forms _logger = logger; _logic = logic; } - private void FormComponents_Load(object sender, EventArgs e) { LoadData(); - } + } private void LoadData() { try @@ -38,14 +38,16 @@ namespace LawFirm.Forms { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ComponentName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка компонентов"); } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки компонентов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } @@ -65,23 +67,27 @@ namespace LawFirm.Forms { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + var service = + Program.ServiceProvider?.GetService(typeof(FormComponent)); if (service is FormComponent form) { - form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + form.Id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) { - LoadData(); + LoadData(); } } } + } private void buttonDel_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); @@ -100,14 +106,19 @@ namespace LawFirm.Forms catch (Exception ex) { _logger.LogError(ex, "Ошибка удаления компонента"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); } } } + } + private void buttonRef_Click(object sender, EventArgs e) { LoadData(); } + + } } diff --git a/LawFirm/LawFirm/FormComponents.resx b/LawFirm/LawFirm/FormComponents.resx index af32865..f298a7b 100644 --- a/LawFirm/LawFirm/FormComponents.resx +++ b/LawFirm/LawFirm/FormComponents.resx @@ -1,64 +1,4 @@ - - - + diff --git a/LawFirm/LawFirm/FormCreateOrder.Designer.cs b/LawFirm/LawFirm/FormCreateOrder.Designer.cs index 58dc151..4145c5f 100644 --- a/LawFirm/LawFirm/FormCreateOrder.Designer.cs +++ b/LawFirm/LawFirm/FormCreateOrder.Designer.cs @@ -1,4 +1,4 @@ -namespace LawFirm.Forms +namespace LawFirmView { partial class FormCreateOrder { @@ -28,116 +28,117 @@ /// private void InitializeComponent() { - label1 = new Label(); - label2 = new Label(); - label3 = new Label(); - textBoxCount = new TextBox(); - comboBoxLaw = new ComboBox(); - textBoxSum = new TextBox(); - buttonSave = new Button(); - buttonCancel = new Button(); - SuspendLayout(); + this.comboBoxDocument = new System.Windows.Forms.ComboBox(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.textBoxSum = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); // - // label1 + // comboBoxDocument // - label1.AutoSize = true; - label1.Location = new Point(19, 12); - label1.Name = "label1"; - label1.Size = new Size(56, 15); - label1.TabIndex = 0; - label1.Text = "Изделие:"; - // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(19, 44); - label2.Name = "label2"; - label2.Size = new Size(75, 15); - label2.TabIndex = 1; - label2.Text = "Количество:"; - // - // label3 - // - label3.AutoSize = true; - label3.Location = new Point(19, 70); - label3.Name = "label3"; - label3.Size = new Size(48, 15); - label3.TabIndex = 2; - label3.Text = "Сумма:"; + this.comboBoxDocument.FormattingEnabled = true; + this.comboBoxDocument.Location = new System.Drawing.Point(116, 12); + this.comboBoxDocument.Name = "comboBoxDocument"; + this.comboBoxDocument.Size = new System.Drawing.Size(198, 23); + this.comboBoxDocument.TabIndex = 0; + this.comboBoxDocument.SelectedIndexChanged += new System.EventHandler(this.comboBoxDocument_SelectedIndexChanged); // // textBoxCount // - textBoxCount.Location = new Point(103, 41); - textBoxCount.Name = "textBoxCount"; - textBoxCount.Size = new Size(246, 23); - textBoxCount.TabIndex = 3; - textBoxCount.TextChanged += textBoxCount_TextChanged; - // - // comboBoxLaw - // - comboBoxLaw.FormattingEnabled = true; - comboBoxLaw.Location = new Point(103, 10); - comboBoxLaw.Name = "comboBoxLaw"; - comboBoxLaw.Size = new Size(246, 23); - comboBoxLaw.TabIndex = 4; - comboBoxLaw.SelectedIndexChanged += ComboBoxLaw_SelectedIndexChanged; + this.textBoxCount.Location = new System.Drawing.Point(116, 41); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(198, 23); + this.textBoxCount.TabIndex = 1; + this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCount_TextChanged); // // textBoxSum // - textBoxSum.Location = new Point(103, 70); - textBoxSum.Name = "textBoxSum"; - textBoxSum.ReadOnly = true; - textBoxSum.Size = new Size(246, 23); - textBoxSum.TabIndex = 5; + this.textBoxSum.Location = new System.Drawing.Point(116, 70); + this.textBoxSum.Name = "textBoxSum"; + this.textBoxSum.Size = new System.Drawing.Size(198, 23); + this.textBoxSum.TabIndex = 2; + this.textBoxSum.TextChanged += new System.EventHandler(this.textBoxSum_TextChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(110, 15); + this.label1.TabIndex = 3; + this.label1.Text = "Пакет документов:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(3, 44); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(75, 15); + this.label2.TabIndex = 4; + this.label2.Text = "Количество:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(3, 70); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(48, 15); + this.label3.TabIndex = 5; + this.label3.Text = "Сумма:"; // // buttonSave // - buttonSave.Location = new Point(150, 101); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(94, 26); - buttonSave.TabIndex = 6; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += buttonSave_Click; + this.buttonSave.Location = new System.Drawing.Point(180, 122); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + this.buttonSave.TabIndex = 6; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); // // buttonCancel // - buttonCancel.Location = new Point(249, 101); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(94, 26); - buttonCancel.TabIndex = 7; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += buttonCancel_Click; + this.buttonCancel.Location = new System.Drawing.Point(282, 122); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 7; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); // // FormCreateOrder // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(374, 136); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(textBoxSum); - Controls.Add(comboBoxLaw); - Controls.Add(textBoxCount); - Controls.Add(label3); - Controls.Add(label2); - Controls.Add(label1); - Name = "FormCreateOrder"; - Text = "Заказ"; - Load += FormCreateOrder_Load; - ResumeLayout(false); - PerformLayout(); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(445, 158); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.textBoxSum); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxDocument); + this.Name = "FormCreateOrder"; + this.Text = "Заказ"; + this.Load += new System.EventHandler(this.FormCreateOrder_Load); + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion + private ComboBox comboBoxDocument; + private TextBox textBoxCount; + private TextBox textBoxSum; private Label label1; private Label label2; private Label label3; - private TextBox textBoxCount; - private ComboBox comboBoxLaw; - private TextBox textBoxSum; private Button buttonSave; private Button buttonCancel; } diff --git a/LawFirm/LawFirm/FormCreateOrder.cs b/LawFirm/LawFirm/FormCreateOrder.cs index 039d79c..693a1ba 100644 --- a/LawFirm/LawFirm/FormCreateOrder.cs +++ b/LawFirm/LawFirm/FormCreateOrder.cs @@ -1,7 +1,6 @@ -using LawFirmContracts.BindingModels; -using LawFirmContracts.BusinessLogicsContracts; -using LawFirmContracts.SearchModels; +using LawFirmContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; +using LawFirmContracts.SearchModels; using System; using System.Collections.Generic; using System.ComponentModel; @@ -11,69 +10,83 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using LawFirmContracts.BindingModels; -namespace LawFirm.Forms +namespace LawFirmView { public partial class FormCreateOrder : Form { private readonly ILogger _logger; - private readonly ILawLogic _logicP; + private readonly IDocumentLogic _logicD; private readonly IOrderLogic _logicO; - public FormCreateOrder(ILogger logger, ILawLogic logicP, IOrderLogic logicO) + public FormCreateOrder(ILogger logger, IDocumentLogic logicD, IOrderLogic logicO) { InitializeComponent(); _logger = logger; - _logicP = logicP; + _logicD = logicD; _logicO = logicO; } private void FormCreateOrder_Load(object sender, EventArgs e) { + _logger.LogInformation("Загрузка пакетов документов для заказа"); try { - var list = _logicP.ReadList(null); + var list = _logicD.ReadList(null); if (list != null) { - comboBoxLaw.DisplayMember = "LawName"; - comboBoxLaw.ValueMember = "Id"; - comboBoxLaw.DataSource = list; - comboBoxLaw.SelectedItem = null; - _logger.LogInformation("Загрузка изделий для заказа"); + comboBoxDocument.DisplayMember = "DocumentName"; + comboBoxDocument.ValueMember = "Id"; + comboBoxDocument.DataSource = list; + comboBoxDocument.SelectedItem = null; } + _logger.LogInformation("Пакеты документов загружены"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки списка изделий"); + _logger.LogError(ex, "Ошибка загрузки пакетов документов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } private void CalcSum() { - if (comboBoxLaw.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + if (comboBoxDocument.SelectedValue != null && + !string.IsNullOrEmpty(textBoxCount.Text)) { try { - int id = Convert.ToInt32(comboBoxLaw.SelectedValue); - var Law = _logicP.ReadElement(new LawSearchModel + int id = Convert.ToInt32(comboBoxDocument.SelectedValue); + var product = _logicD.ReadElement(new DocumentSearchModel { - Id = id + Id + = id }); int count = Convert.ToInt32(textBoxCount.Text); - textBoxSum.Text = Math.Round(count * (Law?.Price ?? 0), 2).ToString(); + textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), + 2).ToString(); _logger.LogInformation("Расчет суммы заказа"); } catch (Exception ex) { _logger.LogError(ex, "Ошибка расчета суммы заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } } + private void textBoxCount_TextChanged(object sender, EventArgs e) { CalcSum(); } - private void ComboBoxLaw_SelectedIndexChanged(object sender, EventArgs e) + private void comboBoxDocument_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void textBoxSum_TextChanged(object sender, EventArgs e) { CalcSum(); } @@ -82,12 +95,14 @@ namespace LawFirm.Forms { if (string.IsNullOrEmpty(textBoxCount.Text)) { - MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (comboBoxLaw.SelectedValue == null) + if (comboBoxDocument.SelectedValue == null) { - MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Выберите пакет документов", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _logger.LogInformation("Создание заказа"); @@ -95,7 +110,7 @@ namespace LawFirm.Forms { var operationResult = _logicO.CreateOrder(new OrderBindingModel { - LawId = Convert.ToInt32(comboBoxLaw.SelectedValue), + DocumentId = Convert.ToInt32(comboBoxDocument.SelectedValue), Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); @@ -103,14 +118,17 @@ namespace LawFirm.Forms { throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка создания заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } + } private void buttonCancel_Click(object sender, EventArgs e) @@ -118,6 +136,5 @@ namespace LawFirm.Forms DialogResult = DialogResult.Cancel; Close(); } - } } diff --git a/LawFirm/LawFirm/FormCreateOrder.resx b/LawFirm/LawFirm/FormCreateOrder.resx index af32865..f298a7b 100644 --- a/LawFirm/LawFirm/FormCreateOrder.resx +++ b/LawFirm/LawFirm/FormCreateOrder.resx @@ -1,64 +1,4 @@ - - - + diff --git a/LawFirm/LawFirm/FormDocument.Designer.cs b/LawFirm/LawFirm/FormDocument.Designer.cs new file mode 100644 index 0000000..106d77a --- /dev/null +++ b/LawFirm/LawFirm/FormDocument.Designer.cs @@ -0,0 +1,226 @@ +namespace LawFirmView +{ + partial class FormDocument + { + /// + /// 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.groupBox1 = new System.Windows.Forms.GroupBox(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.buttonRef); + this.groupBox1.Controls.Add(this.buttonDel); + this.groupBox1.Controls.Add(this.buttonUpd); + this.groupBox1.Controls.Add(this.buttonAdd); + this.groupBox1.Controls.Add(this.dataGridView); + this.groupBox1.Location = new System.Drawing.Point(58, 98); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(605, 288); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Компоненты"; + // + // dataGridView + // + 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.Column1, + this.Column2, + this.Column3}); + this.dataGridView.Location = new System.Drawing.Point(3, 19); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(413, 254); + this.dataGridView.TabIndex = 0; + // + // Column1 + // + this.Column1.HeaderText = "id"; + this.Column1.Name = "Column1"; + this.Column1.Visible = false; + // + // Column2 + // + this.Column2.HeaderText = "Компонент"; + this.Column2.Name = "Column2"; + // + // Column3 + // + this.Column3.HeaderText = "Количество"; + this.Column3.Name = "Column3"; + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(476, 19); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(75, 23); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(476, 61); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(75, 23); + this.buttonUpd.TabIndex = 2; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(476, 108); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(75, 23); + this.buttonDel.TabIndex = 3; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click); + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(476, 156); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(75, 23); + this.buttonRef.TabIndex = 4; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(427, 403); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + this.buttonSave.TabIndex = 1; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(534, 403); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 2; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(102, 12); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(205, 23); + this.textBoxName.TabIndex = 3; + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(102, 41); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(151, 23); + this.textBoxPrice.TabIndex = 4; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(62, 15); + this.label1.TabIndex = 5; + this.label1.Text = "Название:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 41); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(70, 15); + this.label2.TabIndex = 6; + this.label2.Text = "Стоимость:"; + // + // FormDocument + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(691, 450); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.groupBox1); + this.Name = "FormDocument"; + this.Text = "Пакет документов"; + this.Load += new System.EventHandler(this.FormDocument_Load); + this.groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private GroupBox groupBox1; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Column1; + private DataGridViewTextBoxColumn Column2; + private DataGridViewTextBoxColumn Column3; + private Button buttonSave; + private Button buttonCancel; + private TextBox textBoxName; + private TextBox textBoxPrice; + private Label label1; + private Label label2; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormLaw.cs b/LawFirm/LawFirm/FormDocument.cs similarity index 61% rename from LawFirm/LawFirm/FormLaw.cs rename to LawFirm/LawFirm/FormDocument.cs index 5aae91a..30f3fef 100644 --- a/LawFirm/LawFirm/FormLaw.cs +++ b/LawFirm/LawFirm/FormDocument.cs @@ -1,5 +1,8 @@ using LawFirmDataModels.Models; using Microsoft.Extensions.Logging; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.BindingModels; using System; using System.Collections.Generic; using System.ComponentModel; @@ -9,62 +12,66 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using LawFirmContracts.BusinessLogicsContracts; -using LawFirmContracts.SearchModels; -using LawFirmContracts.BindingModels; -namespace LawFirm.Forms +namespace LawFirmView { - public partial class FormLaw : Form + public partial class FormDocument : Form { private readonly ILogger _logger; - private readonly ILawLogic _logic; + private readonly IDocumentLogic _logic; private int? _id; - private Dictionary _productComponents; + private Dictionary _documentComponents; public int Id { set { _id = value; } } - public FormLaw(ILogger logger, ILawLogic logic) + public FormDocument(ILogger logger, IDocumentLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; - _productComponents = new Dictionary(); + _documentComponents = new Dictionary(); } - private void FormLaw_Load(object sender, EventArgs e) + + private void FormDocument_Load(object sender, EventArgs e) { if (_id.HasValue) { _logger.LogInformation("Загрузка изделия"); try { - var view = _logic.ReadElement(new LawSearchModel + var view = _logic.ReadElement(new DocumentSearchModel { - Id = _id.Value + Id = + _id.Value }); if (view != null) { - textBoxName.Text = view.LawName; + textBoxName.Text = view.DocumentName; textBoxPrice.Text = view.Price.ToString(); - _productComponents = view.LawComponents ?? new Dictionary(); + _documentComponents = view.DocumentComponents ?? new + Dictionary(); LoadData(); } } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } + } private void LoadData() { _logger.LogInformation("Загрузка компонент изделия"); try { - if (_productComponents != null) + if (_documentComponents != null) { dataGridView.Rows.Clear(); - foreach (var pc in _productComponents) + foreach (var pc in _documentComponents) { - dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); + dataGridView.Rows.Add(new object[] { pc.Key, +pc.Value.Item1.ComponentName, pc.Value.Item2 }); } textBoxPrice.Text = CalcPrice().ToString(); } @@ -72,111 +79,135 @@ namespace LawFirm.Forms 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(FormLawComponent)); - if (service is FormLawComponent form) + var service = + Program.ServiceProvider?.GetService(typeof(FormDocumentComponent)); + if (service is FormDocumentComponent form) { - if (form.ShowDialog() == DialogResult.OK) + if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) { return; } - _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count); - if (_productComponents.ContainsKey(form.Id)) + _logger.LogInformation("Добавление нового компонента:{ ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count); + if (_documentComponents.ContainsKey(form.Id)) { - _productComponents[form.Id] = (form.ComponentModel, form.Count); + _documentComponents[form.Id] = (form.ComponentModel, + form.Count); } else { - _productComponents.Add(form.Id, (form.ComponentModel, form.Count)); + _documentComponents.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(FormLawComponent)); - if (service is FormLawComponent form) + var service = + Program.ServiceProvider?.GetService(typeof(FormDocumentComponent)); + if (service is FormDocumentComponent form) { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; - form.Count = _productComponents[id].Item2; + form.Count = _documentComponents[id].Item2; if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) { return; } - _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); - _productComponents[form.Id] = (form.ComponentModel, form.Count); + _logger.LogInformation("Изменение компонента:{ ComponentName - { Count}", form.ComponentModel.ComponentName, form.Count); + _documentComponents[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) + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { - _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); - _productComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _logger.LogInformation("Удаление компонента: { ComponentName} - { Count} ", dataGridView.SelectedRows[0].Cells[1].Value); + + _documentComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + 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); + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(textBoxPrice.Text)) { - MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); return; } - if (_productComponents == null || _productComponents.Count == 0) + if (_documentComponents == null || _documentComponents.Count == 0) { - MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните компоненты", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _logger.LogInformation("Сохранение изделия"); try { - var model = new LawBindingModel + var model = new DocumentBindingModel { Id = _id ?? 0, - LawName = textBoxName.Text, + DocumentName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - LawComponents = _productComponents + DocumentComponents = _documentComponents }; - var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; Close(); } catch (Exception ex) @@ -184,6 +215,7 @@ namespace LawFirm.Forms _logger.LogError(ex, "Ошибка сохранения изделия"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } + } private void buttonCancel_Click(object sender, EventArgs e) @@ -191,11 +223,10 @@ namespace LawFirm.Forms DialogResult = DialogResult.Cancel; Close(); } - private double CalcPrice() { double price = 0; - foreach (var elem in _productComponents) + foreach (var elem in _documentComponents) { price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); } diff --git a/LawFirm/LawFirm/FormDocument.resx b/LawFirm/LawFirm/FormDocument.resx new file mode 100644 index 0000000..a9dc853 --- /dev/null +++ b/LawFirm/LawFirm/FormDocument.resx @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/LawFirm/LawFirm/FormDocumentComponent.Designer.cs b/LawFirm/LawFirm/FormDocumentComponent.Designer.cs new file mode 100644 index 0000000..0fa5f66 --- /dev/null +++ b/LawFirm/LawFirm/FormDocumentComponent.Designer.cs @@ -0,0 +1,119 @@ +namespace LawFirmView +{ + partial class FormDocumentComponent + { + /// + /// 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.comboBoxComponent = new System.Windows.Forms.ComboBox(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // comboBoxComponent + // + this.comboBoxComponent.FormattingEnabled = true; + this.comboBoxComponent.Location = new System.Drawing.Point(93, 12); + this.comboBoxComponent.Name = "comboBoxComponent"; + this.comboBoxComponent.Size = new System.Drawing.Size(215, 23); + this.comboBoxComponent.TabIndex = 0; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(93, 50); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(146, 23); + this.textBoxCount.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(72, 15); + this.label1.TabIndex = 2; + this.label1.Text = "Компонент:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 50); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(75, 15); + this.label2.TabIndex = 3; + this.label2.Text = "Количество:"; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(164, 91); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + 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(259, 91); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // FormProductComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(384, 136); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxComponent); + this.Name = "FormProductComponent"; + this.Text = "Компонент пакета документов"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private ComboBox comboBoxComponent; + private TextBox textBoxCount; + private Label label1; + private Label label2; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormLawComponent.cs b/LawFirm/LawFirm/FormDocumentComponent.cs similarity index 82% rename from LawFirm/LawFirm/FormLawComponent.cs rename to LawFirm/LawFirm/FormDocumentComponent.cs index dfd53e9..368a261 100644 --- a/LawFirm/LawFirm/FormLawComponent.cs +++ b/LawFirm/LawFirm/FormDocumentComponent.cs @@ -11,16 +11,17 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace LawFirm.Forms +namespace LawFirmView { - public partial class FormLawComponent : Form + public partial class FormDocumentComponent : Form { private readonly List? _list; public int Id { get { - return Convert.ToInt32(comboBoxComponent.SelectedValue); + return + Convert.ToInt32(comboBoxComponent.SelectedValue); } set { @@ -48,13 +49,13 @@ namespace LawFirm.Forms public int Count { get { return Convert.ToInt32(textBoxCount.Text); } - set { textBoxCount.Text = value.ToString(); } + set + { textBoxCount.Text = value.ToString(); } } - public FormLawComponent(IComponentLogic logic) + public FormDocumentComponent(IComponentLogic logic) { InitializeComponent(); - _list = logic.ReadList(null); if (_list != null) { @@ -63,27 +64,32 @@ namespace LawFirm.Forms 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); + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (comboBoxComponent.SelectedValue == null) { - MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + 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/LawFirm/LawFirm/FormDocumentComponent.resx b/LawFirm/LawFirm/FormDocumentComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirm/FormDocumentComponent.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/LawFirm/LawFirm/FormDocuments.Designer.cs b/LawFirm/LawFirm/FormDocuments.Designer.cs new file mode 100644 index 0000000..40c7ac6 --- /dev/null +++ b/LawFirm/LawFirm/FormDocuments.Designer.cs @@ -0,0 +1,114 @@ +namespace LawFirmView +{ + partial class FormDocuments + { + /// + /// 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.buttonAdd = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(445, 420); + this.dataGridView.TabIndex = 0; + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(514, 22); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(95, 37); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(514, 80); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(95, 39); + this.buttonUpd.TabIndex = 2; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(514, 142); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(95, 40); + this.buttonDel.TabIndex = 3; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click); + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(514, 205); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(95, 39); + this.buttonRef.TabIndex = 4; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click); + // + // FormDocuments + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(669, 432); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.dataGridView); + this.Name = "FormDocuments"; + this.Text = "Пакеты документов"; + this.Load += new System.EventHandler(this.FormDocuments_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private Button buttonRef; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormLaws.cs b/LawFirm/LawFirm/FormDocuments.cs similarity index 69% rename from LawFirm/LawFirm/FormLaws.cs rename to LawFirm/LawFirm/FormDocuments.cs index cf1d546..6960e4f 100644 --- a/LawFirm/LawFirm/FormLaws.cs +++ b/LawFirm/LawFirm/FormDocuments.cs @@ -1,4 +1,8 @@ -using System; +using LawFirmContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using LawFirmContracts.BindingModels; +using Microsoft.VisualBasic.Logging; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -7,29 +11,24 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using LawFirm; -using LawFirmContracts.BindingModels; -using LawFirmContracts.BusinessLogicsContracts; -using Microsoft.Extensions.Logging; -namespace LawFirm.Forms +namespace LawFirmView { - public partial class FormLaws : Form + public partial class FormDocuments : Form { private readonly ILogger _logger; - private readonly ILawLogic _logic; - public FormLaws(ILogger logger, ILawLogic logic) + private readonly IDocumentLogic _logic; + public FormDocuments(ILogger logger, IDocumentLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - private void FormLaws_Load(object sender, EventArgs e) + private void FormDocuments_Load(object sender, EventArgs e) { LoadData(); } - private void LoadData() { try @@ -39,21 +38,24 @@ namespace LawFirm.Forms { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["LawComponents"].Visible = false; - dataGridView.Columns["LawName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["DocumentName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["DocumentComponents"].Visible = false; } - _logger.LogInformation("Загрузка консерв"); + _logger.LogInformation("Загрузка пакетов документов"); } catch (Exception ex) { - _logger.LogError(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(FormLaw)); - if (service is FormLaw form) + var service = Program.ServiceProvider?.GetService(typeof(FormDocument)); + if (service is FormDocument form) { if (form.ShowDialog() == DialogResult.OK) { @@ -66,8 +68,8 @@ namespace LawFirm.Forms { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormLaw)); - if (service is FormLaw form) + var service = Program.ServiceProvider?.GetService(typeof(FormDocument)); + if (service is FormDocument form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) @@ -84,12 +86,11 @@ namespace LawFirm.Forms { if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Удаление консервы"); + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление пакета документов"); try { - if (!_logic.Delete(new LawBindingModel + if (!_logic.Delete(new DocumentBindingModel { Id = id })) @@ -100,7 +101,7 @@ namespace LawFirm.Forms } catch (Exception ex) { - _logger.LogError(ex, "Ошибка удаления консервы"); + _logger.LogError(ex, "Ошибка удаления пакета документов"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/LawFirm/LawFirm/FormDocuments.resx b/LawFirm/LawFirm/FormDocuments.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirm/FormDocuments.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/LawFirm/LawFirm/FormLaw.Designer.cs b/LawFirm/LawFirm/FormLaw.Designer.cs deleted file mode 100644 index 9547954..0000000 --- a/LawFirm/LawFirm/FormLaw.Designer.cs +++ /dev/null @@ -1,235 +0,0 @@ -namespace LawFirm.Forms -{ - partial class FormLaw - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - label1 = new Label(); - label2 = new Label(); - buttonAdd = new Button(); - buttonUpd = new Button(); - buttonDel = new Button(); - buttonRef = new Button(); - dataGridView = new DataGridView(); - Number = new DataGridViewTextBoxColumn(); - Component = new DataGridViewTextBoxColumn(); - Count = new DataGridViewTextBoxColumn(); - textBoxName = new TextBox(); - textBoxPrice = new TextBox(); - groupBox1 = new GroupBox(); - buttonSave = new Button(); - buttonCancel = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - groupBox1.SuspendLayout(); - SuspendLayout(); - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(16, 15); - label1.Name = "label1"; - label1.Size = new Size(62, 15); - label1.TabIndex = 0; - label1.Text = "Название:"; - // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(16, 41); - label2.Name = "label2"; - label2.Size = new Size(70, 15); - label2.TabIndex = 1; - label2.Text = "Стоимость:"; - // - // buttonAdd - // - buttonAdd.Location = new Point(574, 44); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(97, 28); - buttonAdd.TabIndex = 0; - buttonAdd.Text = "Добавить"; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += buttonAdd_Click; - // - // buttonUpd - // - buttonUpd.Location = new Point(574, 90); - buttonUpd.Name = "buttonUpd"; - buttonUpd.Size = new Size(97, 28); - buttonUpd.TabIndex = 1; - buttonUpd.Text = "Изменить"; - buttonUpd.UseVisualStyleBackColor = true; - buttonUpd.Click += buttonUpd_Click; - // - // buttonDel - // - buttonDel.Location = new Point(574, 134); - buttonDel.Name = "buttonDel"; - buttonDel.Size = new Size(97, 28); - buttonDel.TabIndex = 2; - buttonDel.Text = "Удалить"; - buttonDel.UseVisualStyleBackColor = true; - buttonDel.Click += buttonDel_Click; - // - // buttonRef - // - buttonRef.Location = new Point(574, 173); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(97, 28); - buttonRef.TabIndex = 3; - buttonRef.Text = "Обновить"; - buttonRef.UseVisualStyleBackColor = true; - buttonRef.Click += buttonRef_Click; - // - // dataGridView - // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { Number, Component, Count }); - dataGridView.Location = new Point(0, 20); - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 24; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.ShowEditingIcon = false; - dataGridView.Size = new Size(549, 332); - dataGridView.TabIndex = 4; - // - // Number - // - Number.HeaderText = "Номер"; - Number.MinimumWidth = 6; - Number.Name = "Number"; - Number.ReadOnly = true; - Number.Width = 60; - // - // Component - // - Component.HeaderText = "Компонент"; - Component.MinimumWidth = 6; - Component.Name = "Component"; - Component.ReadOnly = true; - Component.Width = 125; - // - // Count - // - Count.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - Count.HeaderText = "Количество"; - Count.MinimumWidth = 6; - Count.Name = "Count"; - Count.ReadOnly = true; - // - // textBoxName - // - textBoxName.Location = new Point(94, 14); - textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(246, 23); - textBoxName.TabIndex = 3; - // - // textBoxPrice - // - textBoxPrice.Location = new Point(94, 39); - textBoxPrice.Name = "textBoxPrice"; - textBoxPrice.ReadOnly = true; - textBoxPrice.Size = new Size(85, 23); - textBoxPrice.TabIndex = 4; - textBoxPrice.TabStop = false; - // - // groupBox1 - // - groupBox1.Controls.Add(buttonRef); - groupBox1.Controls.Add(buttonDel); - groupBox1.Controls.Add(dataGridView); - groupBox1.Controls.Add(buttonUpd); - groupBox1.Controls.Add(buttonAdd); - groupBox1.Location = new Point(14, 71); - groupBox1.Name = "groupBox1"; - groupBox1.Size = new Size(689, 367); - groupBox1.TabIndex = 5; - groupBox1.TabStop = false; - groupBox1.Text = "Компоненты"; - // - // buttonSave - // - buttonSave.Location = new Point(397, 454); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(114, 28); - buttonSave.TabIndex = 0; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += buttonSave_Click; - // - // buttonCancel - // - buttonCancel.Location = new Point(533, 454); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(114, 28); - buttonCancel.TabIndex = 0; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += buttonCancel_Click; - // - // FormLaw - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(711, 497); - Controls.Add(groupBox1); - Controls.Add(textBoxPrice); - Controls.Add(textBoxName); - Controls.Add(label2); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(label1); - Name = "FormLaw"; - Text = "Пакет документов"; - Load += FormLaw_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - groupBox1.ResumeLayout(false); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Label label1; - private Label label2; - private Button buttonRef; - private Button buttonDel; - private Button buttonUpd; - private Button buttonAdd; - private DataGridView dataGridView; - private TextBox textBoxName; - private TextBox textBoxPrice; - private GroupBox groupBox1; - private DataGridViewTextBoxColumn Number; - private DataGridViewTextBoxColumn Component; - private DataGridViewTextBoxColumn Count; - private Button buttonSave; - private Button buttonCancel; - } -} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormLaw.resx b/LawFirm/LawFirm/FormLaw.resx deleted file mode 100644 index 5052aba..0000000 --- a/LawFirm/LawFirm/FormLaw.resx +++ /dev/null @@ -1,129 +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 - - - True - - - True - - - True - - \ No newline at end of file diff --git a/LawFirm/LawFirm/FormLawComponent.Designer.cs b/LawFirm/LawFirm/FormLawComponent.Designer.cs deleted file mode 100644 index d6c1f94..0000000 --- a/LawFirm/LawFirm/FormLawComponent.Designer.cs +++ /dev/null @@ -1,118 +0,0 @@ -namespace LawFirm.Forms -{ - partial class FormLawComponent - { - /// - /// 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() - { - buttonSave = new Button(); - buttonCancel = new Button(); - label1 = new Label(); - label2 = new Label(); - comboBoxComponent = new ComboBox(); - textBoxCount = new TextBox(); - SuspendLayout(); - // - // buttonSave - // - buttonSave.Location = new Point(174, 75); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(86, 27); - buttonSave.TabIndex = 0; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += buttonSave_Click; - // - // buttonCancel - // - buttonCancel.Location = new Point(270, 75); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(86, 27); - buttonCancel.TabIndex = 1; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += buttonCancel_Click; - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(12, 14); - label1.Name = "label1"; - label1.Size = new Size(72, 15); - label1.TabIndex = 2; - label1.Text = "Компонент:"; - // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(12, 44); - label2.Name = "label2"; - label2.Size = new Size(75, 15); - label2.TabIndex = 3; - label2.Text = "Количество:"; - // - // comboBoxComponent - // - comboBoxComponent.FormattingEnabled = true; - comboBoxComponent.Location = new Point(106, 9); - comboBoxComponent.Name = "comboBoxComponent"; - comboBoxComponent.Size = new Size(250, 23); - comboBoxComponent.TabIndex = 4; - // - // textBoxCount - // - textBoxCount.Location = new Point(106, 44); - textBoxCount.Name = "textBoxCount"; - textBoxCount.Size = new Size(250, 23); - textBoxCount.TabIndex = 5; - // - // FormLawComponent - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(373, 112); - Controls.Add(textBoxCount); - Controls.Add(comboBoxComponent); - Controls.Add(label2); - Controls.Add(label1); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Name = "FormLawComponent"; - Text = "Компонент пакета документов"; - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Button buttonSave; - private Button buttonCancel; - private Label label1; - private Label label2; - private ComboBox comboBoxComponent; - private TextBox textBoxCount; - } -} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormLawComponent.resx b/LawFirm/LawFirm/FormLawComponent.resx deleted file mode 100644 index af32865..0000000 --- a/LawFirm/LawFirm/FormLawComponent.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/LawFirm/LawFirm/FormLaws.Designer.cs b/LawFirm/LawFirm/FormLaws.Designer.cs deleted file mode 100644 index 85812a5..0000000 --- a/LawFirm/LawFirm/FormLaws.Designer.cs +++ /dev/null @@ -1,116 +0,0 @@ -namespace LawFirm.Forms -{ - partial class FormLaws - { - /// - /// 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() - { - buttonRef = new Button(); - buttonDel = new Button(); - buttonUpd = new Button(); - buttonAdd = new Button(); - dataGridView = new DataGridView(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // buttonRef - // - buttonRef.Location = new Point(648, 135); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(112, 26); - buttonRef.TabIndex = 9; - buttonRef.Text = "Обновить"; - buttonRef.UseVisualStyleBackColor = true; - buttonRef.Click += buttonRef_Click; - // - // buttonDel - // - buttonDel.Location = new Point(648, 97); - buttonDel.Name = "buttonDel"; - buttonDel.Size = new Size(112, 26); - buttonDel.TabIndex = 8; - buttonDel.Text = "Удалить"; - buttonDel.UseVisualStyleBackColor = true; - buttonDel.Click += buttonDel_Click; - // - // buttonUpd - // - buttonUpd.Location = new Point(648, 58); - buttonUpd.Name = "buttonUpd"; - buttonUpd.Size = new Size(112, 26); - buttonUpd.TabIndex = 7; - buttonUpd.Text = "Изменить"; - buttonUpd.UseVisualStyleBackColor = true; - buttonUpd.Click += buttonUpd_Click; - // - // buttonAdd - // - buttonAdd.Location = new Point(648, 20); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(112, 26); - buttonAdd.TabIndex = 6; - buttonAdd.Text = "Добавить"; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += buttonAdd_Click; - // - // dataGridView - // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(-1, 0); - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 24; - dataGridView.Size = new Size(620, 426); - dataGridView.TabIndex = 5; - // - // FormLaws - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(783, 428); - Controls.Add(buttonRef); - Controls.Add(buttonDel); - Controls.Add(buttonUpd); - Controls.Add(buttonAdd); - Controls.Add(dataGridView); - Margin = new Padding(3, 2, 3, 2); - Name = "FormLaws"; - Text = "Бланки документов"; - Load += FormLaws_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - } - - #endregion - - private Button buttonRef; - private Button buttonDel; - private Button buttonUpd; - private Button buttonAdd; - private DataGridView dataGridView; - } -} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormLaws.resx b/LawFirm/LawFirm/FormLaws.resx deleted file mode 100644 index af32865..0000000 --- a/LawFirm/LawFirm/FormLaws.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/LawFirm/LawFirm/FormMain.Designer.cs b/LawFirm/LawFirm/FormMain.Designer.cs index 2853cfb..a32ae7a 100644 --- a/LawFirm/LawFirm/FormMain.Designer.cs +++ b/LawFirm/LawFirm/FormMain.Designer.cs @@ -1,4 +1,4 @@ -namespace LawFirm.Forms +namespace LawFirmView { partial class FormMain { @@ -28,150 +28,170 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); - toolStrip1 = new ToolStrip(); - toolStripDropDownButton1 = new ToolStripDropDownButton(); - компонентыToolStripMenuItem = new ToolStripMenuItem(); - ПутёвкиToolStripMenuItem = new ToolStripMenuItem(); - buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); - buttonIssuedOrder = new Button(); - buttonRef = new Button(); - dataGridView = new DataGridView(); - toolStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.toolStripMenuItemCatalogs = new System.Windows.Forms.ToolStripMenuItem(); + this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.пакетыДокументовToolStripMenuItem = 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.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonSupplyShop = new System.Windows.Forms.Button(); + this.menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); // - // toolStrip1 + // menuStrip1 // - toolStrip1.ImageScalingSize = new Size(20, 20); - toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1 }); - toolStrip1.Location = new Point(0, 0); - toolStrip1.Name = "toolStrip1"; - toolStrip1.Size = new Size(969, 25); - toolStrip1.TabIndex = 0; - toolStrip1.Text = "toolStrip1"; + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemCatalogs}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(910, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "Справочники"; // - // toolStripDropDownButton1 + // toolStripMenuItemCatalogs // - toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text; - toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, ПутёвкиToolStripMenuItem }); - toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image"); - toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; - toolStripDropDownButton1.Name = "toolStripDropDownButton1"; - toolStripDropDownButton1.Size = new Size(88, 22); - toolStripDropDownButton1.Text = "Справочник"; + this.toolStripMenuItemCatalogs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.компонентыToolStripMenuItem, + this.пакетыДокументовToolStripMenuItem, + this.магазиныToolStripMenuItem}); + this.toolStripMenuItemCatalogs.Name = "toolStripMenuItemCatalogs"; + this.toolStripMenuItemCatalogs.Size = new System.Drawing.Size(94, 20); + this.toolStripMenuItemCatalogs.Text = "Справочники"; // // компонентыToolStripMenuItem // - компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(183, 22); - компонентыToolStripMenuItem.Text = "Бланки документов"; - компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; + this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; + this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.компонентыToolStripMenuItem.Text = "Компоненты"; + this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click); // - // ПутёвкиToolStripMenuItem + // пакетыДокументовToolStripMenuItem // - ПутёвкиToolStripMenuItem.Name = "ПутёвкиToolStripMenuItem"; - ПутёвкиToolStripMenuItem.Size = new Size(183, 22); - ПутёвкиToolStripMenuItem.Text = "Пакеты документов"; - ПутёвкиToolStripMenuItem.Click += консервыToolStripMenuItem_Click; - // - // buttonCreateOrder - // - buttonCreateOrder.Location = new Point(800, 56); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(141, 24); - buttonCreateOrder.TabIndex = 1; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = true; - buttonCreateOrder.Click += buttonCreateOrder_Click; - // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Location = new Point(800, 100); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(141, 24); - buttonTakeOrderInWork.TabIndex = 2; - buttonTakeOrderInWork.Text = "Отдать на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = true; - buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; - // - // buttonOrderReady - // - buttonOrderReady.Location = new Point(800, 142); - buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(141, 24); - buttonOrderReady.TabIndex = 3; - buttonOrderReady.Text = "Заказ готов"; - buttonOrderReady.UseVisualStyleBackColor = true; - buttonOrderReady.Click += buttonOrderReady_Click; - // - // buttonIssuedOrder - // - buttonIssuedOrder.Location = new Point(800, 181); - buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(141, 24); - buttonIssuedOrder.TabIndex = 4; - buttonIssuedOrder.Text = "Заказ выдан"; - buttonIssuedOrder.UseVisualStyleBackColor = true; - buttonIssuedOrder.Click += buttonIssuedOrder_Click; - // - // buttonRef - // - buttonRef.Location = new Point(800, 222); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(141, 24); - buttonRef.TabIndex = 5; - buttonRef.Text = "Обновить список"; - buttonRef.UseVisualStyleBackColor = true; - buttonRef.Click += buttonRef_Click; + this.пакетыДокументовToolStripMenuItem.Name = "пакетыДокументовToolStripMenuItem"; + this.пакетыДокументовToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.пакетыДокументовToolStripMenuItem.Text = "Пакеты документов"; + this.пакетыДокументовToolStripMenuItem.Click += new System.EventHandler(this.пакетыДокументовToolStripMenuItem_Click); // // dataGridView // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 26); - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 24; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(763, 435); - dataGridView.TabIndex = 6; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(0, 27); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(736, 411); + this.dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + this.buttonCreateOrder.Location = new System.Drawing.Point(742, 39); + this.buttonCreateOrder.Name = "buttonCreateOrder"; + this.buttonCreateOrder.Size = new System.Drawing.Size(156, 26); + 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(742, 71); + this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + this.buttonTakeOrderInWork.Size = new System.Drawing.Size(156, 23); + 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(742, 100); + this.buttonOrderReady.Name = "buttonOrderReady"; + this.buttonOrderReady.Size = new System.Drawing.Size(156, 23); + 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(742, 129); + this.buttonIssuedOrder.Name = "buttonIssuedOrder"; + this.buttonIssuedOrder.Size = new System.Drawing.Size(156, 23); + 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(742, 158); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(156, 23); + this.buttonRef.TabIndex = 6; + this.buttonRef.Text = "Обновить список"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click); + // + // магазиныToolStripMenuItem + // + this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; + this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.магазиныToolStripMenuItem.Text = "Магазины"; + this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click); + // + // buttonSupplyShop + // + this.buttonSupplyShop.Location = new System.Drawing.Point(742, 187); + this.buttonSupplyShop.Name = "buttonSupplyShop"; + this.buttonSupplyShop.Size = new System.Drawing.Size(156, 23); + this.buttonSupplyShop.TabIndex = 7; + this.buttonSupplyShop.Text = "Пополнение магазина"; + this.buttonSupplyShop.UseVisualStyleBackColor = true; + this.buttonSupplyShop.Click += new System.EventHandler(this.buttonSupplyShop_Click); // // FormMain // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(969, 461); - Controls.Add(dataGridView); - Controls.Add(buttonRef); - Controls.Add(buttonIssuedOrder); - Controls.Add(buttonOrderReady); - Controls.Add(buttonTakeOrderInWork); - Controls.Add(buttonCreateOrder); - Controls.Add(toolStrip1); - Name = "FormMain"; - Text = "Юридическая фирма"; - Load += FormMain_Load; - toolStrip1.ResumeLayout(false); - toolStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(910, 477); + this.Controls.Add(this.buttonSupplyShop); + 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.Name = "FormMain"; + this.Text = "FormMain"; + 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 ToolStrip toolStrip1; + private MenuStrip menuStrip1; + private ToolStripMenuItem toolStripMenuItemCatalogs; + private ToolStripMenuItem компонентыToolStripMenuItem; + private ToolStripMenuItem пакетыДокументовToolStripMenuItem; + private DataGridView dataGridView; private Button buttonCreateOrder; private Button buttonTakeOrderInWork; private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonRef; - private DataGridView dataGridView; - private ToolStripDropDownButton toolStripDropDownButton1; - private ToolStripMenuItem компонентыToolStripMenuItem; - private ToolStripMenuItem ПутёвкиToolStripMenuItem; + private ToolStripMenuItem магазиныToolStripMenuItem; + private Button buttonSupplyShop; } } \ No newline at end of file diff --git a/LawFirm/LawFirm/FormMain.cs b/LawFirm/LawFirm/FormMain.cs index 1f35414..bcfbaf6 100644 --- a/LawFirm/LawFirm/FormMain.cs +++ b/LawFirm/LawFirm/FormMain.cs @@ -1,5 +1,6 @@ using LawFirmContracts.BindingModels; using LawFirmContracts.BusinessLogicsContracts; +using LawFirmDataModels.Enums; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -11,7 +12,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace LawFirm.Forms +namespace LawFirmView { public partial class FormMain : Form { @@ -23,6 +24,7 @@ namespace LawFirm.Forms _logger = logger; _orderLogic = orderLogic; } + private void FormMain_Load(object sender, EventArgs e) { LoadData(); @@ -33,21 +35,21 @@ namespace LawFirm.Forms try { var list = _orderLogic.ReadList(null); - if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["LawId"].Visible = false; - dataGridView.Columns["LawName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["DocumentId"].Visible = false; + dataGridView.Columns["DocumentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } - _logger.LogInformation("Загрузка заказов"); } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + private void компонентыToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); @@ -55,16 +57,18 @@ namespace LawFirm.Forms { form.ShowDialog(); } - } - private void консервыToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormLaws)); - if (service is FormLaws form) + } + + private void пакетыДокументовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormDocuments)); + if (service is FormDocuments form) { form.ShowDialog(); } } + private void buttonCreateOrder_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); @@ -73,19 +77,19 @@ namespace LawFirm.Forms 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); + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); try { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel - { - Id = id, - }); + var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id)); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -95,20 +99,24 @@ namespace LawFirm.Forms catch (Exception ex) { _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + 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("Заказ №{id}. Меняется статус на 'Готов'", id); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", + id); try { - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); + var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id)); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -118,22 +126,23 @@ namespace LawFirm.Forms catch (Exception ex) { _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + 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("Заказ №{id}. Меняется статус на 'Выдан'", id); + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", + id); try { - var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel - { - Id = id - }); + var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id)); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -143,13 +152,47 @@ namespace LawFirm.Forms } catch (Exception ex) { - _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } + } + private void buttonRef_Click(object sender, EventArgs e) { LoadData(); } + private OrderBindingModel CreateBindingModel(int id, bool isDone = false) + { + return new OrderBindingModel + { + Id = id, + DocumentId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DocumentId"].Value), + 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()), + }; + } + + private void buttonSupplyShop_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShopSupply)); + if (service is FormShopSupply form) + { + form.ShowDialog(); + } + } + + private void магазиныToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) + { + form.ShowDialog(); + } + } } } diff --git a/LawFirm/LawFirm/FormMain.resx b/LawFirm/LawFirm/FormMain.resx index e226a59..05252e7 100644 --- a/LawFirm/LawFirm/FormMain.resx +++ b/LawFirm/LawFirm/FormMain.resx @@ -1,64 +1,4 @@ - - - + @@ -117,26 +57,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG - YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 - 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw - bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc - VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 - c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 - Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo - mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ - kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D - TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - - 56 + 25 \ No newline at end of file diff --git a/LawFirm/LawFirm/FormShop.Designer.cs b/LawFirm/LawFirm/FormShop.Designer.cs new file mode 100644 index 0000000..7eecfa1 --- /dev/null +++ b/LawFirm/LawFirm/FormShop.Designer.cs @@ -0,0 +1,182 @@ +namespace LawFirmView +{ + partial class FormShop + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxAddress = new System.Windows.Forms.TextBox(); + this.dateTimePicker = new System.Windows.Forms.DateTimePicker(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(122, 12); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(200, 23); + this.textBoxName.TabIndex = 0; + // + // textBoxAddress + // + this.textBoxAddress.Location = new System.Drawing.Point(122, 41); + this.textBoxAddress.Name = "textBoxAddress"; + this.textBoxAddress.Size = new System.Drawing.Size(200, 23); + this.textBoxAddress.TabIndex = 1; + // + // dateTimePicker + // + this.dateTimePicker.Location = new System.Drawing.Point(122, 70); + this.dateTimePicker.Name = "dateTimePicker"; + this.dateTimePicker.Size = new System.Drawing.Size(200, 23); + this.dateTimePicker.TabIndex = 2; + // + // dataGridView + // + 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.Column1, + this.Column2, + this.Column3}); + this.dataGridView.Location = new System.Drawing.Point(12, 99); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(536, 245); + this.dataGridView.TabIndex = 3; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(347, 371); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + 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(445, 371); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(42, 15); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(62, 15); + this.label1.TabIndex = 6; + this.label1.Text = "Название:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(52, 44); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(43, 15); + this.label2.TabIndex = 7; + this.label2.Text = "Адрес:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(26, 76); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(90, 15); + this.label3.TabIndex = 8; + this.label3.Text = "Дата открытия:"; + // + // Column1 + // + this.Column1.HeaderText = "id"; + this.Column1.Name = "Column1"; + this.Column1.Visible = false; + // + // Column2 + // + this.Column2.HeaderText = "Название пакета документов"; + this.Column2.Name = "Column2"; + // + // Column3 + // + this.Column3.HeaderText = "Количество"; + this.Column3.Name = "Column3"; + // + // FormShop + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(560, 418); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.dateTimePicker); + this.Controls.Add(this.textBoxAddress); + this.Controls.Add(this.textBoxName); + this.Name = "FormShop"; + this.Text = "FormShop"; + this.Load += new System.EventHandler(this.FormShop_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxName; + private TextBox textBoxAddress; + private DateTimePicker dateTimePicker; + private DataGridView dataGridView; + private Button buttonSave; + private Button buttonCancel; + private Label label1; + private Label label2; + private Label label3; + private DataGridViewTextBoxColumn Column1; + private DataGridViewTextBoxColumn Column2; + private DataGridViewTextBoxColumn Column3; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormShop.cs b/LawFirm/LawFirm/FormShop.cs new file mode 100644 index 0000000..c746916 --- /dev/null +++ b/LawFirm/LawFirm/FormShop.cs @@ -0,0 +1,134 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using LawFirmDataModels.Models; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LawFirmView +{ + public partial class FormShop : Form + { + private readonly IShopLogic _logic; + private readonly ILogger _logger; + private Dictionary _shopDocuments; + private int? _id; + public int Id { set { _id = value; } } + public FormShop(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _shopDocuments = new(); + } + + private void FormShop_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка магазина"); + try + { + var view = _logic.ReadElement(new ShopSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ShopName; + textBoxAddress.Text = view.Address; + dateTimePicker.Value = view.OpeningDate; + _shopDocuments = view.ShopDocuments ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка документов магазина"); + try + { + if (_shopDocuments != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _shopDocuments) + { + dataGridView.Rows.Add(new object[] + { + pc.Key, + pc.Value.Item1.DocumentName, + pc.Value.Item2 + } + ); + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки документов магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxAddress.Text)) + { + MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение магазина"); + try + { + var model = new ShopBindingModel + { + Id = _id ?? 0, + ShopName = textBoxName.Text, + Address = textBoxAddress.Text, + OpeningDate = dateTimePicker.Value.Date, + ShopDocuments = _shopDocuments + }; + 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/LawFirm/LawFirm/FormShop.resx b/LawFirm/LawFirm/FormShop.resx new file mode 100644 index 0000000..cdfa6a5 --- /dev/null +++ b/LawFirm/LawFirm/FormShop.resx @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/LawFirm/LawFirm/FormShopSupply.Designer.cs b/LawFirm/LawFirm/FormShopSupply.Designer.cs new file mode 100644 index 0000000..5f31857 --- /dev/null +++ b/LawFirm/LawFirm/FormShopSupply.Designer.cs @@ -0,0 +1,143 @@ +namespace LawFirmView +{ + partial class FormShopSupply + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.comboBoxShop = new System.Windows.Forms.ComboBox(); + this.comboBoxDocument = new System.Windows.Forms.ComboBox(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // comboBoxShop + // + this.comboBoxShop.FormattingEnabled = true; + this.comboBoxShop.Location = new System.Drawing.Point(98, 12); + this.comboBoxShop.Name = "comboBoxShop"; + this.comboBoxShop.Size = new System.Drawing.Size(213, 23); + this.comboBoxShop.TabIndex = 0; + // + // comboBoxDocument + // + this.comboBoxDocument.FormattingEnabled = true; + this.comboBoxDocument.Location = new System.Drawing.Point(98, 41); + this.comboBoxDocument.Name = "comboBoxDocument"; + this.comboBoxDocument.Size = new System.Drawing.Size(213, 23); + this.comboBoxDocument.TabIndex = 1; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(98, 70); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(213, 23); + this.textBoxCount.TabIndex = 2; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(98, 122); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + this.buttonSave.TabIndex = 3; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(221, 122); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(21, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(66, 15); + this.label1.TabIndex = 5; + this.label1.Text = "Магазины:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(14, 44); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(73, 15); + this.label2.TabIndex = 6; + this.label2.Text = "Документы:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(14, 73); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(75, 15); + this.label3.TabIndex = 7; + this.label3.Text = "Количество:"; + // + // FormShopSupply + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(358, 159); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxDocument); + this.Controls.Add(this.comboBoxShop); + this.Name = "FormShopSupply"; + this.Text = "FormShopSupply"; + this.Load += new System.EventHandler(this.FormShopSupply_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private ComboBox comboBoxShop; + private ComboBox comboBoxDocument; + private TextBox textBoxCount; + private Button buttonSave; + private Button buttonCancel; + private Label label1; + private Label label2; + private Label label3; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormShopSupply.cs b/LawFirm/LawFirm/FormShopSupply.cs new file mode 100644 index 0000000..e21728a --- /dev/null +++ b/LawFirm/LawFirm/FormShopSupply.cs @@ -0,0 +1,125 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LawFirmView +{ + public partial class FormShopSupply : Form + { + private readonly ILogger _logger; + private readonly IDocumentLogic _logicD; + private readonly IShopLogic _logicS; + public FormShopSupply(ILogger logger, IDocumentLogic logicD, IShopLogic logicS) + { + InitializeComponent(); + _logger = logger; + _logicD = logicD; + _logicS = logicS; + } + + private void FormShopSupply_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка документов для пополнения"); + try + { + var list = _logicD.ReadList(null); + if (list != null) + { + comboBoxDocument.DisplayMember = "DocumentName"; + comboBoxDocument.ValueMember = "Id"; + comboBoxDocument.DataSource = list; + comboBoxDocument.SelectedItem = null; + } + + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка документов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + _logger.LogInformation("Загрузка магазинов для пополнения"); + try + { + var list = _logicS.ReadList(null); + if (list != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = list; + comboBoxShop.SelectedItem = null; + } + + } + 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(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxDocument.SelectedValue == null) + { + MessageBox.Show("Выберите документ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание поставки"); + try + { + var operationResult = _logicS.SupplyDocuments( + new ShopSearchModel + { + Id = Convert.ToInt32(comboBoxShop.SelectedValue), + ShopName = comboBoxShop.Text + }, + new DocumentBindingModel + { + Id = Convert.ToInt32(comboBoxDocument.SelectedValue), + DocumentName = comboBoxDocument.Text + }, + Convert.ToInt32(textBoxCount.Text) + ); + if (!operationResult) + { + throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания поставки"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/LawFirm/LawFirm/FormShopSupply.resx b/LawFirm/LawFirm/FormShopSupply.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirm/FormShopSupply.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/LawFirm/LawFirm/FormShops.Designer.cs b/LawFirm/LawFirm/FormShops.Designer.cs new file mode 100644 index 0000000..c314196 --- /dev/null +++ b/LawFirm/LawFirm/FormShops.Designer.cs @@ -0,0 +1,114 @@ +namespace LawFirmView +{ + partial class FormShops + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(450, 21); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(75, 23); + this.buttonAdd.TabIndex = 0; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(450, 62); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(75, 23); + this.buttonUpd.TabIndex = 1; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(450, 104); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(75, 23); + this.buttonDel.TabIndex = 2; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click); + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(450, 143); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(75, 23); + this.buttonRef.TabIndex = 3; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(428, 368); + this.dataGridView.TabIndex = 4; + // + // FormShops + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(558, 380); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Name = "FormShops"; + this.Text = "FormShops"; + this.Load += new System.EventHandler(this.FormShops_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private Button buttonRef; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormShops.cs b/LawFirm/LawFirm/FormShops.cs new file mode 100644 index 0000000..021f250 --- /dev/null +++ b/LawFirm/LawFirm/FormShops.cs @@ -0,0 +1,122 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LawFirmView +{ + public partial class FormShops : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + public FormShops(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + + if (service is FormShop form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void buttonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + + if (service is FormShop form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить магазин?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление магазина"); + + try + { + if (!_logic.Delete(new ShopBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void buttonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + + private void FormShops_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ShopDocuments"].Visible = false; + } + + _logger.LogInformation("Загрузка магазинов"); + + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазинов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + } +} diff --git a/LawFirm/LawFirm/FormShops.resx b/LawFirm/LawFirm/FormShops.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirm/FormShops.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/LawFirm/LawFirm/Program.cs b/LawFirm/LawFirm/Program.cs index 8fd5f1a..33bc432 100644 --- a/LawFirm/LawFirm/Program.cs +++ b/LawFirm/LawFirm/Program.cs @@ -1,13 +1,13 @@ -using LawFirm.Forms; -using LawFirmContracts.BusinessLogicsContracts; using LawFirmBusinessLogic.BusinessLogic; +using LawFirmContracts.BusinessLogicsContracts; using LawFirmContracts.StoragesContracts; using LawFirmListImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; +using System; -namespace LawFirm +namespace LawFirmView { internal static class Program { @@ -25,7 +25,6 @@ namespace LawFirm var services = new ServiceCollection(); ConfigureServices(services); _serviceProvider = services.BuildServiceProvider(); - Application.Run(_serviceProvider.GetRequiredService()); } private static void ConfigureServices(ServiceCollection services) @@ -37,17 +36,23 @@ namespace LawFirm }); 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(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } + } } \ No newline at end of file diff --git a/LawFirm/LawFirm/nlog.config b/LawFirm/LawFirm/nlog.config deleted file mode 100644 index af70d20..0000000 --- a/LawFirm/LawFirm/nlog.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogic/ComponentLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogic/ComponentLogic.cs index 4b6062e..c8570d4 100644 --- a/LawFirm/LawFirmBusinessLogic/BusinessLogic/ComponentLogic.cs +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogic/ComponentLogic.cs @@ -1,9 +1,14 @@ -using LawFirmContracts.BindingModels; +using LawFirmContracts.BindingModels.BindingModels; using LawFirmContracts.BusinessLogicsContracts; using LawFirmContracts.SearchModels; using LawFirmContracts.StoragesContracts; using LawFirmContracts.ViewModels; using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace LawFirmBusinessLogic.BusinessLogic { @@ -19,7 +24,7 @@ namespace LawFirmBusinessLogic.BusinessLogic } public List? ReadList(ComponentSearchModel? model) { - _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{Id}", model?.ComponentName, model?.Id); + _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id); var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model); if (list == null) { @@ -29,14 +34,13 @@ namespace LawFirmBusinessLogic.BusinessLogic _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); + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id); var element = _componentStorage.GetElement(model); if (element == null) { @@ -46,7 +50,6 @@ namespace LawFirmBusinessLogic.BusinessLogic _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); return element; } - public bool Create(ComponentBindingModel model) { CheckModel(model); @@ -57,7 +60,6 @@ namespace LawFirmBusinessLogic.BusinessLogic } return true; } - public bool Update(ComponentBindingModel model) { CheckModel(model); @@ -68,7 +70,6 @@ namespace LawFirmBusinessLogic.BusinessLogic } return true; } - public bool Delete(ComponentBindingModel model) { CheckModel(model, false); @@ -80,8 +81,8 @@ namespace LawFirmBusinessLogic.BusinessLogic } return true; } - - private void CheckModel(ComponentBindingModel model, bool withParams = true) + private void CheckModel(ComponentBindingModel model, bool withParams = + true) { if (model == null) { @@ -93,21 +94,23 @@ namespace LawFirmBusinessLogic.BusinessLogic } if (string.IsNullOrEmpty(model.ComponentName)) { - throw new ArgumentNullException("Нет названия компонента", nameof(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 + _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel { - ComponentName = model.ComponentName + ComponentName = model.ComponentName }); if (element != null && element.Id != model.Id) { throw new InvalidOperationException("Компонент с таким названием уже есть"); } } + } -} \ No newline at end of file +} diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogic/LawLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogic/DocumentLogic.cs similarity index 54% rename from LawFirm/LawFirmBusinessLogic/BusinessLogic/LawLogic.cs rename to LawFirm/LawFirmBusinessLogic/BusinessLogic/DocumentLogic.cs index 3b734e7..8776870 100644 --- a/LawFirm/LawFirmBusinessLogic/BusinessLogic/LawLogic.cs +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogic/DocumentLogic.cs @@ -12,20 +12,20 @@ using System.Threading.Tasks; namespace LawFirmBusinessLogic.BusinessLogic { - public class LawLogic : ILawLogic + public class DocumentLogic : IDocumentLogic { private readonly ILogger _logger; - private readonly ILawStorage _LawStorage; - public LawLogic(ILogger logger, ILawStorage - LawStorage) + private readonly IDocumentStorage _documentStorage; + public DocumentLogic(ILogger logger, IDocumentStorage + documentStorage) { _logger = logger; - _LawStorage = LawStorage; + _documentStorage = documentStorage; } - public List? ReadList(LawSearchModel? model) + public List? ReadList(DocumentSearchModel? model) { - _logger.LogInformation("ReadList. LawName:{LawName}.Id:{Id}", model?.LawName, model?.Id); - var list = model == null ? _LawStorage.GetFullList() : _LawStorage.GetFilteredList(model); + _logger.LogInformation("ReadList. DocumentName:{DocumentName}.Id:{ Id}", model?.DocumentName, model?.Id); + var list = model == null ? _documentStorage.GetFullList() : _documentStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -34,15 +34,14 @@ namespace LawFirmBusinessLogic.BusinessLogic _logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; } - - public LawViewModel? ReadElement(LawSearchModel model) + public DocumentViewModel? ReadElement(DocumentSearchModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. LawName:{LawName}.Id:{Id}", model.LawName, model.Id); - var element = _LawStorage.GetElement(model); + _logger.LogInformation("ReadElement. DocumentName:{DocumentName}.Id:{ Id}", model.DocumentName, model.Id); + var element = _documentStorage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement element not found"); @@ -51,42 +50,38 @@ namespace LawFirmBusinessLogic.BusinessLogic _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); return element; } - - public bool Create(LawBindingModel model) + public bool Create(DocumentBindingModel model) { CheckModel(model); - if (_LawStorage.Insert(model) == null) + if (_documentStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; } return true; } - - public bool Update(LawBindingModel model) + public bool Update(DocumentBindingModel model) { CheckModel(model); - if (_LawStorage.Update(model) == null) + if (_documentStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); return false; } return true; } - - public bool Delete(LawBindingModel model) + public bool Delete(DocumentBindingModel model) { CheckModel(model, false); _logger.LogInformation("Delete. Id:{Id}", model.Id); - if (_LawStorage.Delete(model) == null) + if (_documentStorage.Delete(model) == null) { _logger.LogWarning("Delete operation failed"); return false; } return true; } - - private void CheckModel(LawBindingModel model, bool withParams = true) + private void CheckModel(DocumentBindingModel model, bool withParams = true) { if (model == null) { @@ -96,22 +91,23 @@ namespace LawFirmBusinessLogic.BusinessLogic { return; } - if (string.IsNullOrEmpty(model.LawName)) + if (string.IsNullOrEmpty(model.DocumentName)) { - throw new ArgumentNullException("Нет названия изделия", nameof(model.LawName)); + throw new ArgumentNullException("Нет названия пакета документов", + nameof(model.DocumentName)); } if (model.Price <= 0) { - throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price)); + throw new ArgumentNullException("Цена пакета документов должна быть больше 0", nameof(model.Price)); } - _logger.LogInformation("Law. LawName:{LawName}.Price:{Cost}. Id: {Id}", model.LawName, model.Price, model.Id); - var element = _LawStorage.GetElement(new LawSearchModel + _logger.LogInformation("Document. DocumentName:{DocumentName}.Cost:{ Cost}. Id: { Id}", model.DocumentName, model.Price, model.Id); + var element = _documentStorage.GetElement(new DocumentSearchModel { - LawName = model.LawName + DocumentName = model.DocumentName }); if (element != null && element.Id != model.Id) { - throw new InvalidOperationException("Изделие с таким названием уже есть"); + throw new InvalidOperationException("Пакет документов с таким названием уже есть"); } } } diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogic/OrderLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogic/OrderLogic.cs index e7a5ee9..049f29a 100644 --- a/LawFirm/LawFirmBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogic/OrderLogic.cs @@ -15,10 +15,6 @@ namespace LawFirmBusinessLogic.BusinessLogic { public class OrderLogic : IOrderLogic { - //Класс с логикой для заказов будет отвечать за получение списка заказов, - //создания заказа и смены его статусов. Следует учитывать, что у заказа можно - //менять статус на новый, если его текущий статус предшествует новому - private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; @@ -30,8 +26,9 @@ namespace LawFirmBusinessLogic.BusinessLogic public List? ReadList(OrderSearchModel? model) { - _logger.LogInformation("ReadList. OrderId:{Id}", model?.Id); - var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + _logger.LogInformation("ReadList. Id:{ Id}", model?.Id); + var list = model == null ? _orderStorage.GetFullList() : + _orderStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -44,76 +41,53 @@ namespace LawFirmBusinessLogic.BusinessLogic public bool CreateOrder(OrderBindingModel model) { CheckModel(model); - - if (model.Status != OrderStatus.Неизвестен) - return false; + if (model.Status != OrderStatus.Неизвестен) return false; model.Status = OrderStatus.Принят; - if (_orderStorage.Insert(model) == null) { - model.Status = OrderStatus.Неизвестен; _logger.LogWarning("Insert operation failed"); return false; } return true; } + public bool ChangeStatus(OrderBindingModel model, OrderStatus status) + { + CheckModel(model); + var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); + if (element == null) + { + _logger.LogWarning("Read operation failed"); + return false; + } + if (element.Status != status - 1) + { + _logger.LogWarning("Status change operation failed"); + throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный"); + } + model.Status = status; + if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; + _orderStorage.Update(model); + return true; + } + public bool TakeOrderInWork(OrderBindingModel model) { - return ToNextStatus(model, OrderStatus.Выполняется); + return ChangeStatus(model, OrderStatus.Выполняется); } public bool FinishOrder(OrderBindingModel model) { - return ToNextStatus(model, OrderStatus.Готов); + return ChangeStatus(model, OrderStatus.Готов); } public bool DeliveryOrder(OrderBindingModel model) { - return ToNextStatus(model, OrderStatus.Выдан); + return ChangeStatus(model, OrderStatus.Выдан); } - public bool ToNextStatus(OrderBindingModel model, OrderStatus orderStatus) - { - CheckModel(model, false); - var element = _orderStorage.GetElement(new OrderSearchModel() - { - Id = model.Id - }); - if (element == null) - { - throw new ArgumentNullException(nameof(element)); - } - - model.LawId = element.LawId; - model.DateCreate = element.DateCreate; - model.DateImplement = element.DateImplement; - model.Status = element.Status; - model.Count = element.Count; - model.Sum = element.Sum; - - if (model.Status != orderStatus - 1) - { - _logger.LogWarning("Status update to " + orderStatus + " operation failed"); - return false; - } - model.Status = orderStatus; - - if (model.Status == OrderStatus.Выдан) - { - model.DateImplement = DateTime.Now; - } - - if (_orderStorage.Update(model) == null) - { - model.Status--; - _logger.LogWarning("Changing status operation faled"); - return false; - } - return true; - } - - private void CheckModel(OrderBindingModel model, bool withParams = true) + private void CheckModel(OrderBindingModel model, bool withParams = +true) { if (model == null) { @@ -123,19 +97,15 @@ namespace LawFirmBusinessLogic.BusinessLogic { return; } - if (model.Count <= 0) - { - throw new ArgumentNullException("Количество изделий должно быть больше 0", nameof(model.Count)); - } if (model.Sum <= 0) { throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum)); } - if (model.DateImplement.HasValue && model.DateImplement < model.DateCreate) + if (model.Count <= 0) { - throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} должна быть позже даты его создания {model.DateCreate}"); + throw new ArgumentNullException("Количество элементов в заказе должно быть больше 0", nameof(model.Count)); } - _logger.LogInformation("Law. LawId:{LawId}.Count:{Count}.Sum:{Sum}Id:{Id}", model.LawId, model.Count, model.Sum, model.Id); + _logger.LogInformation("Order. Sum:{ Cost}. Id: { Id}", model.Sum, model.Id); } } } diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogic/ShopLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogic/ShopLogic.cs new file mode 100644 index 0000000..7adc3c0 --- /dev/null +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogic/ShopLogic.cs @@ -0,0 +1,162 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmBusinessLogic.BusinessLogic +{ + public class ShopLogic : IShopLogic + { + private readonly ILogger _logger; + + private readonly IShopStorage _shopStorage; + public ShopLogic(ILogger logger, IShopStorage shopStorage) + { + _logger = logger; + _shopStorage = shopStorage; + } + public List? ReadList(ShopSearchModel? model) + { + _logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id}", model?.ShopName, model?.Id); + + var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ShopViewModel? ReadElement(ShopSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id); + + var element = _shopStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(ShopBindingModel model) + { + CheckModel(model); + + if (_shopStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ShopBindingModel model) + { + CheckModel(model); + + if (_shopStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ShopBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + + if (_shopStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + public bool SupplyDocuments(ShopSearchModel model, IDocumentModel document, int count) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + if (count <= 0) + { + throw new ArgumentException("Количество изделий должно быть больше 0", nameof(count)); + } + _logger.LogInformation("AddPlaneInShop. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id); + var element = _shopStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("AddPlaneInShop element not found"); + return false; + } + _logger.LogInformation("AddPlaneInShop find. Id:{Id}", element.Id); + + if (element.ShopDocuments.TryGetValue(document.Id, out var pair)) + { + element.ShopDocuments[document.Id] = (document, count + pair.Item2); + _logger.LogInformation("AddPlaneInShop. Added {count} {plane} to '{ShopName}' shop", count, document.DocumentName, element.ShopName); + } + else + { + element.ShopDocuments[document.Id] = (document, count); + _logger.LogInformation("AddPlaneInShop. Added {count} new plane {plane} to '{ShopName}' shop", count,document.DocumentName, element.ShopName); + } + + _shopStorage.Update(new() + { + Id = element.Id, + Address = element.Address, + ShopName = element.ShopName, + OpeningDate = element.OpeningDate, + ShopDocuments = element.ShopDocuments + }); + return true; + } + private void CheckModel(ShopBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ShopName)) + { + throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName)); + } + _logger.LogInformation("Shop. ShopName:{ShopName}.Address:{ Address}. Id:{ Id}", model.ShopName, model.Address, model.Id); + var element = _shopStorage.GetElement(new ShopSearchModel + { + ShopName = model.ShopName + }); + if (element != null && element.Id != model.Id && element.ShopName == model.ShopName) + { + throw new InvalidOperationException("Магазин с таким названием уже есть"); + } + } + } +} diff --git a/LawFirm/LawFirmContracts/BindingModels/ComponentBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/ComponentBindingModel.cs index 45fadc4..f228855 100644 --- a/LawFirm/LawFirmContracts/BindingModels/ComponentBindingModel.cs +++ b/LawFirm/LawFirmContracts/BindingModels/ComponentBindingModel.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace LawFirmContracts.BindingModels +namespace LawFirmContracts.BindingModels.BindingModels { public class ComponentBindingModel : IComponentModel { diff --git a/LawFirm/LawFirmContracts/BindingModels/LawBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/DocumentBindingModel.cs similarity index 56% rename from LawFirm/LawFirmContracts/BindingModels/LawBindingModel.cs rename to LawFirm/LawFirmContracts/BindingModels/DocumentBindingModel.cs index 880a232..6e1c7bb 100644 --- a/LawFirm/LawFirmContracts/BindingModels/LawBindingModel.cs +++ b/LawFirm/LawFirmContracts/BindingModels/DocumentBindingModel.cs @@ -7,11 +7,11 @@ using System.Threading.Tasks; namespace LawFirmContracts.BindingModels { - public class LawBindingModel : ILawModel + public class DocumentBindingModel : IDocumentModel { public int Id { get; set; } - public string LawName { get; set; } = string.Empty; + public string DocumentName { get; set; } = string.Empty; public double Price { get; set; } - public Dictionary LawComponents { get; set; } = new(); + public Dictionary DocumentComponents { get; set; } = new(); } } diff --git a/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs index 72d5fde..6390494 100644 --- a/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs +++ b/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs @@ -11,9 +11,9 @@ namespace LawFirmContracts.BindingModels public class OrderBindingModel : IOrderModel { public int Id { get; set; } - public int LawId { get; set; } + public int DocumentId { get; set; } public int Count { get; set; } - public double Sum { get; set; } + public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateImplement { get; set; } diff --git a/LawFirm/LawFirmContracts/BindingModels/ShopBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/ShopBindingModel.cs new file mode 100644 index 0000000..3fab584 --- /dev/null +++ b/LawFirm/LawFirmContracts/BindingModels/ShopBindingModel.cs @@ -0,0 +1,26 @@ +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.BindingModels +{ + public class ShopBindingModel : IShopModel + { + public int Id { get; set; } + + public string ShopName { get; set; } = string.Empty; + + public string Address { get; set; } = string.Empty; + + public DateTime OpeningDate { get; set; } = DateTime.Now; + + public Dictionary ShopDocuments + { + get; + set; + } = new(); + } +} diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IComponentLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IComponentLogic.cs index 32fd504..9eb0bcf 100644 --- a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IComponentLogic.cs +++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -1,9 +1,8 @@ -using LawFirmContracts.BindingModels; +using LawFirmContracts.BindingModels.BindingModels; using LawFirmContracts.SearchModels; using LawFirmContracts.ViewModels; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs new file mode 100644 index 0000000..aaf409e --- /dev/null +++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs @@ -0,0 +1,20 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.BusinessLogicsContracts +{ + public interface IDocumentLogic + { + List? ReadList(DocumentSearchModel? model); + DocumentViewModel? ReadElement(DocumentSearchModel model); + bool Create(DocumentBindingModel model); + bool Update(DocumentBindingModel model); + bool Delete(DocumentBindingModel model); + } +} diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/ILawLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/ILawLogic.cs deleted file mode 100644 index 5a14877..0000000 --- a/LawFirm/LawFirmContracts/BusinessLogicsContracts/ILawLogic.cs +++ /dev/null @@ -1,20 +0,0 @@ -using LawFirmContracts.BindingModels; -using LawFirmContracts.SearchModels; -using LawFirmContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace LawFirmContracts.BusinessLogicsContracts -{ - public interface ILawLogic - { - List? ReadList(LawSearchModel? model); - LawViewModel? ReadElement(LawSearchModel model); - bool Create(LawBindingModel model); - bool Update(LawBindingModel model); - bool Delete(LawBindingModel model); - } -} diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs index 03b0a48..d6a638b 100644 --- a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -14,17 +14,7 @@ namespace LawFirmContracts.BusinessLogicsContracts List? ReadList(OrderSearchModel? model); bool CreateOrder(OrderBindingModel model); bool TakeOrderInWork(OrderBindingModel model); - /// - /// Готов - /// - /// - /// bool FinishOrder(OrderBindingModel model); - /// - /// Доставлен - /// - /// - /// bool DeliveryOrder(OrderBindingModel model); } } diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IShopLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IShopLogic.cs new file mode 100644 index 0000000..8b2cbd2 --- /dev/null +++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IShopLogic.cs @@ -0,0 +1,22 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.BusinessLogicsContracts +{ + public interface IShopLogic + { + List? ReadList(ShopSearchModel? model); + ShopViewModel? ReadElement(ShopSearchModel model); + bool Create(ShopBindingModel model); + bool Update(ShopBindingModel model); + bool Delete(ShopBindingModel model); + bool SupplyDocuments(ShopSearchModel model, IDocumentModel document, int count); + } +} diff --git a/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs new file mode 100644 index 0000000..c556131 --- /dev/null +++ b/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.SearchModels +{ + public class DocumentSearchModel + { + public int? Id { get; set; } + public string? DocumentName { get; set; } + } +} diff --git a/LawFirm/LawFirmContracts/SearchModels/LawSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs similarity index 72% rename from LawFirm/LawFirmContracts/SearchModels/LawSearchModel.cs rename to LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs index 0e9fd1c..fa7522f 100644 --- a/LawFirm/LawFirmContracts/SearchModels/LawSearchModel.cs +++ b/LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; namespace LawFirmContracts.SearchModels { - public class LawSearchModel + public class ShopSearchModel { public int? Id { get; set; } - public string? LawName { get; set; } + public string? ShopName { get; set; } } } diff --git a/LawFirm/LawFirmContracts/StoragesContracts/IComponentStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/IComponentStorage.cs index 6ddc031..1cd97bf 100644 --- a/LawFirm/LawFirmContracts/StoragesContracts/IComponentStorage.cs +++ b/LawFirm/LawFirmContracts/StoragesContracts/IComponentStorage.cs @@ -1,4 +1,4 @@ -using LawFirmContracts.BindingModels; +using LawFirmContracts.BindingModels.BindingModels; using LawFirmContracts.SearchModels; using LawFirmContracts.ViewModels; using System; @@ -17,6 +17,5 @@ namespace LawFirmContracts.StoragesContracts ComponentViewModel? Insert(ComponentBindingModel model); ComponentViewModel? Update(ComponentBindingModel model); ComponentViewModel? Delete(ComponentBindingModel model); - } } diff --git a/LawFirm/LawFirmContracts/StoragesContracts/IDocumentStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/IDocumentStorage.cs new file mode 100644 index 0000000..1039c69 --- /dev/null +++ b/LawFirm/LawFirmContracts/StoragesContracts/IDocumentStorage.cs @@ -0,0 +1,21 @@ +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using LawFirmContracts.BindingModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.StoragesContracts +{ + public interface IDocumentStorage + { + List GetFullList(); + List GetFilteredList(DocumentSearchModel model); + DocumentViewModel? GetElement(DocumentSearchModel model); + DocumentViewModel? Insert(DocumentBindingModel model); + DocumentViewModel? Update(DocumentBindingModel model); + DocumentViewModel? Delete(DocumentBindingModel model); + } +} diff --git a/LawFirm/LawFirmContracts/StoragesContracts/ILawStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/ILawStorage.cs deleted file mode 100644 index c674f35..0000000 --- a/LawFirm/LawFirmContracts/StoragesContracts/ILawStorage.cs +++ /dev/null @@ -1,21 +0,0 @@ -using LawFirmContracts.BindingModels; -using LawFirmContracts.SearchModels; -using LawFirmContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace LawFirmContracts.StoragesContracts -{ - public interface ILawStorage - { - List GetFullList(); - List GetFilteredList(LawSearchModel model); - LawViewModel? GetElement(LawSearchModel model); - LawViewModel? Insert(LawBindingModel model); - LawViewModel? Update(LawBindingModel model); - LawViewModel? Delete(LawBindingModel model); - } -} diff --git a/LawFirm/LawFirmContracts/StoragesContracts/IShopStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/IShopStorage.cs new file mode 100644 index 0000000..68515f3 --- /dev/null +++ b/LawFirm/LawFirmContracts/StoragesContracts/IShopStorage.cs @@ -0,0 +1,21 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using LawFirmContracts.SearchModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.StoragesContracts +{ + public interface IShopStorage + { + List GetFullList(); + List GetFilteredList(ShopSearchModel model); + ShopViewModel? GetElement(ShopSearchModel model); + ShopViewModel? Insert(ShopBindingModel model); + ShopViewModel? Update(ShopBindingModel model); + ShopViewModel? Delete(ShopBindingModel model); + } +} diff --git a/LawFirm/LawFirmContracts/ViewModels/LawViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/DocumentViewModel.cs similarity index 51% rename from LawFirm/LawFirmContracts/ViewModels/LawViewModel.cs rename to LawFirm/LawFirmContracts/ViewModels/DocumentViewModel.cs index 0e3dc0e..b1c6e52 100644 --- a/LawFirm/LawFirmContracts/ViewModels/LawViewModel.cs +++ b/LawFirm/LawFirmContracts/ViewModels/DocumentViewModel.cs @@ -8,14 +8,18 @@ using System.Threading.Tasks; namespace LawFirmContracts.ViewModels { - public class LawViewModel : ILawModel + public class DocumentViewModel : IDocumentModel { public int Id { get; set; } - [DisplayName("Название изделия")] - public string LawName { get; set; } + [DisplayName("Название пакета документов")] + public string DocumentName { get; set; } = string.Empty; [DisplayName("Цена")] public double Price { get; set; } - public Dictionary LawComponents { get; set; } = new(); + public Dictionary DocumentComponents + { + get; + set; + } = new(); } } diff --git a/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs index f010bd0..7b60400 100644 --- a/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs +++ b/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs @@ -1,4 +1,5 @@ using LawFirmDataModels.Enums; +using LawFirmDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -8,13 +9,13 @@ using System.Threading.Tasks; namespace LawFirmContracts.ViewModels { - public class OrderViewModel + public class OrderViewModel : IOrderModel { [DisplayName("Номер")] public int Id { get; set; } - public int LawId { get; set; } - [DisplayName("Изделие")] - public string LawName { get; set; } = string.Empty; + public int DocumentId { get; set; } + [DisplayName("Пакет документов")] + public string DocumentName { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } [DisplayName("Сумма")] diff --git a/LawFirm/LawFirmContracts/ViewModels/ShopViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/ShopViewModel.cs new file mode 100644 index 0000000..3492d68 --- /dev/null +++ b/LawFirm/LawFirmContracts/ViewModels/ShopViewModel.cs @@ -0,0 +1,29 @@ +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.ViewModels +{ + public class ShopViewModel : IShopModel + { + public int Id { get; set; } + + [DisplayName("Название магазина")] + public string ShopName { get; set; } = string.Empty; + + [DisplayName("Адрес магазина")] + public string Address { get; set; } = string.Empty; + + [DisplayName("Дата открытия")] + public DateTime OpeningDate { get; set; } = DateTime.Now; + public Dictionary ShopDocuments + { + get; + set; + } = new(); + } +} diff --git a/LawFirm/LawFirmDataModels/Enums/OrderStatus.cs b/LawFirm/LawFirmDataModels/Enums/OrderStatus.cs index fa2c6b9..afb4ab0 100644 --- a/LawFirm/LawFirmDataModels/Enums/OrderStatus.cs +++ b/LawFirm/LawFirmDataModels/Enums/OrderStatus.cs @@ -1,4 +1,10 @@ -namespace LawFirmDataModels.Enums +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmDataModels.Enums { public enum OrderStatus { @@ -6,6 +12,6 @@ Принят = 0, Выполняется = 1, Готов = 2, - Выдан = 3, + Выдан = 3 } -} \ No newline at end of file +} diff --git a/LawFirm/LawFirmDataModels/Models/IComponentModel.cs b/LawFirm/LawFirmDataModels/Models/IComponentModel.cs index c2e5dec..2031eb5 100644 --- a/LawFirm/LawFirmDataModels/Models/IComponentModel.cs +++ b/LawFirm/LawFirmDataModels/Models/IComponentModel.cs @@ -1,8 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using LawFirmDataModels; + namespace LawFirmDataModels.Models { public interface IComponentModel : IId { string ComponentName { get; } double Cost { get; } + } -} \ No newline at end of file +} diff --git a/LawFirm/LawFirmDataModels/Models/IDocumentModel.cs b/LawFirm/LawFirmDataModels/Models/IDocumentModel.cs new file mode 100644 index 0000000..52039de --- /dev/null +++ b/LawFirm/LawFirmDataModels/Models/IDocumentModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using LawFirmDataModels; + +namespace LawFirmDataModels.Models +{ + public interface IDocumentModel : IId + { + string DocumentName { get; } + double Price { get; } + Dictionary DocumentComponents { get; } + } +} diff --git a/LawFirm/LawFirmDataModels/Models/ILawModel.cs b/LawFirm/LawFirmDataModels/Models/ILawModel.cs deleted file mode 100644 index afa9da1..0000000 --- a/LawFirm/LawFirmDataModels/Models/ILawModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace LawFirmDataModels.Models -{ - public interface ILawModel : IId - { - string LawName { get; } - double Price { get; } - Dictionary LawComponents { get; } - } -} \ No newline at end of file diff --git a/LawFirm/LawFirmDataModels/Models/IOrderModel.cs b/LawFirm/LawFirmDataModels/Models/IOrderModel.cs index c026f23..728eb34 100644 --- a/LawFirm/LawFirmDataModels/Models/IOrderModel.cs +++ b/LawFirm/LawFirmDataModels/Models/IOrderModel.cs @@ -1,14 +1,21 @@ +using LawFirmDataModels; using LawFirmDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace LawFirmDataModels.Models { public interface IOrderModel : IId { - int LawId { get; } + int DocumentId { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } DateTime DateCreate { get; } DateTime? DateImplement { get; } + } -} \ No newline at end of file +} diff --git a/LawFirm/LawFirmDataModels/Models/IShopModel.cs b/LawFirm/LawFirmDataModels/Models/IShopModel.cs new file mode 100644 index 0000000..1a9307c --- /dev/null +++ b/LawFirm/LawFirmDataModels/Models/IShopModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmDataModels.Models +{ + public interface IShopModel : IId + { + String ShopName { get; } + String Address { get; } + DateTime OpeningDate { get; } + Dictionary ShopDocuments { get; } + } +} diff --git a/LawFirm/LawFirmListImplement/DataListSingleton.cs b/LawFirm/LawFirmListImplement/DataListSingleton.cs index fac7511..427f093 100644 --- a/LawFirm/LawFirmListImplement/DataListSingleton.cs +++ b/LawFirm/LawFirmListImplement/DataListSingleton.cs @@ -7,17 +7,19 @@ using System.Threading.Tasks; namespace LawFirmListImplement { - internal class DataListSingleton + public class DataListSingleton { private static DataListSingleton? _instance; public List Components { get; set; } public List Orders { get; set; } - public List Laws { get; set; } + public List Documents { get; set; } + public List Shops { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); - Laws = new List(); + Documents = new List(); + Shops = new List(); } public static DataListSingleton GetInstance() { diff --git a/LawFirm/LawFirmListImplement/Implements/ComponentStorage.cs b/LawFirm/LawFirmListImplement/Implements/ComponentStorage.cs index 364e310..1dc15d1 100644 --- a/LawFirm/LawFirmListImplement/Implements/ComponentStorage.cs +++ b/LawFirm/LawFirmListImplement/Implements/ComponentStorage.cs @@ -1,6 +1,6 @@ -using LawFirmContracts.StoragesContracts; -using LawFirmContracts.BindingModels; +using LawFirmContracts.BindingModels.BindingModels; using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; using LawFirmContracts.ViewModels; using LawFirmListImplement.Models; using System; @@ -27,7 +27,8 @@ namespace LawFirmListImplement.Implements } return result; } - public List GetFilteredList(ComponentSearchModel model) + public List GetFilteredList(ComponentSearchModel + model) { var result = new List(); if (string.IsNullOrEmpty(model.ComponentName)) @@ -51,11 +52,12 @@ namespace LawFirmListImplement.Implements } 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; - } + if ((!string.IsNullOrEmpty(model.ComponentName) && + component.ComponentName == model.ComponentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } } return null; } diff --git a/LawFirm/LawFirmListImplement/Implements/DocumentStorage.cs b/LawFirm/LawFirmListImplement/Implements/DocumentStorage.cs new file mode 100644 index 0000000..801a081 --- /dev/null +++ b/LawFirm/LawFirmListImplement/Implements/DocumentStorage.cs @@ -0,0 +1,109 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BindingModels.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmListImplement.Implements +{ + public class DocumentStorage : IDocumentStorage + { + private readonly DataListSingleton _source; + public DocumentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var document in _source.Documents) + { + result.Add(document.GetViewModel); + } + return result; + } + public List GetFilteredList(DocumentSearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.DocumentName)) + { + return result; + } + foreach (var document in _source.Documents) + { + if (document.DocumentName.Contains(model.DocumentName)) + { + result.Add(document.GetViewModel); + } + } + return result; + } + public DocumentViewModel? GetElement(DocumentSearchModel model) + { + if (string.IsNullOrEmpty(model.DocumentName) && !model.Id.HasValue) + { + return null; + } + foreach (var document in _source.Documents) + { + if ((!string.IsNullOrEmpty(model.DocumentName) && + document.DocumentName == model.DocumentName) || + (model.Id.HasValue && document.Id == model.Id)) + { + return document.GetViewModel; + } + } + return null; + } + public DocumentViewModel? Insert(DocumentBindingModel model) + { + model.Id = 1; + foreach (var document in _source.Documents) + { + if (model.Id <= document.Id) + { + model.Id = document.Id + 1; + } + } + var newDocument = Document.Create(model); + if (newDocument == null) + { + return null; + } + _source.Documents.Add(newDocument); + return newDocument.GetViewModel; + } + public DocumentViewModel? Update(DocumentBindingModel model) + { + foreach (var document in _source.Documents) + { + if (document.Id == model.Id) + { + document.Update(model); + return document.GetViewModel; + } + } + return null; + } + public DocumentViewModel? Delete(DocumentBindingModel model) + { + for (int i = 0; i < _source.Documents.Count; ++i) + { + if (_source.Documents[i].Id == model.Id) + { + var element = _source.Documents[i]; + _source.Documents.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/LawFirm/LawFirmListImplement/Implements/LawStorage.cs b/LawFirm/LawFirmListImplement/Implements/LawStorage.cs deleted file mode 100644 index b928db3..0000000 --- a/LawFirm/LawFirmListImplement/Implements/LawStorage.cs +++ /dev/null @@ -1,112 +0,0 @@ -using LawFirmContracts.BindingModels; -using LawFirmContracts.SearchModels; -using LawFirmContracts.StoragesContracts; -using LawFirmContracts.ViewModels; -using LawFirmListImplement.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace LawFirmListImplement.Implements -{ - public class LawStorage : ILawStorage - { - private readonly DataListSingleton _source; - public LawStorage() - { - _source = DataListSingleton.GetInstance(); - } - - public LawViewModel? Delete(LawBindingModel model) - { - for (int i = 0; i < _source.Laws.Count; ++i) - { - if (_source.Laws[i].Id == model.Id) - { - var element = _source.Laws[i]; - _source.Laws.RemoveAt(i); - return element.GetViewModel; - } - } - return null; - } - - public LawViewModel? GetElement(LawSearchModel model) - { - if (string.IsNullOrEmpty(model.LawName) && !model.Id.HasValue) - { - return null; - } - foreach (var Law in _source.Laws) - { - if ((!string.IsNullOrEmpty(model.LawName) && Law.LawName == model.LawName) || - (model.Id.HasValue && Law.Id == model.Id)) - { - return Law.GetViewModel; - } - } - return null; - } - - public List GetFilteredList(LawSearchModel model) - { - var result = new List(); - if (string.IsNullOrEmpty(model.LawName)) - { - return result; - } - foreach (var Law in _source.Laws) - { - if (Law.LawName.Contains(model.LawName)) - { - result.Add(Law.GetViewModel); - } - } - return result; - } - - public List GetFullList() - { - var result = new List(); - foreach (var Law in _source.Laws) - { - result.Add(Law.GetViewModel); - } - return result; - } - - public LawViewModel? Insert(LawBindingModel model) - { - model.Id = 1; - foreach (var Law in _source.Laws) - { - if (model.Id <= Law.Id) - { - model.Id = Law.Id + 1; - } - } - var newLaw = Law.Create(model); - if (newLaw == null) - { - return null; - } - _source.Laws.Add(newLaw); - return newLaw.GetViewModel; - } - - public LawViewModel? Update(LawBindingModel model) - { - foreach (var Law in _source.Laws) - { - if (Law.Id == model.Id) - { - Law.Update(model); - return Law.GetViewModel; - } - } - return null; - } - } -} diff --git a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs index 64929e5..50a482d 100644 --- a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs @@ -1,8 +1,8 @@ using LawFirmContracts.BindingModels; using LawFirmContracts.SearchModels; -using LawFirmContracts.StoragesContracts; using LawFirmContracts.ViewModels; using LawFirmListImplement.Models; +using LawFirmContracts.StoragesContracts; using System; using System.Collections.Generic; using System.Linq; @@ -14,26 +14,24 @@ namespace LawFirmListImplement.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(AttachLawName(order.GetViewModel)); + result.Add(AccessDocumentStorage(order.GetViewModel)); } return result; } - - public List GetFilteredList(OrderSearchModel model) + public List GetFilteredList(OrderSearchModel + model) { var result = new List(); - if (model == null || !model.Id.HasValue) + if (!model.Id.HasValue) { return result; } @@ -41,12 +39,11 @@ namespace LawFirmListImplement.Implements { if (order.Id == model.Id) { - result.Add(AttachLawName(order.GetViewModel)); + result.Add(AccessDocumentStorage(order.GetViewModel)); } } return result; } - public OrderViewModel? GetElement(OrderSearchModel model) { if (!model.Id.HasValue) @@ -57,12 +54,11 @@ namespace LawFirmListImplement.Implements { if (model.Id.HasValue && order.Id == model.Id) { - return AttachLawName(order.GetViewModel); + return order.GetViewModel; } } return null; } - public OrderViewModel? Insert(OrderBindingModel model) { model.Id = 1; @@ -79,9 +75,8 @@ namespace LawFirmListImplement.Implements return null; } _source.Orders.Add(newOrder); - return AttachLawName(newOrder.GetViewModel); + return newOrder.GetViewModel; } - public OrderViewModel? Update(OrderBindingModel model) { foreach (var order in _source.Orders) @@ -89,12 +84,11 @@ namespace LawFirmListImplement.Implements if (order.Id == model.Id) { order.Update(model); - return AttachLawName(order.GetViewModel); + return order.GetViewModel; } } return null; } - public OrderViewModel? Delete(OrderBindingModel model) { for (int i = 0; i < _source.Orders.Count; ++i) @@ -103,20 +97,19 @@ namespace LawFirmListImplement.Implements { var element = _source.Orders[i]; _source.Orders.RemoveAt(i); - return AttachLawName(element.GetViewModel); + return element.GetViewModel; } } return null; } - - private OrderViewModel AttachLawName(OrderViewModel model) + public OrderViewModel AccessDocumentStorage(OrderViewModel model) { - foreach (var Law in _source.Laws) + foreach (var document in _source.Documents) { - if (Law.Id == model.LawId) + if (document.Id == model.DocumentId) { - model.LawName = Law.LawName; - return model; + model.DocumentName = document.DocumentName; + break; } } return model; diff --git a/LawFirm/LawFirmListImplement/Implements/ShopStorage.cs b/LawFirm/LawFirmListImplement/Implements/ShopStorage.cs new file mode 100644 index 0000000..0a9f551 --- /dev/null +++ b/LawFirm/LawFirmListImplement/Implements/ShopStorage.cs @@ -0,0 +1,118 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmListImplement.Implements +{ + public class ShopStorage : IShopStorage + { + private readonly DataListSingleton _source; + + public ShopStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public ShopViewModel? GetElement(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue) + { + return null; + } + foreach (var shop in _source.Shops) + { + if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id)) + { + return shop.GetViewModel; + } + } + + return null; + } + + public List GetFilteredList(ShopSearchModel model) + { + var result = new List(); + + if (string.IsNullOrEmpty(model.ShopName)) + { + return result; + } + foreach (var shop in _source.Shops) + { + if (shop.ShopName.Contains(model.ShopName)) + { + result.Add(shop.GetViewModel); + } + } + return result; + } + + public List GetFullList() + { + var result = new List(); + foreach (var shop in _source.Shops) + { + result.Add(shop.GetViewModel); + } + return result; + } + + public ShopViewModel? Insert(ShopBindingModel model) + { + model.Id = 1; + + foreach (var shop in _source.Shops) + { + if (model.Id <= shop.Id) + { + model.Id = shop.Id + 1; + } + } + + var newShop = Shop.Create(model); + + if (newShop == null) + { + return null; + } + _source.Shops.Add(newShop); + + return newShop.GetViewModel; + } + + public ShopViewModel? Update(ShopBindingModel model) + { + foreach (var shop in _source.Shops) + { + if (shop.Id == model.Id) + { + shop.Update(model); + return shop.GetViewModel; + } + } + + return null; + } + public ShopViewModel? Delete(ShopBindingModel model) + { + for (int i = 0; i < _source.Shops.Count; ++i) + { + if (_source.Shops[i].Id == model.Id) + { + var element = _source.Shops[i]; + _source.Shops.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/LawFirm/LawFirmListImplement/Models/Component.cs b/LawFirm/LawFirmListImplement/Models/Component.cs index efe1e46..b1e0016 100644 --- a/LawFirm/LawFirmListImplement/Models/Component.cs +++ b/LawFirm/LawFirmListImplement/Models/Component.cs @@ -1,6 +1,11 @@ -using LawFirmContracts.BindingModels; +using LawFirmContracts.BindingModels.BindingModels; using LawFirmContracts.ViewModels; using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace LawFirmListImplement.Models { @@ -37,5 +42,6 @@ namespace LawFirmListImplement.Models ComponentName = ComponentName, Cost = Cost }; + } -} \ No newline at end of file +} diff --git a/LawFirm/LawFirmListImplement/Models/Law.cs b/LawFirm/LawFirmListImplement/Models/Document.cs similarity index 55% rename from LawFirm/LawFirmListImplement/Models/Law.cs rename to LawFirm/LawFirmListImplement/Models/Document.cs index 387891e..fe83cdb 100644 --- a/LawFirm/LawFirmListImplement/Models/Law.cs +++ b/LawFirm/LawFirmListImplement/Models/Document.cs @@ -9,47 +9,47 @@ using System.Threading.Tasks; namespace LawFirmListImplement.Models { - internal class Law : ILawModel + public class Document : IDocumentModel { public int Id { get; private set; } - public string LawName { get; private set; } = string.Empty; + public string DocumentName { get; private set; } = string.Empty; public double Price { get; private set; } - public Dictionary LawComponents + public Dictionary DocumentComponents { get; private set; } = new Dictionary(); - public static Law? Create(LawBindingModel? model) + public static Document? Create(DocumentBindingModel? model) { if (model == null) { return null; } - return new Law() + return new Document() { + Id = model.Id, - LawName = model.LawName, + DocumentName = model.DocumentName, Price = model.Price, - LawComponents = model.LawComponents + DocumentComponents = model.DocumentComponents }; } - public void Update(LawBindingModel? model) + public void Update(DocumentBindingModel? model) { if (model == null) { return; } - LawName = model.LawName; + DocumentName = model.DocumentName; Price = model.Price; - LawComponents = model.LawComponents; + DocumentComponents = model.DocumentComponents; } - public LawViewModel GetViewModel => new() + public DocumentViewModel GetViewModel => new() { Id = Id, - LawName = LawName, + DocumentName = DocumentName, Price = Price, - LawComponents = LawComponents + DocumentComponents = DocumentComponents }; - } } diff --git a/LawFirm/LawFirmListImplement/Models/Order.cs b/LawFirm/LawFirmListImplement/Models/Order.cs index 7f40e77..90b76e1 100644 --- a/LawFirm/LawFirmListImplement/Models/Order.cs +++ b/LawFirm/LawFirmListImplement/Models/Order.cs @@ -5,7 +5,6 @@ using LawFirmDataModels.Models; using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -14,7 +13,7 @@ namespace LawFirmListImplement.Models public class Order : IOrderModel { public int Id { get; private set; } - public int LawId { get; private set; } + public int DocumentId { get; private set; } public int Count { get; private set; } public double Sum { get; private set; } public OrderStatus Status { get; private set; } @@ -29,7 +28,7 @@ namespace LawFirmListImplement.Models return new Order() { Id = model.Id, - LawId = model.LawId, + DocumentId = model.DocumentId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -43,7 +42,8 @@ namespace LawFirmListImplement.Models { return; } - LawId = model.LawId; + Id = model.Id; + DocumentId = model.DocumentId; Count = model.Count; Sum = model.Sum; Status = model.Status; @@ -53,12 +53,13 @@ namespace LawFirmListImplement.Models public OrderViewModel GetViewModel => new() { Id = Id, - LawId = LawId, + DocumentId = DocumentId, Count = Count, Sum = Sum, Status = Status, DateCreate = DateCreate, DateImplement = DateImplement, }; + } } diff --git a/LawFirm/LawFirmListImplement/Models/Shop.cs b/LawFirm/LawFirmListImplement/Models/Shop.cs new file mode 100644 index 0000000..338bc49 --- /dev/null +++ b/LawFirm/LawFirmListImplement/Models/Shop.cs @@ -0,0 +1,60 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmListImplement.Models +{ + public class Shop : IShopModel + { + public int Id { get; private set; } + public string ShopName { get; private set; } = string.Empty; + public string Address { get; private set; } = string.Empty; + public DateTime OpeningDate { get; private set; } + public Dictionary ShopDocuments + { + get; + private set; + } = new Dictionary(); + public static Shop? Create(ShopBindingModel? model) + { + if (model == null) + { + return null; + } + + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Address = model.Address, + OpeningDate = model.OpeningDate, + ShopDocuments = model.ShopDocuments + }; + } + public void Update(ShopBindingModel? model) + { + if (model == null) + { + return; + } + + ShopName = model.ShopName; + Address = model.Address; + OpeningDate = model.OpeningDate; + ShopDocuments = model.ShopDocuments; + } + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Address = Address, + OpeningDate = OpeningDate, + ShopDocuments = ShopDocuments + }; + } +} From 0d477364213f4369a0376730edb241e7606e27c1 Mon Sep 17 00:00:00 2001 From: aleksandr chegodaev Date: Sun, 16 Jun 2024 21:52:07 +0400 Subject: [PATCH 2/2] lab1 hard --- LawFirm/LawFirm/FormMain.Designer.cs | 127 +++++++++--------- LawFirm/LawFirm/FormMain.cs | 30 +++++ LawFirm/LawFirm/Program.cs | 15 ++- .../SearchModels/DocumentSearchModel.cs | 7 - .../SearchModels/ShopSearchModel.cs | 7 - .../LawFirmListImplement/DataListSingleton.cs | 6 +- 6 files changed, 111 insertions(+), 81 deletions(-) diff --git a/LawFirm/LawFirm/FormMain.Designer.cs b/LawFirm/LawFirm/FormMain.Designer.cs index 6a92ac0..a32ae7a 100644 --- a/LawFirm/LawFirm/FormMain.Designer.cs +++ b/LawFirm/LawFirm/FormMain.Designer.cs @@ -28,20 +28,21 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); - toolStrip1 = new ToolStrip(); - toolStripDropDownButton1 = new ToolStripDropDownButton(); - компонентыToolStripMenuItem = new ToolStripMenuItem(); - ПутёвкиToolStripMenuItem = new ToolStripMenuItem(); - buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); - buttonIssuedOrder = new Button(); - buttonRef = new Button(); - dataGridView = new DataGridView(); - toolStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.toolStripMenuItemCatalogs = new System.Windows.Forms.ToolStripMenuItem(); + this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.пакетыДокументовToolStripMenuItem = 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.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonSupplyShop = new System.Windows.Forms.Button(); + this.menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); // // menuStrip1 // @@ -55,13 +56,13 @@ // // toolStripMenuItemCatalogs // - toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text; - toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, ПутёвкиToolStripMenuItem }); - toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image"); - toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; - toolStripDropDownButton1.Name = "toolStripDropDownButton1"; - toolStripDropDownButton1.Size = new Size(88, 22); - toolStripDropDownButton1.Text = "Справочник"; + this.toolStripMenuItemCatalogs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.компонентыToolStripMenuItem, + this.пакетыДокументовToolStripMenuItem, + this.магазиныToolStripMenuItem}); + this.toolStripMenuItemCatalogs.Name = "toolStripMenuItemCatalogs"; + this.toolStripMenuItemCatalogs.Size = new System.Drawing.Size(94, 20); + this.toolStripMenuItemCatalogs.Text = "Справочники"; // // компонентыToolStripMenuItem // @@ -128,46 +129,54 @@ // // buttonRef // - buttonRef.Location = new Point(800, 222); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(141, 24); - buttonRef.TabIndex = 5; - buttonRef.Text = "Обновить список"; - buttonRef.UseVisualStyleBackColor = true; - buttonRef.Click += buttonRef_Click; + this.buttonRef.Location = new System.Drawing.Point(742, 158); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(156, 23); + this.buttonRef.TabIndex = 6; + this.buttonRef.Text = "Обновить список"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click); // - // dataGridView + // магазиныToolStripMenuItem // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 26); - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 24; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(763, 435); - dataGridView.TabIndex = 6; + this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; + this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.магазиныToolStripMenuItem.Text = "Магазины"; + this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click); + // + // buttonSupplyShop + // + this.buttonSupplyShop.Location = new System.Drawing.Point(742, 187); + this.buttonSupplyShop.Name = "buttonSupplyShop"; + this.buttonSupplyShop.Size = new System.Drawing.Size(156, 23); + this.buttonSupplyShop.TabIndex = 7; + this.buttonSupplyShop.Text = "Пополнение магазина"; + this.buttonSupplyShop.UseVisualStyleBackColor = true; + this.buttonSupplyShop.Click += new System.EventHandler(this.buttonSupplyShop_Click); // // FormMain // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(969, 461); - Controls.Add(dataGridView); - Controls.Add(buttonRef); - Controls.Add(buttonIssuedOrder); - Controls.Add(buttonOrderReady); - Controls.Add(buttonTakeOrderInWork); - Controls.Add(buttonCreateOrder); - Controls.Add(toolStrip1); - Name = "FormMain"; - Text = "Юридическая фирма"; - Load += FormMain_Load; - toolStrip1.ResumeLayout(false); - toolStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(910, 477); + this.Controls.Add(this.buttonSupplyShop); + 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.Name = "FormMain"; + this.Text = "FormMain"; + 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 @@ -182,9 +191,7 @@ private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonRef; - private DataGridView dataGridView; - private ToolStripDropDownButton toolStripDropDownButton1; - private ToolStripMenuItem компонентыToolStripMenuItem; - private ToolStripMenuItem ПутёвкиToolStripMenuItem; + private ToolStripMenuItem магазиныToolStripMenuItem; + private Button buttonSupplyShop; } } \ No newline at end of file diff --git a/LawFirm/LawFirm/FormMain.cs b/LawFirm/LawFirm/FormMain.cs index 9b26e73..bcfbaf6 100644 --- a/LawFirm/LawFirm/FormMain.cs +++ b/LawFirm/LawFirm/FormMain.cs @@ -164,5 +164,35 @@ namespace LawFirmView { LoadData(); } + private OrderBindingModel CreateBindingModel(int id, bool isDone = false) + { + return new OrderBindingModel + { + Id = id, + DocumentId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DocumentId"].Value), + 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()), + }; + } + + private void buttonSupplyShop_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShopSupply)); + if (service is FormShopSupply form) + { + form.ShowDialog(); + } + } + + private void магазиныToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) + { + form.ShowDialog(); + } + } } } diff --git a/LawFirm/LawFirm/Program.cs b/LawFirm/LawFirm/Program.cs index afdb8d6..33bc432 100644 --- a/LawFirm/LawFirm/Program.cs +++ b/LawFirm/LawFirm/Program.cs @@ -36,17 +36,22 @@ namespace LawFirmView }); 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(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } diff --git a/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs index 74b3d30..c556131 100644 --- a/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs +++ b/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs @@ -6,16 +6,9 @@ using System.Threading.Tasks; namespace LawFirmContracts.SearchModels { -<<<<<<<< HEAD:LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs - public class ShopSearchModel - { - public int? Id { get; set; } - public string? ShopName { get; set; } -======== public class DocumentSearchModel { public int? Id { get; set; } public string? DocumentName { get; set; } ->>>>>>>> lab1:LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs } } diff --git a/LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs index 74b3d30..fa7522f 100644 --- a/LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs +++ b/LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs @@ -6,16 +6,9 @@ using System.Threading.Tasks; namespace LawFirmContracts.SearchModels { -<<<<<<<< HEAD:LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs public class ShopSearchModel { public int? Id { get; set; } public string? ShopName { get; set; } -======== - public class DocumentSearchModel - { - public int? Id { get; set; } - public string? DocumentName { get; set; } ->>>>>>>> lab1:LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs } } diff --git a/LawFirm/LawFirmListImplement/DataListSingleton.cs b/LawFirm/LawFirmListImplement/DataListSingleton.cs index 22abdaf..427f093 100644 --- a/LawFirm/LawFirmListImplement/DataListSingleton.cs +++ b/LawFirm/LawFirmListImplement/DataListSingleton.cs @@ -12,12 +12,14 @@ namespace LawFirmListImplement private static DataListSingleton? _instance; public List Components { get; set; } public List Orders { get; set; } - public List Laws { get; set; } + public List Documents { get; set; } + public List Shops { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); - Laws = new List(); + Documents = new List(); + Shops = new List(); } public static DataListSingleton GetInstance() {