Лабораторная_5

This commit is contained in:
yuliya.mavrina@internet.ru 2024-04-25 23:23:04 +03:00
parent 58c76a07fd
commit 6e11c1f758
2 changed files with 382 additions and 382 deletions

View File

@ -1,216 +1,216 @@
namespace RenovationWorkView namespace RenovationWorkView
{ {
partial class FormMain partial class FormMain
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
menuStrip = new MenuStrip(); menuStrip = new MenuStrip();
refbooksToolStripMenuItem = new ToolStripMenuItem(); refbooksToolStripMenuItem = new ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem(); componentsToolStripMenuItem = new ToolStripMenuItem();
JobTypeToolStripMenuItem = new ToolStripMenuItem(); JobTypeToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem(); ClientsToolStripMenuItem = new ToolStripMenuItem();
listComponentsToolStripMenuItem = new ToolStripMenuItem(); отчетыToolStripMenuItem = new ToolStripMenuItem();
componentRepairsПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); listComponentsToolStripMenuItem = new ToolStripMenuItem();
OrdersToolStripMenuItem = new ToolStripMenuItem(); componentRepairsПоИзделиямToolStripMenuItem = new ToolStripMenuItem();
dataGridView = new DataGridView(); OrdersToolStripMenuItem = new ToolStripMenuItem();
buttonCreateOrder = new Button(); dataGridView = new DataGridView();
buttonTakeOrderInWork = new Button(); buttonCreateOrder = new Button();
buttonOrderReady = new Button(); buttonTakeOrderInWork = new Button();
buttonIssuedOrder = new Button(); buttonOrderReady = new Button();
buttonRef = new Button(); buttonIssuedOrder = new Button();
ClientsToolStripMenuItem = new ToolStripMenuItem(); buttonRef = new Button();
menuStrip.SuspendLayout(); menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// menuStrip // menuStrip
// //
menuStrip.Items.AddRange(new ToolStripItem[] { refbooksToolStripMenuItem, отчетыToolStripMenuItem }); menuStrip.Items.AddRange(new ToolStripItem[] { refbooksToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Location = new Point(0, 0); menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip"; menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(984, 24); menuStrip.Size = new Size(1028, 24);
menuStrip.TabIndex = 0; menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip1"; menuStrip.Text = "menuStrip1";
// //
// refbooksToolStripMenuItem // refbooksToolStripMenuItem
// //
refbooksToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, JobTypeToolStripMenuItem, ClientsToolStripMenuItem }); refbooksToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, JobTypeToolStripMenuItem, ClientsToolStripMenuItem });
refbooksToolStripMenuItem.Name = "refbooksToolStripMenuItem"; refbooksToolStripMenuItem.Name = "refbooksToolStripMenuItem";
refbooksToolStripMenuItem.Size = new Size(94, 20); refbooksToolStripMenuItem.Size = new Size(94, 20);
refbooksToolStripMenuItem.Text = "Справочники"; refbooksToolStripMenuItem.Text = "Справочники";
// //
// componentsToolStripMenuItem // componentsToolStripMenuItem
// //
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
componentsToolStripMenuItem.Size = new Size(180, 22); componentsToolStripMenuItem.Size = new Size(145, 22);
componentsToolStripMenuItem.Text = "Компоненты"; componentsToolStripMenuItem.Text = "Компоненты";
componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click; componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click;
// //
// JobTypeToolStripMenuItem // JobTypeToolStripMenuItem
// //
JobTypeToolStripMenuItem.Name = "JobTypeToolStripMenuItem"; JobTypeToolStripMenuItem.Name = "JobTypeToolStripMenuItem";
JobTypeToolStripMenuItem.Size = new Size(180, 22); JobTypeToolStripMenuItem.Size = new Size(145, 22);
JobTypeToolStripMenuItem.Text = "Вид работы"; JobTypeToolStripMenuItem.Text = "Вид работы";
JobTypeToolStripMenuItem.Click += JobTypeToolStripMenuItem_Click; JobTypeToolStripMenuItem.Click += JobTypeToolStripMenuItem_Click;
// //
// отчетыToolStripMenuItem // ClientsToolStripMenuItem
// //
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { listComponentsToolStripMenuItem, componentRepairsПоИзделиямToolStripMenuItem, OrdersToolStripMenuItem }); ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; ClientsToolStripMenuItem.Size = new Size(145, 22);
отчетыToolStripMenuItem.Size = new Size(60, 20); ClientsToolStripMenuItem.Text = "Клиенты";
отчетыToolStripMenuItem.Text = "Отчеты"; ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
// //
// listComponentsToolStripMenuItem // отчетыToolStripMenuItem
// //
listComponentsToolStripMenuItem.Name = "listComponentsToolStripMenuItem"; отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { listComponentsToolStripMenuItem, componentRepairsПоИзделиямToolStripMenuItem, OrdersToolStripMenuItem });
listComponentsToolStripMenuItem.Size = new Size(218, 22); отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
listComponentsToolStripMenuItem.Text = "Список изделий"; отчетыToolStripMenuItem.Size = new Size(60, 20);
listComponentsToolStripMenuItem.Click += listComponentsToolStripMenuItem_Click; отчетыToolStripMenuItem.Text = "Отчеты";
// //
// componentRepairsПоИзделиямToolStripMenuItem // listComponentsToolStripMenuItem
// //
componentRepairsПоИзделиямToolStripMenuItem.Name = "componentRepairsПоИзделиямToolStripMenuItem"; listComponentsToolStripMenuItem.Name = "listComponentsToolStripMenuItem";
componentRepairsПоИзделиямToolStripMenuItem.Size = new Size(218, 22); listComponentsToolStripMenuItem.Size = new Size(218, 22);
componentRepairsПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; listComponentsToolStripMenuItem.Text = "Список изделий";
componentRepairsПоИзделиямToolStripMenuItem.Click += componentRepairsПоИзделиямToolStripMenuItem_Click; listComponentsToolStripMenuItem.Click += listComponentsToolStripMenuItem_Click;
// //
// OrdersToolStripMenuItem // componentRepairsПоИзделиямToolStripMenuItem
// //
OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; componentRepairsПоИзделиямToolStripMenuItem.Name = "componentRepairsПоИзделиямToolStripMenuItem";
OrdersToolStripMenuItem.Size = new Size(218, 22); componentRepairsПоИзделиямToolStripMenuItem.Size = new Size(218, 22);
OrdersToolStripMenuItem.Text = "Список заказов"; componentRepairsПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям";
OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; componentRepairsПоИзделиямToolStripMenuItem.Click += componentRepairsПоИзделиямToolStripMenuItem_Click;
// //
// dataGridView // OrdersToolStripMenuItem
// //
dataGridView.BackgroundColor = SystemColors.ControlLightLight; OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; OrdersToolStripMenuItem.Size = new Size(218, 22);
dataGridView.Location = new Point(12, 27); OrdersToolStripMenuItem.Text = "Список заказов";
dataGridView.Name = "dataGridView"; OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
dataGridView.RowTemplate.Height = 25; //
dataGridView.Size = new Size(797, 341); // dataGridView
dataGridView.TabIndex = 1; //
// dataGridView.BackgroundColor = SystemColors.ControlLightLight;
// buttonCreateOrder dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
// dataGridView.Location = new Point(12, 27);
buttonCreateOrder.Location = new Point(815, 42); dataGridView.Name = "dataGridView";
buttonCreateOrder.Name = "buttonCreateOrder"; dataGridView.RowTemplate.Height = 25;
buttonCreateOrder.Size = new Size(157, 23); dataGridView.Size = new Size(853, 341);
buttonCreateOrder.TabIndex = 2; dataGridView.TabIndex = 1;
buttonCreateOrder.Text = "Создать заказ"; //
buttonCreateOrder.UseVisualStyleBackColor = true; // buttonCreateOrder
buttonCreateOrder.Click += buttonCreateOrder_Click; //
// buttonCreateOrder.Location = new Point(871, 42);
// buttonTakeOrderInWork buttonCreateOrder.Name = "buttonCreateOrder";
// buttonCreateOrder.Size = new Size(157, 23);
buttonTakeOrderInWork.Location = new Point(815, 71); buttonCreateOrder.TabIndex = 2;
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; buttonCreateOrder.Text = "Создать заказ";
buttonTakeOrderInWork.Size = new Size(157, 23); buttonCreateOrder.UseVisualStyleBackColor = true;
buttonTakeOrderInWork.TabIndex = 3; buttonCreateOrder.Click += buttonCreateOrder_Click;
buttonTakeOrderInWork.Text = "Отладить на выполнение"; //
buttonTakeOrderInWork.UseVisualStyleBackColor = true; // buttonTakeOrderInWork
buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; //
// buttonTakeOrderInWork.Location = new Point(871, 71);
// buttonOrderReady buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
// buttonTakeOrderInWork.Size = new Size(157, 23);
buttonOrderReady.Location = new Point(815, 100); buttonTakeOrderInWork.TabIndex = 3;
buttonOrderReady.Name = "buttonOrderReady"; buttonTakeOrderInWork.Text = "Отладить на выполнение";
buttonOrderReady.Size = new Size(157, 23); buttonTakeOrderInWork.UseVisualStyleBackColor = true;
buttonOrderReady.TabIndex = 4; buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
buttonOrderReady.Text = "Заказ готов"; //
buttonOrderReady.UseVisualStyleBackColor = true; // buttonOrderReady
buttonOrderReady.Click += buttonOrderReady_Click; //
// buttonOrderReady.Location = new Point(871, 100);
// buttonIssuedOrder buttonOrderReady.Name = "buttonOrderReady";
// buttonOrderReady.Size = new Size(157, 23);
buttonIssuedOrder.Location = new Point(815, 129); buttonOrderReady.TabIndex = 4;
buttonIssuedOrder.Name = "buttonIssuedOrder"; buttonOrderReady.Text = "Заказ готов";
buttonIssuedOrder.Size = new Size(157, 23); buttonOrderReady.UseVisualStyleBackColor = true;
buttonIssuedOrder.TabIndex = 5; buttonOrderReady.Click += buttonOrderReady_Click;
buttonIssuedOrder.Text = "Заказ выдан"; //
buttonIssuedOrder.UseVisualStyleBackColor = true; // buttonIssuedOrder
buttonIssuedOrder.Click += buttonIssuedOrder_Click; //
// buttonIssuedOrder.Location = new Point(871, 129);
// buttonRef buttonIssuedOrder.Name = "buttonIssuedOrder";
// buttonIssuedOrder.Size = new Size(157, 23);
buttonRef.Location = new Point(815, 158); buttonIssuedOrder.TabIndex = 5;
buttonRef.Name = "buttonRef"; buttonIssuedOrder.Text = "Заказ выдан";
buttonRef.Size = new Size(157, 23); buttonIssuedOrder.UseVisualStyleBackColor = true;
buttonRef.TabIndex = 6; buttonIssuedOrder.Click += buttonIssuedOrder_Click;
buttonRef.Text = "Обновить список"; //
buttonRef.UseVisualStyleBackColor = true; // buttonRef
buttonRef.Click += buttonRef_Click; //
// buttonRef.Location = new Point(871, 158);
// ClientsToolStripMenuItem buttonRef.Name = "buttonRef";
// buttonRef.Size = new Size(157, 23);
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; buttonRef.TabIndex = 6;
ClientsToolStripMenuItem.Size = new Size(180, 22); buttonRef.Text = "Обновить список";
ClientsToolStripMenuItem.Text = "Клиенты"; buttonRef.UseVisualStyleBackColor = true;
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; buttonRef.Click += buttonRef_Click;
// //
// FormMain // FormMain
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(984, 370); ClientSize = new Size(1028, 370);
Controls.Add(buttonRef); Controls.Add(buttonRef);
Controls.Add(buttonIssuedOrder); Controls.Add(buttonIssuedOrder);
Controls.Add(buttonOrderReady); Controls.Add(buttonOrderReady);
Controls.Add(buttonTakeOrderInWork); Controls.Add(buttonTakeOrderInWork);
Controls.Add(buttonCreateOrder); Controls.Add(buttonCreateOrder);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Controls.Add(menuStrip); Controls.Add(menuStrip);
MainMenuStrip = menuStrip; MainMenuStrip = menuStrip;
Name = "FormMain"; Name = "FormMain";
Text = "Ремонтные работы"; Text = "Ремонтные работы";
Load += FormMain_Load; Load += FormMain_Load;
menuStrip.ResumeLayout(false); menuStrip.ResumeLayout(false);
menuStrip.PerformLayout(); menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
#endregion #endregion
private MenuStrip menuStrip; private MenuStrip menuStrip;
private ToolStripMenuItem refbooksToolStripMenuItem; private ToolStripMenuItem refbooksToolStripMenuItem;
private ToolStripMenuItem componentsToolStripMenuItem; private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem JobTypeToolStripMenuItem; private ToolStripMenuItem JobTypeToolStripMenuItem;
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonCreateOrder; private Button buttonCreateOrder;
private Button buttonTakeOrderInWork; private Button buttonTakeOrderInWork;
private Button buttonOrderReady; private Button buttonOrderReady;
private Button buttonIssuedOrder; private Button buttonIssuedOrder;
private Button buttonRef; private Button buttonRef;
private ToolStripMenuItem отчетыToolStripMenuItem; private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem listComponentsToolStripMenuItem; private ToolStripMenuItem listComponentsToolStripMenuItem;
private ToolStripMenuItem componentRepairsПоИзделиямToolStripMenuItem; private ToolStripMenuItem componentRepairsПоИзделиямToolStripMenuItem;
private ToolStripMenuItem OrdersToolStripMenuItem; private ToolStripMenuItem OrdersToolStripMenuItem;
private ToolStripMenuItem ClientsToolStripMenuItem; private ToolStripMenuItem ClientsToolStripMenuItem;
} }
} }

View File

@ -14,191 +14,191 @@ using RenovationWorkBusinessLogic.BusinessLogics;
namespace RenovationWorkView namespace RenovationWorkView
{ {
public partial class FormMain : Form public partial class FormMain : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic; private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic; private readonly IReportLogic _reportLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic) public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_orderLogic = orderLogic; _orderLogic = orderLogic;
_reportLogic = reportLogic; _reportLogic = reportLogic;
} }
private void FormMain_Load(object sender, EventArgs e) private void FormMain_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void LoadData() private void LoadData()
{ {
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
try try
{ {
var list = _orderLogic.ReadList(null); var list = _orderLogic.ReadList(null);
if (list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["RepairId"].Visible = false; dataGridView.Columns["RepairId"].Visible = false;
dataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ClientId"].Visible = false; dataGridView.Columns["ClientId"].Visible = false;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки заказов"); _logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void componentsToolStripMenuItem_Click(object sender, EventArgs e) private void componentsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form) if (service is FormComponents form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void JobTypeToolStripMenuItem_Click(object sender, EventArgs e) private void JobTypeToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormRepairs)); var service = Program.ServiceProvider?.GetService(typeof(FormRepairs));
if (service is FormRepairs form) if (service is FormRepairs form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void buttonCreateOrder_Click(object sender, EventArgs e) private void buttonCreateOrder_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form) if (service is FormCreateOrder form)
{ {
form.ShowDialog(); form.ShowDialog();
LoadData(); LoadData();
} }
} }
private void buttonTakeOrderInWork_Click(object sender, EventArgs e) private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) 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); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try try
{ {
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(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) private void buttonOrderReady_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
int id = int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try try
{ {
var operationResult = _orderLogic.FinishOrder(new var operationResult = _orderLogic.FinishOrder(new
OrderBindingModel OrderBindingModel
{ Id = id }); { Id = id });
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(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) private void buttonIssuedOrder_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
int id = int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try try
{ {
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
_logger.LogInformation("Заказ №{id} выдан", id); _logger.LogInformation("Заказ №{id} выдан", id);
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(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) private void buttonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void listComponentsToolStripMenuItem_Click(object sender, EventArgs e) private void listComponentsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK) if (dialog.ShowDialog() == DialogResult.OK)
{ {
_reportLogic.SaveRepairsToWordFile(new ReportBindingModel _reportLogic.SaveRepairsToWordFile(new ReportBindingModel
{ {
FileName = dialog.FileName FileName = dialog.FileName
}); });
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information); MessageBoxIcon.Information);
} }
} }
private void componentRepairsПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) private void componentRepairsПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportRepairComponents)); var service = Program.ServiceProvider?.GetService(typeof(FormReportRepairComponents));
if (service is FormReportRepairComponents form) if (service is FormReportRepairComponents form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
if (service is FormReportOrders form) if (service is FormReportOrders form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormClients)); var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form) if (service is FormClients form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
} }
} }