From 6b6526b2c8a5747bf1ba5769537006fe546e3506 Mon Sep 17 00:00:00 2001 From: "leonteva.v" Date: Fri, 24 May 2024 22:17:46 +0400 Subject: [PATCH] laba 6 --- LawFirm/LawFirm/FormCreateOrder.cs | 17 +- LawFirm/LawFirm/FormImplementer.Designer.cs | 173 ++++++++ LawFirm/LawFirm/FormImplementer.cs | 97 ++++ LawFirm/LawFirm/FormImplementer.resx | 60 +++ LawFirm/LawFirm/FormMain.Designer.cs | 420 +++++++++--------- LawFirm/LawFirm/FormMain.cs | 411 +++++++++-------- .../LawFirm/FormViewImplementers.Designer.cs | 126 ++++++ LawFirm/LawFirm/FormViewImplementers.cs | 110 +++++ LawFirm/LawFirm/FormViewImplementers.resx | 120 +++++ LawFirm/LawFirm/Program.cs | 11 +- .../Controllers/ImplementerController.cs | 102 +++++ 11 files changed, 1232 insertions(+), 415 deletions(-) create mode 100644 LawFirm/LawFirm/FormImplementer.Designer.cs create mode 100644 LawFirm/LawFirm/FormImplementer.cs create mode 100644 LawFirm/LawFirm/FormImplementer.resx create mode 100644 LawFirm/LawFirm/FormViewImplementers.Designer.cs create mode 100644 LawFirm/LawFirm/FormViewImplementers.cs create mode 100644 LawFirm/LawFirm/FormViewImplementers.resx create mode 100644 LawFirm/LawFirmRestApi/Controllers/ImplementerController.cs diff --git a/LawFirm/LawFirm/FormCreateOrder.cs b/LawFirm/LawFirm/FormCreateOrder.cs index 18b0710..988fc65 100644 --- a/LawFirm/LawFirm/FormCreateOrder.cs +++ b/LawFirm/LawFirm/FormCreateOrder.cs @@ -25,7 +25,22 @@ namespace LawFirmView _logicO = logicO; _clientLogic = clientLogic; _list = logicD.ReadList(null); - } + if (_list != null) + { + comboBoxDocument.DisplayMember = "PastryName"; + comboBoxDocument.ValueMember = "Id"; + comboBoxDocument.DataSource = _list; + comboBoxDocument.SelectedItem = null; + } + var clients = _clientLogic.ReadList(null); + if (clients != null) + { + comboBoxClient.DisplayMember = "clientFIO"; + comboBoxClient.ValueMember = "Id"; + comboBoxClient.DataSource = clients; + comboBoxClient.SelectedItem = null; + } + } private void FormCreateOrder_Load(object sender, EventArgs e) { _logger.LogInformation("Загрузка документов для заказа"); diff --git a/LawFirm/LawFirm/FormImplementer.Designer.cs b/LawFirm/LawFirm/FormImplementer.Designer.cs new file mode 100644 index 0000000..f01d459 --- /dev/null +++ b/LawFirm/LawFirm/FormImplementer.Designer.cs @@ -0,0 +1,173 @@ +namespace LawFirmView +{ + partial class FormImplementer + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + textBoxFio = new TextBox(); + textBoxPassword = new TextBox(); + numericUpDownWorkExperience = new NumericUpDown(); + numericUpDownQualification = new NumericUpDown(); + buttonCancel = new Button(); + buttonSave = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWorkExperience).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownQualification).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(79, 12); + label1.Name = "label1"; + label1.Size = new Size(37, 15); + label1.TabIndex = 0; + label1.Text = "ФИО:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(69, 41); + label2.Name = "label2"; + label2.Size = new Size(52, 15); + label2.TabIndex = 1; + label2.Text = "Пароль:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(78, 68); + label3.Name = "label3"; + label3.Size = new Size(38, 15); + label3.TabIndex = 2; + label3.Text = "Стаж:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(25, 97); + label4.Name = "label4"; + label4.Size = new Size(91, 15); + label4.TabIndex = 3; + label4.Text = "Квалификация:"; + // + // textBoxFio + // + textBoxFio.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxFio.Location = new Point(127, 9); + textBoxFio.Name = "textBoxFio"; + textBoxFio.Size = new Size(271, 23); + textBoxFio.TabIndex = 4; + // + // textBoxPassword + // + textBoxPassword.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxPassword.Location = new Point(127, 38); + textBoxPassword.Name = "textBoxPassword"; + textBoxPassword.PasswordChar = '*'; + textBoxPassword.Size = new Size(271, 23); + textBoxPassword.TabIndex = 5; + // + // numericUpDownWorkExperience + // + numericUpDownWorkExperience.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownWorkExperience.Location = new Point(127, 66); + numericUpDownWorkExperience.Name = "numericUpDownWorkExperience"; + numericUpDownWorkExperience.Size = new Size(271, 23); + numericUpDownWorkExperience.TabIndex = 6; + // + // numericUpDownQualification + // + numericUpDownQualification.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownQualification.Location = new Point(127, 95); + numericUpDownQualification.Name = "numericUpDownQualification"; + numericUpDownQualification.Size = new Size(271, 23); + numericUpDownQualification.TabIndex = 7; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(309, 138); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(89, 33); + buttonCancel.TabIndex = 8; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonSave.Location = new Point(214, 138); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(89, 33); + buttonSave.TabIndex = 9; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormImplementer + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(410, 183); + Controls.Add(buttonSave); + Controls.Add(buttonCancel); + Controls.Add(numericUpDownQualification); + Controls.Add(numericUpDownWorkExperience); + Controls.Add(textBoxPassword); + Controls.Add(textBoxFio); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormImplementer"; + Text = "Добавление / Редактирование исполнителя"; + Load += FormImplementer_Load; + ((System.ComponentModel.ISupportInitialize)numericUpDownWorkExperience).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownQualification).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private TextBox textBoxFio; + private TextBox textBoxPassword; + private NumericUpDown numericUpDownWorkExperience; + private NumericUpDown numericUpDownQualification; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormImplementer.cs b/LawFirm/LawFirm/FormImplementer.cs new file mode 100644 index 0000000..d3ae8f5 --- /dev/null +++ b/LawFirm/LawFirm/FormImplementer.cs @@ -0,0 +1,97 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System.Windows.Forms; + +namespace LawFirmView +{ + public partial class FormImplementer : Form + { + private readonly ILogger _logger; + private readonly IImplementerLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + public FormImplementer(ILogger logger, IImplementerLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormImplementer_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение исполнителя"); + var view = _logic.ReadElement(new ImplementerSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxFio.Text = view.ImplementerFIO; + textBoxPassword.Text = view.Password; + numericUpDownQualification.Value = view.Qualification; + numericUpDownWorkExperience.Value = view.WorkExperience; + } + } + 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(textBoxPassword.Text)) + { + MessageBox.Show("Заполните пароль", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxFio.Text)) + { + MessageBox.Show("Заполните фио", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение исполнителя"); + try + { + var model = new ImplementerBindingModel + { + Id = _id ?? 0, + ImplementerFIO = textBoxFio.Text, + Password = textBoxPassword.Text, + Qualification = (int)numericUpDownQualification.Value, + WorkExperience = (int)numericUpDownWorkExperience.Value, + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения исполнителя"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + } +} diff --git a/LawFirm/LawFirm/FormImplementer.resx b/LawFirm/LawFirm/FormImplementer.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirm/FormImplementer.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/FormMain.Designer.cs b/LawFirm/LawFirm/FormMain.Designer.cs index 7649656..02c4ccd 100644 --- a/LawFirm/LawFirm/FormMain.Designer.cs +++ b/LawFirm/LawFirm/FormMain.Designer.cs @@ -1,222 +1,214 @@ namespace LawFirmView { - partial class FormMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } + /// + /// 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 + #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() - { - menuStrip = new MenuStrip(); - toolStripMenuItem = new ToolStripMenuItem(); - BlanksToolStripMenuItem = new ToolStripMenuItem(); - DocumentsToolStripMenuItem = new ToolStripMenuItem(); - ReportsToolStripMenuItem = new ToolStripMenuItem(); - ListOfDocumentsToolStripMenuItem = new ToolStripMenuItem(); - FormsForDocumentsToolStripMenuItem = new ToolStripMenuItem(); - OrderListToolStripMenuItem = new ToolStripMenuItem(); - dataGridView = new DataGridView(); - buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); - buttonIssuedOrder = new Button(); - buttonUpdate = new Button(); - ClientsToolStripMenuItem = new ToolStripMenuItem(); - menuStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // menuStrip - // - menuStrip.ImageScalingSize = new Size(20, 20); - menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, ReportsToolStripMenuItem }); - menuStrip.Location = new Point(0, 0); - menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(929, 28); - menuStrip.TabIndex = 0; - menuStrip.Text = "Справочники"; - // - // toolStripMenuItem - // - toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { BlanksToolStripMenuItem, DocumentsToolStripMenuItem, ClientsToolStripMenuItem }); - toolStripMenuItem.Name = "toolStripMenuItem"; - toolStripMenuItem.Size = new Size(117, 24); - toolStripMenuItem.Text = "Справочники"; - // - // BlanksToolStripMenuItem - // - BlanksToolStripMenuItem.Name = "BlanksToolStripMenuItem"; - BlanksToolStripMenuItem.Size = new Size(224, 26); - BlanksToolStripMenuItem.Text = "Бланки"; - BlanksToolStripMenuItem.Click += BlanksToolStripMenuItem_Click; - // - // DocumentsToolStripMenuItem - // - DocumentsToolStripMenuItem.Name = "DocumentsToolStripMenuItem"; - DocumentsToolStripMenuItem.Size = new Size(224, 26); - DocumentsToolStripMenuItem.Text = "Документы"; - DocumentsToolStripMenuItem.Click += DocumentsToolStripMenuItem_Click; - // - // ReportsToolStripMenuItem - // - ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ListOfDocumentsToolStripMenuItem, FormsForDocumentsToolStripMenuItem, OrderListToolStripMenuItem }); - ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem"; - ReportsToolStripMenuItem.Size = new Size(73, 24); - ReportsToolStripMenuItem.Text = "Отчеты"; - // - // ListOfDocumentsToolStripMenuItem - // - ListOfDocumentsToolStripMenuItem.Name = "ListOfDocumentsToolStripMenuItem"; - ListOfDocumentsToolStripMenuItem.Size = new Size(252, 26); - ListOfDocumentsToolStripMenuItem.Text = "Список документов"; - ListOfDocumentsToolStripMenuItem.Click += ListOfDocumentsToolStripMenuItem_Click; - // - // FormsForDocumentsToolStripMenuItem - // - FormsForDocumentsToolStripMenuItem.Name = "FormsForDocumentsToolStripMenuItem"; - FormsForDocumentsToolStripMenuItem.Size = new Size(252, 26); - FormsForDocumentsToolStripMenuItem.Text = "Бланки по документам"; - FormsForDocumentsToolStripMenuItem.Click += FormsForDocumentsToolStripMenuItem_Click; - // - // OrderListToolStripMenuItem - // - OrderListToolStripMenuItem.Name = "OrderListToolStripMenuItem"; - OrderListToolStripMenuItem.Size = new Size(252, 26); - OrderListToolStripMenuItem.Text = "Список заказов"; - OrderListToolStripMenuItem.Click += OrderListToolStripMenuItem_Click; - // - // dataGridView - // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.BackgroundColor = Color.White; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(12, 31); - dataGridView.Margin = new Padding(3, 4, 3, 4); - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(714, 606); - dataGridView.TabIndex = 1; - // - // buttonCreateOrder - // - buttonCreateOrder.Location = new Point(732, 42); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(185, 29); - buttonCreateOrder.TabIndex = 2; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = true; - buttonCreateOrder.Click += buttonCreateOrder_Click; - // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Location = new Point(732, 86); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(185, 29); - buttonTakeOrderInWork.TabIndex = 3; - buttonTakeOrderInWork.Text = "Отдать на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = true; - buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; - // - // buttonOrderReady - // - buttonOrderReady.Location = new Point(732, 132); - buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(185, 29); - buttonOrderReady.TabIndex = 4; - buttonOrderReady.Text = "Заказ готов"; - buttonOrderReady.UseVisualStyleBackColor = true; - buttonOrderReady.Click += buttonOrderReady_Click; - // - // buttonIssuedOrder - // - buttonIssuedOrder.Location = new Point(732, 177); - buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(185, 29); - buttonIssuedOrder.TabIndex = 5; - buttonIssuedOrder.Text = "Заказ выдан"; - buttonIssuedOrder.UseVisualStyleBackColor = true; - buttonIssuedOrder.Click += buttonIssuedOrder_Click; - // - // buttonUpdate - // - buttonUpdate.Location = new Point(732, 221); - buttonUpdate.Name = "buttonUpdate"; - buttonUpdate.Size = new Size(185, 29); - buttonUpdate.TabIndex = 6; - buttonUpdate.Text = "Обновить список"; - buttonUpdate.UseVisualStyleBackColor = true; - buttonUpdate.Click += buttonUpdate_Click; - // - // ClientsToolStripMenuItem - // - ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; - ClientsToolStripMenuItem.Size = new Size(224, 26); - ClientsToolStripMenuItem.Text = "Клиенты"; - ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; - // - // FormMain - // - AutoScaleDimensions = new SizeF(8F, 20F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(929, 649); - Controls.Add(buttonUpdate); - Controls.Add(buttonIssuedOrder); - Controls.Add(buttonOrderReady); - Controls.Add(buttonTakeOrderInWork); - Controls.Add(buttonCreateOrder); - Controls.Add(dataGridView); - Controls.Add(menuStrip); - MainMenuStrip = menuStrip; - Name = "FormMain"; - Text = "Юридическая фирма"; - Load += FormMain_Load; - menuStrip.ResumeLayout(false); - menuStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip = new MenuStrip(); + toolStripMenuItem = new ToolStripMenuItem(); + BlanksToolStripMenuItem = new ToolStripMenuItem(); + DocumentsToolStripMenuItem = new ToolStripMenuItem(); + ClientsToolStripMenuItem = new ToolStripMenuItem(); + ImplementersToolStripMenuItem = new ToolStripMenuItem(); + ReportsToolStripMenuItem = new ToolStripMenuItem(); + ListOfDocumentsToolStripMenuItem = new ToolStripMenuItem(); + FormsForDocumentsToolStripMenuItem = new ToolStripMenuItem(); + OrderListToolStripMenuItem = new ToolStripMenuItem(); + StartWorksToolStripMenuItem = new ToolStripMenuItem(); + dataGridView = new DataGridView(); + buttonCreateOrder = new Button(); + buttonIssuedOrder = new Button(); + buttonUpdate = new Button(); + menuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, ReportsToolStripMenuItem, StartWorksToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(929, 28); + menuStrip.TabIndex = 0; + menuStrip.Text = "Справочники"; + // + // toolStripMenuItem + // + toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { BlanksToolStripMenuItem, DocumentsToolStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem }); + toolStripMenuItem.Name = "toolStripMenuItem"; + toolStripMenuItem.Size = new Size(117, 24); + toolStripMenuItem.Text = "Справочники"; + // + // BlanksToolStripMenuItem + // + BlanksToolStripMenuItem.Name = "BlanksToolStripMenuItem"; + BlanksToolStripMenuItem.Size = new Size(185, 26); + BlanksToolStripMenuItem.Text = "Бланки"; + BlanksToolStripMenuItem.Click += BlanksToolStripMenuItem_Click; + // + // DocumentsToolStripMenuItem + // + DocumentsToolStripMenuItem.Name = "DocumentsToolStripMenuItem"; + DocumentsToolStripMenuItem.Size = new Size(185, 26); + DocumentsToolStripMenuItem.Text = "Документы"; + DocumentsToolStripMenuItem.Click += DocumentsToolStripMenuItem_Click; + // + // ClientsToolStripMenuItem + // + ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; + ClientsToolStripMenuItem.Size = new Size(185, 26); + ClientsToolStripMenuItem.Text = "Клиенты"; + ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; + // + // ImplementersToolStripMenuItem + // + ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem"; + ImplementersToolStripMenuItem.Size = new Size(185, 26); + ImplementersToolStripMenuItem.Text = "Исполнители"; + ImplementersToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click; + // + // ReportsToolStripMenuItem + // + ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ListOfDocumentsToolStripMenuItem, FormsForDocumentsToolStripMenuItem, OrderListToolStripMenuItem }); + ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem"; + ReportsToolStripMenuItem.Size = new Size(73, 24); + ReportsToolStripMenuItem.Text = "Отчеты"; + // + // ListOfDocumentsToolStripMenuItem + // + ListOfDocumentsToolStripMenuItem.Name = "ListOfDocumentsToolStripMenuItem"; + ListOfDocumentsToolStripMenuItem.Size = new Size(252, 26); + ListOfDocumentsToolStripMenuItem.Text = "Список документов"; + ListOfDocumentsToolStripMenuItem.Click += ListOfDocumentsToolStripMenuItem_Click; + // + // FormsForDocumentsToolStripMenuItem + // + FormsForDocumentsToolStripMenuItem.Name = "FormsForDocumentsToolStripMenuItem"; + FormsForDocumentsToolStripMenuItem.Size = new Size(252, 26); + FormsForDocumentsToolStripMenuItem.Text = "Бланки по документам"; + FormsForDocumentsToolStripMenuItem.Click += FormsForDocumentsToolStripMenuItem_Click; + // + // OrderListToolStripMenuItem + // + OrderListToolStripMenuItem.Name = "OrderListToolStripMenuItem"; + OrderListToolStripMenuItem.Size = new Size(252, 26); + OrderListToolStripMenuItem.Text = "Список заказов"; + OrderListToolStripMenuItem.Click += OrderListToolStripMenuItem_Click; + // + // StartWorksToolStripMenuItem + // + StartWorksToolStripMenuItem.Name = "StartWorksToolStripMenuItem"; + StartWorksToolStripMenuItem.Size = new Size(114, 24); + StartWorksToolStripMenuItem.Text = "Запуск работ"; + StartWorksToolStripMenuItem.Click += StartWorksToolStripMenuItem_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.BackgroundColor = Color.White; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 31); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(714, 606); + dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + buttonCreateOrder.Location = new Point(732, 42); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(185, 29); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += buttonCreateOrder_Click; + // + // buttonIssuedOrder + // + buttonIssuedOrder.Location = new Point(732, 103); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(185, 29); + buttonIssuedOrder.TabIndex = 5; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += buttonIssuedOrder_Click; + // + // buttonUpdate + // + buttonUpdate.Location = new Point(732, 164); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(185, 29); + buttonUpdate.TabIndex = 6; + buttonUpdate.Text = "Обновить список"; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += buttonUpdate_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(929, 649); + Controls.Add(buttonUpdate); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormMain"; + Text = "Юридическая фирма"; + Load += FormMain_Load; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private MenuStrip menuStrip; - private ToolStripMenuItem toolStripMenuItem; - private ToolStripMenuItem BlanksToolStripMenuItem; - private ToolStripMenuItem DocumentsToolStripMenuItem; - private DataGridView dataGridView; - private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button buttonOrderReady; - private Button buttonIssuedOrder; - private Button buttonUpdate; - private ToolStripMenuItem ReportsToolStripMenuItem; - private ToolStripMenuItem ListOfDocumentsToolStripMenuItem; - private ToolStripMenuItem FormsForDocumentsToolStripMenuItem; - private ToolStripMenuItem OrderListToolStripMenuItem; - private ToolStripMenuItem ClientsToolStripMenuItem; - } + private MenuStrip menuStrip; + private ToolStripMenuItem toolStripMenuItem; + private ToolStripMenuItem BlanksToolStripMenuItem; + private ToolStripMenuItem DocumentsToolStripMenuItem; + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonIssuedOrder; + private Button buttonUpdate; + private ToolStripMenuItem ReportsToolStripMenuItem; + private ToolStripMenuItem ListOfDocumentsToolStripMenuItem; + private ToolStripMenuItem FormsForDocumentsToolStripMenuItem; + private ToolStripMenuItem OrderListToolStripMenuItem; + private ToolStripMenuItem ClientsToolStripMenuItem; + private ToolStripMenuItem StartWorksToolStripMenuItem; + private ToolStripMenuItem ImplementersToolStripMenuItem; + } } \ No newline at end of file diff --git a/LawFirm/LawFirm/FormMain.cs b/LawFirm/LawFirm/FormMain.cs index 5f429c5..f471a1f 100644 --- a/LawFirm/LawFirm/FormMain.cs +++ b/LawFirm/LawFirm/FormMain.cs @@ -8,201 +8,218 @@ using LawFirmContracts.BusinessLogicContracts; namespace LawFirmView { - public partial class FormMain : Form - { - private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; - private readonly IReportLogic _reportLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) - { - InitializeComponent(); - _logger = logger; - _orderLogic = orderLogic; - _reportLogic = reportLogic; - } - private void FormMain_Load(object sender, EventArgs e) - { - LoadData(); - } - private void LoadData() - { - _logger.LogInformation("Загрузка заказов"); - try - { - var list = _orderLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["DocumentId"].Visible = false; - dataGridView.Columns["ClientId"].Visible = false; - } - _logger.LogInformation("Загрузка прошла успешно"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки заказов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - private void buttonCreateOrder_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - if (service is FormCreateOrder form) - { - form.ShowDialog(); - LoadData(); - } - } - private void buttonTakeOrderInWork_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try - { - var operationResult = _orderLogic.TakeOrderInWork(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()) - }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void buttonOrderReady_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); - try - { - var operationResult = _orderLogic.FinishOrder(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()) - }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - private void buttonIssuedOrder_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); - try - { - var operationResult = _orderLogic.DeliveryOrder(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()) - }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - _logger.LogInformation("Заказ №{id} выдан", id); - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void buttonUpdate_Click(object sender, EventArgs e) - { - LoadData(); - } - private void BlanksToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormBlanks)); - if (service is FormBlanks form) - { - form.ShowDialog(); - } - } - private void DocumentsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormDocuments)); - if (service is FormDocuments form) - { - form.ShowDialog(); - } - } - private void ListOfDocumentsToolStripMenuItem_Click(object sender, EventArgs e) - { - using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; - if (dialog.ShowDialog() == DialogResult.OK) - { - _reportLogic.SaveDocumentsToWordFile(new ReportBindingModel - { - FileName = dialog.FileName - }); - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - private void FormsForDocumentsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks)); - if (service is FormReportDocumentBlanks form) - { - form.ShowDialog(); - } - } - private void OrderListToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportOrder)); - if (service is FormReportOrder form) - { - form.ShowDialog(); - } - } - private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormViewClients)); - if (service is FormViewClients form) - { - form.ShowDialog(); - } - } - } + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; + private readonly IWorkProcess _workProcess; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + _reportLogic = reportLogic; + _workProcess = workProcess; + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["DocumentId"].Visible = false; + dataGridView.Columns["ClientId"].Visible = false; + dataGridView.Columns["ImplementerId"].Visible = false; + } + _logger.LogInformation("Загрузка прошла успешно"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void buttonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private void buttonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(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()) + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void buttonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(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()) + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void buttonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(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()) + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void buttonUpdate_Click(object sender, EventArgs e) + { + LoadData(); + } + private void BlanksToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormBlanks)); + if (service is FormBlanks form) + { + form.ShowDialog(); + } + } + private void DocumentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormDocuments)); + if (service is FormDocuments form) + { + form.ShowDialog(); + } + } + private void ListOfDocumentsToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveDocumentsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + private void FormsForDocumentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks)); + if (service is FormReportDocumentBlanks form) + { + form.ShowDialog(); + } + } + private void OrderListToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrder)); + if (service is FormReportOrder form) + { + form.ShowDialog(); + } + } + private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormViewClients)); + if (service is FormViewClients form) + { + form.ShowDialog(); + } + } + private void StartWorksToolStripMenuItem_Click(object sender, EventArgs e) + { + _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); + MessageBox.Show("Процесс обработки запущен", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + } + private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormViewImplementers)); + if (service is FormViewImplementers form) + { + form.ShowDialog(); + } + } + } } diff --git a/LawFirm/LawFirm/FormViewImplementers.Designer.cs b/LawFirm/LawFirm/FormViewImplementers.Designer.cs new file mode 100644 index 0000000..09d596c --- /dev/null +++ b/LawFirm/LawFirm/FormViewImplementers.Designer.cs @@ -0,0 +1,126 @@ +namespace LawFirmView +{ + partial class FormViewImplementers + { + /// + /// 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.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonRef.Location = new Point(447, 279); + buttonRef.Margin = new Padding(3, 4, 3, 4); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(103, 49); + buttonRef.TabIndex = 9; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += ButtonRef_Click; + // + // buttonDel + // + buttonDel.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonDel.Location = new Point(447, 211); + buttonDel.Margin = new Padding(3, 4, 3, 4); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(103, 44); + buttonDel.TabIndex = 8; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonUpd.Location = new Point(447, 145); + buttonUpd.Margin = new Padding(3, 4, 3, 4); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(103, 45); + buttonUpd.TabIndex = 7; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonAdd.Location = new Point(447, 85); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(103, 40); + buttonAdd.TabIndex = 6; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.BackgroundColor = Color.White; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(14, 16); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(392, 403); + dataGridView.TabIndex = 5; + // + // FormViewImplementers + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(585, 425); + Controls.Add(buttonRef); + Controls.Add(buttonDel); + Controls.Add(buttonUpd); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Margin = new Padding(3, 4, 3, 4); + Name = "FormViewImplementers"; + Text = "Просмотр списка исполнителей"; + Load += FormViewImplementers_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/FormViewImplementers.cs b/LawFirm/LawFirm/FormViewImplementers.cs new file mode 100644 index 0000000..93a0df7 --- /dev/null +++ b/LawFirm/LawFirm/FormViewImplementers.cs @@ -0,0 +1,110 @@ +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 FormViewImplementers : Form + { + private readonly ILogger _logger; + private readonly IImplementerLogic _logic; + public FormViewImplementers(ILogger logger, IImplementerLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormViewImplementers_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; + } + _logger.LogInformation("Загрузка исполнителей"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки исполнителей"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); + if (service is FormImplementer 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(FormImplementer)); + if (service is FormImplementer 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 ImplementerBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления исполнителя"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/LawFirm/LawFirm/FormViewImplementers.resx b/LawFirm/LawFirm/FormViewImplementers.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/LawFirm/LawFirm/FormViewImplementers.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LawFirm/LawFirm/Program.cs b/LawFirm/LawFirm/Program.cs index 67c2aa2..9c98b1a 100644 --- a/LawFirm/LawFirm/Program.cs +++ b/LawFirm/LawFirm/Program.cs @@ -40,14 +40,17 @@ 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(); @@ -61,6 +64,8 @@ namespace LawFirmView services.AddTransient(); services.AddTransient(); services.AddTransient(); - } + services.AddTransient(); + services.AddTransient(); + } } } \ No newline at end of file diff --git a/LawFirm/LawFirmRestApi/Controllers/ImplementerController.cs b/LawFirm/LawFirmRestApi/Controllers/ImplementerController.cs new file mode 100644 index 0000000..89632ef --- /dev/null +++ b/LawFirm/LawFirmRestApi/Controllers/ImplementerController.cs @@ -0,0 +1,102 @@ +using DocumentFormat.OpenXml.Office2010.Excel; +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Enums; +using Microsoft.AspNetCore.Mvc; + +namespace LawFirmRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ImplementerController : Controller + { + private readonly ILogger _logger; + private readonly IOrderLogic _order; + private readonly IImplementerLogic _logic; + public ImplementerController(IOrderLogic order, IImplementerLogic logic, + ILogger logger) + { + _logger = logger; + _order = order; + _logic = logic; + } + [HttpGet] + public ImplementerViewModel? Login(string login, string password) + { + try + { + return _logic.ReadElement(new ImplementerSearchModel + { + ImplementerFIO = login, + Password = password + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка авторизации сотрудника"); + throw; + } + } + [HttpGet] + public List? GetNewOrders() + { + try + { + return _order.ReadList(new OrderSearchModel + { + OrderStatus = OrderStatus.Принят + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения новых заказов"); + throw; + } + } + [HttpGet] + public OrderViewModel? GetImplementerOrder(int implementerId) + { + try + { + return _order.ReadElement(new OrderSearchModel + { + ImplementerId = implementerId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения текущего заказа исполнителя"); + throw; + } + } + [HttpPost] + public void TakeOrderInWork(OrderBindingModel model) + { + try + { + _order.TakeOrderInWork(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу", + model.Id); + throw; + } + } + [HttpPost] + public void FinishOrder(OrderBindingModel model) + { + try + { + _order.FinishOrder(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа с№{ Id}", model.Id); + throw; + } + } + } +} \ No newline at end of file