случайно положил ветку, поднял заного, залил коммит, нашёл потеряшки)))

This commit is contained in:
Леонид Малафеев 2024-04-08 13:19:39 +04:00
parent c780cee181
commit 8b3d7e65e1
4 changed files with 375 additions and 326 deletions

View File

@ -13,12 +13,14 @@ namespace JewelryStoreListImplement
public List<Component> Components { get; set; } public List<Component> Components { get; set; }
public List<Order> Orders { get; set; } public List<Order> Orders { get; set; }
public List<Jewel> Jewels { get; set; } public List<Jewel> Jewels { get; set; }
public List<Shop> Shops { get; set; }
private DataListSingleton() private DataListSingleton()
{ {
Components = new List<Component>(); Components = new List<Component>();
Orders = new List<Order>(); Orders = new List<Order>();
Jewels = new List<Jewel>(); Jewels = new List<Jewel>();
Shops = new List<Shop>();
} }
public static DataListSingleton GetInstance() public static DataListSingleton GetInstance()

View File

@ -1,176 +1,198 @@
namespace JewelryStoreView namespace JewelryStoreView
{ {
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()
{ {
dataGridView = new DataGridView(); dataGridView = new DataGridView();
menuStripMain = new MenuStrip(); menuStripMain = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem(); справочникиToolStripMenuItem = new ToolStripMenuItem();
компонентыToolStripMenuItem = new ToolStripMenuItem(); компонентыToolStripMenuItem = new ToolStripMenuItem();
изделияToolStripMenuItem = new ToolStripMenuItem(); изделияToolStripMenuItem = new ToolStripMenuItem();
buttonCreateOrder = new Button(); магазинToolStripMenuItem = new ToolStripMenuItem();
buttonTakeOrderInWork = new Button(); buttonCreateOrder = new Button();
buttonOrderReady = new Button(); buttonTakeOrderInWork = new Button();
buttonIssuedOrder = new Button(); buttonOrderReady = new Button();
buttonRefresh = new Button(); buttonIssuedOrder = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); buttonRefresh = new Button();
menuStripMain.SuspendLayout(); buttonAddJewel = new Button();
SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
// menuStripMain.SuspendLayout();
// dataGridView SuspendLayout();
// //
dataGridView.BackgroundColor = SystemColors.Control; // dataGridView
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; //
dataGridView.Location = new Point(12, 31); dataGridView.BackgroundColor = SystemColors.Control;
dataGridView.Name = "dataGridView"; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.RowTemplate.Height = 25; dataGridView.Location = new Point(12, 31);
dataGridView.Size = new Size(762, 407); dataGridView.Name = "dataGridView";
dataGridView.TabIndex = 0; dataGridView.RowTemplate.Height = 25;
// dataGridView.Size = new Size(762, 407);
// menuStripMain dataGridView.TabIndex = 0;
// //
menuStripMain.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem }); // menuStripMain
menuStripMain.Location = new Point(0, 0); //
menuStripMain.Name = "menuStripMain"; menuStripMain.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
menuStripMain.Size = new Size(1039, 24); menuStripMain.Location = new Point(0, 0);
menuStripMain.TabIndex = 2; menuStripMain.Name = "menuStripMain";
menuStripMain.Text = "menuStripMain"; menuStripMain.Size = new Size(1021, 24);
// menuStripMain.TabIndex = 2;
// справочникиToolStripMenuItem menuStripMain.Text = "menuStripMain";
// //
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem }); // справочникиToolStripMenuItem
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; //
справочникиToolStripMenuItem.Size = new Size(94, 20); справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem, магазинToolStripMenuItem });
справочникиToolStripMenuItem.Text = "Справочники"; справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
// справочникиToolStripMenuItem.Size = new Size(94, 20);
// компонентыToolStripMenuItem справочникиToolStripMenuItem.Text = "Справочники";
// //
компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem"; // компонентыToolStripMenuItem
компонентыToolStripMenuItem.Size = new Size(180, 22); //
компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem";
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click_1; компонентыToolStripMenuItem.Size = new Size(145, 22);
// компонентыToolStripMenuItem.Text = "Компоненты";
// изделияToolStripMenuItem компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click_1;
// //
изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; // изделияToolStripMenuItem
изделияToolStripMenuItem.Size = new Size(180, 22); //
изделияToolStripMenuItem.Text = "Изделия"; изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
изделияToolStripMenuItem.Click += изделияToolStripMenuItem_Click; изделияToolStripMenuItem.Size = new Size(145, 22);
// изделияToolStripMenuItem.Text = "Изделия";
// buttonCreateOrder изделияToolStripMenuItem.Click += изделияToolStripMenuItem_Click;
// //
buttonCreateOrder.Location = new Point(836, 31); // магазинToolStripMenuItem
buttonCreateOrder.Margin = new Padding(2); //
buttonCreateOrder.Name = "buttonCreateOrder"; магазинToolStripMenuItem.Name = агазинToolStripMenuItem";
buttonCreateOrder.Size = new Size(147, 34); магазинToolStripMenuItem.Size = new Size(145, 22);
buttonCreateOrder.TabIndex = 3; магазинToolStripMenuItem.Text = "Магазины";
buttonCreateOrder.Text = "Создать заказ"; магазинToolStripMenuItem.Click += МагазиныToolStripMenuItem_Click;
buttonCreateOrder.UseVisualStyleBackColor = true; //
buttonCreateOrder.Click += ButtonCreateOrder_Click; // buttonCreateOrder
// //
// buttonTakeOrderInWork buttonCreateOrder.Location = new Point(836, 31);
// buttonCreateOrder.Margin = new Padding(2);
buttonTakeOrderInWork.Location = new Point(836, 81); buttonCreateOrder.Name = "buttonCreateOrder";
buttonTakeOrderInWork.Margin = new Padding(2); buttonCreateOrder.Size = new Size(147, 34);
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; buttonCreateOrder.TabIndex = 3;
buttonTakeOrderInWork.Size = new Size(147, 36); buttonCreateOrder.Text = "Создать заказ";
buttonTakeOrderInWork.TabIndex = 4; buttonCreateOrder.UseVisualStyleBackColor = true;
buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonCreateOrder.Click += ButtonCreateOrder_Click;
buttonTakeOrderInWork.UseVisualStyleBackColor = true; //
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; // buttonTakeOrderInWork
// //
// buttonOrderReady buttonTakeOrderInWork.Location = new Point(836, 81);
// buttonTakeOrderInWork.Margin = new Padding(2);
buttonOrderReady.Location = new Point(836, 132); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonOrderReady.Margin = new Padding(2); buttonTakeOrderInWork.Size = new Size(147, 36);
buttonOrderReady.Name = "buttonOrderReady"; buttonTakeOrderInWork.TabIndex = 4;
buttonOrderReady.Size = new Size(147, 34); buttonTakeOrderInWork.Text = "Отдать на выполнение";
buttonOrderReady.TabIndex = 5; buttonTakeOrderInWork.UseVisualStyleBackColor = true;
buttonOrderReady.Text = "Заказ готов"; buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
buttonOrderReady.UseVisualStyleBackColor = true; //
buttonOrderReady.Click += ButtonOrderReady_Click; // buttonOrderReady
// //
// buttonIssuedOrder buttonOrderReady.Location = new Point(836, 132);
// buttonOrderReady.Margin = new Padding(2);
buttonIssuedOrder.Location = new Point(836, 183); buttonOrderReady.Name = "buttonOrderReady";
buttonIssuedOrder.Margin = new Padding(2); buttonOrderReady.Size = new Size(147, 34);
buttonIssuedOrder.Name = "buttonIssuedOrder"; buttonOrderReady.TabIndex = 5;
buttonIssuedOrder.Size = new Size(147, 35); buttonOrderReady.Text = "Заказ готов";
buttonIssuedOrder.TabIndex = 6; buttonOrderReady.UseVisualStyleBackColor = true;
buttonIssuedOrder.Text = "Заказ выдан"; buttonOrderReady.Click += ButtonOrderReady_Click;
buttonIssuedOrder.UseVisualStyleBackColor = true; //
buttonIssuedOrder.Click += ButtonIssuedOrder_Click; // buttonIssuedOrder
// //
// buttonRefresh buttonIssuedOrder.Location = new Point(836, 183);
// buttonIssuedOrder.Margin = new Padding(2);
buttonRefresh.Location = new Point(836, 234); buttonIssuedOrder.Name = "buttonIssuedOrder";
buttonRefresh.Margin = new Padding(2); buttonIssuedOrder.Size = new Size(147, 35);
buttonRefresh.Name = "buttonRefresh"; buttonIssuedOrder.TabIndex = 6;
buttonRefresh.Size = new Size(147, 39); buttonIssuedOrder.Text = "Заказ выдан";
buttonRefresh.TabIndex = 7; buttonIssuedOrder.UseVisualStyleBackColor = true;
buttonRefresh.Text = "Обновить список"; buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
buttonRefresh.UseVisualStyleBackColor = true; //
buttonRefresh.Click += ButtonRefresh_Click; // buttonRefresh
// //
// FormMain buttonRefresh.Location = new Point(836, 234);
// buttonRefresh.Margin = new Padding(2);
AutoScaleDimensions = new SizeF(7F, 15F); buttonRefresh.Name = "buttonRefresh";
AutoScaleMode = AutoScaleMode.Font; buttonRefresh.Size = new Size(147, 39);
ClientSize = new Size(1039, 450); buttonRefresh.TabIndex = 7;
Controls.Add(buttonRefresh); buttonRefresh.Text = "Обновить список";
Controls.Add(buttonIssuedOrder); buttonRefresh.UseVisualStyleBackColor = true;
Controls.Add(buttonOrderReady); buttonRefresh.Click += ButtonRefresh_Click;
Controls.Add(buttonTakeOrderInWork); //
Controls.Add(buttonCreateOrder); // buttonAddJewel
Controls.Add(menuStripMain); //
Controls.Add(dataGridView); buttonAddJewel.Location = new Point(836, 287);
MainMenuStrip = menuStripMain; buttonAddJewel.Name = "buttonAddJewel";
Name = "FormMain"; buttonAddJewel.Size = new Size(147, 35);
Text = "Ювелирный"; buttonAddJewel.TabIndex = 8;
Load += FormMain_Load; buttonAddJewel.Text = "Добавить украшение";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); buttonAddJewel.UseVisualStyleBackColor = true;
menuStripMain.ResumeLayout(false); buttonAddJewel.Click += ButtonAddJewel_Click;
menuStripMain.PerformLayout(); //
ResumeLayout(false); // FormMain
PerformLayout(); //
} 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 DataGridView dataGridView;
private MenuStrip menuStripMain; private MenuStrip menuStripMain;
private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem;
private ToolStripMenuItem изделияToolStripMenuItem; private ToolStripMenuItem изделияToolStripMenuItem;
private Button buttonCreateOrder; private ToolStripMenuItem магазинToolStripMenuItem;
private Button buttonTakeOrderInWork; private Button buttonCreateOrder;
private Button buttonOrderReady; private Button buttonTakeOrderInWork;
private Button buttonIssuedOrder; private Button buttonOrderReady;
private Button buttonRefresh; private Button buttonIssuedOrder;
} private Button buttonRefresh;
private Button buttonAddJewel;
}
} }

View File

@ -1,6 +1,7 @@
using JewelryStoreContracts.BindingModels; using JewelryStoreContracts.BindingModels;
using JewelryStoreContracts.BusinessLogicsContracts; using JewelryStoreContracts.BusinessLogicsContracts;
using JewerlyStoreDataModels.Enums; using JewerlyStoreDataModels.Enums;
using JewerlyStoreView;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -14,168 +15,186 @@ using System.Windows.Forms;
namespace JewelryStoreView namespace JewelryStoreView
{ {
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;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic) public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_orderLogic = orderLogic; _orderLogic = orderLogic;
} }
private void FormMain_Load(object sender, EventArgs e) private void FormMain_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void LoadData() private void LoadData()
{ {
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["JewelId"].Visible = false; dataGridView.Columns["JewelId"].Visible = false;
} }
_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 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 var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
{ {
Id = id, Id = id,
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
}); });
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 = 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 OrderBindingModel var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
{ {
Id = id, Id = id,
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString())
}); });
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 OrderBindingModel var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
{ {
Id = id, Id = id,
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value), JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
}); });
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 ButtonRefresh_Click(object sender, EventArgs e) private void ButtonRefresh_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void компонентыToolStripMenuItem_Click_1(object sender, EventArgs e) private void компонентыToolStripMenuItem_Click_1(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 изделияToolStripMenuItem_Click(object sender, EventArgs e) private void изделияToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormJewels)); var service = Program.ServiceProvider?.GetService(typeof(FormJewels));
if (service is FormJewels form) if (service is FormJewels form)
{ {
form.ShowDialog(); 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();
}
}
}
} }

View File

@ -6,6 +6,7 @@ using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
using JewelryStoreBusinessLogic.BusinessLogics; using JewelryStoreBusinessLogic.BusinessLogics;
using System.Drawing; using System.Drawing;
using JewerlyStoreView;
namespace JewelryStoreView namespace JewelryStoreView
{ {
@ -38,16 +39,21 @@ namespace JewelryStoreView
services.AddTransient<IComponentStorage, ComponentStorage>(); services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>(); services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IJewelStorage, JewelStorage>(); services.AddTransient<IJewelStorage, JewelStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>(); services.AddTransient<IShopStorage, ShopStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IJewelLogic, JewelLogic>(); services.AddTransient<IJewelLogic, JewelLogic>();
services.AddTransient<FormMain>(); services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>(); services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>(); services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>(); services.AddTransient<FormCreateOrder>();
services.AddTransient<FormJewel>(); services.AddTransient<FormJewel>();
services.AddTransient<FormJewelComponent>(); services.AddTransient<FormJewelComponent>();
services.AddTransient<FormJewels>(); services.AddTransient<FormJewels>();
} services.AddTransient<FormAddJewel>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
}
} }
} }