diff --git a/FlowerShop/FlowerShop/FlowerShopView.csproj b/FlowerShop/FlowerShop/FlowerShopView.csproj
index c843b3a..a06ab23 100644
--- a/FlowerShop/FlowerShop/FlowerShopView.csproj
+++ b/FlowerShop/FlowerShop/FlowerShopView.csproj
@@ -17,6 +17,7 @@
+
diff --git a/FlowerShop/FlowerShop/FormMain.Designer.cs b/FlowerShop/FlowerShop/FormMain.Designer.cs
index 22ed023..e1f429d 100644
--- a/FlowerShop/FlowerShop/FormMain.Designer.cs
+++ b/FlowerShop/FlowerShop/FormMain.Designer.cs
@@ -22,177 +22,182 @@
#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()
- {
- menuStrip1 = new MenuStrip();
- справочникиToolStripMenuItem = new ToolStripMenuItem();
- ЦветыToolStripMenuItem = new ToolStripMenuItem();
- КомпонентыToolStripMenuItem = new ToolStripMenuItem();
- магазиныToolStripMenuItem = new ToolStripMenuItem();
- продажаЦветовToolStripMenuItem = new ToolStripMenuItem();
- dataGridView = new DataGridView();
- buttonCreateOrder = new Button();
- buttonTakeOrderInWork = new Button();
- buttonOrderReady = new Button();
- buttonIssuedOrder = new Button();
- buttonRef = new Button();
- пополениеМагазинаToolStripMenuItem = new ToolStripMenuItem();
- menuStrip1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
- SuspendLayout();
- //
- // menuStrip1
- //
- menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, пополениеМагазинаToolStripMenuItem, продажаЦветовToolStripMenuItem });
- menuStrip1.Location = new Point(0, 0);
- menuStrip1.Name = "menuStrip1";
- menuStrip1.Size = new Size(964, 24);
- menuStrip1.TabIndex = 0;
- menuStrip1.Text = "menuStrip1";
- //
- // справочники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(180, 22);
- ЦветыToolStripMenuItem.Text = "Цветы";
- ЦветыToolStripMenuItem.Click += ЦветыToolStripMenuItem_Click;
- //
- // КомпонентыToolStripMenuItem
- //
- КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
- КомпонентыToolStripMenuItem.Size = new Size(180, 22);
- КомпонентыToolStripMenuItem.Text = "Компоненты";
- КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
- //
- // магазиныToolStripMenuItem
- //
- магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
- магазиныToolStripMenuItem.Size = new Size(180, 22);
- магазиныToolStripMenuItem.Text = "Магазины";
- магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click;
- //
- // продажаЦветовToolStripMenuItem
- //
- продажаЦветовToolStripMenuItem.Name = "продажаЦветовToolStripMenuItem";
- продажаЦветовToolStripMenuItem.Size = new Size(109, 20);
- продажаЦветовToolStripMenuItem.Text = "Продажа цветов";
- продажаЦветовToolStripMenuItem.Click += продажаЦветовToolStripMenuItem_Click;
- //
- // dataGridView
- //
- dataGridView.BackgroundColor = Color.White;
- dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- dataGridView.Location = new Point(12, 27);
- dataGridView.Name = "dataGridView";
- dataGridView.RowTemplate.Height = 25;
- dataGridView.Size = new Size(739, 411);
- dataGridView.TabIndex = 1;
- //
- // buttonCreateOrder
- //
- buttonCreateOrder.Location = new Point(775, 55);
- buttonCreateOrder.Name = "buttonCreateOrder";
- buttonCreateOrder.Size = new Size(158, 32);
- buttonCreateOrder.TabIndex = 2;
- buttonCreateOrder.Text = "Создать заказ";
- buttonCreateOrder.UseVisualStyleBackColor = true;
- buttonCreateOrder.Click += ButtonCreateOrder_Click;
- //
- // buttonTakeOrderInWork
- //
- buttonTakeOrderInWork.Location = new Point(775, 110);
- buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
- buttonTakeOrderInWork.Size = new Size(158, 34);
- buttonTakeOrderInWork.TabIndex = 3;
- buttonTakeOrderInWork.Text = "Отдать на выполнение";
- buttonTakeOrderInWork.UseVisualStyleBackColor = true;
- buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
- //
- // buttonOrderReady
- //
- buttonOrderReady.Location = new Point(775, 168);
- buttonOrderReady.Name = "buttonOrderReady";
- buttonOrderReady.Size = new Size(158, 34);
- buttonOrderReady.TabIndex = 4;
- buttonOrderReady.Text = "Заказ готов";
- buttonOrderReady.UseVisualStyleBackColor = true;
- buttonOrderReady.Click += ButtonOrderReady_Click;
- //
- // buttonIssuedOrder
- //
- buttonIssuedOrder.Location = new Point(775, 230);
- buttonIssuedOrder.Name = "buttonIssuedOrder";
- buttonIssuedOrder.Size = new Size(158, 34);
- buttonIssuedOrder.TabIndex = 5;
- buttonIssuedOrder.Text = "Заказ выдан";
- buttonIssuedOrder.UseVisualStyleBackColor = true;
- buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
- //
- // buttonRef
- //
- buttonRef.Location = new Point(775, 289);
- buttonRef.Name = "buttonRef";
- buttonRef.Size = new Size(158, 34);
- buttonRef.TabIndex = 6;
- buttonRef.Text = "Обновить список";
- buttonRef.UseVisualStyleBackColor = true;
- buttonRef.Click += ButtonRef_Click;
- //
- // пополениеМагазинаToolStripMenuItem
- //
- пополениеМагазинаToolStripMenuItem.Name = "пополениеМагазинаToolStripMenuItem";
- пополениеМагазинаToolStripMenuItem.Size = new Size(136, 20);
- пополениеМагазинаToolStripMenuItem.Text = "Пополение магазина";
- пополениеМагазинаToolStripMenuItem.Click += пополениеМагазинаToolStripMenuItem_Click;
- //
- // FormMain
- //
- AutoScaleDimensions = new SizeF(7F, 15F);
- AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(964, 450);
- Controls.Add(buttonRef);
- Controls.Add(buttonIssuedOrder);
- Controls.Add(buttonOrderReady);
- Controls.Add(buttonTakeOrderInWork);
- Controls.Add(buttonCreateOrder);
- Controls.Add(dataGridView);
- Controls.Add(menuStrip1);
- MainMenuStrip = menuStrip1;
- Name = "FormMain";
- Text = "Цветочный магазин";
- Load += FormMain_Load;
- menuStrip1.ResumeLayout(false);
- menuStrip1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
- ResumeLayout(false);
- PerformLayout();
- }
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ menuStrip1 = new MenuStrip();
+ справочникиToolStripMenuItem = new ToolStripMenuItem();
+ ЦветыToolStripMenuItem = new ToolStripMenuItem();
+ КомпонентыToolStripMenuItem = new ToolStripMenuItem();
+ отчётыToolStripMenuItem = new ToolStripMenuItem();
+ списокЦветковToolStripMenuItem = new ToolStripMenuItem();
+ компонентыПоЦветамToolStripMenuItem = new ToolStripMenuItem();
+ списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
+ dataGridView = new DataGridView();
+ buttonCreateOrder = new Button();
+ buttonTakeOrderInWork = new Button();
+ buttonOrderReady = new Button();
+ buttonIssuedOrder = new Button();
+ buttonRef = new Button();
+ menuStrip1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // menuStrip1
+ //
+ menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem });
+ menuStrip1.Location = new Point(0, 0);
+ menuStrip1.Name = "menuStrip1";
+ menuStrip1.Size = new Size(964, 24);
+ menuStrip1.TabIndex = 0;
+ menuStrip1.Text = "menuStrip1";
+ //
+ // справочники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(145, 22);
+ ЦветыToolStripMenuItem.Text = "Цветы";
+ ЦветыToolStripMenuItem.Click += ЦветыToolStripMenuItem_Click;
+ //
+ // КомпонентыToolStripMenuItem
+ //
+ КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
+ КомпонентыToolStripMenuItem.Size = new Size(145, 22);
+ КомпонентыToolStripMenuItem.Text = "Компоненты";
+ КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
+ //
+ // отчётыToolStripMenuItem
+ //
+ отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокЦветковToolStripMenuItem, компонентыПоЦветамToolStripMenuItem, списокЗаказовToolStripMenuItem });
+ отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
+ отчётыToolStripMenuItem.Size = new Size(60, 20);
+ отчётыToolStripMenuItem.Text = "Отчёты";
+ //
+ // списокЦветковToolStripMenuItem
+ //
+ списокЦветковToolStripMenuItem.Name = "списокЦветковToolStripMenuItem";
+ списокЦветковToolStripMenuItem.Size = new Size(204, 22);
+ списокЦветковToolStripMenuItem.Text = "Список цветков";
+ списокЦветковToolStripMenuItem.Click += списокЦветковToolStripMenuItem_Click;
+ //
+ // компонентыПоЦветамToolStripMenuItem
+ //
+ компонентыПоЦветамToolStripMenuItem.Name = "компонентыПоЦветамToolStripMenuItem";
+ компонентыПоЦветамToolStripMenuItem.Size = new Size(204, 22);
+ компонентыПоЦветамToolStripMenuItem.Text = "Компоненты по цветам";
+ компонентыПоЦветамToolStripMenuItem.Click += компонентыПоЦветамToolStripMenuItem_Click;
+ //
+ // списокЗаказовToolStripMenuItem
+ //
+ списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
+ списокЗаказовToolStripMenuItem.Size = new Size(204, 22);
+ списокЗаказовToolStripMenuItem.Text = "Список заказов";
+ списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.BackgroundColor = Color.White;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 27);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(739, 411);
+ dataGridView.TabIndex = 1;
+ //
+ // buttonCreateOrder
+ //
+ buttonCreateOrder.Location = new Point(775, 55);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(158, 32);
+ buttonCreateOrder.TabIndex = 2;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += ButtonCreateOrder_Click;
+ //
+ // buttonTakeOrderInWork
+ //
+ buttonTakeOrderInWork.Location = new Point(775, 110);
+ buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ buttonTakeOrderInWork.Size = new Size(158, 34);
+ buttonTakeOrderInWork.TabIndex = 3;
+ buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
+ //
+ // buttonOrderReady
+ //
+ buttonOrderReady.Location = new Point(775, 168);
+ buttonOrderReady.Name = "buttonOrderReady";
+ buttonOrderReady.Size = new Size(158, 34);
+ buttonOrderReady.TabIndex = 4;
+ buttonOrderReady.Text = "Заказ готов";
+ buttonOrderReady.UseVisualStyleBackColor = true;
+ buttonOrderReady.Click += ButtonOrderReady_Click;
+ //
+ // buttonIssuedOrder
+ //
+ buttonIssuedOrder.Location = new Point(775, 230);
+ buttonIssuedOrder.Name = "buttonIssuedOrder";
+ buttonIssuedOrder.Size = new Size(158, 34);
+ buttonIssuedOrder.TabIndex = 5;
+ buttonIssuedOrder.Text = "Заказ выдан";
+ buttonIssuedOrder.UseVisualStyleBackColor = true;
+ buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(775, 289);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(158, 34);
+ buttonRef.TabIndex = 6;
+ buttonRef.Text = "Обновить список";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += ButtonRef_Click;
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(964, 450);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonIssuedOrder);
+ Controls.Add(buttonOrderReady);
+ Controls.Add(buttonTakeOrderInWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip1);
+ MainMenuStrip = menuStrip1;
+ Name = "FormMain";
+ Text = "Цветочный магазин";
+ Load += FormMain_Load;
+ menuStrip1.ResumeLayout(false);
+ menuStrip1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
#endregion
- private MenuStrip menuStrip1;
- private ToolStripMenuItem справочникиToolStripMenuItem;
- private ToolStripMenuItem ЦветыToolStripMenuItem;
- private ToolStripMenuItem КомпонентыToolStripMenuItem;
- private DataGridView dataGridView;
- private Button buttonCreateOrder;
- private Button buttonTakeOrderInWork;
- private Button buttonOrderReady;
- private Button buttonIssuedOrder;
- private Button buttonRef;
- private ToolStripMenuItem магазиныToolStripMenuItem;
- private ToolStripMenuItem продажаЦветовToolStripMenuItem;
- private ToolStripMenuItem пополениеМагазинаToolStripMenuItem;
- }
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private ToolStripMenuItem ЦветыToolStripMenuItem;
+ private ToolStripMenuItem КомпонентыToolStripMenuItem;
+ private DataGridView dataGridView;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonRef;
+ }
}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormMain.cs b/FlowerShop/FlowerShop/FormMain.cs
index 9e57bee..4f3779d 100644
--- a/FlowerShop/FlowerShop/FormMain.cs
+++ b/FlowerShop/FlowerShop/FormMain.cs
@@ -1,166 +1,178 @@
-using FlowerShopContracts.BindingModels;
+using FlowerShopBusinessLogic.BusinessLogics;
+using FlowerShopContracts.BindingModels;
using FlowerShopContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace FlowerShopView
{
- public partial class FormMain : Form
- {
- private readonly ILogger _logger;
- private readonly IOrderLogic _orderLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic)
- {
- InitializeComponent();
- _logger = logger;
- _orderLogic = orderLogic;
- }
- 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["FlowerId"].Visible = false;
- }
- }
- 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 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 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();
- }
+ 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["FlowerId"].Visible = false;
+ dataGridView.Columns["FlowerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void КомпонентыToolStripMenuItem_Click(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(FormFlowers));
+ if (service is FormFlowers 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 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 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 КомпонентыToolStripMenuItem_Click(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(FormFlowers));
- if (service is FormFlowers 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 продажаЦветовToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormMakeSale));
- if (service is FormMakeSale form)
- {
- form.ShowDialog();
- }
- }
+ private void списокЦветковToolStripMenuItem_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 пополениеМагазинаToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormMakeSupply));
- if (service is FormMakeSupply form)
- {
- form.ShowDialog();
- }
- }
- }
+ private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
+ if (service is FormReportOrders form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void компонентыПоЦветамToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportFlowerComponents));
+ if (service is FormReportFlowerComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+ }
}
diff --git a/FlowerShop/FlowerShop/FormReportFlowerComponents.Designer.cs b/FlowerShop/FlowerShop/FormReportFlowerComponents.Designer.cs
new file mode 100644
index 0000000..f56e034
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormReportFlowerComponents.Designer.cs
@@ -0,0 +1,113 @@
+namespace FlowerShopView
+{
+ partial class FormReportFlowerComponents
+ {
+ ///
+ /// 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);
+ }
+
+ #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();
+ buttonSaveToExcel = new Button();
+ ColumnComponent = new DataGridViewTextBoxColumn();
+ ColumnFlower = new DataGridViewTextBoxColumn();
+ ColumnCount = new DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.AllowUserToOrderColumns = true;
+ dataGridView.AllowUserToResizeColumns = false;
+ dataGridView.AllowUserToResizeRows = false;
+ dataGridView.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnComponent, ColumnFlower, ColumnCount });
+ dataGridView.Dock = DockStyle.Bottom;
+ dataGridView.Location = new Point(0, 47);
+ dataGridView.Margin = new Padding(4, 3, 4, 3);
+ dataGridView.MultiSelect = false;
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.Size = new Size(616, 510);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonSaveToExcel
+ //
+ buttonSaveToExcel.Location = new Point(14, 14);
+ buttonSaveToExcel.Margin = new Padding(4, 3, 4, 3);
+ buttonSaveToExcel.Name = "buttonSaveToExcel";
+ buttonSaveToExcel.Size = new Size(186, 27);
+ buttonSaveToExcel.TabIndex = 1;
+ buttonSaveToExcel.Text = "Сохранить в Excel";
+ buttonSaveToExcel.UseVisualStyleBackColor = true;
+ buttonSaveToExcel.Click += ButtonSaveToExcel_Click;
+ //
+ // ColumnComponent
+ //
+ ColumnComponent.HeaderText = "Цветы";
+ ColumnComponent.Name = "ColumnComponent";
+ ColumnComponent.ReadOnly = true;
+ ColumnComponent.Width = 200;
+ //
+ // ColumnFlower
+ //
+ ColumnFlower.HeaderText = "Компонент";
+ ColumnFlower.Name = "ColumnFlower";
+ ColumnFlower.ReadOnly = true;
+ ColumnFlower.Width = 200;
+ //
+ // ColumnCount
+ //
+ ColumnCount.HeaderText = "Количество";
+ ColumnCount.Name = "ColumnCount";
+ ColumnCount.ReadOnly = true;
+ //
+ // FormReportFlowerComponents
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(616, 557);
+ Controls.Add(buttonSaveToExcel);
+ Controls.Add(dataGridView);
+ Margin = new Padding(4, 3, 4, 3);
+ Name = "FormReportFlowerComponents";
+ Text = "Компоненты по цветам";
+ Load += FormReportFlowerComponents_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView dataGridView;
+ private System.Windows.Forms.Button buttonSaveToExcel;
+ private DataGridViewTextBoxColumn ColumnComponent;
+ private DataGridViewTextBoxColumn ColumnFlower;
+ private DataGridViewTextBoxColumn ColumnCount;
+ }
+}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormReportFlowerComponents.cs b/FlowerShop/FlowerShop/FormReportFlowerComponents.cs
new file mode 100644
index 0000000..e0aee65
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormReportFlowerComponents.cs
@@ -0,0 +1,79 @@
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace FlowerShopView
+{
+ public partial class FormReportFlowerComponents : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IReportLogic _logic;
+
+ public FormReportFlowerComponents(ILogger logger, IReportLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormReportFlowerComponents_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetFlowerComponent();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.FlowerName, "", "" });
+ foreach (var listElem in elem.Components)
+ {
+ dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
+ }
+ dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
+ dataGridView.Rows.Add(Array.Empty