исправлен FormClients

This commit is contained in:
DavidMakarov 2024-04-04 18:40:18 +04:00
parent e69f7a046a
commit 8d16b12e86
6 changed files with 541 additions and 522 deletions

View File

@ -1,88 +1,88 @@
namespace FlowerShopView namespace FlowerShopView
{ {
partial class FormClients partial class FormClients
{ {
/// <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()
{ {
buttonRef = new Button(); buttonRef = new Button();
buttonDel = new Button(); buttonDel = new Button();
dataGridView = new DataGridView(); dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// buttonRef // buttonRef
// //
buttonRef.Location = new Point(277, 56); buttonRef.Location = new Point(413, 46);
buttonRef.Name = "buttonRef"; buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(103, 28); buttonRef.Size = new Size(103, 28);
buttonRef.TabIndex = 9; buttonRef.TabIndex = 9;
buttonRef.Text = "Обновить"; buttonRef.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true; buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += buttonRef_Click; buttonRef.Click += buttonRef_Click;
// //
// buttonDel // buttonDel
// //
buttonDel.Location = new Point(277, 22); buttonDel.Location = new Point(413, 12);
buttonDel.Name = "buttonDel"; buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(103, 28); buttonDel.Size = new Size(103, 28);
buttonDel.TabIndex = 8; buttonDel.TabIndex = 8;
buttonDel.Text = "Удалить"; buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true; buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click; buttonDel.Click += buttonDel_Click;
// //
// dataGridView // dataGridView
// //
dataGridView.BackgroundColor = Color.White; dataGridView.BackgroundColor = Color.White;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 12); dataGridView.Location = new Point(12, 12);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25; dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(240, 426); dataGridView.Size = new Size(345, 426);
dataGridView.TabIndex = 5; dataGridView.TabIndex = 5;
// //
// FormClients // FormClients
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(401, 450); ClientSize = new Size(528, 450);
Controls.Add(buttonRef); Controls.Add(buttonRef);
Controls.Add(buttonDel); Controls.Add(buttonDel);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Name = "FormClients"; Name = "FormClients";
Text = "Клиенты"; Text = "Клиенты";
Load += FormClients_Load; Load += FormClients_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }
#endregion #endregion
private Button buttonRef; private Button buttonRef;
private Button buttonDel; private Button buttonDel;
private DataGridView dataGridView; private DataGridView dataGridView;
} }
} }

View File

@ -4,78 +4,76 @@ using Microsoft.Extensions.Logging;
namespace FlowerShopView namespace FlowerShopView
{ {
public partial class FormClients : Form public partial class FormClients : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IClientLogic _logic; private readonly IClientLogic _logic;
public FormClients(ILogger<FormClients> logger, IClientLogic logic) public FormClients(ILogger<FormClients> logger, IClientLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
} }
private void FormClients_Load(object sender, EventArgs e) private void FormClients_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void LoadData() private void LoadData()
{ {
try try
{ {
var list = _logic.ReadList(null); var list = _logic.ReadList(null);
if (list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ClientFIO"].AutoSizeMode = }
DataGridViewAutoSizeColumnMode.Fill; _logger.LogInformation("Загрузка клиентов");
} }
_logger.LogInformation("Загрузка клиентов"); catch (Exception ex)
} {
catch (Exception ex) _logger.LogError(ex, "Ошибка загрузки клиентов");
{ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
_logger.LogError(ex, "Ошибка загрузки клиентов"); MessageBoxIcon.Error);
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, }
MessageBoxIcon.Error); }
}
}
private void buttonDel_Click(object sender, EventArgs e) private void buttonDel_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
if (MessageBox.Show("Удалить запись?", "Вопрос", if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
int id = int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление клиента"); _logger.LogInformation("Удаление клиента");
try try
{ {
if (!_logic.Delete(new ClientBindingModel if (!_logic.Delete(new ClientBindingModel
{ {
Id = id Id = id
})) }))
{ {
throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
} }
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка удаления клиента"); _logger.LogError(ex, "Ошибка удаления клиента");
MessageBox.Show(ex.Message, "Ошибка", MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
} }
private void buttonRef_Click(object sender, EventArgs e) private void buttonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
} }
} }

View File

@ -1,207 +1,216 @@
namespace FlowerShopView namespace FlowerShopView
{ {
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()
{ {
menuStrip1 = new MenuStrip(); menuStrip1 = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem(); справочникиToolStripMenuItem = new ToolStripMenuItem();
ЦветыToolStripMenuItem = new ToolStripMenuItem(); ЦветыToolStripMenuItem = new ToolStripMenuItem();
КомпонентыToolStripMenuItem = new ToolStripMenuItem(); КомпонентыToolStripMenuItem = new ToolStripMenuItem();
отчётыToolStripMenuItem = new ToolStripMenuItem(); отчётыToolStripMenuItem = new ToolStripMenuItem();
списокЦветковToolStripMenuItem = new ToolStripMenuItem(); списокЦветковToolStripMenuItem = new ToolStripMenuItem();
компонентыПоЦветамToolStripMenuItem = new ToolStripMenuItem(); компонентыПоЦветамToolStripMenuItem = new ToolStripMenuItem();
списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
dataGridView = new DataGridView(); dataGridView = new DataGridView();
buttonCreateOrder = new Button(); buttonCreateOrder = new Button();
buttonTakeOrderInWork = new Button(); buttonTakeOrderInWork = new Button();
buttonOrderReady = new Button(); buttonOrderReady = new Button();
buttonIssuedOrder = new Button(); buttonIssuedOrder = new Button();
buttonRef = new Button(); buttonRef = new Button();
menuStrip1.SuspendLayout(); клиентыToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); menuStrip1.SuspendLayout();
SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
// SuspendLayout();
// menuStrip1 //
// // menuStrip1
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem }); //
menuStrip1.Location = new Point(0, 0); menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem });
menuStrip1.Name = "menuStrip1"; menuStrip1.Location = new Point(0, 0);
menuStrip1.Size = new Size(964, 24); menuStrip1.Name = "menuStrip1";
menuStrip1.TabIndex = 0; menuStrip1.Size = new Size(964, 24);
menuStrip1.Text = "menuStrip1"; menuStrip1.TabIndex = 0;
// menuStrip1.Text = "menuStrip1";
// справочникиToolStripMenuItem //
// // справочникиToolStripMenuItem
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ЦветыToolStripMenuItem, КомпонентыToolStripMenuItem }); //
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ЦветыToolStripMenuItem, КомпонентыToolStripMenuItem, клиентыToolStripMenuItem });
справочникиToolStripMenuItem.Size = new Size(94, 20); справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Text = "Справочники"; справочникиToolStripMenuItem.Size = new Size(94, 20);
// справочникиToolStripMenuItem.Text = "Справочники";
// ЦветыToolStripMenuItem //
// // ЦветыToolStripMenuItem
ЦветыToolStripMenuItem.Name = "ЦветыToolStripMenuItem"; //
ЦветыToolStripMenuItem.Size = new Size(145, 22); ЦветыToolStripMenuItem.Name = "ЦветыToolStripMenuItem";
ЦветыToolStripMenuItem.Text = "Цветы"; ЦветыToolStripMenuItem.Size = new Size(180, 22);
ЦветыToolStripMenuItem.Click += ЦветыToolStripMenuItem_Click; ЦветыToolStripMenuItem.Text = "Цветы";
// ЦветыToolStripMenuItem.Click += ЦветыToolStripMenuItem_Click;
// КомпонентыToolStripMenuItem //
// // КомпонентыToolStripMenuItem
КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem"; //
КомпонентыToolStripMenuItem.Size = new Size(145, 22); КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
КомпонентыToolStripMenuItem.Text = "Компоненты"; КомпонентыToolStripMenuItem.Size = new Size(180, 22);
КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click; КомпонентыToolStripMenuItem.Text = "Компоненты";
// КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
// отчётыToolStripMenuItem //
// // отчётыToolStripMenuItem
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокЦветковToolStripMenuItem, компонентыПоЦветамToolStripMenuItem, списокЗаказовToolStripMenuItem }); //
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокЦветковToolStripMenuItem, компонентыПоЦветамToolStripMenuItem, списокЗаказовToolStripMenuItem });
отчётыToolStripMenuItem.Size = new Size(60, 20); отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
отчётыToolStripMenuItem.Text = "Отчёты"; отчётыToolStripMenuItem.Size = new Size(60, 20);
// отчётыToolStripMenuItem.Text = "Отчёты";
// списокЦветковToolStripMenuItem //
// // списокЦветковToolStripMenuItem
списокЦветковToolStripMenuItem.Name = "списокЦветковToolStripMenuItem"; //
списокЦветковToolStripMenuItem.Size = new Size(204, 22); списокЦветковToolStripMenuItem.Name = "списокЦветковToolStripMenuItem";
списокЦветковToolStripMenuItem.Text = "Список цветков"; списокЦветковToolStripMenuItem.Size = new Size(204, 22);
списокЦветковToolStripMenuItem.Click += списокЦветковToolStripMenuItem_Click; списокЦветковToolStripMenuItem.Text = "Список цветков";
// списокЦветковToolStripMenuItem.Click += списокЦветковToolStripMenuItem_Click;
// компонентыПоЦветамToolStripMenuItem //
// // компонентыПоЦветамToolStripMenuItem
компонентыПоЦветамToolStripMenuItem.Name = омпонентыПоЦветамToolStripMenuItem"; //
компонентыПоЦветамToolStripMenuItem.Size = new Size(204, 22); компонентыПоЦветамToolStripMenuItem.Name = омпонентыПоЦветамToolStripMenuItem";
компонентыПоЦветамToolStripMenuItem.Text = "Компоненты по цветам"; компонентыПоЦветамToolStripMenuItem.Size = new Size(204, 22);
компонентыПоЦветамToolStripMenuItem.Click += компонентыПоЦветамToolStripMenuItem_Click; компонентыПоЦветамToolStripMenuItem.Text = "Компоненты по цветам";
// компонентыПоЦветамToolStripMenuItem.Click += компонентыПоЦветамToolStripMenuItem_Click;
// списокЗаказовToolStripMenuItem //
// // списокЗаказовToolStripMenuItem
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; //
списокЗаказовToolStripMenuItem.Size = new Size(204, 22); списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
списокЗаказовToolStripMenuItem.Text = "Список заказов"; списокЗаказовToolStripMenuItem.Size = new Size(204, 22);
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; списокЗаказовToolStripMenuItem.Text = "Список заказов";
// списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
// dataGridView //
// // dataGridView
dataGridView.BackgroundColor = Color.White; //
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.BackgroundColor = Color.White;
dataGridView.Location = new Point(12, 27); dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Name = "dataGridView"; dataGridView.Location = new Point(12, 27);
dataGridView.RowTemplate.Height = 25; dataGridView.Name = "dataGridView";
dataGridView.Size = new Size(739, 411); dataGridView.RowTemplate.Height = 25;
dataGridView.TabIndex = 1; dataGridView.Size = new Size(739, 411);
// dataGridView.TabIndex = 1;
// buttonCreateOrder //
// // buttonCreateOrder
buttonCreateOrder.Location = new Point(775, 55); //
buttonCreateOrder.Name = "buttonCreateOrder"; buttonCreateOrder.Location = new Point(775, 55);
buttonCreateOrder.Size = new Size(158, 32); buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.TabIndex = 2; buttonCreateOrder.Size = new Size(158, 32);
buttonCreateOrder.Text = "Создать заказ"; buttonCreateOrder.TabIndex = 2;
buttonCreateOrder.UseVisualStyleBackColor = true; buttonCreateOrder.Text = "Создать заказ";
buttonCreateOrder.Click += ButtonCreateOrder_Click; buttonCreateOrder.UseVisualStyleBackColor = true;
// buttonCreateOrder.Click += ButtonCreateOrder_Click;
// buttonTakeOrderInWork //
// // buttonTakeOrderInWork
buttonTakeOrderInWork.Location = new Point(775, 110); //
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; buttonTakeOrderInWork.Location = new Point(775, 110);
buttonTakeOrderInWork.Size = new Size(158, 34); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonTakeOrderInWork.TabIndex = 3; buttonTakeOrderInWork.Size = new Size(158, 34);
buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonTakeOrderInWork.TabIndex = 3;
buttonTakeOrderInWork.UseVisualStyleBackColor = true; buttonTakeOrderInWork.Text = "Отдать на выполнение";
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; buttonTakeOrderInWork.UseVisualStyleBackColor = true;
// buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
// buttonOrderReady //
// // buttonOrderReady
buttonOrderReady.Location = new Point(775, 168); //
buttonOrderReady.Name = "buttonOrderReady"; buttonOrderReady.Location = new Point(775, 168);
buttonOrderReady.Size = new Size(158, 34); buttonOrderReady.Name = "buttonOrderReady";
buttonOrderReady.TabIndex = 4; buttonOrderReady.Size = new Size(158, 34);
buttonOrderReady.Text = "Заказ готов"; buttonOrderReady.TabIndex = 4;
buttonOrderReady.UseVisualStyleBackColor = true; buttonOrderReady.Text = "Заказ готов";
buttonOrderReady.Click += ButtonOrderReady_Click; buttonOrderReady.UseVisualStyleBackColor = true;
// buttonOrderReady.Click += ButtonOrderReady_Click;
// buttonIssuedOrder //
// // buttonIssuedOrder
buttonIssuedOrder.Location = new Point(775, 230); //
buttonIssuedOrder.Name = "buttonIssuedOrder"; buttonIssuedOrder.Location = new Point(775, 230);
buttonIssuedOrder.Size = new Size(158, 34); buttonIssuedOrder.Name = "buttonIssuedOrder";
buttonIssuedOrder.TabIndex = 5; buttonIssuedOrder.Size = new Size(158, 34);
buttonIssuedOrder.Text = "Заказ выдан"; buttonIssuedOrder.TabIndex = 5;
buttonIssuedOrder.UseVisualStyleBackColor = true; buttonIssuedOrder.Text = "Заказ выдан";
buttonIssuedOrder.Click += ButtonIssuedOrder_Click; buttonIssuedOrder.UseVisualStyleBackColor = true;
// buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
// buttonRef //
// // buttonRef
buttonRef.Location = new Point(775, 289); //
buttonRef.Name = "buttonRef"; buttonRef.Location = new Point(775, 289);
buttonRef.Size = new Size(158, 34); buttonRef.Name = "buttonRef";
buttonRef.TabIndex = 6; buttonRef.Size = new Size(158, 34);
buttonRef.Text = "Обновить список"; buttonRef.TabIndex = 6;
buttonRef.UseVisualStyleBackColor = true; buttonRef.Text = "Обновить список";
buttonRef.Click += ButtonRef_Click; buttonRef.UseVisualStyleBackColor = true;
// buttonRef.Click += ButtonRef_Click;
// FormMain //
// // клиентыToolStripMenuItem
AutoScaleDimensions = new SizeF(7F, 15F); //
AutoScaleMode = AutoScaleMode.Font; клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
ClientSize = new Size(964, 450); клиентыToolStripMenuItem.Size = new Size(180, 22);
Controls.Add(buttonRef); клиентыToolStripMenuItem.Text = "Клиенты";
Controls.Add(buttonIssuedOrder); клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
Controls.Add(buttonOrderReady); //
Controls.Add(buttonTakeOrderInWork); // FormMain
Controls.Add(buttonCreateOrder); //
Controls.Add(dataGridView); AutoScaleDimensions = new SizeF(7F, 15F);
Controls.Add(menuStrip1); AutoScaleMode = AutoScaleMode.Font;
MainMenuStrip = menuStrip1; ClientSize = new Size(964, 450);
Name = "FormMain"; Controls.Add(buttonRef);
Text = "Цветочный магазин"; Controls.Add(buttonIssuedOrder);
Load += FormMain_Load; Controls.Add(buttonOrderReady);
menuStrip1.ResumeLayout(false); Controls.Add(buttonTakeOrderInWork);
menuStrip1.PerformLayout(); Controls.Add(buttonCreateOrder);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); Controls.Add(dataGridView);
ResumeLayout(false); Controls.Add(menuStrip1);
PerformLayout(); MainMenuStrip = menuStrip1;
} Name = "FormMain";
Text = "Цветочный магазин";
Load += FormMain_Load;
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion #endregion
private MenuStrip menuStrip1; private MenuStrip menuStrip1;
private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem ЦветыToolStripMenuItem; private ToolStripMenuItem ЦветыToolStripMenuItem;
private ToolStripMenuItem КомпонентыToolStripMenuItem; private ToolStripMenuItem КомпонентыToolStripMenuItem;
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonCreateOrder; private Button buttonCreateOrder;
private Button buttonTakeOrderInWork; private Button buttonTakeOrderInWork;
private Button buttonOrderReady; private Button buttonOrderReady;
private Button buttonIssuedOrder; private Button buttonIssuedOrder;
private Button buttonRef; private Button buttonRef;
private ToolStripMenuItem отчётыToolStripMenuItem; private ToolStripMenuItem отчётыToolStripMenuItem;
private ToolStripMenuItem списокЦветковToolStripMenuItem; private ToolStripMenuItem списокЦветковToolStripMenuItem;
private ToolStripMenuItem компонентыПоЦветамToolStripMenuItem; private ToolStripMenuItem компонентыПоЦветамToolStripMenuItem;
private ToolStripMenuItem списокЗаказовToolStripMenuItem; private ToolStripMenuItem списокЗаказовToolStripMenuItem;
} private ToolStripMenuItem клиентыToolStripMenuItem;
}
} }

View File

@ -5,176 +5,185 @@ using Microsoft.Extensions.Logging;
namespace FlowerShopView namespace FlowerShopView
{ {
public partial class FormMain : Form public partial class FormMain : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic; private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic; private readonly IReportLogic _reportLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic) public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_orderLogic = orderLogic; _orderLogic = orderLogic;
_reportLogic = reportLogic; _reportLogic = reportLogic;
} }
private void FormMain_Load(object sender, EventArgs e) private void FormMain_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void LoadData() private void LoadData()
{ {
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
try try
{ {
var list = _orderLogic.ReadList(null); var list = _orderLogic.ReadList(null);
if (list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["FlowerId"].Visible = false; dataGridView.Columns["FlowerId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false; dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["FlowerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["FlowerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
} }
} }
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 КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form) if (service is FormComponents form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ЦветыToolStripMenuItem_Click(object sender, EventArgs e) private void ЦветыToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormFlowers)); var service = Program.ServiceProvider?.GetService(typeof(FormFlowers));
if (service is FormFlowers form) if (service is FormFlowers form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ButtonCreateOrder_Click(object sender, EventArgs e) private void ButtonCreateOrder_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form) if (service is FormCreateOrder form)
{ {
form.ShowDialog(); form.ShowDialog();
LoadData(); LoadData();
} }
} }
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
int id = int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try try
{ {
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка передачи заказа в работу"); _logger.LogError(ex, "Ошибка передачи заказа в работу");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
private void 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 = int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
id); id);
try try
{ {
var operationResult = _orderLogic.FinishOrder(new var operationResult = _orderLogic.FinishOrder(new
OrderBindingModel OrderBindingModel
{ Id = id }); { Id = id });
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка отметки о готовности заказа"); _logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
private void ButtonIssuedOrder_Click(object sender, EventArgs e) private void ButtonIssuedOrder_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
int id = int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try try
{ {
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
_logger.LogInformation("Заказ №{id} выдан", id); _logger.LogInformation("Заказ №{id} выдан", id);
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка отметки о выдачи заказа"); _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); MessageBoxIcon.Error);
} }
} }
} }
private void ButtonRef_Click(object sender, EventArgs e) private void ButtonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void списокЦветковToolStripMenuItem_Click(object sender, EventArgs e) private void списокЦветковToolStripMenuItem_Click(object sender, EventArgs e)
{ {
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK) if (dialog.ShowDialog() == DialogResult.OK)
{ {
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel _reportLogic.SaveComponentsToWordFile(new ReportBindingModel
{ {
FileName = dialog.FileName FileName = dialog.FileName
}); });
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
} }
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
if (service is FormReportOrders form) if (service is FormReportOrders form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void компонентыПоЦветамToolStripMenuItem_Click(object sender, EventArgs e) private void компонентыПоЦветамToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportFlowerComponents)); var service = Program.ServiceProvider?.GetService(typeof(FormReportFlowerComponents));
if (service is FormReportFlowerComponents form) if (service is FormReportFlowerComponents form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
}
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients)) ;
if (service is FormClients form)
{
form.ShowDialog();
}
}
}
} }

View File

@ -18,7 +18,7 @@
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>

View File

@ -38,13 +38,15 @@ namespace FlowerShopView
services.AddTransient<IComponentStorage, ComponentStorage>(); services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>(); services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IFlowerStorage, FlowerStorage>(); services.AddTransient<IFlowerStorage, FlowerStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>(); services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IFlowerLogic, FlowerLogic>(); services.AddTransient<IFlowerLogic, FlowerLogic>();
services.AddTransient<IReportLogic, ReportLogic>(); services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>(); services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>(); services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<AbstractSaveToWord, SaveToWord>(); services.AddTransient<AbstractSaveToWord, SaveToWord>();
@ -57,6 +59,7 @@ namespace FlowerShopView
services.AddTransient<FormFlowers>(); services.AddTransient<FormFlowers>();
services.AddTransient<FormReportOrders>(); services.AddTransient<FormReportOrders>();
services.AddTransient<FormReportFlowerComponents>(); services.AddTransient<FormReportFlowerComponents>();
} services.AddTransient<FormClients>();
}
} }
} }