Хранилища потом допилю
This commit is contained in:
parent
d2241ea027
commit
68efc94156
162
IceCreamShop/IceCreamShop/ImplementerForm.Designer.cs
generated
Normal file
162
IceCreamShop/IceCreamShop/ImplementerForm.Designer.cs
generated
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
namespace IceCreamShop
|
||||||
|
{
|
||||||
|
partial class ImplementerForm
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
FIOTextBox = new TextBox();
|
||||||
|
PasswordTextBox = new TextBox();
|
||||||
|
QualificationTextBox = new TextBox();
|
||||||
|
WorkExperienceTextBox = new TextBox();
|
||||||
|
label1 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label4 = new Label();
|
||||||
|
SaveButton = new Button();
|
||||||
|
CancelButton = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// FIOTextBox
|
||||||
|
//
|
||||||
|
FIOTextBox.Location = new Point(124, 19);
|
||||||
|
FIOTextBox.Name = "FIOTextBox";
|
||||||
|
FIOTextBox.Size = new Size(411, 27);
|
||||||
|
FIOTextBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// PasswordTextBox
|
||||||
|
//
|
||||||
|
PasswordTextBox.Location = new Point(124, 52);
|
||||||
|
PasswordTextBox.Name = "PasswordTextBox";
|
||||||
|
PasswordTextBox.Size = new Size(411, 27);
|
||||||
|
PasswordTextBox.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// QualificationTextBox
|
||||||
|
//
|
||||||
|
QualificationTextBox.Location = new Point(124, 85);
|
||||||
|
QualificationTextBox.Name = "QualificationTextBox";
|
||||||
|
QualificationTextBox.Size = new Size(411, 27);
|
||||||
|
QualificationTextBox.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// WorkExperienceTextBox
|
||||||
|
//
|
||||||
|
WorkExperienceTextBox.Location = new Point(124, 118);
|
||||||
|
WorkExperienceTextBox.Name = "WorkExperienceTextBox";
|
||||||
|
WorkExperienceTextBox.Size = new Size(411, 27);
|
||||||
|
WorkExperienceTextBox.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(9, 19);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(42, 20);
|
||||||
|
label1.TabIndex = 4;
|
||||||
|
label1.Text = "ФИО";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(9, 52);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(62, 20);
|
||||||
|
label2.TabIndex = 5;
|
||||||
|
label2.Text = "Пароль";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(9, 85);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(111, 20);
|
||||||
|
label3.TabIndex = 6;
|
||||||
|
label3.Text = "Квалификация";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(9, 118);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(99, 20);
|
||||||
|
label4.TabIndex = 7;
|
||||||
|
label4.Text = "Стаж работы";
|
||||||
|
//
|
||||||
|
// SaveButton
|
||||||
|
//
|
||||||
|
SaveButton.Location = new Point(341, 151);
|
||||||
|
SaveButton.Name = "SaveButton";
|
||||||
|
SaveButton.Size = new Size(94, 29);
|
||||||
|
SaveButton.TabIndex = 8;
|
||||||
|
SaveButton.Text = "Сохранить";
|
||||||
|
SaveButton.UseVisualStyleBackColor = true;
|
||||||
|
SaveButton.Click += SaveButton_Click;
|
||||||
|
//
|
||||||
|
// CancelButton
|
||||||
|
//
|
||||||
|
CancelButton.Location = new Point(441, 151);
|
||||||
|
CancelButton.Name = "CancelButton";
|
||||||
|
CancelButton.Size = new Size(94, 29);
|
||||||
|
CancelButton.TabIndex = 9;
|
||||||
|
CancelButton.Text = "Отмена";
|
||||||
|
CancelButton.UseVisualStyleBackColor = true;
|
||||||
|
CancelButton.Click += CancelButton_Click;
|
||||||
|
//
|
||||||
|
// ImplementerForm
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(548, 186);
|
||||||
|
Controls.Add(CancelButton);
|
||||||
|
Controls.Add(SaveButton);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(WorkExperienceTextBox);
|
||||||
|
Controls.Add(QualificationTextBox);
|
||||||
|
Controls.Add(PasswordTextBox);
|
||||||
|
Controls.Add(FIOTextBox);
|
||||||
|
Name = "ImplementerForm";
|
||||||
|
Text = "Исполнитель";
|
||||||
|
Load += ImplementerForm_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox FIOTextBox;
|
||||||
|
private TextBox PasswordTextBox;
|
||||||
|
private TextBox QualificationTextBox;
|
||||||
|
private TextBox WorkExperienceTextBox;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private Button SaveButton;
|
||||||
|
private Button CancelButton;
|
||||||
|
}
|
||||||
|
}
|
109
IceCreamShop/IceCreamShop/ImplementerForm.cs
Normal file
109
IceCreamShop/IceCreamShop/ImplementerForm.cs
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
using IceCreamShopContracts.BindingModels;
|
||||||
|
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||||
|
using IceCreamShopContracts.SearchModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace IceCreamShop
|
||||||
|
{
|
||||||
|
public partial class ImplementerForm : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public ImplementerForm(ILogger<ImplementerForm> logger, IImplementerLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ImplementerForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение исполнителя");
|
||||||
|
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||||
|
{
|
||||||
|
Id =
|
||||||
|
_id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
FIOTextBox.Text = view.ImplementerFIO;
|
||||||
|
PasswordTextBox.Text = view.Password;
|
||||||
|
QualificationTextBox.Text = view.Qualification.ToString();
|
||||||
|
WorkExperienceTextBox.Text = view.WorkExperience.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(FIOTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните ФИО", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(PasswordTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните пароль", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение компонента");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ImplementerBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ImplementerFIO = FIOTextBox.Text,
|
||||||
|
Password = PasswordTextBox.Text,
|
||||||
|
Qualification = Convert.ToInt32(QualificationTextBox.Text),
|
||||||
|
WorkExperience = Convert.ToInt32(WorkExperienceTextBox.Text),
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) :
|
||||||
|
_logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения исполнителя");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
IceCreamShop/IceCreamShop/ImplementerForm.resx
Normal file
120
IceCreamShop/IceCreamShop/ImplementerForm.resx
Normal 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>
|
114
IceCreamShop/IceCreamShop/ImplementersForm.Designer.cs
generated
Normal file
114
IceCreamShop/IceCreamShop/ImplementersForm.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
namespace IceCreamShop
|
||||||
|
{
|
||||||
|
partial class ImplementersForm
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
dataGridView1 = new DataGridView();
|
||||||
|
CreateButton = new Button();
|
||||||
|
ChangeButton = new Button();
|
||||||
|
DeleteButton = new Button();
|
||||||
|
RefreshButton = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView1
|
||||||
|
//
|
||||||
|
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView1.Location = new Point(12, 12);
|
||||||
|
dataGridView1.Name = "dataGridView1";
|
||||||
|
dataGridView1.RowHeadersWidth = 51;
|
||||||
|
dataGridView1.RowTemplate.Height = 29;
|
||||||
|
dataGridView1.Size = new Size(565, 426);
|
||||||
|
dataGridView1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// CreateButton
|
||||||
|
//
|
||||||
|
CreateButton.Location = new Point(583, 12);
|
||||||
|
CreateButton.Name = "CreateButton";
|
||||||
|
CreateButton.Size = new Size(205, 29);
|
||||||
|
CreateButton.TabIndex = 1;
|
||||||
|
CreateButton.Text = "Создать";
|
||||||
|
CreateButton.UseVisualStyleBackColor = true;
|
||||||
|
CreateButton.Click += CreateButton_Click;
|
||||||
|
//
|
||||||
|
// ChangeButton
|
||||||
|
//
|
||||||
|
ChangeButton.Location = new Point(583, 47);
|
||||||
|
ChangeButton.Name = "ChangeButton";
|
||||||
|
ChangeButton.Size = new Size(205, 29);
|
||||||
|
ChangeButton.TabIndex = 2;
|
||||||
|
ChangeButton.Text = "Изменить";
|
||||||
|
ChangeButton.UseVisualStyleBackColor = true;
|
||||||
|
ChangeButton.Click += ChangeButton_Click;
|
||||||
|
//
|
||||||
|
// DeleteButton
|
||||||
|
//
|
||||||
|
DeleteButton.Location = new Point(583, 82);
|
||||||
|
DeleteButton.Name = "DeleteButton";
|
||||||
|
DeleteButton.Size = new Size(205, 29);
|
||||||
|
DeleteButton.TabIndex = 3;
|
||||||
|
DeleteButton.Text = "Удалить";
|
||||||
|
DeleteButton.UseVisualStyleBackColor = true;
|
||||||
|
DeleteButton.Click += DeleteButton_Click;
|
||||||
|
//
|
||||||
|
// RefreshButton
|
||||||
|
//
|
||||||
|
RefreshButton.Location = new Point(583, 117);
|
||||||
|
RefreshButton.Name = "RefreshButton";
|
||||||
|
RefreshButton.Size = new Size(205, 29);
|
||||||
|
RefreshButton.TabIndex = 4;
|
||||||
|
RefreshButton.Text = "Обновить";
|
||||||
|
RefreshButton.UseVisualStyleBackColor = true;
|
||||||
|
RefreshButton.Click += RefreshButton_Click;
|
||||||
|
//
|
||||||
|
// ImplementersForm
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(RefreshButton);
|
||||||
|
Controls.Add(DeleteButton);
|
||||||
|
Controls.Add(ChangeButton);
|
||||||
|
Controls.Add(CreateButton);
|
||||||
|
Controls.Add(dataGridView1);
|
||||||
|
Name = "ImplementersForm";
|
||||||
|
Text = "Исполнители";
|
||||||
|
Load += ImplementersForm_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView1;
|
||||||
|
private Button CreateButton;
|
||||||
|
private Button ChangeButton;
|
||||||
|
private Button DeleteButton;
|
||||||
|
private Button RefreshButton;
|
||||||
|
}
|
||||||
|
}
|
125
IceCreamShop/IceCreamShop/ImplementersForm.cs
Normal file
125
IceCreamShop/IceCreamShop/ImplementersForm.cs
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
using IceCreamShopContracts.BindingModels;
|
||||||
|
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace IceCreamShop
|
||||||
|
{
|
||||||
|
public partial class ImplementersForm : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
public ImplementersForm(ILogger<ImplementersForm> logger, IImplementerLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ImplementersForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView1.DataSource = list;
|
||||||
|
dataGridView1.Columns["Id"].Visible = false;
|
||||||
|
dataGridView1.Columns["ImplementerFIO"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["Password"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["Qualification"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["WorkExperience"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки исполнителей");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||||
|
if (service is ImplementerForm form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||||
|
if (service is ImplementerForm form)
|
||||||
|
{
|
||||||
|
form.Id =
|
||||||
|
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id =
|
||||||
|
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
_logger.LogInformation("Удаление компонента");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new ImplementerBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления исполнителя");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
IceCreamShop/IceCreamShop/ImplementersForm.resx
Normal file
120
IceCreamShop/IceCreamShop/ImplementersForm.resx
Normal 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>
|
357
IceCreamShop/IceCreamShop/MainForm.Designer.cs
generated
357
IceCreamShop/IceCreamShop/MainForm.Designer.cs
generated
@ -20,199 +20,182 @@
|
|||||||
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();
|
||||||
ToolStripMenu = new ToolStripMenuItem();
|
ToolStripMenu = new ToolStripMenuItem();
|
||||||
КомпонентыStripMenuItem = new ToolStripMenuItem();
|
КомпонентыStripMenuItem = 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();
|
списокМороженногоToolStripMenuItem = new ToolStripMenuItem();
|
||||||
DataGridView = new DataGridView();
|
компонентыПоМороженнымToolStripMenuItem = new ToolStripMenuItem();
|
||||||
CreateOrderButton = new Button();
|
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
TakeInWorkButton = new Button();
|
DataGridView = new DataGridView();
|
||||||
ReadyButton = new Button();
|
CreateOrderButton = new Button();
|
||||||
IssuedButton = new Button();
|
IssuedButton = new Button();
|
||||||
RefreshButton = new Button();
|
RefreshButton = new Button();
|
||||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenu, отчетыToolStripMenuItem });
|
menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenu, отчетыToolStripMenuItem, запускРаботToolStripMenuItem });
|
||||||
menuStrip1.Location = new Point(0, 0);
|
menuStrip1.Location = new Point(0, 0);
|
||||||
menuStrip1.Name = "menuStrip1";
|
menuStrip1.Name = "menuStrip1";
|
||||||
menuStrip1.Padding = new Padding(5, 2, 0, 2);
|
menuStrip1.Padding = new Padding(6, 3, 0, 3);
|
||||||
menuStrip1.Size = new Size(1134, 24);
|
menuStrip1.Size = new Size(1296, 30);
|
||||||
menuStrip1.TabIndex = 0;
|
menuStrip1.TabIndex = 0;
|
||||||
menuStrip1.Text = "menuStrip1";
|
menuStrip1.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
// ToolStripMenu
|
// ToolStripMenu
|
||||||
//
|
//
|
||||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, МороженноеStripMenuItem, клиентыToolStripMenuItem });
|
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, МороженноеStripMenuItem, клиентыToolStripMenuItem, исполнителиToolStripMenuItem });
|
||||||
ToolStripMenu.Name = "ToolStripMenu";
|
ToolStripMenu.Name = "ToolStripMenu";
|
||||||
ToolStripMenu.Size = new Size(94, 20);
|
ToolStripMenu.Size = new Size(117, 24);
|
||||||
ToolStripMenu.Text = "Справочники";
|
ToolStripMenu.Text = "Справочники";
|
||||||
//
|
//
|
||||||
// КомпонентыStripMenuItem
|
// КомпонентыStripMenuItem
|
||||||
//
|
//
|
||||||
КомпонентыStripMenuItem.Name = "КомпонентыStripMenuItem";
|
КомпонентыStripMenuItem.Name = "КомпонентыStripMenuItem";
|
||||||
КомпонентыStripMenuItem.Size = new Size(180, 22);
|
КомпонентыStripMenuItem.Size = new Size(186, 26);
|
||||||
КомпонентыStripMenuItem.Text = "Компоненты";
|
КомпонентыStripMenuItem.Text = "Компоненты";
|
||||||
КомпонентыStripMenuItem.Click += КомпонентыStripMenuItem_Click;
|
КомпонентыStripMenuItem.Click += КомпонентыStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// МороженноеStripMenuItem
|
// МороженноеStripMenuItem
|
||||||
//
|
//
|
||||||
МороженноеStripMenuItem.Name = "МороженноеStripMenuItem";
|
МороженноеStripMenuItem.Name = "МороженноеStripMenuItem";
|
||||||
МороженноеStripMenuItem.Size = new Size(180, 22);
|
МороженноеStripMenuItem.Size = new Size(186, 26);
|
||||||
МороженноеStripMenuItem.Text = "Мороженное";
|
МороженноеStripMenuItem.Text = "Мороженное";
|
||||||
МороженноеStripMenuItem.Click += МороженноеStripMenuItem_Click;
|
МороженноеStripMenuItem.Click += МороженноеStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// отчетыToolStripMenuItem
|
// клиентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокМороженногоToolStripMenuItem, компонентыПоМороженнымToolStripMenuItem, списокЗаказовToolStripMenuItem });
|
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
клиентыToolStripMenuItem.Size = new Size(186, 26);
|
||||||
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// списокМороженногоToolStripMenuItem
|
// исполнителиToolStripMenuItem
|
||||||
//
|
//
|
||||||
списокМороженногоToolStripMenuItem.Name = "списокМороженногоToolStripMenuItem";
|
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||||
списокМороженногоToolStripMenuItem.Size = new Size(242, 22);
|
исполнителиToolStripMenuItem.Size = new Size(186, 26);
|
||||||
списокМороженногоToolStripMenuItem.Text = "Список мороженного";
|
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||||
списокМороженногоToolStripMenuItem.Click += списокМороженногоToolStripMenuItem_Click;
|
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// компонентыПоМороженнымToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
компонентыПоМороженнымToolStripMenuItem.Name = "компонентыПоМороженнымToolStripMenuItem";
|
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокМороженногоToolStripMenuItem, компонентыПоМороженнымToolStripMenuItem, списокЗаказовToolStripMenuItem });
|
||||||
компонентыПоМороженнымToolStripMenuItem.Size = new Size(242, 22);
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
компонентыПоМороженнымToolStripMenuItem.Text = "Компоненты по мороженным";
|
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||||
компонентыПоМороженнымToolStripMenuItem.Click += компонентыПоМороженнымToolStripMenuItem_Click;
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
//
|
//
|
||||||
// списокЗаказовToolStripMenuItem
|
// списокМороженногоToolStripMenuItem
|
||||||
//
|
//
|
||||||
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
списокМороженногоToolStripMenuItem.Name = "списокМороженногоToolStripMenuItem";
|
||||||
списокЗаказовToolStripMenuItem.Size = new Size(242, 22);
|
списокМороженногоToolStripMenuItem.Size = new Size(305, 26);
|
||||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
списокМороженногоToolStripMenuItem.Text = "Список мороженного";
|
||||||
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
списокМороженногоToolStripMenuItem.Click += списокМороженногоToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// DataGridView
|
// компонентыПоМороженнымToolStripMenuItem
|
||||||
//
|
//
|
||||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
компонентыПоМороженнымToolStripMenuItem.Name = "компонентыПоМороженнымToolStripMenuItem";
|
||||||
DataGridView.Location = new Point(10, 23);
|
компонентыПоМороженнымToolStripMenuItem.Size = new Size(305, 26);
|
||||||
DataGridView.Margin = new Padding(3, 2, 3, 2);
|
компонентыПоМороженнымToolStripMenuItem.Text = "Компоненты по мороженным";
|
||||||
DataGridView.Name = "DataGridView";
|
компонентыПоМороженнымToolStripMenuItem.Click += компонентыПоМороженнымToolStripMenuItem_Click;
|
||||||
DataGridView.RowHeadersWidth = 51;
|
//
|
||||||
DataGridView.Size = new Size(881, 305);
|
// списокЗаказовToolStripMenuItem
|
||||||
DataGridView.TabIndex = 1;
|
//
|
||||||
//
|
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
||||||
// CreateOrderButton
|
списокЗаказовToolStripMenuItem.Size = new Size(305, 26);
|
||||||
//
|
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||||
CreateOrderButton.Location = new Point(897, 23);
|
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
||||||
CreateOrderButton.Margin = new Padding(3, 2, 3, 2);
|
//
|
||||||
CreateOrderButton.Name = "CreateOrderButton";
|
// DataGridView
|
||||||
CreateOrderButton.Size = new Size(227, 22);
|
//
|
||||||
CreateOrderButton.TabIndex = 2;
|
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
CreateOrderButton.Text = "Создать заказ";
|
DataGridView.Location = new Point(11, 31);
|
||||||
CreateOrderButton.UseVisualStyleBackColor = true;
|
DataGridView.Name = "DataGridView";
|
||||||
CreateOrderButton.Click += CreateOrderButton_Click;
|
DataGridView.RowHeadersWidth = 51;
|
||||||
//
|
DataGridView.Size = new Size(1007, 407);
|
||||||
// TakeInWorkButton
|
DataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
TakeInWorkButton.Location = new Point(897, 50);
|
// CreateOrderButton
|
||||||
TakeInWorkButton.Margin = new Padding(3, 2, 3, 2);
|
//
|
||||||
TakeInWorkButton.Name = "TakeInWorkButton";
|
CreateOrderButton.Location = new Point(1025, 31);
|
||||||
TakeInWorkButton.Size = new Size(227, 22);
|
CreateOrderButton.Name = "CreateOrderButton";
|
||||||
TakeInWorkButton.TabIndex = 3;
|
CreateOrderButton.Size = new Size(259, 29);
|
||||||
TakeInWorkButton.Text = "Отдать заказ в работу";
|
CreateOrderButton.TabIndex = 2;
|
||||||
TakeInWorkButton.UseVisualStyleBackColor = true;
|
CreateOrderButton.Text = "Создать заказ";
|
||||||
TakeInWorkButton.Click += TakeInWorkButton_Click;
|
CreateOrderButton.UseVisualStyleBackColor = true;
|
||||||
//
|
CreateOrderButton.Click += CreateOrderButton_Click;
|
||||||
// ReadyButton
|
//
|
||||||
//
|
// IssuedButton
|
||||||
ReadyButton.Location = new Point(897, 76);
|
//
|
||||||
ReadyButton.Margin = new Padding(3, 2, 3, 2);
|
IssuedButton.Location = new Point(1024, 66);
|
||||||
ReadyButton.Name = "ReadyButton";
|
IssuedButton.Name = "IssuedButton";
|
||||||
ReadyButton.Size = new Size(227, 22);
|
IssuedButton.Size = new Size(259, 29);
|
||||||
ReadyButton.TabIndex = 4;
|
IssuedButton.TabIndex = 5;
|
||||||
ReadyButton.Text = "Заказ готов";
|
IssuedButton.Text = "Заказ выдан";
|
||||||
ReadyButton.UseVisualStyleBackColor = true;
|
IssuedButton.UseVisualStyleBackColor = true;
|
||||||
ReadyButton.Click += ReadyButton_Click;
|
IssuedButton.Click += IssuedButton_Click;
|
||||||
//
|
//
|
||||||
// IssuedButton
|
// RefreshButton
|
||||||
//
|
//
|
||||||
IssuedButton.Location = new Point(897, 102);
|
RefreshButton.Location = new Point(1025, 101);
|
||||||
IssuedButton.Margin = new Padding(3, 2, 3, 2);
|
RefreshButton.Name = "RefreshButton";
|
||||||
IssuedButton.Name = "IssuedButton";
|
RefreshButton.Size = new Size(259, 29);
|
||||||
IssuedButton.Size = new Size(227, 22);
|
RefreshButton.TabIndex = 6;
|
||||||
IssuedButton.TabIndex = 5;
|
RefreshButton.Text = "Обновить";
|
||||||
IssuedButton.Text = "Заказ выдан";
|
RefreshButton.UseVisualStyleBackColor = true;
|
||||||
IssuedButton.UseVisualStyleBackColor = true;
|
RefreshButton.Click += RefreshButton_Click;
|
||||||
IssuedButton.Click += IssuedButton_Click;
|
//
|
||||||
//
|
// запускРаботToolStripMenuItem
|
||||||
// RefreshButton
|
//
|
||||||
//
|
запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
||||||
RefreshButton.Location = new Point(897, 128);
|
запускРаботToolStripMenuItem.Size = new Size(114, 24);
|
||||||
RefreshButton.Margin = new Padding(3, 2, 3, 2);
|
запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||||
RefreshButton.Name = "RefreshButton";
|
запускРаботToolStripMenuItem.Click += запускРаботToolStripMenuItem_Click;
|
||||||
RefreshButton.Size = new Size(227, 22);
|
//
|
||||||
RefreshButton.TabIndex = 6;
|
// MainForm
|
||||||
RefreshButton.Text = "Обновить";
|
//
|
||||||
RefreshButton.UseVisualStyleBackColor = true;
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
RefreshButton.Click += RefreshButton_Click;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
//
|
ClientSize = new Size(1296, 451);
|
||||||
// клиентыToolStripMenuItem
|
Controls.Add(RefreshButton);
|
||||||
//
|
Controls.Add(IssuedButton);
|
||||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
Controls.Add(CreateOrderButton);
|
||||||
клиентыToolStripMenuItem.Size = new Size(180, 22);
|
Controls.Add(DataGridView);
|
||||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
Controls.Add(menuStrip1);
|
||||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
MainMenuStrip = menuStrip1;
|
||||||
//
|
Name = "MainForm";
|
||||||
// MainForm
|
Text = "Форма главная";
|
||||||
//
|
Load += MainForm_Load;
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
menuStrip1.ResumeLayout(false);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
menuStrip1.PerformLayout();
|
||||||
ClientSize = new Size(1134, 338);
|
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||||
Controls.Add(RefreshButton);
|
ResumeLayout(false);
|
||||||
Controls.Add(IssuedButton);
|
PerformLayout();
|
||||||
Controls.Add(ReadyButton);
|
}
|
||||||
Controls.Add(TakeInWorkButton);
|
|
||||||
Controls.Add(CreateOrderButton);
|
|
||||||
Controls.Add(DataGridView);
|
|
||||||
Controls.Add(menuStrip1);
|
|
||||||
MainMenuStrip = menuStrip1;
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
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 MenuStrip menuStrip1;
|
||||||
private ToolStripMenuItem ToolStripMenu;
|
private ToolStripMenuItem ToolStripMenu;
|
||||||
private ToolStripMenuItem КомпонентыStripMenuItem;
|
private ToolStripMenuItem КомпонентыStripMenuItem;
|
||||||
private ToolStripMenuItem МороженноеStripMenuItem;
|
private ToolStripMenuItem МороженноеStripMenuItem;
|
||||||
private DataGridView DataGridView;
|
private DataGridView DataGridView;
|
||||||
private Button CreateOrderButton;
|
private Button CreateOrderButton;
|
||||||
private Button TakeInWorkButton;
|
|
||||||
private Button ReadyButton;
|
|
||||||
private Button IssuedButton;
|
private Button IssuedButton;
|
||||||
private Button RefreshButton;
|
private Button RefreshButton;
|
||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
@ -220,5 +203,7 @@
|
|||||||
private ToolStripMenuItem компонентыПоМороженнымToolStripMenuItem;
|
private ToolStripMenuItem компонентыПоМороженнымToolStripMenuItem;
|
||||||
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
||||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||||
}
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||||
|
}
|
||||||
}
|
}
|
@ -16,221 +16,244 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace IceCreamShop
|
namespace IceCreamShop
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : 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 MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
private readonly IWorkProcess _workProcess;
|
||||||
{
|
public MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
||||||
InitializeComponent();
|
{
|
||||||
_logger = logger;
|
InitializeComponent();
|
||||||
_orderLogic = orderLogic;
|
_logger = logger;
|
||||||
_reportLogic = reportLogic;
|
_orderLogic = orderLogic;
|
||||||
}
|
_reportLogic = reportLogic;
|
||||||
|
_workProcess = workProcess;
|
||||||
|
}
|
||||||
|
|
||||||
private void КомпонентыStripMenuItem_Click(object sender, EventArgs e)
|
private void КомпонентыStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(ComponentsForm));
|
Program.ServiceProvider?.GetService(typeof(ComponentsForm));
|
||||||
if (service is ComponentsForm form)
|
if (service is ComponentsForm form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_Load(object sender, EventArgs e)
|
private void MainForm_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["IceCreamId"].Visible = false;
|
DataGridView.Columns["IceCreamId"].Visible = false;
|
||||||
DataGridView.Columns["ClientId"].Visible = false;
|
DataGridView.Columns["ClientId"].Visible = false;
|
||||||
DataGridView.Columns["IceCreamName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
DataGridView.Columns["ImplementerId"].Visible = false;
|
||||||
}
|
DataGridView.Columns["IceCreamName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
_logger.LogInformation("Загрузка заказов");
|
}
|
||||||
}
|
_logger.LogInformation("Загрузка заказов");
|
||||||
catch (Exception ex)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||||
}
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void МороженноеStripMenuItem_Click(object sender, EventArgs e)
|
private void МороженноеStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(IceCreamsForm));
|
var service = Program.ServiceProvider?.GetService(typeof(IceCreamsForm));
|
||||||
if (service is IceCreamsForm form)
|
if (service is IceCreamsForm form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(OrderForm));
|
Program.ServiceProvider?.GetService(typeof(OrderForm));
|
||||||
if (service is OrderForm form)
|
if (service is OrderForm form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
|
private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
|
||||||
{
|
{
|
||||||
return new OrderBindingModel
|
return new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
IceCreamId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["IceCreamId"].Value),
|
IceCreamId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["IceCreamId"].Value),
|
||||||
ClientId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ClientId"].Value),
|
ClientId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ClientId"].Value),
|
||||||
Status = Enum.Parse<OrderStatus>(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
Status = Enum.Parse<OrderStatus>(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||||
Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
|
Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||||
Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||||
DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TakeInWorkButton_Click(object sender, EventArgs e)
|
private void TakeInWorkButton_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(CreateBindingModel(id));
|
var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(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 ReadyButton_Click(object sender, EventArgs e)
|
private void ReadyButton_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(CreateBindingModel(id));
|
var operationResult = _orderLogic.FinishOrder(CreateBindingModel(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 IssuedButton_Click(object sender, EventArgs e)
|
private void IssuedButton_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(CreateBindingModel(id));
|
var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(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 RefreshButton_Click(object sender, EventArgs e)
|
private void RefreshButton_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.SaveIceCreamToWordFile(new ReportBindingModel
|
_reportLogic.SaveIceCreamToWordFile(new ReportBindingModel
|
||||||
{
|
{
|
||||||
FileName = dialog.FileName
|
FileName = dialog.FileName
|
||||||
});
|
});
|
||||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Information);
|
MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void компонентыПоМороженнымToolStripMenuItem_Click(object sender, EventArgs e)
|
private void компонентыПоМороженнымToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(ReportIceCreamComponentForm));
|
Program.ServiceProvider?.GetService(typeof(ReportIceCreamComponentForm));
|
||||||
if (service is ReportIceCreamComponentForm form)
|
if (service is ReportIceCreamComponentForm form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(ReportOrdersForm));
|
Program.ServiceProvider?.GetService(typeof(ReportOrdersForm));
|
||||||
if (service is ReportOrdersForm form)
|
if (service is ReportOrdersForm form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(ClientsForm));
|
Program.ServiceProvider?.GetService(typeof(ClientsForm));
|
||||||
if (service is ClientsForm form)
|
if (service is ClientsForm form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(ImplementersForm));
|
||||||
|
if (service is ImplementersForm 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,19 @@ namespace IceCreamShop
|
|||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
services.AddTransient<IIceCreamLogic, IceCreamLogic>();
|
services.AddTransient<IIceCreamLogic, IceCreamLogic>();
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
|
services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
services.AddTransient<MainForm>();
|
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||||
|
services.AddTransient<MainForm>();
|
||||||
services.AddTransient<ComponentForm>();
|
services.AddTransient<ComponentForm>();
|
||||||
services.AddTransient<ComponentsForm>();
|
services.AddTransient<ComponentsForm>();
|
||||||
services.AddTransient<OrderForm>();
|
services.AddTransient<OrderForm>();
|
||||||
services.AddTransient<IceCreamForm>();
|
services.AddTransient<IceCreamForm>();
|
||||||
services.AddTransient<ClientsForm>();
|
services.AddTransient<ImplementersForm>();
|
||||||
|
services.AddTransient<ImplementerForm>();
|
||||||
|
services.AddTransient<ClientsForm>();
|
||||||
services.AddTransient<IceCreamComponentForm>();
|
services.AddTransient<IceCreamComponentForm>();
|
||||||
services.AddTransient<IceCreamsForm>();
|
services.AddTransient<IceCreamsForm>();
|
||||||
services.AddTransient<ReportIceCreamComponentForm>();
|
services.AddTransient<ReportIceCreamComponentForm>();
|
||||||
|
@ -24,8 +24,24 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
}
|
}
|
||||||
|
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
|
||||||
|
var element = _orderStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
||||||
var list = model == null ? _orderStorage.GetFullList() :
|
var list = model == null ? _orderStorage.GetFullList() :
|
||||||
@ -54,7 +70,7 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
|
|||||||
|
|
||||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model, false);
|
||||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
@ -68,6 +84,8 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
|
|||||||
}
|
}
|
||||||
model.Status = status;
|
model.Status = status;
|
||||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||||
|
if (element.ImplementerId.HasValue)
|
||||||
|
model.ImplementerId = element.ImplementerId;
|
||||||
_orderStorage.Update(model);
|
_orderStorage.Update(model);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,145 @@
|
|||||||
|
using IceCreamShopContracts.BindingModels;
|
||||||
|
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||||
|
using IceCreamShopContracts.SearchModels;
|
||||||
|
using IceCreamShopContracts.ViewModels;
|
||||||
|
using IceCreamShopDataModels.Enums;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace IceCreamShopBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class WorkModeling : IWorkProcess
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly Random _rnd;
|
||||||
|
private IOrderLogic? _orderLogic;
|
||||||
|
public WorkModeling(ILogger<WorkModeling> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_rnd = new Random(1000);
|
||||||
|
}
|
||||||
|
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic
|
||||||
|
orderLogic)
|
||||||
|
{
|
||||||
|
_orderLogic = orderLogic;
|
||||||
|
var implementers = implementerLogic.ReadList(null);
|
||||||
|
if (implementers == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("DoWork. Implementers is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var orders = _orderLogic.ReadList(new OrderSearchModel
|
||||||
|
{
|
||||||
|
Status =
|
||||||
|
OrderStatus.Принят
|
||||||
|
});
|
||||||
|
if (orders == null || orders.Count == 0)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||||
|
foreach (var implementer in implementers)
|
||||||
|
{
|
||||||
|
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// Иммитация работы исполнителя
|
||||||
|
private async Task WorkerWorkAsync(ImplementerViewModel implementer,
|
||||||
|
List<OrderViewModel> orders)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await RunOrderInWork(implementer);
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
foreach (var order in orders)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} try get order { Order}", implementer.Id, order.Id);
|
||||||
|
// пытаемся назначить заказ на исполнителя
|
||||||
|
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = order.Id,
|
||||||
|
ImplementerId = implementer.Id
|
||||||
|
});
|
||||||
|
// делаем работу
|
||||||
|
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100,
|
||||||
|
1000) * order.Count);
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} finish order { Order}", implementer.Id, order.Id);
|
||||||
|
|
||||||
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = order.Id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
}
|
||||||
|
// заканчиваем выполнение имитации в случае иной ошибки
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
// отдыхаем
|
||||||
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
||||||
|
private async Task RunOrderInWork(ImplementerViewModel implementer)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new
|
||||||
|
OrderSearchModel
|
||||||
|
{
|
||||||
|
ImplementerId = implementer.Id,
|
||||||
|
Status = OrderStatus.Выполняется
|
||||||
|
}));
|
||||||
|
if (runOrder == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}",
|
||||||
|
implementer.Id, runOrder.Id);
|
||||||
|
// доделываем работу
|
||||||
|
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) *
|
||||||
|
runOrder.Count);
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}",
|
||||||
|
implementer.Id, runOrder.Id);
|
||||||
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = runOrder.Id
|
||||||
|
});
|
||||||
|
// отдыхаем
|
||||||
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
|
}
|
||||||
|
// заказа может не быть, просто игнорируем ошибку
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
}
|
||||||
|
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,8 @@ namespace IceCreamShopContracts.BusinessLogicsContracts
|
|||||||
public interface IOrderLogic
|
public interface IOrderLogic
|
||||||
{
|
{
|
||||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||||
bool CreateOrder(OrderBindingModel model);
|
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||||
|
bool CreateOrder(OrderBindingModel model);
|
||||||
bool TakeOrderInWork(OrderBindingModel model);
|
bool TakeOrderInWork(OrderBindingModel model);
|
||||||
bool FinishOrder(OrderBindingModel model);
|
bool FinishOrder(OrderBindingModel model);
|
||||||
bool DeliveryOrder(OrderBindingModel model);
|
bool DeliveryOrder(OrderBindingModel model);
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace IceCreamShopContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IWorkProcess
|
||||||
|
{
|
||||||
|
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using IceCreamShopDataModels.Enums;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -10,6 +11,8 @@ namespace IceCreamShopContracts.SearchModels
|
|||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
public int? ImplementerId { get; set; }
|
||||||
|
public OrderStatus? Status { get; set; }
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace IceCreamShopDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new IceCreamShopDataBase();
|
using var context = new IceCreamShopDataBase();
|
||||||
return context.Orders.Include(x => x.IceCream)
|
return context.Orders.Include(x => x.IceCream)
|
||||||
.Include(x => x.Client).Select(x => x.GetViewModel)
|
.Include(x => x.Client).Include(x => x.Implementer).Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
@ -27,12 +27,14 @@ namespace IceCreamShopDatabaseImplement.Implements
|
|||||||
using var context = new IceCreamShopDataBase();
|
using var context = new IceCreamShopDataBase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.IceCream)
|
.Include(x => x.IceCream)
|
||||||
.Include(x => x.Client).Where(x => (
|
.Include(x => x.Client).Include(x => x.Implementer).Where(x => (
|
||||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo)
|
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo)
|
||||||
&&
|
&&
|
||||||
(!model.ClientId.HasValue || x.ClientId == model.ClientId)
|
(!model.ClientId.HasValue || x.ClientId == model.ClientId)
|
||||||
|
&&
|
||||||
|
(!model.Status.HasValue || x.Status == model.Status)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
@ -40,12 +42,11 @@ namespace IceCreamShopDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new IceCreamShopDataBase();
|
using var context = new IceCreamShopDataBase();
|
||||||
return context.Orders.Include(x => x.IceCream).Include(x=> x.Client).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
return context.Orders.Include(x => x.IceCream).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)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -62,7 +63,7 @@ namespace IceCreamShopDatabaseImplement.Implements
|
|||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new IceCreamShopDataBase();
|
using var context = new IceCreamShopDataBase();
|
||||||
var order = context.Orders.Include(x => x.IceCream).Include(x => x.Client).FirstOrDefault(x => x.Id ==
|
var order = context.Orders.Include(x => x.IceCream).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id ==
|
||||||
model.Id);
|
model.Id);
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
namespace IceCreamShopDatabaseImplement.Migrations
|
namespace IceCreamShopDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(IceCreamShopDataBase))]
|
[DbContext(typeof(IceCreamShopDataBase))]
|
||||||
[Migration("20240401114939_InitialCreate")]
|
[Migration("20240415130513_InitialCreate")]
|
||||||
partial class InitialCreate
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -116,6 +116,33 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
b.ToTable("IceCreamComponents");
|
b.ToTable("IceCreamComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -139,6 +166,9 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
b.Property<int>("IceCreamId")
|
b.Property<int>("IceCreamId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -151,6 +181,8 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("IceCreamId");
|
b.HasIndex("IceCreamId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -187,9 +219,15 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("IceCreamShopDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
b.Navigation("IceCream");
|
b.Navigation("IceCream");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Client", b =>
|
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Client", b =>
|
||||||
@ -208,6 +246,11 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.Navigation("Orders");
|
b.Navigation("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,6 +54,22 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
table.PrimaryKey("PK_IceCreams", x => x.Id);
|
table.PrimaryKey("PK_IceCreams", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Implementers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Qualification = table.Column<int>(type: "int", nullable: false),
|
||||||
|
WorkExperience = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "IceCreamComponents",
|
name: "IceCreamComponents",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -93,7 +109,8 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||||
IceCreamId = table.Column<int>(type: "int", nullable: false),
|
IceCreamId = table.Column<int>(type: "int", nullable: false),
|
||||||
ClientId = table.Column<int>(type: "int", nullable: false)
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ImplementerId = table.Column<int>(type: "int", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@ -110,6 +127,11 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
principalTable: "IceCreams",
|
principalTable: "IceCreams",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerId",
|
||||||
|
column: x => x.ImplementerId,
|
||||||
|
principalTable: "Implementers",
|
||||||
|
principalColumn: "Id");
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
@ -131,6 +153,11 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
name: "IX_Orders_IceCreamId",
|
name: "IX_Orders_IceCreamId",
|
||||||
table: "Orders",
|
table: "Orders",
|
||||||
column: "IceCreamId");
|
column: "IceCreamId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ImplementerId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ImplementerId");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -150,6 +177,9 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "IceCreams");
|
name: "IceCreams");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Implementers");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("Version", "7.0.3")
|
.HasAnnotation("ProductVersion", "7.0.3")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
@ -113,6 +113,33 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
b.ToTable("IceCreamComponents");
|
b.ToTable("IceCreamComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -136,6 +163,9 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
b.Property<int>("IceCreamId")
|
b.Property<int>("IceCreamId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -148,6 +178,8 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("IceCreamId");
|
b.HasIndex("IceCreamId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -184,9 +216,15 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("IceCreamShopDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
b.Navigation("IceCream");
|
b.Navigation("IceCream");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Client", b =>
|
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Client", b =>
|
||||||
@ -205,6 +243,11 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.Navigation("Orders");
|
b.Navigation("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ namespace IceCreamShopDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
public virtual Client Client { get; private set; }
|
public virtual Client Client { get; private set; }
|
||||||
[Required]
|
|
||||||
public int? ImplementerId { get; private set; } = null;
|
public int? ImplementerId { get; private set; } = null;
|
||||||
public virtual Implementer? Implementer { get; private set; }
|
public virtual Implementer? Implementer { get; private set; }
|
||||||
public static Order? Create(IceCreamShopDataBase context, OrderBindingModel model)
|
public static Order? Create(IceCreamShopDataBase context, OrderBindingModel model)
|
||||||
@ -51,7 +50,8 @@ namespace IceCreamShopDatabaseImplement.Models
|
|||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
Client = context.Clients.FirstOrDefault(x => x.Id == model.ClientId),
|
Client = context.Clients.FirstOrDefault(x => x.Id == model.ClientId),
|
||||||
ImplementerId = model.ImplementerId,
|
ImplementerId = model.ImplementerId,
|
||||||
Implementer = context.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId),
|
Implementer = (model.ImplementerId.HasValue ? context.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId)
|
||||||
|
: null),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +63,7 @@ namespace IceCreamShopDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
|
ImplementerId = model.ImplementerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
|
@ -0,0 +1,105 @@
|
|||||||
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
|
using IceCreamShopContracts.BindingModels;
|
||||||
|
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||||
|
using IceCreamShopContracts.SearchModels;
|
||||||
|
using IceCreamShopContracts.ViewModels;
|
||||||
|
using IceCreamShopDataModels.Enums;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace IceCreamShopRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ImplementerController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IOrderLogic _order;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
public ImplementerController(IOrderLogic order, IImplementerLogic logic,
|
||||||
|
ILogger<ImplementerController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_order = order;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public ImplementerViewModel? Login(string login, string password)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadElement(new ImplementerSearchModel
|
||||||
|
{
|
||||||
|
ImplementerFIO = login,
|
||||||
|
Password = password
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка авторизации сотрудника");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public List<OrderViewModel>? GetNewOrders()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _order.ReadList(new OrderSearchModel
|
||||||
|
{
|
||||||
|
Status = OrderStatus.Принят
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения новых заказов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public OrderViewModel? GetImplementerOrder(int implementerId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _order.ReadElement(new OrderSearchModel
|
||||||
|
{
|
||||||
|
ImplementerId = implementerId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения текущего заказа исполнителя");
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void TakeOrderInWork(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_order.TakeOrderInWork(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу",
|
||||||
|
model.Id);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void FinishOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_order.FinishOrder(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка отметки о готовности заказа с №{ Id}", model.Id);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user