правки

This commit is contained in:
Андрей Байгулов 2024-05-03 23:00:14 +04:00
parent 3b9bca0157
commit 2fb30acd26
6 changed files with 660 additions and 357 deletions

View File

@ -1,24 +1,18 @@
@using SushiBarContracts.ViewModels @using SushiBarContracts.ViewModels
@model List<OrderViewModel> @model List<OrderViewModel>
@{ @{
ViewData["Title"] = "Home Page"; ViewData["Title"] = "Home Page";
} }
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Заказы</h1> <h1 class="display-4">Заказы</h1>
</div> </div>
<div class="text-center"> <div class="text-center">
@{ @{
if (Model == null) if (Model == null)
{ {
<h3 class="display-4">Авторизируйтесь</h3> <h3 class="display-4">Авторизуйтесь</h3>
return; return;
} }
<p> <p>
<a asp-action="Create">Создать заказ</a> <a asp-action="Create">Создать заказ</a>
</p> </p>
@ -29,7 +23,7 @@
Номер Номер
</th> </th>
<th> <th>
Суши Изделие
</th> </th>
<th> <th>
Дата создания Дата создания
@ -72,4 +66,4 @@
</tbody> </tbody>
</table> </table>
} }
</div> </div>

View File

@ -0,0 +1,86 @@
namespace SushiBarView
{
partial class FormClients
{
/// <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);
}
#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()
{
buttonDel = new Button();
buttonRef = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonDel
//
buttonDel.Location = new Point(382, 12);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(119, 38);
buttonDel.TabIndex = 0;
buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonRef
//
buttonRef.Location = new Point(382, 56);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(119, 37);
buttonRef.TabIndex = 1;
buttonRef.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += buttonRef_Click;
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(2, 2);
dataGridView.Name = "dataGridView";
dataGridView.Size = new Size(374, 447);
dataGridView.TabIndex = 2;
//
// FormClients
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(513, 450);
Controls.Add(dataGridView);
Controls.Add(buttonRef);
Controls.Add(buttonDel);
Name = "FormClients";
Text = "Клиенты";
Load += FormClients_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonDel;
private Button buttonRef;
private DataGridView dataGridView;
}
}

View File

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

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, 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="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -20,175 +20,183 @@
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
dataGridView = new DataGridView(); dataGridView = new DataGridView();
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();
menuStrip = new MenuStrip(); menuStrip = new MenuStrip();
toolStripMenuItem = new ToolStripMenuItem(); toolStripMenuItem = new ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem(); componentsToolStripMenuItem = new ToolStripMenuItem();
sushiToolStripMenuItem = new ToolStripMenuItem(); sushiToolStripMenuItem = new ToolStripMenuItem();
ReportsToolStripMenuItem = new ToolStripMenuItem(); ReportsToolStripMenuItem = new ToolStripMenuItem();
ComponentsListToolStripMenuItem = new ToolStripMenuItem(); ComponentsListToolStripMenuItem = new ToolStripMenuItem();
ComponentSushisToolStripMenuItem = new ToolStripMenuItem(); ComponentSushisToolStripMenuItem = new ToolStripMenuItem();
OrdersToolStripMenuItem = new ToolStripMenuItem(); OrdersToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); clientToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); menuStrip.SuspendLayout();
// SuspendLayout();
// dataGridView //
// // dataGridView
dataGridView.BackgroundColor = SystemColors.Window; //
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.BackgroundColor = SystemColors.Window;
dataGridView.Location = new Point(1, 29); dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Name = "dataGridView"; dataGridView.Location = new Point(1, 29);
dataGridView.Size = new Size(1080, 307); dataGridView.Name = "dataGridView";
dataGridView.TabIndex = 0; dataGridView.Size = new Size(1080, 307);
// dataGridView.TabIndex = 0;
// ButtonCreateOrder //
// // ButtonCreateOrder
ButtonCreateOrder.Location = new Point(1087, 41); //
ButtonCreateOrder.Name = "ButtonCreateOrder"; ButtonCreateOrder.Location = new Point(1087, 41);
ButtonCreateOrder.Size = new Size(147, 33); ButtonCreateOrder.Name = "ButtonCreateOrder";
ButtonCreateOrder.TabIndex = 1; ButtonCreateOrder.Size = new Size(147, 33);
ButtonCreateOrder.Text = "Создать заказ"; ButtonCreateOrder.TabIndex = 1;
ButtonCreateOrder.UseVisualStyleBackColor = true; ButtonCreateOrder.Text = "Создать заказ";
ButtonCreateOrder.Click += ButtonCreateOrder_Click; ButtonCreateOrder.UseVisualStyleBackColor = true;
// ButtonCreateOrder.Click += ButtonCreateOrder_Click;
// ButtonTakeOrderInWork //
// // ButtonTakeOrderInWork
ButtonTakeOrderInWork.Location = new Point(1087, 80); //
ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork"; ButtonTakeOrderInWork.Location = new Point(1087, 80);
ButtonTakeOrderInWork.Size = new Size(147, 33); ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
ButtonTakeOrderInWork.TabIndex = 2; ButtonTakeOrderInWork.Size = new Size(147, 33);
ButtonTakeOrderInWork.Text = "Отдать на выполнение"; ButtonTakeOrderInWork.TabIndex = 2;
ButtonTakeOrderInWork.UseVisualStyleBackColor = true; ButtonTakeOrderInWork.Text = "Отдать на выполнение";
ButtonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
// ButtonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
// ButtonOrderReady //
// // ButtonOrderReady
ButtonOrderReady.Location = new Point(1087, 119); //
ButtonOrderReady.Name = "ButtonOrderReady"; ButtonOrderReady.Location = new Point(1087, 119);
ButtonOrderReady.Size = new Size(147, 33); ButtonOrderReady.Name = "ButtonOrderReady";
ButtonOrderReady.TabIndex = 3; ButtonOrderReady.Size = new Size(147, 33);
ButtonOrderReady.Text = "Заказ готов"; ButtonOrderReady.TabIndex = 3;
ButtonOrderReady.UseVisualStyleBackColor = true; ButtonOrderReady.Text = "Заказ готов";
ButtonOrderReady.Click += ButtonOrderReady_Click; ButtonOrderReady.UseVisualStyleBackColor = true;
// ButtonOrderReady.Click += ButtonOrderReady_Click;
// ButtonIssuedOrder //
// // ButtonIssuedOrder
ButtonIssuedOrder.Location = new Point(1087, 158); //
ButtonIssuedOrder.Name = "ButtonIssuedOrder"; ButtonIssuedOrder.Location = new Point(1087, 158);
ButtonIssuedOrder.Size = new Size(147, 33); ButtonIssuedOrder.Name = "ButtonIssuedOrder";
ButtonIssuedOrder.TabIndex = 4; ButtonIssuedOrder.Size = new Size(147, 33);
ButtonIssuedOrder.Text = "Заказ выдан"; ButtonIssuedOrder.TabIndex = 4;
ButtonIssuedOrder.UseVisualStyleBackColor = true; ButtonIssuedOrder.Text = "Заказ выдан";
ButtonIssuedOrder.Click += ButtonIssuedOrder_Click; ButtonIssuedOrder.UseVisualStyleBackColor = true;
// ButtonIssuedOrder.Click += ButtonIssuedOrder_Click;
// ButtonRef //
// // ButtonRef
ButtonRef.Location = new Point(1087, 197); //
ButtonRef.Name = "ButtonRef"; ButtonRef.Location = new Point(1087, 197);
ButtonRef.Size = new Size(147, 33); ButtonRef.Name = "ButtonRef";
ButtonRef.TabIndex = 5; ButtonRef.Size = new Size(147, 33);
ButtonRef.Text = "Обновить список"; ButtonRef.TabIndex = 5;
ButtonRef.UseVisualStyleBackColor = true; ButtonRef.Text = "Обновить список";
ButtonRef.Click += ButtonRef_Click; ButtonRef.UseVisualStyleBackColor = true;
// ButtonRef.Click += ButtonRef_Click;
// menuStrip //
// // menuStrip
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, ReportsToolStripMenuItem }); //
menuStrip.Location = new Point(0, 0); menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, ReportsToolStripMenuItem });
menuStrip.Name = "menuStrip"; menuStrip.Location = new Point(0, 0);
menuStrip.Size = new Size(1265, 24); menuStrip.Name = "menuStrip";
menuStrip.TabIndex = 6; menuStrip.Size = new Size(1265, 24);
menuStrip.Text = "menuStrip1"; menuStrip.TabIndex = 6;
// menuStrip.Text = "menuStrip1";
// toolStripMenuItem //
// // toolStripMenuItem
toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, sushiToolStripMenuItem }); //
toolStripMenuItem.Name = "toolStripMenuItem"; toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, sushiToolStripMenuItem, clientToolStripMenuItem });
toolStripMenuItem.Size = new Size(94, 20); toolStripMenuItem.Name = "toolStripMenuItem";
toolStripMenuItem.Text = "Справочники"; toolStripMenuItem.Size = new Size(94, 20);
// toolStripMenuItem.Text = "Справочники";
// componentsToolStripMenuItem //
// // componentsToolStripMenuItem
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; //
componentsToolStripMenuItem.Size = new Size(145, 22); componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
componentsToolStripMenuItem.Text = "Компоненты"; componentsToolStripMenuItem.Size = new Size(180, 22);
componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click; componentsToolStripMenuItem.Text = "Компоненты";
// componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click;
// sushiToolStripMenuItem //
// // sushiToolStripMenuItem
sushiToolStripMenuItem.Name = "sushiToolStripMenuItem"; //
sushiToolStripMenuItem.Size = new Size(145, 22); sushiToolStripMenuItem.Name = "sushiToolStripMenuItem";
sushiToolStripMenuItem.Text = "Суши"; sushiToolStripMenuItem.Size = new Size(180, 22);
sushiToolStripMenuItem.Click += sushiToolStripMenuItem_Click; sushiToolStripMenuItem.Text = "Суши";
// sushiToolStripMenuItem.Click += sushiToolStripMenuItem_Click;
// ReportsToolStripMenuItem //
// // ReportsToolStripMenuItem
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsListToolStripMenuItem, ComponentSushisToolStripMenuItem, OrdersToolStripMenuItem }); //
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem"; ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsListToolStripMenuItem, ComponentSushisToolStripMenuItem, OrdersToolStripMenuItem });
ReportsToolStripMenuItem.Size = new Size(60, 20); ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
ReportsToolStripMenuItem.Text = "Отчеты"; ReportsToolStripMenuItem.Size = new Size(60, 20);
// ReportsToolStripMenuItem.Text = "Отчеты";
// ComponentsListToolStripMenuItem //
// // ComponentsListToolStripMenuItem
ComponentsListToolStripMenuItem.Name = "ComponentsListToolStripMenuItem"; //
ComponentsListToolStripMenuItem.Size = new Size(218, 22); ComponentsListToolStripMenuItem.Name = "ComponentsListToolStripMenuItem";
ComponentsListToolStripMenuItem.Text = "Список изделий"; ComponentsListToolStripMenuItem.Size = new Size(218, 22);
ComponentsListToolStripMenuItem.Click += ComponentsListToolStripMenuItem_Click; ComponentsListToolStripMenuItem.Text = "Список изделий";
// ComponentsListToolStripMenuItem.Click += ComponentsListToolStripMenuItem_Click;
// ComponentSushisToolStripMenuItem //
// // ComponentSushisToolStripMenuItem
ComponentSushisToolStripMenuItem.Name = "ComponentSushisToolStripMenuItem"; //
ComponentSushisToolStripMenuItem.Size = new Size(218, 22); ComponentSushisToolStripMenuItem.Name = "ComponentSushisToolStripMenuItem";
ComponentSushisToolStripMenuItem.Text = "Компоненты по изделиям"; ComponentSushisToolStripMenuItem.Size = new Size(218, 22);
ComponentSushisToolStripMenuItem.Click += ComponentSushisToolStripMenuItem_Click; ComponentSushisToolStripMenuItem.Text = "Компоненты по изделиям";
// ComponentSushisToolStripMenuItem.Click += ComponentSushisToolStripMenuItem_Click;
// OrdersToolStripMenuItem //
// // OrdersToolStripMenuItem
OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; //
OrdersToolStripMenuItem.Size = new Size(218, 22); OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
OrdersToolStripMenuItem.Text = "Список заказов"; OrdersToolStripMenuItem.Size = new Size(218, 22);
OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; OrdersToolStripMenuItem.Text = "Список заказов";
// OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
// FormMain //
// // clientToolStripMenuItem
AutoScaleDimensions = new SizeF(7F, 15F); //
AutoScaleMode = AutoScaleMode.Font; clientToolStripMenuItem.Name = "clientToolStripMenuItem";
ClientSize = new Size(1265, 337); clientToolStripMenuItem.Size = new Size(180, 22);
Controls.Add(ButtonRef); clientToolStripMenuItem.Text = "Клиент";
Controls.Add(ButtonIssuedOrder); clientToolStripMenuItem.Click += клиентToolStripMenuItem_Click;
Controls.Add(ButtonOrderReady); //
Controls.Add(ButtonTakeOrderInWork); // FormMain
Controls.Add(ButtonCreateOrder); //
Controls.Add(dataGridView); AutoScaleDimensions = new SizeF(7F, 15F);
Controls.Add(menuStrip); AutoScaleMode = AutoScaleMode.Font;
MainMenuStrip = menuStrip; ClientSize = new Size(1265, 337);
Name = "FormMain"; Controls.Add(ButtonRef);
Text = "Суши-бар"; Controls.Add(ButtonIssuedOrder);
Load += FormMain_Load; Controls.Add(ButtonOrderReady);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); Controls.Add(ButtonTakeOrderInWork);
menuStrip.ResumeLayout(false); Controls.Add(ButtonCreateOrder);
menuStrip.PerformLayout(); Controls.Add(dataGridView);
ResumeLayout(false); Controls.Add(menuStrip);
PerformLayout(); MainMenuStrip = menuStrip;
} Name = "FormMain";
Text = "Суши-бар";
Load += FormMain_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion #endregion
private DataGridView dataGridView; private DataGridView dataGridView;
private Button ButtonCreateOrder; private Button ButtonCreateOrder;
private Button ButtonTakeOrderInWork; private Button ButtonTakeOrderInWork;
private Button ButtonOrderReady; private Button ButtonOrderReady;
@ -202,5 +210,6 @@
private ToolStripMenuItem ComponentsListToolStripMenuItem; private ToolStripMenuItem ComponentsListToolStripMenuItem;
private ToolStripMenuItem ComponentSushisToolStripMenuItem; private ToolStripMenuItem ComponentSushisToolStripMenuItem;
private ToolStripMenuItem OrdersToolStripMenuItem; private ToolStripMenuItem OrdersToolStripMenuItem;
} private ToolStripMenuItem clientToolStripMenuItem;
}
} }

View File

@ -14,188 +14,198 @@ using System.Windows.Forms;
namespace SushiBarView namespace SushiBarView
{ {
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["SushiId"].Visible = false; dataGridView.Columns["SushiId"].Visible = false;
dataGridView.Columns["SushiName"].AutoSizeMode = dataGridView.Columns["ClientId"].Visible = false;
DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["SushiName"].AutoSizeMode =
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; DataGridViewAutoSizeColumnMode.Fill;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
} }
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки заказов"); _logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void componentsToolStripMenuItem_Click(object sender, EventArgs e) private void componentsToolStripMenuItem_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 sushiToolStripMenuItem_Click(object sender, EventArgs e) private void sushiToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormSushis)); var service = Program.ServiceProvider?.GetService(typeof(FormSushis));
if (service is FormSushis form) if (service is FormSushis form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ButtonCreateOrder_Click(object sender, EventArgs e) private void ButtonCreateOrder_Click(object sender, EventArgs e)
{ {
var service = var service =
Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); 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 var operationResult = _orderLogic.TakeOrderInWork(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, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); 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}. Меняется статус на 'Выдан'", _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
id); id);
try try
{ {
var operationResult = _orderLogic.DeliveryOrder(new var operationResult = _orderLogic.DeliveryOrder(new
OrderBindingModel OrderBindingModel
{ Id = id }); { 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 ComponentsListToolStripMenuItem_Click(object sender, EventArgs private void ComponentsListToolStripMenuItem_Click(object sender, EventArgs
e) 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, MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information); MessageBoxIcon.Information);
} }
} }
private void ComponentSushisToolStripMenuItem_Click(object sender, private void ComponentSushisToolStripMenuItem_Click(object sender,
EventArgs e) EventArgs e)
{ {
var service = var service =
Program.ServiceProvider?.GetService(typeof(FormReportSushiComponents)); Program.ServiceProvider?.GetService(typeof(FormReportSushiComponents));
if (service is FormReportSushiComponents form) if (service is FormReportSushiComponents form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = var service =
Program.ServiceProvider?.GetService(typeof(FormReportOrders)); Program.ServiceProvider?.GetService(typeof(FormReportOrders));
if (service is FormReportOrders form) if (service is FormReportOrders form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ButtonRef_Click(object sender, EventArgs e) private void ButtonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
}
private void clientToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
}
}
}
} }