From 8b3d7e65e118855367b1bb3390f905f9984c94e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=9C=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=D1=84=D0=B5=D0=B5=D0=B2?= Date: Mon, 8 Apr 2024 13:19:39 +0400 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B9=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=BF=D0=BE=D0=BB=D0=BE=D0=B6=D0=B8=D0=BB=20=D0=B2?= =?UTF-8?q?=D0=B5=D1=82=D0=BA=D1=83,=20=D0=BF=D0=BE=D0=B4=D0=BD=D1=8F?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=BD=D0=BE=D0=B3=D0=BE,=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=BB=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82,=20?= =?UTF-8?q?=D0=BD=D0=B0=D1=88=D1=91=D0=BB=20=D0=BF=D0=BE=D1=82=D0=B5=D1=80?= =?UTF-8?q?=D1=8F=D1=88=D0=BA=D0=B8)))?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataListSingleton.cs | 4 +- .../JewerlyStoreView/FormMain.Designer.cs | 358 ++++++++++-------- JewelryStore/JewerlyStoreView/FormMain.cs | 327 ++++++++-------- JewelryStore/JewerlyStoreView/Program.cs | 12 +- 4 files changed, 375 insertions(+), 326 deletions(-) diff --git a/JewelryStore/JewelryStoreListImplement/DataListSingleton.cs b/JewelryStore/JewelryStoreListImplement/DataListSingleton.cs index d9a2839..16e3ad0 100644 --- a/JewelryStore/JewelryStoreListImplement/DataListSingleton.cs +++ b/JewelryStore/JewelryStoreListImplement/DataListSingleton.cs @@ -13,12 +13,14 @@ namespace JewelryStoreListImplement public List Components { get; set; } public List Orders { get; set; } public List Jewels { get; set; } + public List Shops { get; set; } - private DataListSingleton() + private DataListSingleton() { Components = new List(); Orders = new List(); Jewels = new List(); + Shops = new List(); } public static DataListSingleton GetInstance() diff --git a/JewelryStore/JewerlyStoreView/FormMain.Designer.cs b/JewelryStore/JewerlyStoreView/FormMain.Designer.cs index 630f2f4..9d4e47c 100644 --- a/JewelryStore/JewerlyStoreView/FormMain.Designer.cs +++ b/JewelryStore/JewerlyStoreView/FormMain.Designer.cs @@ -1,176 +1,198 @@ namespace JewelryStoreView { - 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() - { - dataGridView = new DataGridView(); - menuStripMain = new MenuStrip(); - справочникиToolStripMenuItem = new ToolStripMenuItem(); - компонентыToolStripMenuItem = new ToolStripMenuItem(); - изделияToolStripMenuItem = new ToolStripMenuItem(); - buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); - buttonIssuedOrder = new Button(); - buttonRefresh = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - menuStripMain.SuspendLayout(); - SuspendLayout(); - // - // dataGridView - // - dataGridView.BackgroundColor = SystemColors.Control; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(12, 31); - dataGridView.Name = "dataGridView"; - dataGridView.RowTemplate.Height = 25; - dataGridView.Size = new Size(762, 407); - dataGridView.TabIndex = 0; - // - // menuStripMain - // - menuStripMain.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem }); - menuStripMain.Location = new Point(0, 0); - menuStripMain.Name = "menuStripMain"; - menuStripMain.Size = new Size(1039, 24); - menuStripMain.TabIndex = 2; - menuStripMain.Text = "menuStripMain"; - // - // справочникиToolStripMenuItem - // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem }); - справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; - справочникиToolStripMenuItem.Size = new Size(94, 20); - справочникиToolStripMenuItem.Text = "Справочники"; - // - // компонентыToolStripMenuItem - // - компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(180, 22); - компонентыToolStripMenuItem.Text = "Компоненты"; - компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click_1; - // - // изделияToolStripMenuItem - // - изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; - изделияToolStripMenuItem.Size = new Size(180, 22); - изделияToolStripMenuItem.Text = "Изделия"; - изделияToolStripMenuItem.Click += изделияToolStripMenuItem_Click; - // - // buttonCreateOrder - // - buttonCreateOrder.Location = new Point(836, 31); - buttonCreateOrder.Margin = new Padding(2); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(147, 34); - buttonCreateOrder.TabIndex = 3; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = true; - buttonCreateOrder.Click += ButtonCreateOrder_Click; - // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Location = new Point(836, 81); - buttonTakeOrderInWork.Margin = new Padding(2); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(147, 36); - buttonTakeOrderInWork.TabIndex = 4; - buttonTakeOrderInWork.Text = "Отдать на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = true; - buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; - // - // buttonOrderReady - // - buttonOrderReady.Location = new Point(836, 132); - buttonOrderReady.Margin = new Padding(2); - buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(147, 34); - buttonOrderReady.TabIndex = 5; - buttonOrderReady.Text = "Заказ готов"; - buttonOrderReady.UseVisualStyleBackColor = true; - buttonOrderReady.Click += ButtonOrderReady_Click; - // - // buttonIssuedOrder - // - buttonIssuedOrder.Location = new Point(836, 183); - buttonIssuedOrder.Margin = new Padding(2); - buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(147, 35); - buttonIssuedOrder.TabIndex = 6; - buttonIssuedOrder.Text = "Заказ выдан"; - buttonIssuedOrder.UseVisualStyleBackColor = true; - buttonIssuedOrder.Click += ButtonIssuedOrder_Click; - // - // buttonRefresh - // - buttonRefresh.Location = new Point(836, 234); - buttonRefresh.Margin = new Padding(2); - buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(147, 39); - buttonRefresh.TabIndex = 7; - buttonRefresh.Text = "Обновить список"; - buttonRefresh.UseVisualStyleBackColor = true; - buttonRefresh.Click += ButtonRefresh_Click; - // - // FormMain - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1039, 450); - Controls.Add(buttonRefresh); - Controls.Add(buttonIssuedOrder); - Controls.Add(buttonOrderReady); - Controls.Add(buttonTakeOrderInWork); - Controls.Add(buttonCreateOrder); - Controls.Add(menuStripMain); - Controls.Add(dataGridView); - MainMenuStrip = menuStripMain; - Name = "FormMain"; - Text = "Ювелирный"; - Load += FormMain_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - menuStripMain.ResumeLayout(false); - menuStripMain.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(); + menuStripMain = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + компонентыToolStripMenuItem = new ToolStripMenuItem(); + изделияToolStripMenuItem = new ToolStripMenuItem(); + магазинToolStripMenuItem = new ToolStripMenuItem(); + buttonCreateOrder = new Button(); + buttonTakeOrderInWork = new Button(); + buttonOrderReady = new Button(); + buttonIssuedOrder = new Button(); + buttonRefresh = new Button(); + buttonAddJewel = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + menuStripMain.SuspendLayout(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.BackgroundColor = SystemColors.Control; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 31); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(762, 407); + dataGridView.TabIndex = 0; + // + // menuStripMain + // + menuStripMain.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem }); + menuStripMain.Location = new Point(0, 0); + menuStripMain.Name = "menuStripMain"; + menuStripMain.Size = new Size(1021, 24); + menuStripMain.TabIndex = 2; + menuStripMain.Text = "menuStripMain"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem, магазинToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // компонентыToolStripMenuItem + // + компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; + компонентыToolStripMenuItem.Size = new Size(145, 22); + компонентыToolStripMenuItem.Text = "Компоненты"; + компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click_1; + // + // изделияToolStripMenuItem + // + изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; + изделияToolStripMenuItem.Size = new Size(145, 22); + изделияToolStripMenuItem.Text = "Изделия"; + изделияToolStripMenuItem.Click += изделияToolStripMenuItem_Click; + // + // магазинToolStripMenuItem + // + магазинToolStripMenuItem.Name = "магазинToolStripMenuItem"; + магазинToolStripMenuItem.Size = new Size(145, 22); + магазинToolStripMenuItem.Text = "Магазины"; + магазинToolStripMenuItem.Click += МагазиныToolStripMenuItem_Click; + // + // buttonCreateOrder + // + buttonCreateOrder.Location = new Point(836, 31); + buttonCreateOrder.Margin = new Padding(2); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(147, 34); + buttonCreateOrder.TabIndex = 3; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += ButtonCreateOrder_Click; + // + // buttonTakeOrderInWork + // + buttonTakeOrderInWork.Location = new Point(836, 81); + buttonTakeOrderInWork.Margin = new Padding(2); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(147, 36); + buttonTakeOrderInWork.TabIndex = 4; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; + // + // buttonOrderReady + // + buttonOrderReady.Location = new Point(836, 132); + buttonOrderReady.Margin = new Padding(2); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(147, 34); + buttonOrderReady.TabIndex = 5; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += ButtonOrderReady_Click; + // + // buttonIssuedOrder + // + buttonIssuedOrder.Location = new Point(836, 183); + buttonIssuedOrder.Margin = new Padding(2); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(147, 35); + buttonIssuedOrder.TabIndex = 6; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += ButtonIssuedOrder_Click; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(836, 234); + buttonRefresh.Margin = new Padding(2); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(147, 39); + buttonRefresh.TabIndex = 7; + buttonRefresh.Text = "Обновить список"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonRefresh_Click; + // + // buttonAddJewel + // + buttonAddJewel.Location = new Point(836, 287); + buttonAddJewel.Name = "buttonAddJewel"; + buttonAddJewel.Size = new Size(147, 35); + buttonAddJewel.TabIndex = 8; + buttonAddJewel.Text = "Добавить украшение"; + buttonAddJewel.UseVisualStyleBackColor = true; + buttonAddJewel.Click += ButtonAddJewel_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1021, 450); + Controls.Add(buttonAddJewel); + Controls.Add(buttonRefresh); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonOrderReady); + Controls.Add(buttonTakeOrderInWork); + Controls.Add(buttonCreateOrder); + Controls.Add(menuStripMain); + Controls.Add(dataGridView); + MainMenuStrip = menuStripMain; + Name = "FormMain"; + Text = "Ювелирный"; + Load += FormMain_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + menuStripMain.ResumeLayout(false); + menuStripMain.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private DataGridView dataGridView; - private MenuStrip menuStripMain; - private ToolStripMenuItem справочникиToolStripMenuItem; - private ToolStripMenuItem компонентыToolStripMenuItem; - private ToolStripMenuItem изделияToolStripMenuItem; - private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button buttonOrderReady; - private Button buttonIssuedOrder; - private Button buttonRefresh; - } + private DataGridView dataGridView; + private MenuStrip menuStripMain; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem компонентыToolStripMenuItem; + private ToolStripMenuItem изделияToolStripMenuItem; + private ToolStripMenuItem магазинToolStripMenuItem; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; + private Button buttonRefresh; + private Button buttonAddJewel; + } } \ No newline at end of file diff --git a/JewelryStore/JewerlyStoreView/FormMain.cs b/JewelryStore/JewerlyStoreView/FormMain.cs index c872555..7f21044 100644 --- a/JewelryStore/JewerlyStoreView/FormMain.cs +++ b/JewelryStore/JewerlyStoreView/FormMain.cs @@ -1,6 +1,7 @@ using JewelryStoreContracts.BindingModels; using JewelryStoreContracts.BusinessLogicsContracts; using JewerlyStoreDataModels.Enums; +using JewerlyStoreView; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -14,168 +15,186 @@ using System.Windows.Forms; namespace JewelryStoreView { - public partial class FormMain : Form - { - private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) - { - InitializeComponent(); - _logger = logger; - _orderLogic = orderLogic; - } + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } - private void FormMain_Load(object sender, EventArgs e) - { - LoadData(); - } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } - private void LoadData() - { - try - { - var list = _orderLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["JewelId"].Visible = false; - } - _logger.LogInformation("Загрузка заказов"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки заказов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } + private void LoadData() + { + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["JewelId"].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 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, - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), - 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 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, + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), + 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, - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) - }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + 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, + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), + 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); - } - } - } + 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, - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), - 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 ButtonRefresh_Click(object sender, EventArgs e) - { - LoadData(); - } + 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, + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), + 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 ButtonRefresh_Click(object sender, EventArgs e) + { + LoadData(); + } - private void компонентыToolStripMenuItem_Click_1(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) - { - form.ShowDialog(); - } - } + private void компонентыToolStripMenuItem_Click_1(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } - private void изделияToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormJewels)); - if (service is FormJewels form) - { - form.ShowDialog(); - } - } - } + private void изделияToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormJewels)); + if (service is FormJewels form) + { + form.ShowDialog(); + } + } + private void МагазиныToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) + { + form.ShowDialog(); + } + } + + private void ButtonAddJewel_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormAddJewel)); + if (service is FormAddJewel form) + { + form.ShowDialog(); + LoadData(); + } + } + } } diff --git a/JewelryStore/JewerlyStoreView/Program.cs b/JewelryStore/JewerlyStoreView/Program.cs index 528100e..083e2aa 100644 --- a/JewelryStore/JewerlyStoreView/Program.cs +++ b/JewelryStore/JewerlyStoreView/Program.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using JewelryStoreBusinessLogic.BusinessLogics; using System.Drawing; +using JewerlyStoreView; namespace JewelryStoreView { @@ -38,16 +39,21 @@ namespace JewelryStoreView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); - } + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } } } \ No newline at end of file