врожде все
This commit is contained in:
parent
dd789b780d
commit
927d771b4b
@ -50,8 +50,6 @@ namespace FlowerShopDatabaseImplement.Models
|
||||
FlowerId = model.FlowerId,
|
||||
ClientId = model.ClientId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
Implementer = (model.ImplementerId.HasValue ? context.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId)
|
||||
: null),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -37,10 +37,15 @@ namespace FlowerShopDatabaseImplement.Implements
|
||||
{
|
||||
|
||||
using var context = new FlowerShopDataBase();
|
||||
return context.Orders.Include(x => x.Flower).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(
|
||||
x => ((model.Id.HasValue && x.Id == model.Id) ||
|
||||
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||
x.ImplementerId == model.ImplementerId && x.Status == model.Status)))?.GetViewModel;
|
||||
return context.Orders
|
||||
.Include(x => x.Flower)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(
|
||||
x => (model.Id.HasValue && x.Id == model.Id) ||
|
||||
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||
x.ImplementerId == model.ImplementerId && x.Status == model.Status))?
|
||||
.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
@ -70,7 +75,7 @@ namespace FlowerShopDatabaseImplement.Implements
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new FlowerShopDataBase();
|
||||
var element = context.Orders.Include(x => x.Flower).Include(x => x.Client).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Orders.Include(x => x.Flower).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Orders.Remove(element);
|
||||
|
434
ProjectFlowerShop/MainForm.Designer.cs
generated
434
ProjectFlowerShop/MainForm.Designer.cs
generated
@ -1,216 +1,234 @@
|
||||
namespace ProjectFlowerShop
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
menuStrip1 = new MenuStrip();
|
||||
ToolStripMenu = new ToolStripMenuItem();
|
||||
КомпонентыStripMenuItem = new ToolStripMenuItem();
|
||||
ЦветыStripMenuItem = new ToolStripMenuItem();
|
||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||
DataGridView = new DataGridView();
|
||||
CreateOrderButton = new Button();
|
||||
TakeInWorkButton = new Button();
|
||||
ReadyButton = new Button();
|
||||
IssuedButton = new Button();
|
||||
RefreshButton = new Button();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenu, отчетыToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(1296, 28);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// ToolStripMenu
|
||||
//
|
||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, ЦветыStripMenuItem, клиентыToolStripMenuItem });
|
||||
ToolStripMenu.Name = "ToolStripMenu";
|
||||
ToolStripMenu.Size = new Size(117, 24);
|
||||
ToolStripMenu.Text = "Справочники";
|
||||
//
|
||||
// КомпонентыStripMenuItem
|
||||
//
|
||||
КомпонентыStripMenuItem.Name = "КомпонентыStripMenuItem";
|
||||
КомпонентыStripMenuItem.Size = new Size(224, 26);
|
||||
КомпонентыStripMenuItem.Text = "Компоненты";
|
||||
КомпонентыStripMenuItem.Click += КомпонентыStripMenuItem_Click;
|
||||
//
|
||||
// ЦветыStripMenuItem
|
||||
//
|
||||
ЦветыStripMenuItem.Name = "ЦветыStripMenuItem";
|
||||
ЦветыStripMenuItem.Size = new Size(224, 26);
|
||||
ЦветыStripMenuItem.Text = "Цветы";
|
||||
ЦветыStripMenuItem.Click += ЦветыStripMenuItem_Click;
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
клиентыToolStripMenuItem.Size = new Size(224, 26);
|
||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыToolStripMenuItem, списокЗаказовToolStripMenuItem });
|
||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// списокКомпонентовToolStripMenuItem
|
||||
//
|
||||
списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
|
||||
списокКомпонентовToolStripMenuItem.Size = new Size(280, 26);
|
||||
списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
|
||||
списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click;
|
||||
//
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(280, 26);
|
||||
компонентыToolStripMenuItem.Text = "Компоненты по изделиям ";
|
||||
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
|
||||
//
|
||||
// списокЗаказовToolStripMenuItem
|
||||
//
|
||||
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
||||
списокЗаказовToolStripMenuItem.Size = new Size(280, 26);
|
||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(12, 31);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.Size = new Size(1007, 407);
|
||||
DataGridView.TabIndex = 1;
|
||||
//
|
||||
// CreateOrderButton
|
||||
//
|
||||
CreateOrderButton.Location = new Point(1025, 31);
|
||||
CreateOrderButton.Name = "CreateOrderButton";
|
||||
CreateOrderButton.Size = new Size(259, 29);
|
||||
CreateOrderButton.TabIndex = 2;
|
||||
CreateOrderButton.Text = "Создать заказ";
|
||||
CreateOrderButton.UseVisualStyleBackColor = true;
|
||||
CreateOrderButton.Click += CreateOrderButton_Click;
|
||||
//
|
||||
// TakeInWorkButton
|
||||
//
|
||||
TakeInWorkButton.Location = new Point(1025, 66);
|
||||
TakeInWorkButton.Name = "TakeInWorkButton";
|
||||
TakeInWorkButton.Size = new Size(259, 29);
|
||||
TakeInWorkButton.TabIndex = 3;
|
||||
TakeInWorkButton.Text = "Отдать заказ в работу";
|
||||
TakeInWorkButton.UseVisualStyleBackColor = true;
|
||||
TakeInWorkButton.Click += TakeInWorkButton_Click;
|
||||
//
|
||||
// ReadyButton
|
||||
//
|
||||
ReadyButton.Location = new Point(1025, 101);
|
||||
ReadyButton.Name = "ReadyButton";
|
||||
ReadyButton.Size = new Size(259, 29);
|
||||
ReadyButton.TabIndex = 4;
|
||||
ReadyButton.Text = "Заказ готов";
|
||||
ReadyButton.UseVisualStyleBackColor = true;
|
||||
ReadyButton.Click += ReadyButton_Click;
|
||||
//
|
||||
// IssuedButton
|
||||
//
|
||||
IssuedButton.Location = new Point(1025, 136);
|
||||
IssuedButton.Name = "IssuedButton";
|
||||
IssuedButton.Size = new Size(259, 29);
|
||||
IssuedButton.TabIndex = 5;
|
||||
IssuedButton.Text = "Заказ выдан";
|
||||
IssuedButton.UseVisualStyleBackColor = true;
|
||||
IssuedButton.Click += IssuedButton_Click;
|
||||
//
|
||||
// RefreshButton
|
||||
//
|
||||
RefreshButton.Location = new Point(1025, 171);
|
||||
RefreshButton.Name = "RefreshButton";
|
||||
RefreshButton.Size = new Size(259, 29);
|
||||
RefreshButton.TabIndex = 6;
|
||||
RefreshButton.Text = "Обновить";
|
||||
RefreshButton.UseVisualStyleBackColor = true;
|
||||
RefreshButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1296, 450);
|
||||
Controls.Add(RefreshButton);
|
||||
Controls.Add(IssuedButton);
|
||||
Controls.Add(ReadyButton);
|
||||
Controls.Add(TakeInWorkButton);
|
||||
Controls.Add(CreateOrderButton);
|
||||
Controls.Add(DataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "MainForm";
|
||||
Text = "Главная форма";
|
||||
Load += MainForm_Load;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
menuStrip1 = new MenuStrip();
|
||||
ToolStripMenu = new ToolStripMenuItem();
|
||||
КомпонентыStripMenuItem = new ToolStripMenuItem();
|
||||
ЦветыStripMenuItem = 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();
|
||||
CreateOrderButton = new Button();
|
||||
TakeInWorkButton = new Button();
|
||||
ReadyButton = new Button();
|
||||
IssuedButton = new Button();
|
||||
RefreshButton = new Button();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenu, отчетыToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(1296, 28);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// ToolStripMenu
|
||||
//
|
||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, ЦветыStripMenuItem, клиентыToolStripMenuItem, исполнителиToolStripMenuItem, стартРаботToolStripMenuItem });
|
||||
ToolStripMenu.Name = "ToolStripMenu";
|
||||
ToolStripMenu.Size = new Size(117, 24);
|
||||
ToolStripMenu.Text = "Справочники";
|
||||
//
|
||||
// КомпонентыStripMenuItem
|
||||
//
|
||||
КомпонентыStripMenuItem.Name = "КомпонентыStripMenuItem";
|
||||
КомпонентыStripMenuItem.Size = new Size(224, 26);
|
||||
КомпонентыStripMenuItem.Text = "Компоненты";
|
||||
КомпонентыStripMenuItem.Click += КомпонентыStripMenuItem_Click;
|
||||
//
|
||||
// ЦветыStripMenuItem
|
||||
//
|
||||
ЦветыStripMenuItem.Name = "ЦветыStripMenuItem";
|
||||
ЦветыStripMenuItem.Size = new Size(224, 26);
|
||||
ЦветыStripMenuItem.Text = "Цветы";
|
||||
ЦветыStripMenuItem.Click += ЦветыStripMenuItem_Click;
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
клиентыToolStripMenuItem.Size = new Size(224, 26);
|
||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||
//
|
||||
// исполнителиToolStripMenuItem
|
||||
//
|
||||
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||
исполнителиToolStripMenuItem.Size = new Size(224, 26);
|
||||
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
||||
//
|
||||
// стартРаботToolStripMenuItem
|
||||
//
|
||||
стартРаботToolStripMenuItem.Name = "стартРаботToolStripMenuItem";
|
||||
стартРаботToolStripMenuItem.Size = new Size(224, 26);
|
||||
стартРаботToolStripMenuItem.Text = "Старт работ";
|
||||
стартРаботToolStripMenuItem.Click += стартРаботToolStripMenuItem_Click;
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыToolStripMenuItem, списокЗаказовToolStripMenuItem });
|
||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// списокКомпонентовToolStripMenuItem
|
||||
//
|
||||
списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
|
||||
списокКомпонентовToolStripMenuItem.Size = new Size(280, 26);
|
||||
списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
|
||||
списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click;
|
||||
//
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(280, 26);
|
||||
компонентыToolStripMenuItem.Text = "Компоненты по изделиям ";
|
||||
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
|
||||
//
|
||||
// списокЗаказовToolStripMenuItem
|
||||
//
|
||||
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
||||
списокЗаказовToolStripMenuItem.Size = new Size(280, 26);
|
||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(12, 31);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.Size = new Size(1007, 407);
|
||||
DataGridView.TabIndex = 1;
|
||||
//
|
||||
// CreateOrderButton
|
||||
//
|
||||
CreateOrderButton.Location = new Point(1025, 31);
|
||||
CreateOrderButton.Name = "CreateOrderButton";
|
||||
CreateOrderButton.Size = new Size(259, 29);
|
||||
CreateOrderButton.TabIndex = 2;
|
||||
CreateOrderButton.Text = "Создать заказ";
|
||||
CreateOrderButton.UseVisualStyleBackColor = true;
|
||||
CreateOrderButton.Click += CreateOrderButton_Click;
|
||||
//
|
||||
// TakeInWorkButton
|
||||
//
|
||||
TakeInWorkButton.Location = new Point(1025, 66);
|
||||
TakeInWorkButton.Name = "TakeInWorkButton";
|
||||
TakeInWorkButton.Size = new Size(259, 29);
|
||||
TakeInWorkButton.TabIndex = 3;
|
||||
TakeInWorkButton.Text = "Отдать заказ в работу";
|
||||
TakeInWorkButton.UseVisualStyleBackColor = true;
|
||||
TakeInWorkButton.Click += TakeInWorkButton_Click;
|
||||
//
|
||||
// ReadyButton
|
||||
//
|
||||
ReadyButton.Location = new Point(1025, 101);
|
||||
ReadyButton.Name = "ReadyButton";
|
||||
ReadyButton.Size = new Size(259, 29);
|
||||
ReadyButton.TabIndex = 4;
|
||||
ReadyButton.Text = "Заказ готов";
|
||||
ReadyButton.UseVisualStyleBackColor = true;
|
||||
ReadyButton.Click += ReadyButton_Click;
|
||||
//
|
||||
// IssuedButton
|
||||
//
|
||||
IssuedButton.Location = new Point(1025, 136);
|
||||
IssuedButton.Name = "IssuedButton";
|
||||
IssuedButton.Size = new Size(259, 29);
|
||||
IssuedButton.TabIndex = 5;
|
||||
IssuedButton.Text = "Заказ выдан";
|
||||
IssuedButton.UseVisualStyleBackColor = true;
|
||||
IssuedButton.Click += IssuedButton_Click;
|
||||
//
|
||||
// RefreshButton
|
||||
//
|
||||
RefreshButton.Location = new Point(1025, 171);
|
||||
RefreshButton.Name = "RefreshButton";
|
||||
RefreshButton.Size = new Size(259, 29);
|
||||
RefreshButton.TabIndex = 6;
|
||||
RefreshButton.Text = "Обновить";
|
||||
RefreshButton.UseVisualStyleBackColor = true;
|
||||
RefreshButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1296, 450);
|
||||
Controls.Add(RefreshButton);
|
||||
Controls.Add(IssuedButton);
|
||||
Controls.Add(ReadyButton);
|
||||
Controls.Add(TakeInWorkButton);
|
||||
Controls.Add(CreateOrderButton);
|
||||
Controls.Add(DataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "MainForm";
|
||||
Text = "Главная форма";
|
||||
Load += MainForm_Load;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem ToolStripMenu;
|
||||
private ToolStripMenuItem КомпонентыStripMenuItem;
|
||||
private ToolStripMenuItem ЦветыStripMenuItem;
|
||||
private DataGridView DataGridView;
|
||||
private Button CreateOrderButton;
|
||||
private Button TakeInWorkButton;
|
||||
private Button ReadyButton;
|
||||
private Button IssuedButton;
|
||||
private Button RefreshButton;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
private ToolStripMenuItem списокКомпонентовToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
}
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem ToolStripMenu;
|
||||
private ToolStripMenuItem КомпонентыStripMenuItem;
|
||||
private ToolStripMenuItem ЦветыStripMenuItem;
|
||||
private DataGridView DataGridView;
|
||||
private Button CreateOrderButton;
|
||||
private Button TakeInWorkButton;
|
||||
private Button ReadyButton;
|
||||
private Button IssuedButton;
|
||||
private Button RefreshButton;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
private ToolStripMenuItem списокКомпонентовToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
private ToolStripMenuItem стартРаботToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -17,214 +17,232 @@ using System.Windows.Forms;
|
||||
|
||||
namespace ProjectFlowerShop
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
public MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
}
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IWorkProcess _workProcess;
|
||||
public MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
}
|
||||
|
||||
private void КомпонентыStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void КомпонентыStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void MainForm_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["ClientId"].Visible = false;
|
||||
DataGridView.Columns["FlowerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
DataGridView.DataSource = list;
|
||||
DataGridView.Columns["FlowerId"].Visible = false;
|
||||
DataGridView.Columns["ClientId"].Visible = false;
|
||||
DataGridView.Columns["FlowerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ЦветыStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormFlowers));
|
||||
if (service is FormFlowers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ЦветыStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormFlowers));
|
||||
if (service is FormFlowers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
|
||||
{
|
||||
return new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
FlowerId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["FlowerId"].Value),
|
||||
ClientId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ClientId"].Value),
|
||||
Status = Enum.Parse<OrderStatus>(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
};
|
||||
}
|
||||
private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
|
||||
{
|
||||
return new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
FlowerId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["FlowerId"].Value),
|
||||
ClientId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ClientId"].Value),
|
||||
Status = Enum.Parse<OrderStatus>(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
};
|
||||
}
|
||||
|
||||
private void TakeInWorkButton_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(CreateBindingModel(id));
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void TakeInWorkButton_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(CreateBindingModel(id));
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadyButton_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(CreateBindingModel(id));
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ReadyButton_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(CreateBindingModel(id));
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void IssuedButton_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(CreateBindingModel(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 IssuedButton_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(CreateBindingModel(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 RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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(FormReportFlowerComponent));
|
||||
if (service is FormReportFlowerComponent form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportFlowerComponent));
|
||||
if (service is FormReportFlowerComponent 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(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void стартРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ImplementersForm));
|
||||
if (service is ImplementersForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,16 +45,22 @@ namespace ProjectFlowerShop
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IFlowerLogic, FlowerLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<MainForm>();
|
||||
services.AddTransient<ComponentForm>();
|
||||
services.AddTransient<IWorkProcess, WorkProcess>();
|
||||
services.AddTransient<MainForm>();
|
||||
services.AddTransient<ComponentForm>();
|
||||
services.AddTransient<FormComponents>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormFlower>();
|
||||
services.AddTransient<FormFlowerComponent>();
|
||||
services.AddTransient<FormFlowers>();
|
||||
services.AddTransient<FormClients>();
|
||||
services.AddTransient<FormReportFlowerComponent>();
|
||||
services.AddTransient<ImplementersForm>();
|
||||
services.AddTransient<ImplementerForm>();
|
||||
services.AddTransient<FormReportFlowerComponent>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
|
Loading…
Reference in New Issue
Block a user