diff --git a/Confectionery/ConfectioneryView/FormMain.Designer.cs b/Confectionery/ConfectioneryView/FormMain.Designer.cs index f99849b..744a776 100644 --- a/Confectionery/ConfectioneryView/FormMain.Designer.cs +++ b/Confectionery/ConfectioneryView/FormMain.Designer.cs @@ -20,182 +20,190 @@ 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() - { - dataGridView = new DataGridView(); - menuStrip = new MenuStrip(); - toolStripMenuItem = new ToolStripMenuItem(); - componentsToolStripMenuItem = new ToolStripMenuItem(); - pastryToolStripMenuItem = new ToolStripMenuItem(); - отчетыToolStripMenuItem = new ToolStripMenuItem(); - pastrysListToolStripMenuItem = new ToolStripMenuItem(); - componentPastryToolStripMenuItem = new ToolStripMenuItem(); - ordersListToolStripMenuItem = new ToolStripMenuItem(); - buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); - buttonIssuedOrder = new Button(); - buttonRef = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - menuStrip.SuspendLayout(); - SuspendLayout(); - // - // dataGridView - // - dataGridView.BackgroundColor = Color.AliceBlue; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(12, 60); - dataGridView.Name = "dataGridView"; - dataGridView.RowHeadersWidth = 62; - dataGridView.Size = new Size(1374, 549); - dataGridView.TabIndex = 0; - // - // menuStrip - // - menuStrip.ImageScalingSize = new Size(24, 24); - menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчетыToolStripMenuItem }); - menuStrip.Location = new Point(0, 0); - menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(1666, 33); - menuStrip.TabIndex = 1; - menuStrip.Text = "menuStrip1"; - // - // toolStripMenuItem - // - toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, pastryToolStripMenuItem }); - toolStripMenuItem.Name = "toolStripMenuItem"; - toolStripMenuItem.Size = new Size(139, 29); - toolStripMenuItem.Text = "Справочники"; - // - // componentsToolStripMenuItem - // - componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; - componentsToolStripMenuItem.Size = new Size(298, 34); - componentsToolStripMenuItem.Text = "Компоненты"; - componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click; - // - // pastryToolStripMenuItem - // - pastryToolStripMenuItem.Name = "pastryToolStripMenuItem"; - pastryToolStripMenuItem.Size = new Size(298, 34); - pastryToolStripMenuItem.Text = "Кондитерские изделия"; - pastryToolStripMenuItem.Click += pastryToolStripMenuItem_Click; - // - // отчетыToolStripMenuItem - // - отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastrysListToolStripMenuItem, componentPastryToolStripMenuItem, ordersListToolStripMenuItem }); - отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; - отчетыToolStripMenuItem.Size = new Size(88, 29); - отчетыToolStripMenuItem.Text = "Отчеты"; - // - // pastrysListToolStripMenuItem - // - pastrysListToolStripMenuItem.Name = "pastrysListToolStripMenuItem"; - pastrysListToolStripMenuItem.Size = new Size(327, 34); - pastrysListToolStripMenuItem.Text = "Список изделий"; - pastrysListToolStripMenuItem.Click += pastrysListToolStripMenuItem_Click; - // - // componentPastryToolStripMenuItem - // - componentPastryToolStripMenuItem.Name = "componentPastryToolStripMenuItem"; - componentPastryToolStripMenuItem.Size = new Size(327, 34); - componentPastryToolStripMenuItem.Text = "Компоненты по изделиям"; - componentPastryToolStripMenuItem.Click += componentPastryToolStripMenuItem_Click; - // - // ordersListToolStripMenuItem - // - ordersListToolStripMenuItem.Name = "ordersListToolStripMenuItem"; - ordersListToolStripMenuItem.Size = new Size(327, 34); - ordersListToolStripMenuItem.Text = "Список заказов"; - ordersListToolStripMenuItem.Click += ordersListToolStripMenuItem_Click; - // - // buttonCreateOrder - // - buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonCreateOrder.Location = new Point(1402, 83); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(232, 34); - buttonCreateOrder.TabIndex = 2; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = true; - buttonCreateOrder.Click += buttonCreateOrder_Click; - // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonTakeOrderInWork.Location = new Point(1402, 143); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(232, 34); - buttonTakeOrderInWork.TabIndex = 3; - buttonTakeOrderInWork.Text = "Отдать на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = true; - buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; - // - // buttonOrderReady - // - buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonOrderReady.Location = new Point(1402, 203); - buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(232, 34); - buttonOrderReady.TabIndex = 4; - buttonOrderReady.Text = "Заказ готов"; - buttonOrderReady.UseVisualStyleBackColor = true; - buttonOrderReady.Click += buttonOrderReady_Click; - // - // buttonIssuedOrder - // - buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonIssuedOrder.Location = new Point(1402, 266); - buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(232, 34); - buttonIssuedOrder.TabIndex = 5; - buttonIssuedOrder.Text = "Заказ выдан"; - buttonIssuedOrder.UseVisualStyleBackColor = true; - buttonIssuedOrder.Click += buttonIssuedOrder_Click; - // - // buttonRef - // - buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonRef.Location = new Point(1402, 329); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(232, 34); - buttonRef.TabIndex = 6; - buttonRef.Text = "Обновить список"; - 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(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + menuStrip = new MenuStrip(); + toolStripMenuItem = new ToolStripMenuItem(); + componentsToolStripMenuItem = new ToolStripMenuItem(); + pastryToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + pastrysListToolStripMenuItem = new ToolStripMenuItem(); + componentPastryToolStripMenuItem = new ToolStripMenuItem(); + ordersListToolStripMenuItem = new ToolStripMenuItem(); + buttonCreateOrder = new Button(); + buttonTakeOrderInWork = new Button(); + buttonOrderReady = new Button(); + buttonIssuedOrder = new Button(); + buttonRef = new Button(); + clientsToolStripMenuItem = new ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.BackgroundColor = Color.AliceBlue; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 60); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 62; + dataGridView.Size = new Size(1374, 549); + dataGridView.TabIndex = 0; + // + // menuStrip + // + menuStrip.ImageScalingSize = new Size(24, 24); + menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(1666, 33); + menuStrip.TabIndex = 1; + menuStrip.Text = "menuStrip1"; + // + // toolStripMenuItem + // + toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, pastryToolStripMenuItem, clientsToolStripMenuItem }); + toolStripMenuItem.Name = "toolStripMenuItem"; + toolStripMenuItem.Size = new Size(139, 29); + toolStripMenuItem.Text = "Справочники"; + // + // componentsToolStripMenuItem + // + componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; + componentsToolStripMenuItem.Size = new Size(298, 34); + componentsToolStripMenuItem.Text = "Компоненты"; + componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click; + // + // pastryToolStripMenuItem + // + pastryToolStripMenuItem.Name = "pastryToolStripMenuItem"; + pastryToolStripMenuItem.Size = new Size(298, 34); + pastryToolStripMenuItem.Text = "Кондитерские изделия"; + pastryToolStripMenuItem.Click += pastryToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastrysListToolStripMenuItem, componentPastryToolStripMenuItem, ordersListToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(88, 29); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // pastrysListToolStripMenuItem + // + pastrysListToolStripMenuItem.Name = "pastrysListToolStripMenuItem"; + pastrysListToolStripMenuItem.Size = new Size(327, 34); + pastrysListToolStripMenuItem.Text = "Список изделий"; + pastrysListToolStripMenuItem.Click += pastrysListToolStripMenuItem_Click; + // + // componentPastryToolStripMenuItem + // + componentPastryToolStripMenuItem.Name = "componentPastryToolStripMenuItem"; + componentPastryToolStripMenuItem.Size = new Size(327, 34); + componentPastryToolStripMenuItem.Text = "Компоненты по изделиям"; + componentPastryToolStripMenuItem.Click += componentPastryToolStripMenuItem_Click; + // + // ordersListToolStripMenuItem + // + ordersListToolStripMenuItem.Name = "ordersListToolStripMenuItem"; + ordersListToolStripMenuItem.Size = new Size(327, 34); + ordersListToolStripMenuItem.Text = "Список заказов"; + ordersListToolStripMenuItem.Click += ordersListToolStripMenuItem_Click; + // + // buttonCreateOrder + // + buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonCreateOrder.Location = new Point(1402, 83); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(232, 34); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += buttonCreateOrder_Click; + // + // buttonTakeOrderInWork + // + buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonTakeOrderInWork.Location = new Point(1402, 143); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(232, 34); + buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; + // + // buttonOrderReady + // + buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonOrderReady.Location = new Point(1402, 203); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(232, 34); + buttonOrderReady.TabIndex = 4; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += buttonOrderReady_Click; + // + // buttonIssuedOrder + // + buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonIssuedOrder.Location = new Point(1402, 266); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(232, 34); + buttonIssuedOrder.TabIndex = 5; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += buttonIssuedOrder_Click; + // + // buttonRef + // + buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonRef.Location = new Point(1402, 329); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(232, 34); + buttonRef.TabIndex = 6; + buttonRef.Text = "Обновить список"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; + // + // clientsToolStripMenuItem + // + clientsToolStripMenuItem.Name = "clientsToolStripMenuItem"; + clientsToolStripMenuItem.Size = new Size(298, 34); + clientsToolStripMenuItem.Text = "Клиенты"; + clientsToolStripMenuItem.Click += clientsToolStripMenuItem_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 ToolStripMenuItem toolStripMenuItem; private Button buttonCreateOrder; @@ -209,5 +217,6 @@ private ToolStripMenuItem pastrysListToolStripMenuItem; private ToolStripMenuItem componentPastryToolStripMenuItem; private ToolStripMenuItem ordersListToolStripMenuItem; - } + private ToolStripMenuItem clientsToolStripMenuItem; + } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormMain.cs b/Confectionery/ConfectioneryView/FormMain.cs index 7f65823..fc573b3 100644 --- a/Confectionery/ConfectioneryView/FormMain.cs +++ b/Confectionery/ConfectioneryView/FormMain.cs @@ -13,186 +13,195 @@ using System.Windows.Forms; namespace ConfectioneryView { - public partial class FormMain : Form - { - private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; - private readonly IReportLogic _reportLogic; + 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["PastryId"].Visible = false; - dataGridView.Columns["ClientId"].Visible = false; - dataGridView.Columns["PastryName"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; - } - _logger.LogInformation("Загрузка заказов"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки заказов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - private void componentsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) - { - form.ShowDialog(); - } - } - private void pastryToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormPastrys)); - if (service is FormPastrys form) - { - form.ShowDialog(); - } - } + 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["PastryId"].Visible = false; + dataGridView.Columns["ClientId"].Visible = false; + dataGridView.Columns["PastryName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void componentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void pastryToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormPastrys)); + if (service is FormPastrys form) + { + form.ShowDialog(); + } + } - private void buttonCreateOrder_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - if (service is FormCreateOrder form) - { - form.ShowDialog(); - LoadData(); - } - } + private void 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 }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } + 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 }); + 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 }); - 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 }); + 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 }); - 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 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 }); + 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 buttonRef_Click(object sender, EventArgs e) - { - LoadData(); - } + private void buttonRef_Click(object sender, EventArgs e) + { + LoadData(); + } - private void componentPastryToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryComponents)); - if (service is FormReportPastryComponents form) - { - form.ShowDialog(); - } + private void componentPastryToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryComponents)); + if (service is FormReportPastryComponents form) + { + form.ShowDialog(); + } - } + } - private void ordersListToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); - if (service is FormReportOrders form) - { - form.ShowDialog(); - } - } + private void ordersListToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } - private void pastrysListToolStripMenuItem_Click(object sender, EventArgs e) - { - using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; - if (dialog.ShowDialog() == DialogResult.OK) - { - _reportLogic.SaveComponentsToWordFile(new ReportBindingModel - { - FileName = dialog.FileName - }); - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - } - } + private void pastrysListToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveComponentsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + } + + private void clientsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormClients)); + if (service is FormClients form) + { + form.ShowDialog(); + } + } + } }