сломается ли...

This commit is contained in:
malimova 2024-05-04 00:37:27 +04:00
parent 8514947e25
commit 521c14bcc7
3 changed files with 449 additions and 404 deletions

View File

@ -20,67 +20,68 @@
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()
{ {
dataGridView = new DataGridView(); dataGridView = new DataGridView();
buttonDelete = new Button(); buttonDelete = new Button();
buttonRefresh = new Button(); buttonRefresh = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// dataGridView // dataGridView
// //
dataGridView.BackgroundColor = Color.AliceBlue; dataGridView.BackgroundColor = Color.AliceBlue;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(0, 1); dataGridView.Location = new Point(0, 1);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 62; dataGridView.RowHeadersWidth = 62;
dataGridView.Size = new Size(738, 450); dataGridView.Size = new Size(738, 450);
dataGridView.TabIndex = 0; dataGridView.TabIndex = 0;
// //
// buttonDelete // buttonDelete
// //
buttonDelete.Location = new Point(771, 93); buttonDelete.Location = new Point(771, 93);
buttonDelete.Name = "buttonDelete"; buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(133, 49); buttonDelete.Size = new Size(133, 49);
buttonDelete.TabIndex = 1; buttonDelete.TabIndex = 1;
buttonDelete.Text = "Удалить"; buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true; buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += buttonDelete_Click; buttonDelete.Click += buttonDelete_Click;
// //
// buttonRefresh // buttonRefresh
// //
buttonRefresh.Location = new Point(771, 183); buttonRefresh.Location = new Point(771, 183);
buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(133, 49); buttonRefresh.Size = new Size(133, 49);
buttonRefresh.TabIndex = 2; buttonRefresh.TabIndex = 2;
buttonRefresh.Text = "Обновить"; buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true; buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += buttonRefresh_Click; buttonRefresh.Click += buttonRefresh_Click;
// //
// FormClients // FormClients
// //
AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(938, 450); ClientSize = new Size(938, 450);
Controls.Add(buttonRefresh); Controls.Add(buttonRefresh);
Controls.Add(buttonDelete); Controls.Add(buttonDelete);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Name = "FormClients"; Name = "FormClients";
Text = "Список клиентов"; Text = "Список клиентов";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); Load += FormClients_Load;
ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
} ResumeLayout(false);
}
#endregion #endregion
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonDelete; private Button buttonDelete;
private Button buttonRefresh; private Button buttonRefresh;
} }

View File

@ -20,182 +20,205 @@
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()
{ {
dataGridView = new DataGridView(); dataGridView = new DataGridView();
menuStrip = new MenuStrip(); menuStrip = new MenuStrip();
toolStripMenuItem = new ToolStripMenuItem(); toolStripMenuItem = new ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem(); componentsToolStripMenuItem = new ToolStripMenuItem();
pastryToolStripMenuItem = new ToolStripMenuItem(); pastryToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem(); clientsToolStripMenuItem = new ToolStripMenuItem();
pastrysListToolStripMenuItem = new ToolStripMenuItem(); implementersToolStripMenuItem = new ToolStripMenuItem();
componentPastryToolStripMenuItem = new ToolStripMenuItem(); отчетыToolStripMenuItem = new ToolStripMenuItem();
ordersListToolStripMenuItem = new ToolStripMenuItem(); pastrysListToolStripMenuItem = new ToolStripMenuItem();
buttonCreateOrder = new Button(); componentPastryToolStripMenuItem = new ToolStripMenuItem();
buttonTakeOrderInWork = new Button(); ordersListToolStripMenuItem = new ToolStripMenuItem();
buttonOrderReady = new Button(); startWorkToolStripMenuItem = new ToolStripMenuItem();
buttonIssuedOrder = new Button(); buttonCreateOrder = new Button();
buttonRef = new Button(); buttonTakeOrderInWork = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); buttonOrderReady = new Button();
menuStrip.SuspendLayout(); buttonIssuedOrder = new Button();
SuspendLayout(); buttonRef = new Button();
// ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
// dataGridView menuStrip.SuspendLayout();
// SuspendLayout();
dataGridView.BackgroundColor = Color.AliceBlue; //
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; // dataGridView
dataGridView.Location = new Point(12, 60); //
dataGridView.Name = "dataGridView"; dataGridView.BackgroundColor = Color.AliceBlue;
dataGridView.RowHeadersWidth = 62; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Size = new Size(1374, 549); dataGridView.Location = new Point(12, 60);
dataGridView.TabIndex = 0; dataGridView.Name = "dataGridView";
// dataGridView.RowHeadersWidth = 62;
// menuStrip dataGridView.Size = new Size(1374, 549);
// dataGridView.TabIndex = 0;
menuStrip.ImageScalingSize = new Size(24, 24); //
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчетыToolStripMenuItem }); // menuStrip
menuStrip.Location = new Point(0, 0); //
menuStrip.Name = "menuStrip"; menuStrip.ImageScalingSize = new Size(24, 24);
menuStrip.Size = new Size(1666, 33); menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчетыToolStripMenuItem, startWorkToolStripMenuItem });
menuStrip.TabIndex = 1; menuStrip.Location = new Point(0, 0);
menuStrip.Text = "menuStrip1"; menuStrip.Name = "menuStrip";
// menuStrip.Size = new Size(1666, 33);
// toolStripMenuItem menuStrip.TabIndex = 1;
// menuStrip.Text = "menuStrip1";
toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, pastryToolStripMenuItem }); //
toolStripMenuItem.Name = "toolStripMenuItem"; // toolStripMenuItem
toolStripMenuItem.Size = new Size(139, 29); //
toolStripMenuItem.Text = "Справочники"; toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, pastryToolStripMenuItem, clientsToolStripMenuItem, implementersToolStripMenuItem });
// toolStripMenuItem.Name = "toolStripMenuItem";
// componentsToolStripMenuItem toolStripMenuItem.Size = new Size(139, 29);
// toolStripMenuItem.Text = "Справочники";
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; //
componentsToolStripMenuItem.Size = new Size(298, 34); // componentsToolStripMenuItem
componentsToolStripMenuItem.Text = "Компоненты"; //
componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click; componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
// componentsToolStripMenuItem.Size = new Size(298, 34);
// pastryToolStripMenuItem componentsToolStripMenuItem.Text = "Компоненты";
// componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click;
pastryToolStripMenuItem.Name = "pastryToolStripMenuItem"; //
pastryToolStripMenuItem.Size = new Size(298, 34); // pastryToolStripMenuItem
pastryToolStripMenuItem.Text = "Кондитерские изделия"; //
pastryToolStripMenuItem.Click += pastryToolStripMenuItem_Click; pastryToolStripMenuItem.Name = "pastryToolStripMenuItem";
// pastryToolStripMenuItem.Size = new Size(298, 34);
// отчетыToolStripMenuItem pastryToolStripMenuItem.Text = "Кондитерские изделия";
// pastryToolStripMenuItem.Click += pastryToolStripMenuItem_Click;
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastrysListToolStripMenuItem, componentPastryToolStripMenuItem, ordersListToolStripMenuItem }); //
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; // clientsToolStripMenuItem
отчетыToolStripMenuItem.Size = new Size(88, 29); //
отчетыToolStripMenuItem.Text = "Отчеты"; clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
// clientsToolStripMenuItem.Size = new Size(298, 34);
// pastrysListToolStripMenuItem clientsToolStripMenuItem.Text = "Клиенты";
// clientsToolStripMenuItem.Click += clientsToolStripMenuItem_Click;
pastrysListToolStripMenuItem.Name = "pastrysListToolStripMenuItem"; //
pastrysListToolStripMenuItem.Size = new Size(327, 34); // implementersToolStripMenuItem
pastrysListToolStripMenuItem.Text = "Список изделий"; //
pastrysListToolStripMenuItem.Click += pastrysListToolStripMenuItem_Click; implementersToolStripMenuItem.Name = "implementersToolStripMenuItem";
// implementersToolStripMenuItem.Size = new Size(298, 34);
// componentPastryToolStripMenuItem implementersToolStripMenuItem.Text = "Исполнители";
// implementersToolStripMenuItem.Click += implementersToolStripMenuItem_Click;
componentPastryToolStripMenuItem.Name = "componentPastryToolStripMenuItem"; //
componentPastryToolStripMenuItem.Size = new Size(327, 34); // отчетыToolStripMenuItem
componentPastryToolStripMenuItem.Text = "Компоненты по изделиям"; //
componentPastryToolStripMenuItem.Click += componentPastryToolStripMenuItem_Click; отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastrysListToolStripMenuItem, componentPastryToolStripMenuItem, ordersListToolStripMenuItem });
// отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
// ordersListToolStripMenuItem отчетыToolStripMenuItem.Size = new Size(88, 29);
// отчетыToolStripMenuItem.Text = "Отчеты";
ordersListToolStripMenuItem.Name = "ordersListToolStripMenuItem"; //
ordersListToolStripMenuItem.Size = new Size(327, 34); // pastrysListToolStripMenuItem
ordersListToolStripMenuItem.Text = "Список заказов"; //
ordersListToolStripMenuItem.Click += ordersListToolStripMenuItem_Click; pastrysListToolStripMenuItem.Name = "pastrysListToolStripMenuItem";
// pastrysListToolStripMenuItem.Size = new Size(327, 34);
// buttonCreateOrder pastrysListToolStripMenuItem.Text = "Список изделий";
// pastrysListToolStripMenuItem.Click += pastrysListToolStripMenuItem_Click;
buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; //
buttonCreateOrder.Location = new Point(1402, 83); // componentPastryToolStripMenuItem
buttonCreateOrder.Name = "buttonCreateOrder"; //
buttonCreateOrder.Size = new Size(232, 34); componentPastryToolStripMenuItem.Name = "componentPastryToolStripMenuItem";
buttonCreateOrder.TabIndex = 2; componentPastryToolStripMenuItem.Size = new Size(327, 34);
buttonCreateOrder.Text = "Создать заказ"; componentPastryToolStripMenuItem.Text = "Компоненты по изделиям";
buttonCreateOrder.UseVisualStyleBackColor = true; componentPastryToolStripMenuItem.Click += componentPastryToolStripMenuItem_Click;
buttonCreateOrder.Click += buttonCreateOrder_Click; //
// // ordersListToolStripMenuItem
// buttonTakeOrderInWork //
// ordersListToolStripMenuItem.Name = "ordersListToolStripMenuItem";
buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; ordersListToolStripMenuItem.Size = new Size(327, 34);
buttonTakeOrderInWork.Location = new Point(1402, 143); ordersListToolStripMenuItem.Text = "Список заказов";
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; ordersListToolStripMenuItem.Click += ordersListToolStripMenuItem_Click;
buttonTakeOrderInWork.Size = new Size(232, 34); //
buttonTakeOrderInWork.TabIndex = 3; // startWorkToolStripMenuItem
buttonTakeOrderInWork.Text = "Отдать на выполнение"; //
buttonTakeOrderInWork.UseVisualStyleBackColor = true; startWorkToolStripMenuItem.Name = "startWorkToolStripMenuItem";
buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; startWorkToolStripMenuItem.Size = new Size(136, 29);
// startWorkToolStripMenuItem.Text = "Запуск работ";
// buttonOrderReady //
// // buttonCreateOrder
buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right; //
buttonOrderReady.Location = new Point(1402, 203); buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonOrderReady.Name = "buttonOrderReady"; buttonCreateOrder.Location = new Point(1402, 83);
buttonOrderReady.Size = new Size(232, 34); buttonCreateOrder.Name = "buttonCreateOrder";
buttonOrderReady.TabIndex = 4; buttonCreateOrder.Size = new Size(232, 34);
buttonOrderReady.Text = "Заказ готов"; buttonCreateOrder.TabIndex = 2;
buttonOrderReady.UseVisualStyleBackColor = true; buttonCreateOrder.Text = "Создать заказ";
buttonOrderReady.Click += buttonOrderReady_Click; buttonCreateOrder.UseVisualStyleBackColor = true;
// buttonCreateOrder.Click += buttonCreateOrder_Click;
// buttonIssuedOrder //
// // buttonTakeOrderInWork
buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; //
buttonIssuedOrder.Location = new Point(1402, 266); buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonIssuedOrder.Name = "buttonIssuedOrder"; buttonTakeOrderInWork.Location = new Point(1402, 143);
buttonIssuedOrder.Size = new Size(232, 34); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonIssuedOrder.TabIndex = 5; buttonTakeOrderInWork.Size = new Size(232, 34);
buttonIssuedOrder.Text = "Заказ выдан"; buttonTakeOrderInWork.TabIndex = 3;
buttonIssuedOrder.UseVisualStyleBackColor = true; buttonTakeOrderInWork.Text = "Отдать на выполнение";
buttonIssuedOrder.Click += buttonIssuedOrder_Click; buttonTakeOrderInWork.UseVisualStyleBackColor = true;
// buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
// buttonRef //
// // buttonOrderReady
buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; //
buttonRef.Location = new Point(1402, 329); buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonRef.Name = "buttonRef"; buttonOrderReady.Location = new Point(1402, 203);
buttonRef.Size = new Size(232, 34); buttonOrderReady.Name = "buttonOrderReady";
buttonRef.TabIndex = 6; buttonOrderReady.Size = new Size(232, 34);
buttonRef.Text = "Обновить список"; buttonOrderReady.TabIndex = 4;
buttonRef.UseVisualStyleBackColor = true; buttonOrderReady.Text = "Заказ готов";
buttonRef.Click += buttonRef_Click; buttonOrderReady.UseVisualStyleBackColor = true;
// buttonOrderReady.Click += buttonOrderReady_Click;
// FormMain //
// // buttonIssuedOrder
AutoScaleDimensions = new SizeF(10F, 25F); //
AutoScaleMode = AutoScaleMode.Font; buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
ClientSize = new Size(1666, 621); buttonIssuedOrder.Location = new Point(1402, 266);
Controls.Add(buttonRef); buttonIssuedOrder.Name = "buttonIssuedOrder";
Controls.Add(buttonIssuedOrder); buttonIssuedOrder.Size = new Size(232, 34);
Controls.Add(buttonOrderReady); buttonIssuedOrder.TabIndex = 5;
Controls.Add(buttonTakeOrderInWork); buttonIssuedOrder.Text = "Заказ выдан";
Controls.Add(buttonCreateOrder); buttonIssuedOrder.UseVisualStyleBackColor = true;
Controls.Add(dataGridView); buttonIssuedOrder.Click += buttonIssuedOrder_Click;
Controls.Add(menuStrip); //
MainMenuStrip = menuStrip; // buttonRef
Name = "FormMain"; //
Text = "Кондитерская"; buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
Load += FormMain_Load; buttonRef.Location = new Point(1402, 329);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); buttonRef.Name = "buttonRef";
menuStrip.ResumeLayout(false); buttonRef.Size = new Size(232, 34);
menuStrip.PerformLayout(); buttonRef.TabIndex = 6;
ResumeLayout(false); buttonRef.Text = "Обновить список";
PerformLayout(); buttonRef.UseVisualStyleBackColor = true;
} buttonRef.Click += buttonRef_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1666, 621);
Controls.Add(buttonRef);
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;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion #endregion
private DataGridView dataGridView; private DataGridView dataGridView;
private MenuStrip menuStrip; private MenuStrip menuStrip;
private ToolStripMenuItem toolStripMenuItem; private ToolStripMenuItem toolStripMenuItem;
private Button buttonCreateOrder; private Button buttonCreateOrder;
@ -209,5 +232,8 @@
private ToolStripMenuItem pastrysListToolStripMenuItem; private ToolStripMenuItem pastrysListToolStripMenuItem;
private ToolStripMenuItem componentPastryToolStripMenuItem; private ToolStripMenuItem componentPastryToolStripMenuItem;
private ToolStripMenuItem ordersListToolStripMenuItem; private ToolStripMenuItem ordersListToolStripMenuItem;
} private ToolStripMenuItem clientsToolStripMenuItem;
private ToolStripMenuItem implementersToolStripMenuItem;
private ToolStripMenuItem startWorkToolStripMenuItem;
}
} }

View File

@ -13,186 +13,204 @@ using System.Windows.Forms;
namespace ConfectioneryView namespace ConfectioneryView
{ {
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["PastryId"].Visible = false; dataGridView.Columns["PastryId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false; dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["PastryName"].AutoSizeMode = dataGridView.Columns["PastryName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill; DataGridViewAutoSizeColumnMode.Fill;
} }
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
} }
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 pastryToolStripMenuItem_Click(object sender, EventArgs e) private void pastryToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormPastrys)); var service = Program.ServiceProvider?.GetService(typeof(FormPastrys));
if (service is FormPastrys form) if (service is FormPastrys 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 var operationResult = _orderLogic.TakeOrderInWork(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, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); 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 = 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.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 = 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.DeliveryOrder(new var operationResult = _orderLogic.DeliveryOrder(new
OrderBindingModel OrderBindingModel
{ Id = id }); { 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, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); MessageBoxIcon.Error);
} }
} }
} }
private void buttonRef_Click(object sender, EventArgs e) private void buttonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void componentPastryToolStripMenuItem_Click(object sender, EventArgs e) private void componentPastryToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryComponents)); var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryComponents));
if (service is FormReportPastryComponents form) if (service is FormReportPastryComponents form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ordersListToolStripMenuItem_Click(object sender, EventArgs e) private void ordersListToolStripMenuItem_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 pastrysListToolStripMenuItem_Click(object sender, EventArgs e) private void pastrysListToolStripMenuItem_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.SaveComponentsToWordFile(new ReportBindingModel _reportLogic.SaveComponentsToWordFile(new ReportBindingModel
{ {
FileName = dialog.FileName FileName = dialog.FileName
}); });
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information); MessageBoxIcon.Information);
} }
} }
}
private void clientsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
}
}
private void implementersToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
if (service is FormImplementers form)
{
form.ShowDialog();
}
}
}
} }