Compare commits
2 Commits
master
...
lab01_hard
Author | SHA1 | Date | |
---|---|---|---|
d910cc8942 | |||
11ca98df8b |
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,6 +6,8 @@
|
||||
|
||||
#mac file
|
||||
.DS_Store
|
||||
ImplementationExtensions/
|
||||
/ImplementationExtensions/
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
|
@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.4.33103.184
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssembly", "FurnitureAssembly\FurnitureAssembly.csproj", "{3AC381EC-9240-4540-97F6-C0B3248727E7}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyView", "FurnitureAssembly\FurnitureAssemblyView.csproj", "{3AC381EC-9240-4540-97F6-C0B3248727E7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyDataModels", "FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj", "{19FD6936-DAB7-440F-8094-E6843CA0E391}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyContracts", "FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj", "{E2AF65E4-8E5D-4ED3-86DF-C47471A637B1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyListImplement", "FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj", "{8C437D7B-78C2-4CDC-B8AE-FC27943D8DA2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyBusinessLogic", "FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj", "{D5118A99-17DE-4722-AA56-3A358CE0BB62}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -15,6 +23,22 @@ Global
|
||||
{3AC381EC-9240-4540-97F6-C0B3248727E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3AC381EC-9240-4540-97F6-C0B3248727E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3AC381EC-9240-4540-97F6-C0B3248727E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{19FD6936-DAB7-440F-8094-E6843CA0E391}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{19FD6936-DAB7-440F-8094-E6843CA0E391}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{19FD6936-DAB7-440F-8094-E6843CA0E391}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{19FD6936-DAB7-440F-8094-E6843CA0E391}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E2AF65E4-8E5D-4ED3-86DF-C47471A637B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E2AF65E4-8E5D-4ED3-86DF-C47471A637B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E2AF65E4-8E5D-4ED3-86DF-C47471A637B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E2AF65E4-8E5D-4ED3-86DF-C47471A637B1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8C437D7B-78C2-4CDC-B8AE-FC27943D8DA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8C437D7B-78C2-4CDC-B8AE-FC27943D8DA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8C437D7B-78C2-4CDC-B8AE-FC27943D8DA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8C437D7B-78C2-4CDC-B8AE-FC27943D8DA2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D5118A99-17DE-4722-AA56-3A358CE0BB62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D5118A99-17DE-4722-AA56-3A358CE0BB62}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D5118A99-17DE-4722-AA56-3A358CE0BB62}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D5118A99-17DE-4722-AA56-3A358CE0BB62}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,10 +0,0 @@
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
151
FurnitureAssembly/FurnitureAssembly/FormAddFurniture.Designer.cs
generated
Normal file
151
FurnitureAssembly/FurnitureAssembly/FormAddFurniture.Designer.cs
generated
Normal file
@ -0,0 +1,151 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormAddFurniture
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.labelFurniture = new System.Windows.Forms.Label();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.labelShop = new System.Windows.Forms.Label();
|
||||
this.comboBoxFurniture = new System.Windows.Forms.ComboBox();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelFurniture
|
||||
//
|
||||
this.labelFurniture.AutoSize = true;
|
||||
this.labelFurniture.Location = new System.Drawing.Point(28, 58);
|
||||
this.labelFurniture.Name = "labelFurniture";
|
||||
this.labelFurniture.Size = new System.Drawing.Size(56, 15);
|
||||
this.labelFurniture.TabIndex = 0;
|
||||
this.labelFurniture.Text = "Изделие:";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(28, 91);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(75, 15);
|
||||
this.labelCount.TabIndex = 1;
|
||||
this.labelCount.Text = "Количество:";
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
this.labelShop.AutoSize = true;
|
||||
this.labelShop.Location = new System.Drawing.Point(28, 23);
|
||||
this.labelShop.Name = "labelShop";
|
||||
this.labelShop.Size = new System.Drawing.Size(57, 15);
|
||||
this.labelShop.TabIndex = 2;
|
||||
this.labelShop.Text = "Магазин:";
|
||||
//
|
||||
// comboBoxFurniture
|
||||
//
|
||||
this.comboBoxFurniture.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxFurniture.FormattingEnabled = true;
|
||||
this.comboBoxFurniture.Location = new System.Drawing.Point(149, 55);
|
||||
this.comboBoxFurniture.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.comboBoxFurniture.Name = "comboBoxFurniture";
|
||||
this.comboBoxFurniture.Size = new System.Drawing.Size(230, 23);
|
||||
this.comboBoxFurniture.TabIndex = 3;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(149, 88);
|
||||
this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(230, 23);
|
||||
this.textBoxCount.TabIndex = 4;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(209, 123);
|
||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(82, 22);
|
||||
this.buttonSave.TabIndex = 6;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(297, 123);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// comboBoxShop
|
||||
//
|
||||
this.comboBoxShop.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxShop.FormattingEnabled = true;
|
||||
this.comboBoxShop.Location = new System.Drawing.Point(149, 23);
|
||||
this.comboBoxShop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.comboBoxShop.Name = "comboBoxShop";
|
||||
this.comboBoxShop.Size = new System.Drawing.Size(230, 23);
|
||||
this.comboBoxShop.TabIndex = 8;
|
||||
//
|
||||
// FormAddFurniture
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(394, 159);
|
||||
this.Controls.Add(this.comboBoxShop);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.comboBoxFurniture);
|
||||
this.Controls.Add(this.labelShop);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelFurniture);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormAddFurniture";
|
||||
this.Text = "Пополнение магазина";
|
||||
this.Load += new System.EventHandler(this.FormAddFurniture_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelFurniture;
|
||||
private Label labelCount;
|
||||
private Label labelShop;
|
||||
private ComboBox comboBoxFurniture;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private ComboBox comboBoxShop;
|
||||
}
|
||||
}
|
128
FurnitureAssembly/FurnitureAssembly/FormAddFurniture.cs
Normal file
128
FurnitureAssembly/FurnitureAssembly/FormAddFurniture.cs
Normal file
@ -0,0 +1,128 @@
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormAddFurniture : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFurnitureLogic _logicI;
|
||||
private readonly IShopLogic _logicS;
|
||||
|
||||
public FormAddFurniture(ILogger<FormAddFurniture> logger, IFurnitureLogic logicI, IShopLogic logicS)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicI = logicI;
|
||||
_logicS = logicS;
|
||||
}
|
||||
|
||||
private void FormAddFurniture_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка списка изделий для пополнения");
|
||||
|
||||
try
|
||||
{
|
||||
var list = _logicI.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxFurniture.DisplayMember = "FurnitureName";
|
||||
comboBoxFurniture.ValueMember = "Id";
|
||||
comboBoxFurniture.DataSource = list;
|
||||
comboBoxFurniture.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка изделий");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка списка магазинов для пополнения");
|
||||
try
|
||||
{
|
||||
var list = _logicS.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxShop.DisplayMember = "ShopName";
|
||||
comboBoxShop.ValueMember = "Id";
|
||||
comboBoxShop.DataSource = list;
|
||||
comboBoxShop.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxFurniture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxShop.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Пополнение магазина");
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _logicS.AddFurniture(new ShopSearchModel
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxShop.SelectedValue)
|
||||
},
|
||||
|
||||
_logicI.ReadElement(new FurnitureSearchModel()
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxFurniture.SelectedValue)
|
||||
})!, Convert.ToInt32(textBoxCount.Text));
|
||||
|
||||
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 ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
FurnitureAssembly/FurnitureAssembly/FormAddFurniture.resx
Normal file
60
FurnitureAssembly/FurnitureAssembly/FormAddFurniture.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
145
FurnitureAssembly/FurnitureAssembly/FormCreateOrder.Designer.cs
generated
Normal file
145
FurnitureAssembly/FurnitureAssembly/FormCreateOrder.Designer.cs
generated
Normal file
@ -0,0 +1,145 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormCreateOrder
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.comboBoxFurniture = new System.Windows.Forms.ComboBox();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.textBoxSum = new System.Windows.Forms.TextBox();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Location = new System.Drawing.Point(313, 212);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(150, 46);
|
||||
this.ButtonSave.TabIndex = 0;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(31, 36);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(114, 32);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Изделие:";
|
||||
//
|
||||
// comboBoxFurniture
|
||||
//
|
||||
this.comboBoxFurniture.FormattingEnabled = true;
|
||||
this.comboBoxFurniture.Location = new System.Drawing.Point(188, 33);
|
||||
this.comboBoxFurniture.Name = "comboBoxFurniture";
|
||||
this.comboBoxFurniture.Size = new System.Drawing.Size(441, 40);
|
||||
this.comboBoxFurniture.TabIndex = 2;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(188, 90);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(441, 39);
|
||||
this.textBoxCount.TabIndex = 3;
|
||||
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(31, 97);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(149, 32);
|
||||
this.label2.TabIndex = 4;
|
||||
this.label2.Text = "Количество:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(31, 155);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(92, 32);
|
||||
this.label3.TabIndex = 6;
|
||||
this.label3.Text = "Сумма:";
|
||||
//
|
||||
// textBoxSum
|
||||
//
|
||||
this.textBoxSum.Location = new System.Drawing.Point(188, 152);
|
||||
this.textBoxSum.Name = "textBoxSum";
|
||||
this.textBoxSum.ReadOnly = true;
|
||||
this.textBoxSum.Size = new System.Drawing.Size(441, 39);
|
||||
this.textBoxSum.TabIndex = 5;
|
||||
this.textBoxSum.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(479, 212);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(150, 46);
|
||||
this.ButtonCancel.TabIndex = 7;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormCreateOrder
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(650, 278);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.textBoxSum);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.comboBoxFurniture);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Name = "FormCreateOrder";
|
||||
this.Text = "Заказ";
|
||||
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button ButtonSave;
|
||||
private Label label1;
|
||||
private ComboBox comboBoxFurniture;
|
||||
private TextBox textBoxCount;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private TextBox textBoxSum;
|
||||
private Button ButtonCancel;
|
||||
}
|
||||
}
|
145
FurnitureAssembly/FurnitureAssembly/FormCreateOrder.cs
Normal file
145
FurnitureAssembly/FurnitureAssembly/FormCreateOrder.cs
Normal file
@ -0,0 +1,145 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormCreateOrder : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IFurnitureLogic _logicM;
|
||||
|
||||
private readonly IOrderLogic _logicO;
|
||||
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IFurnitureLogic logicM, IOrderLogic logicO)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logicM = logicM;
|
||||
_logicO = logicO;
|
||||
}
|
||||
|
||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий для заказа");
|
||||
|
||||
try
|
||||
{
|
||||
var list = _logicM.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxFurniture.DisplayMember = "FurnitureName";
|
||||
comboBoxFurniture.ValueMember = "Id";
|
||||
comboBoxFurniture.DataSource = list;
|
||||
comboBoxFurniture.SelectedItem = null;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий для заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void CalcSum()
|
||||
{
|
||||
if (comboBoxFurniture.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxFurniture.SelectedValue);
|
||||
|
||||
var furniture = _logicM.ReadElement(new FurnitureSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
|
||||
textBoxSum.Text = Math.Round(count * (furniture?.Price ?? 0), 2).ToString();
|
||||
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void ComboBoxFurniture_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxFurniture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Создание заказа");
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
FurnitureId = Convert.ToInt32(comboBoxFurniture.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||
});
|
||||
|
||||
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 ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
FurnitureAssembly/FurnitureAssembly/FormCreateOrder.resx
Normal file
60
FurnitureAssembly/FurnitureAssembly/FormCreateOrder.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
242
FurnitureAssembly/FurnitureAssembly/FormFurniture.Designer.cs
generated
Normal file
242
FurnitureAssembly/FurnitureAssembly/FormFurniture.Designer.cs
generated
Normal file
@ -0,0 +1,242 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormFurniture
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.groupBoxWorkpieces = new System.Windows.Forms.GroupBox();
|
||||
this.ButtonRef = new System.Windows.Forms.Button();
|
||||
this.ButtonDel = new System.Windows.Forms.Button();
|
||||
this.ButtonUpd = new System.Windows.Forms.Button();
|
||||
this.ButtonAdd = new System.Windows.Forms.Button();
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.groupBoxWorkpieces.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxPrice
|
||||
//
|
||||
this.textBoxPrice.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxPrice.Enabled = false;
|
||||
this.textBoxPrice.Location = new System.Drawing.Point(180, 103);
|
||||
this.textBoxPrice.Name = "textBoxPrice";
|
||||
this.textBoxPrice.Size = new System.Drawing.Size(178, 39);
|
||||
this.textBoxPrice.TabIndex = 8;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(41, 106);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(136, 32);
|
||||
this.label2.TabIndex = 7;
|
||||
this.label2.Text = "Стоимость:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxName.Location = new System.Drawing.Point(180, 38);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(328, 39);
|
||||
this.textBoxName.TabIndex = 6;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(41, 41);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(125, 32);
|
||||
this.label1.TabIndex = 5;
|
||||
this.label1.Text = "Название:";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumnId,
|
||||
this.ColumnName,
|
||||
this.ColumnCount});
|
||||
this.dataGridView.Location = new System.Drawing.Point(5, 40);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersVisible = false;
|
||||
this.dataGridView.RowHeadersWidth = 82;
|
||||
this.dataGridView.RowTemplate.Height = 41;
|
||||
this.dataGridView.Size = new System.Drawing.Size(749, 543);
|
||||
this.dataGridView.TabIndex = 9;
|
||||
//
|
||||
// ColumnId
|
||||
//
|
||||
this.ColumnId.HeaderText = "Id";
|
||||
this.ColumnId.MinimumWidth = 10;
|
||||
this.ColumnId.Name = "ColumnId";
|
||||
this.ColumnId.Visible = false;
|
||||
//
|
||||
// ColumnName
|
||||
//
|
||||
this.ColumnName.HeaderText = "Заготовка";
|
||||
this.ColumnName.MinimumWidth = 10;
|
||||
this.ColumnName.Name = "ColumnName";
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
this.ColumnCount.HeaderText = "Количество";
|
||||
this.ColumnCount.MinimumWidth = 10;
|
||||
this.ColumnCount.Name = "ColumnCount";
|
||||
//
|
||||
// groupBoxWorkpieces
|
||||
//
|
||||
this.groupBoxWorkpieces.Controls.Add(this.ButtonRef);
|
||||
this.groupBoxWorkpieces.Controls.Add(this.ButtonDel);
|
||||
this.groupBoxWorkpieces.Controls.Add(this.ButtonUpd);
|
||||
this.groupBoxWorkpieces.Controls.Add(this.ButtonAdd);
|
||||
this.groupBoxWorkpieces.Controls.Add(this.dataGridView);
|
||||
this.groupBoxWorkpieces.Location = new System.Drawing.Point(41, 166);
|
||||
this.groupBoxWorkpieces.Name = "groupBoxWorkpieces";
|
||||
this.groupBoxWorkpieces.Size = new System.Drawing.Size(1040, 593);
|
||||
this.groupBoxWorkpieces.TabIndex = 10;
|
||||
this.groupBoxWorkpieces.TabStop = false;
|
||||
this.groupBoxWorkpieces.Text = "Заготовки";
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
this.ButtonRef.Location = new System.Drawing.Point(782, 362);
|
||||
this.ButtonRef.Name = "ButtonRef";
|
||||
this.ButtonRef.Size = new System.Drawing.Size(224, 62);
|
||||
this.ButtonRef.TabIndex = 13;
|
||||
this.ButtonRef.Text = "Обновить";
|
||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
this.ButtonDel.Location = new System.Drawing.Point(782, 265);
|
||||
this.ButtonDel.Name = "ButtonDel";
|
||||
this.ButtonDel.Size = new System.Drawing.Size(224, 62);
|
||||
this.ButtonDel.TabIndex = 12;
|
||||
this.ButtonDel.Text = "Удалить";
|
||||
this.ButtonDel.UseVisualStyleBackColor = true;
|
||||
this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
this.ButtonUpd.Location = new System.Drawing.Point(782, 174);
|
||||
this.ButtonUpd.Name = "ButtonUpd";
|
||||
this.ButtonUpd.Size = new System.Drawing.Size(224, 62);
|
||||
this.ButtonUpd.TabIndex = 11;
|
||||
this.ButtonUpd.Text = "Изменить";
|
||||
this.ButtonUpd.UseVisualStyleBackColor = true;
|
||||
this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
this.ButtonAdd.Location = new System.Drawing.Point(782, 88);
|
||||
this.ButtonAdd.Name = "ButtonAdd";
|
||||
this.ButtonAdd.Size = new System.Drawing.Size(224, 62);
|
||||
this.ButtonAdd.TabIndex = 10;
|
||||
this.ButtonAdd.Text = "Добавить";
|
||||
this.ButtonAdd.UseVisualStyleBackColor = true;
|
||||
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Location = new System.Drawing.Point(604, 765);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(224, 55);
|
||||
this.ButtonSave.TabIndex = 14;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(857, 765);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(224, 55);
|
||||
this.ButtonCancel.TabIndex = 15;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormFurniture
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1101, 832);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.groupBoxWorkpieces);
|
||||
this.Controls.Add(this.textBoxPrice);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "FormFurniture";
|
||||
this.Text = "Мебель";
|
||||
this.Load += new System.EventHandler(this.FormFurniture_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.groupBoxWorkpieces.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxPrice;
|
||||
private Label label2;
|
||||
private TextBox textBoxName;
|
||||
private Label label1;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn ColumnId;
|
||||
private DataGridViewTextBoxColumn ColumnName;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private GroupBox groupBoxWorkpieces;
|
||||
private Button ButtonRef;
|
||||
private Button ButtonDel;
|
||||
private Button ButtonUpd;
|
||||
private Button ButtonAdd;
|
||||
private Button ButtonSave;
|
||||
private Button ButtonCancel;
|
||||
}
|
||||
}
|
214
FurnitureAssembly/FurnitureAssembly/FormFurniture.cs
Normal file
214
FurnitureAssembly/FurnitureAssembly/FormFurniture.cs
Normal file
@ -0,0 +1,214 @@
|
||||
using FurnitureAssembly;
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormFurniture : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFurnitureLogic _logic;
|
||||
private int? _id;
|
||||
private Dictionary<int, (IWorkpieceModel, int)> _productWorkpieces;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormFurniture(ILogger<FormFurniture> logger, IFurnitureLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_productWorkpieces = new Dictionary<int, (IWorkpieceModel, int)>();
|
||||
}
|
||||
private void FormFurniture_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка заготовки");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new FurnitureSearchModel { Id =_id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.FurnitureName;
|
||||
textBoxPrice.Text = view.Price.ToString();
|
||||
_productWorkpieces = view.FurnitureWorkpieces ?? new Dictionary<int, (IWorkpieceModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заготовки");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка компонент заготовки");
|
||||
try
|
||||
{
|
||||
if (_productWorkpieces != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var pc in _productWorkpieces)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.WorkpieceName, pc.Value.Item2 });
|
||||
}
|
||||
textBoxPrice.Text = CalcPrice().ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонент заготовки");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormFurnitureWorkpiece));
|
||||
if (service is FormFurnitureWorkpiece form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.WorkpieceModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление нового компонента:{ WorkpieceName} - { Count} ", form.WorkpieceModel.WorkpieceName, form.Count);
|
||||
if (_productWorkpieces.ContainsKey(form.Id))
|
||||
{
|
||||
_productWorkpieces[form.Id] = (form.WorkpieceModel,form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_productWorkpieces.Add(form.Id, (form.WorkpieceModel,form.Count));
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormFurnitureWorkpiece));
|
||||
if (service is FormFurnitureWorkpiece form)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _productWorkpieces[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.WorkpieceModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Изменение компонента:{ WorkpieceName} - { Count} ", form.WorkpieceModel.WorkpieceName, form.Count);
|
||||
_productWorkpieces[form.Id] = (form.WorkpieceModel,form.Count);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Удаление компонента: { WorkpieceName} - { Count} ", dataGridView.SelectedRows[0].Cells[1].Value);
|
||||
|
||||
_productWorkpieces?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (_productWorkpieces == null || _productWorkpieces.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Заполните компоненты", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение заготовки");
|
||||
try
|
||||
{
|
||||
var model = new FurnitureBindingModel
|
||||
{
|
||||
Id = _id ?? 0, FurnitureName = textBoxName.Text,
|
||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||
FurnitureWorkpieces = _productWorkpieces
|
||||
};
|
||||
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 ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
private double CalcPrice()
|
||||
{
|
||||
double price = 0;
|
||||
foreach (var elem in _productWorkpieces)
|
||||
{
|
||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||
}
|
||||
return Math.Round(price * 1.1, 2);
|
||||
}
|
||||
}
|
||||
}
|
69
FurnitureAssembly/FurnitureAssembly/FormFurniture.resx
Normal file
69
FurnitureAssembly/FurnitureAssembly/FormFurniture.resx
Normal file
@ -0,0 +1,69 @@
|
||||
<root>
|
||||
<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>
|
||||
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
121
FurnitureAssembly/FurnitureAssembly/FormFurnitureWorkpiece.Designer.cs
generated
Normal file
121
FurnitureAssembly/FurnitureAssembly/FormFurnitureWorkpiece.Designer.cs
generated
Normal file
@ -0,0 +1,121 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormFurnitureWorkpiece
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxWorkpiece = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(191, 114);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(409, 39);
|
||||
this.textBoxCount.TabIndex = 0;
|
||||
//
|
||||
// comboBoxWorkpiece
|
||||
//
|
||||
this.comboBoxWorkpiece.FormattingEnabled = true;
|
||||
this.comboBoxWorkpiece.Location = new System.Drawing.Point(191, 42);
|
||||
this.comboBoxWorkpiece.Name = "comboBoxWorkpiece";
|
||||
this.comboBoxWorkpiece.Size = new System.Drawing.Size(409, 40);
|
||||
this.comboBoxWorkpiece.TabIndex = 1;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(29, 45);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(121, 32);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "Изделие: ";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(29, 117);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(156, 32);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Количество: ";
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonSave.Location = new System.Drawing.Point(282, 185);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(150, 46);
|
||||
this.ButtonSave.TabIndex = 4;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(450, 185);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(150, 46);
|
||||
this.ButtonCancel.TabIndex = 5;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormFurnitureWorkpiece
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(622, 243);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.comboBoxWorkpiece);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Name = "FormFurnitureWorkpiece";
|
||||
this.Text = "Заготовка мебели";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxCount;
|
||||
private ComboBox comboBoxWorkpiece;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Button ButtonSave;
|
||||
private Button ButtonCancel;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormFurnitureWorkpiece : Form
|
||||
{
|
||||
private readonly List<WorkpieceViewModel>? _list;
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
Convert.ToInt32(comboBoxWorkpiece.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBoxWorkpiece.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
public IWorkpieceModel? WorkpieceModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _list)
|
||||
{
|
||||
if (elem.Id == Id)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||
set
|
||||
{ textBoxCount.Text = value.ToString(); }
|
||||
}
|
||||
public FormFurnitureWorkpiece(IWorkpieceLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_list = logic.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
comboBoxWorkpiece.DisplayMember = "WorkpieceName";
|
||||
comboBoxWorkpiece.ValueMember = "Id";
|
||||
comboBoxWorkpiece.DataSource = _list;
|
||||
comboBoxWorkpiece.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxWorkpiece.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите компонент", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
126
FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs
generated
Normal file
126
FurnitureAssembly/FurnitureAssembly/FormFurnitures.Designer.cs
generated
Normal file
@ -0,0 +1,126 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormFurnitures
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ButtonAdd = new System.Windows.Forms.Button();
|
||||
this.ButtonUpd = new System.Windows.Forms.Button();
|
||||
this.ButtonDel = new System.Windows.Forms.Button();
|
||||
this.ButtonRef = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersVisible = false;
|
||||
this.dataGridView.RowHeadersWidth = 82;
|
||||
this.dataGridView.RowTemplate.Height = 41;
|
||||
this.dataGridView.Size = new System.Drawing.Size(1033, 753);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
this.ButtonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonAdd.Location = new System.Drawing.Point(1063, 26);
|
||||
this.ButtonAdd.Name = "ButtonAdd";
|
||||
this.ButtonAdd.Size = new System.Drawing.Size(239, 46);
|
||||
this.ButtonAdd.TabIndex = 1;
|
||||
this.ButtonAdd.Text = "Добавить";
|
||||
this.ButtonAdd.UseVisualStyleBackColor = true;
|
||||
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
this.ButtonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonUpd.Location = new System.Drawing.Point(1063, 78);
|
||||
this.ButtonUpd.Name = "ButtonUpd";
|
||||
this.ButtonUpd.Size = new System.Drawing.Size(239, 46);
|
||||
this.ButtonUpd.TabIndex = 2;
|
||||
this.ButtonUpd.Text = "Изменить";
|
||||
this.ButtonUpd.UseVisualStyleBackColor = true;
|
||||
this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
this.ButtonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonDel.Location = new System.Drawing.Point(1063, 130);
|
||||
this.ButtonDel.Name = "ButtonDel";
|
||||
this.ButtonDel.Size = new System.Drawing.Size(239, 46);
|
||||
this.ButtonDel.TabIndex = 3;
|
||||
this.ButtonDel.Text = "Удалить";
|
||||
this.ButtonDel.UseVisualStyleBackColor = true;
|
||||
this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
this.ButtonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonRef.Location = new System.Drawing.Point(1063, 182);
|
||||
this.ButtonRef.Name = "ButtonRef";
|
||||
this.ButtonRef.Size = new System.Drawing.Size(239, 46);
|
||||
this.ButtonRef.TabIndex = 4;
|
||||
this.ButtonRef.Text = "Обновить список";
|
||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// FormFurnitures
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1334, 757);
|
||||
this.Controls.Add(this.ButtonRef);
|
||||
this.Controls.Add(this.ButtonDel);
|
||||
this.Controls.Add(this.ButtonUpd);
|
||||
this.Controls.Add(this.ButtonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormFurnitures";
|
||||
this.Text = "Список мебели";
|
||||
this.Load += new System.EventHandler(this.FormFurnitures_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button ButtonAdd;
|
||||
private Button ButtonUpd;
|
||||
private Button ButtonDel;
|
||||
private Button ButtonRef;
|
||||
}
|
||||
}
|
127
FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs
Normal file
127
FurnitureAssembly/FurnitureAssembly/FormFurnitures.cs
Normal file
@ -0,0 +1,127 @@
|
||||
using FurnitureAssembly;
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormFurnitures : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IFurnitureLogic _logic;
|
||||
|
||||
public FormFurnitures(ILogger<FormFurnitures> logger, IFurnitureLogic logic)
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormFurnitures_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["FurnitureWorkPieces"].Visible = false;
|
||||
dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormFurniture));
|
||||
|
||||
if (service is FormFurniture form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormFurniture));
|
||||
|
||||
if (service is FormFurniture form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
_logger.LogInformation("Удаление изделия");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new FurnitureBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления компонента");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
60
FurnitureAssembly/FurnitureAssembly/FormFurnitures.resx
Normal file
60
FurnitureAssembly/FurnitureAssembly/FormFurnitures.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
201
FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs
generated
Normal file
201
FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,201 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
menuStrip1 = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
заготовкиToolStripMenuItem = new ToolStripMenuItem();
|
||||
мебельToolStripMenuItem = new ToolStripMenuItem();
|
||||
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||
пополнениеМагазинаToolStripMenuItem = new ToolStripMenuItem();
|
||||
dataGridView = new DataGridView();
|
||||
ButtonCreateOrder = new Button();
|
||||
ButtonTakeOrderInWork = new Button();
|
||||
ButtonOrderReady = new Button();
|
||||
ButtonIssuedOrder = new Button();
|
||||
ButtonRef = new Button();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(32, 32);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(1631, 42);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заготовкиToolStripMenuItem, мебельToolStripMenuItem, магазиныToolStripMenuItem, пополнениеМагазинаToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(184, 38);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// заготовкиToolStripMenuItem
|
||||
//
|
||||
заготовкиToolStripMenuItem.Name = "заготовкиToolStripMenuItem";
|
||||
заготовкиToolStripMenuItem.Size = new Size(395, 44);
|
||||
заготовкиToolStripMenuItem.Text = "Заготовки";
|
||||
заготовкиToolStripMenuItem.Click += ЗаготовкиToolStripMenuItem_Click;
|
||||
//
|
||||
// мебельToolStripMenuItem
|
||||
//
|
||||
мебельToolStripMenuItem.Name = "мебельToolStripMenuItem";
|
||||
мебельToolStripMenuItem.Size = new Size(395, 44);
|
||||
мебельToolStripMenuItem.Text = "Мебель";
|
||||
мебельToolStripMenuItem.Click += МебельToolStripMenuItem_Click;
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
магазиныToolStripMenuItem.Size = new Size(395, 44);
|
||||
магазиныToolStripMenuItem.Text = "Магазины";
|
||||
магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click;
|
||||
//
|
||||
// пополнениеМагазинаToolStripMenuItem
|
||||
//
|
||||
пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
|
||||
пополнениеМагазинаToolStripMenuItem.Size = new Size(395, 44);
|
||||
пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
|
||||
пополнениеМагазинаToolStripMenuItem.Click += пополнениеМагазинаToolStripMenuItem_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(0, 65);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 82;
|
||||
dataGridView.RowTemplate.Height = 41;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(1237, 528);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// ButtonCreateOrder
|
||||
//
|
||||
ButtonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
ButtonCreateOrder.Location = new Point(1266, 65);
|
||||
ButtonCreateOrder.Name = "ButtonCreateOrder";
|
||||
ButtonCreateOrder.Size = new Size(334, 46);
|
||||
ButtonCreateOrder.TabIndex = 2;
|
||||
ButtonCreateOrder.Text = "Создать заказ";
|
||||
ButtonCreateOrder.UseVisualStyleBackColor = true;
|
||||
ButtonCreateOrder.Click += ButtonCreateOrder_Click;
|
||||
//
|
||||
// ButtonTakeOrderInWork
|
||||
//
|
||||
ButtonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
ButtonTakeOrderInWork.Location = new Point(1266, 119);
|
||||
ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
|
||||
ButtonTakeOrderInWork.Size = new Size(334, 46);
|
||||
ButtonTakeOrderInWork.TabIndex = 3;
|
||||
ButtonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
ButtonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
|
||||
//
|
||||
// ButtonOrderReady
|
||||
//
|
||||
ButtonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
ButtonOrderReady.Location = new Point(1266, 196);
|
||||
ButtonOrderReady.Name = "ButtonOrderReady";
|
||||
ButtonOrderReady.Size = new Size(334, 46);
|
||||
ButtonOrderReady.TabIndex = 4;
|
||||
ButtonOrderReady.Text = "Заказ готов";
|
||||
ButtonOrderReady.UseVisualStyleBackColor = true;
|
||||
ButtonOrderReady.Click += ButtonOrderReady_Click;
|
||||
//
|
||||
// ButtonIssuedOrder
|
||||
//
|
||||
ButtonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
ButtonIssuedOrder.Location = new Point(1266, 252);
|
||||
ButtonIssuedOrder.Name = "ButtonIssuedOrder";
|
||||
ButtonIssuedOrder.Size = new Size(334, 46);
|
||||
ButtonIssuedOrder.TabIndex = 5;
|
||||
ButtonIssuedOrder.Text = "Заказ выдан";
|
||||
ButtonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
ButtonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
ButtonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
ButtonRef.Location = new Point(1266, 336);
|
||||
ButtonRef.Name = "ButtonRef";
|
||||
ButtonRef.Size = new Size(334, 46);
|
||||
ButtonRef.TabIndex = 6;
|
||||
ButtonRef.Text = "Обновить список";
|
||||
ButtonRef.UseVisualStyleBackColor = true;
|
||||
ButtonRef.Click += ButtonRef_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1631, 594);
|
||||
Controls.Add(ButtonRef);
|
||||
Controls.Add(ButtonIssuedOrder);
|
||||
Controls.Add(ButtonOrderReady);
|
||||
Controls.Add(ButtonTakeOrderInWork);
|
||||
Controls.Add(ButtonCreateOrder);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "FormMain";
|
||||
Text = "Сборка мебели";
|
||||
Load += FormMain_Load;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem заготовкиToolStripMenuItem;
|
||||
private ToolStripMenuItem мебельToolStripMenuItem;
|
||||
private DataGridView dataGridView;
|
||||
private Button ButtonCreateOrder;
|
||||
private Button ButtonTakeOrderInWork;
|
||||
private Button ButtonOrderReady;
|
||||
private Button ButtonIssuedOrder;
|
||||
private Button ButtonRef;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
|
||||
}
|
||||
}
|
202
FurnitureAssembly/FurnitureAssembly/FormMain.cs
Normal file
202
FurnitureAssembly/FurnitureAssembly/FormMain.cs
Normal file
@ -0,0 +1,202 @@
|
||||
using FurnitureAssembly;
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["FurnitureId"].Visible = false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ЗаготовкиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorkpieces));
|
||||
|
||||
if (service is FormWorkpieces form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void МебельToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormFurnitures));
|
||||
|
||||
if (service is FormFurnitures form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Заказ не отправлен в сборку. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Заказ не в статусе готовности. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void пополнениеМагазинаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormAddFurniture));
|
||||
|
||||
if (service is FormAddFurniture form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
|
||||
if (service is FormShops form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
FurnitureAssembly/FurnitureAssembly/FormMain.resx
Normal file
123
FurnitureAssembly/FurnitureAssembly/FormMain.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?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>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
211
FurnitureAssembly/FurnitureAssembly/FormShop.Designer.cs
generated
Normal file
211
FurnitureAssembly/FurnitureAssembly/FormShop.Designer.cs
generated
Normal file
@ -0,0 +1,211 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormShop
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelName = new Label();
|
||||
labelAddress = new Label();
|
||||
textBoxName = new TextBox();
|
||||
textBoxAddress = new TextBox();
|
||||
groupBoxIceCreams = new GroupBox();
|
||||
dataGridView = new DataGridView();
|
||||
ID = new DataGridViewTextBoxColumn();
|
||||
ColumnFurnitureName = new DataGridViewTextBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
labelDate = new Label();
|
||||
dateTimePickerDate = new DateTimePicker();
|
||||
groupBoxIceCreams.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(33, 21);
|
||||
labelName.Margin = new Padding(6, 0, 6, 0);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(125, 32);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Название:";
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
labelAddress.AutoSize = true;
|
||||
labelAddress.Location = new Point(48, 66);
|
||||
labelAddress.Margin = new Padding(6, 0, 6, 0);
|
||||
labelAddress.Name = "labelAddress";
|
||||
labelAddress.Size = new Size(85, 32);
|
||||
labelAddress.TabIndex = 1;
|
||||
labelAddress.Text = "Адрес:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(252, 14);
|
||||
textBoxName.Margin = new Padding(6, 4, 6, 4);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(557, 39);
|
||||
textBoxName.TabIndex = 2;
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
textBoxAddress.Location = new Point(252, 66);
|
||||
textBoxAddress.Margin = new Padding(6, 4, 6, 4);
|
||||
textBoxAddress.Name = "textBoxAddress";
|
||||
textBoxAddress.Size = new Size(557, 39);
|
||||
textBoxAddress.TabIndex = 3;
|
||||
//
|
||||
// groupBoxIceCreams
|
||||
//
|
||||
groupBoxIceCreams.Controls.Add(dataGridView);
|
||||
groupBoxIceCreams.Location = new Point(15, 172);
|
||||
groupBoxIceCreams.Margin = new Padding(6, 4, 6, 4);
|
||||
groupBoxIceCreams.Name = "groupBoxIceCreams";
|
||||
groupBoxIceCreams.Padding = new Padding(6, 4, 6, 4);
|
||||
groupBoxIceCreams.Size = new Size(794, 439);
|
||||
groupBoxIceCreams.TabIndex = 4;
|
||||
groupBoxIceCreams.TabStop = false;
|
||||
groupBoxIceCreams.Text = "Изделия";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, ColumnFurnitureName, ColumnCount });
|
||||
dataGridView.Location = new Point(9, 43);
|
||||
dataGridView.Margin = new Padding(6, 4, 6, 4);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(763, 388);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ID
|
||||
//
|
||||
ID.HeaderText = "ID";
|
||||
ID.MinimumWidth = 10;
|
||||
ID.Name = "ID";
|
||||
ID.Visible = false;
|
||||
//
|
||||
// ColumnFurnitureName
|
||||
//
|
||||
ColumnFurnitureName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
ColumnFurnitureName.HeaderText = "Изделие";
|
||||
ColumnFurnitureName.MinimumWidth = 6;
|
||||
ColumnFurnitureName.Name = "ColumnFurnitureName";
|
||||
ColumnFurnitureName.Resizable = DataGridViewTriState.True;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(288, 619);
|
||||
buttonSave.Margin = new Padding(6, 4, 6, 4);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(231, 49);
|
||||
buttonSave.TabIndex = 5;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(556, 619);
|
||||
buttonCancel.Margin = new Padding(6, 4, 6, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(231, 46);
|
||||
buttonCancel.TabIndex = 6;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
labelDate.AutoSize = true;
|
||||
labelDate.Location = new Point(15, 109);
|
||||
labelDate.Margin = new Padding(6, 0, 6, 0);
|
||||
labelDate.Name = "labelDate";
|
||||
labelDate.Size = new Size(180, 32);
|
||||
labelDate.TabIndex = 7;
|
||||
labelDate.Text = "Дата открытия:";
|
||||
//
|
||||
// dateTimePickerDate
|
||||
//
|
||||
dateTimePickerDate.Location = new Point(497, 115);
|
||||
dateTimePickerDate.Margin = new Padding(6);
|
||||
dateTimePickerDate.Name = "dateTimePickerDate";
|
||||
dateTimePickerDate.Size = new Size(312, 39);
|
||||
dateTimePickerDate.TabIndex = 9;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(834, 681);
|
||||
Controls.Add(dateTimePickerDate);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(labelDate);
|
||||
Controls.Add(groupBoxIceCreams);
|
||||
Controls.Add(textBoxAddress);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelAddress);
|
||||
Controls.Add(labelName);
|
||||
Margin = new Padding(6, 4, 6, 4);
|
||||
Name = "FormShop";
|
||||
Text = "Магазин";
|
||||
Load += FormShop_Load;
|
||||
groupBoxIceCreams.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private Label labelAddress;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxAddress;
|
||||
private GroupBox groupBoxIceCreams;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label labelDate;
|
||||
private DateTimePicker dateTimePickerDate;
|
||||
private DataGridViewTextBoxColumn ID;
|
||||
private DataGridViewTextBoxColumn ColumnFurnitureName;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
133
FurnitureAssembly/FurnitureAssembly/FormShop.cs
Normal file
133
FurnitureAssembly/FurnitureAssembly/FormShop.cs
Normal file
@ -0,0 +1,133 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using FurnitureAssemblyListImplement.Models;
|
||||
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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
private Dictionary<int, (IFurnitureModel, int)> _shopFurnitures;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_shopFurnitures = new Dictionary<int, (IFurnitureModel, int)>();
|
||||
}
|
||||
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазина");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ShopSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address.ToString();
|
||||
dateTimePickerDate.Value = view.DateOpen;
|
||||
_shopFurnitures = view.Furnitures ?? new Dictionary<int, (IFurnitureModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий в магазине");
|
||||
try
|
||||
{
|
||||
if (_shopFurnitures != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var element in _shopFurnitures)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { element.Key, element.Value.Item1.FurnitureName, element.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий в магазине");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpen = dateTimePickerDate.Value.Date,
|
||||
Furnitures = _shopFurnitures
|
||||
};
|
||||
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 ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?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
|
||||
|
||||
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>
|
||||
@ -26,36 +26,36 @@
|
||||
<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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
120
FurnitureAssembly/FurnitureAssembly/FormShops.Designer.cs
generated
Normal file
120
FurnitureAssembly/FurnitureAssembly/FormShops.Designer.cs
generated
Normal file
@ -0,0 +1,120 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormShops
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonAdd = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonDelete = new Button();
|
||||
buttonRefresh = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(19, 19);
|
||||
dataGridView.Margin = new Padding(6, 4, 6, 4);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(825, 683);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(864, 51);
|
||||
buttonAdd.Margin = new Padding(6, 4, 6, 4);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(247, 55);
|
||||
buttonAdd.TabIndex = 2;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(864, 114);
|
||||
buttonUpdate.Margin = new Padding(6, 4, 6, 4);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(247, 50);
|
||||
buttonUpdate.TabIndex = 3;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(864, 172);
|
||||
buttonDelete.Margin = new Padding(6, 4, 6, 4);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(247, 50);
|
||||
buttonDelete.TabIndex = 4;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(864, 233);
|
||||
buttonRefresh.Margin = new Padding(6, 4, 6, 4);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(247, 49);
|
||||
buttonRefresh.TabIndex = 5;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += ButtonRefresh_Click;
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1133, 721);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Margin = new Padding(6, 4, 6, 4);
|
||||
Name = "FormShops";
|
||||
Text = "Магазины";
|
||||
Load += FormShops_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonAdd;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonRefresh;
|
||||
}
|
||||
}
|
118
FurnitureAssembly/FurnitureAssembly/FormShops.cs
Normal file
118
FurnitureAssembly/FurnitureAssembly/FormShops.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using FurnitureAssembly;
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormShops : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormShops_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["Furnitures"].Visible = false;
|
||||
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
if (service is FormShop form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
if (service is FormShop form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление магазина");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ShopBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
FurnitureAssembly/FurnitureAssembly/FormShops.resx
Normal file
120
FurnitureAssembly/FurnitureAssembly/FormShops.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>
|
129
FurnitureAssembly/FurnitureAssembly/FormWorkpiece.Designer.cs
generated
Normal file
129
FurnitureAssembly/FurnitureAssembly/FormWorkpiece.Designer.cs
generated
Normal file
@ -0,0 +1,129 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormWorkpiece
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxCost = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.Location = new System.Drawing.Point(335, 208);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(150, 46);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "Сохранить";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(26, 43);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(125, 32);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Название:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxName.Location = new System.Drawing.Point(165, 40);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(496, 39);
|
||||
this.textBoxName.TabIndex = 2;
|
||||
//
|
||||
// textBoxCost
|
||||
//
|
||||
this.textBoxCost.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxCost.Location = new System.Drawing.Point(165, 105);
|
||||
this.textBoxCost.Name = "textBoxCost";
|
||||
this.textBoxCost.Size = new System.Drawing.Size(245, 39);
|
||||
this.textBoxCost.TabIndex = 4;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(26, 108);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(76, 32);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Цена:";
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button2.Location = new System.Drawing.Point(511, 208);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(150, 46);
|
||||
this.button2.TabIndex = 5;
|
||||
this.button2.Text = "Отмена";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormWorkpiece
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(686, 280);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.textBoxCost);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Name = "FormWorkpiece";
|
||||
this.Text = "Заготовка";
|
||||
this.Load += new System.EventHandler(this.FormComponent_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button button1;
|
||||
private Label label1;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxCost;
|
||||
private Label label2;
|
||||
private Button button2;
|
||||
}
|
||||
}
|
97
FurnitureAssembly/FurnitureAssembly/FormWorkpiece.cs
Normal file
97
FurnitureAssembly/FurnitureAssembly/FormWorkpiece.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormWorkpiece : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkpieceLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormWorkpiece(ILogger<FormWorkpiece> logger, IWorkpieceLogic
|
||||
logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
private void FormComponent_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение компонента");
|
||||
var view = _logic.ReadElement(new WorkpieceSearchModel
|
||||
{
|
||||
Id =
|
||||
_id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.WorkpieceName;
|
||||
textBoxCost.Text = view.Cost.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения компонента");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение компонента");
|
||||
try
|
||||
{
|
||||
var model = new WorkpieceBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
WorkpieceName = textBoxName.Text,
|
||||
Cost = Convert.ToDouble(textBoxCost.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 ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
FurnitureAssembly/FurnitureAssembly/FormWorkpiece.resx
Normal file
60
FurnitureAssembly/FurnitureAssembly/FormWorkpiece.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
127
FurnitureAssembly/FurnitureAssembly/FormWorkpieces.Designer.cs
generated
Normal file
127
FurnitureAssembly/FurnitureAssembly/FormWorkpieces.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormWorkpieces
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ButtonAdd = new System.Windows.Forms.Button();
|
||||
this.ButtonUpd = new System.Windows.Forms.Button();
|
||||
this.ButtonDel = new System.Windows.Forms.Button();
|
||||
this.ButtonRef = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView.MultiSelect = false;
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersVisible = false;
|
||||
this.dataGridView.RowHeadersWidth = 82;
|
||||
this.dataGridView.RowTemplate.Height = 41;
|
||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.dataGridView.Size = new System.Drawing.Size(796, 760);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
this.ButtonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonAdd.Location = new System.Drawing.Point(895, 86);
|
||||
this.ButtonAdd.Name = "ButtonAdd";
|
||||
this.ButtonAdd.Size = new System.Drawing.Size(170, 55);
|
||||
this.ButtonAdd.TabIndex = 1;
|
||||
this.ButtonAdd.Text = "Добавить";
|
||||
this.ButtonAdd.UseVisualStyleBackColor = true;
|
||||
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
this.ButtonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonUpd.Location = new System.Drawing.Point(895, 170);
|
||||
this.ButtonUpd.Name = "ButtonUpd";
|
||||
this.ButtonUpd.Size = new System.Drawing.Size(170, 55);
|
||||
this.ButtonUpd.TabIndex = 2;
|
||||
this.ButtonUpd.Text = "Изменить";
|
||||
this.ButtonUpd.UseVisualStyleBackColor = true;
|
||||
this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
this.ButtonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonDel.Location = new System.Drawing.Point(895, 256);
|
||||
this.ButtonDel.Name = "ButtonDel";
|
||||
this.ButtonDel.Size = new System.Drawing.Size(170, 55);
|
||||
this.ButtonDel.TabIndex = 3;
|
||||
this.ButtonDel.Text = "Удалить";
|
||||
this.ButtonDel.UseVisualStyleBackColor = true;
|
||||
this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
this.ButtonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonRef.Location = new System.Drawing.Point(895, 351);
|
||||
this.ButtonRef.Name = "ButtonRef";
|
||||
this.ButtonRef.Size = new System.Drawing.Size(170, 55);
|
||||
this.ButtonRef.TabIndex = 4;
|
||||
this.ButtonRef.Text = "Обновить";
|
||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// FormWorkpieces
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1135, 760);
|
||||
this.Controls.Add(this.ButtonRef);
|
||||
this.Controls.Add(this.ButtonDel);
|
||||
this.Controls.Add(this.ButtonUpd);
|
||||
this.Controls.Add(this.ButtonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormWorkpieces";
|
||||
this.Text = "Заготовки";
|
||||
this.Load += new System.EventHandler(this.FormWorkpieces_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button ButtonAdd;
|
||||
private Button ButtonUpd;
|
||||
private Button ButtonDel;
|
||||
private Button ButtonRef;
|
||||
}
|
||||
}
|
111
FurnitureAssembly/FurnitureAssembly/FormWorkpieces.cs
Normal file
111
FurnitureAssembly/FurnitureAssembly/FormWorkpieces.cs
Normal file
@ -0,0 +1,111 @@
|
||||
using FurnitureAssembly;
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormWorkpieces : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkpieceLogic _logic;
|
||||
public FormWorkpieces(ILogger<FormWorkpieces> logger, IWorkpieceLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
private void FormWorkpieces_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["WorkpieceName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонентов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorkpiece));
|
||||
if (service is FormWorkpiece form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorkpiece));
|
||||
|
||||
if (service is FormWorkpiece form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление компонента");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new WorkpieceBindingModel{Id = id}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении.Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления компонента");
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
60
FurnitureAssembly/FurnitureAssembly/FormWorkpieces.resx
Normal file
60
FurnitureAssembly/FurnitureAssembly/FormWorkpieces.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
@ -1,11 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,34 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="nlog.config" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="nlog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||
<ProjectReference Include="..\FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,7 +1,20 @@
|
||||
using FurnitureAssemblyBusinessLogic;
|
||||
using FurnitureAssemblyBusinessLogic.BusinessLogics;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyListImplement.Implements;
|
||||
using FurnitureAssemblyView;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -11,7 +24,39 @@ namespace FurnitureAssembly
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
services.AddTransient<IWorkpieceStorage, WorkpieceStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IFurnitureStorage, FurnitureStorage>();
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
|
||||
services.AddTransient<IWorkpieceLogic, WorkpieceLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IFurnitureLogic, FurnitureLogic>();
|
||||
services.AddTransient<IShopLogic, ShopLogic>();
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormWorkpiece>();
|
||||
services.AddTransient<FormWorkpieces>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormFurniture>();
|
||||
services.AddTransient<FormFurnitureWorkpiece>();
|
||||
services.AddTransient<FormFurnitures>();
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormAddFurniture>();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
namespace FurnitureAssembly
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class Form1
|
||||
partial class nlog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// 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)
|
||||
@ -23,15 +23,15 @@
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
this.Text = "nlog";
|
||||
}
|
||||
|
||||
#endregion
|
18
FurnitureAssembly/FurnitureAssembly/nlog.config
Normal file
18
FurnitureAssembly/FurnitureAssembly/nlog.config
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true" internalLogLevel="Info">
|
||||
|
||||
<targets>
|
||||
<target xsi:type="File" name="tofile" fileName="logs/log-${shortdate}.log" />
|
||||
</targets>
|
||||
<target name="console" xsi:type="Console" layout="Access Log|${level:uppercase=true}|${logger}|${message}">
|
||||
<highlight-row condition="true" foregroundColor="red"/>
|
||||
</target>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Info" writeTo="tofile,console" />
|
||||
</rules>
|
||||
</nlog>
|
||||
</configuration>
|
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,147 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic
|
||||
{
|
||||
public class FurnitureLogic : IFurnitureLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IFurnitureStorage _furnitureStorage;
|
||||
|
||||
public FurnitureLogic(ILogger<FurnitureLogic> logger, IFurnitureStorage furnitureStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_furnitureStorage = furnitureStorage;
|
||||
}
|
||||
|
||||
public List<FurnitureViewModel>? ReadList(FurnitureSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. FurnitureName: {FurnitureName}. Id:{Id}", model?.FurnitureName, model?.Id);
|
||||
|
||||
var list = model == null ? _furnitureStorage.GetFullList() : _furnitureStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? ReadElement(FurnitureSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. FurnitureName: {FurnitureName}. Id:{Id}", model.FurnitureName, model.Id);
|
||||
|
||||
var element = _furnitureStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Readelement find. Id:{Id}", model.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(FurnitureBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_furnitureStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Create operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(FurnitureBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_furnitureStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(FurnitureBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete, Id:{Id}", model.Id);
|
||||
|
||||
if (_furnitureStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(FurnitureBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.FurnitureName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия заготовки", nameof(model.FurnitureName));
|
||||
}
|
||||
|
||||
if (model.Price <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена заготовки должна быть больше 0", nameof(model.Price));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Furniture. FurnitureName:{FurnitureName}. Price:{Price}. Id:{Id}",
|
||||
model.FurnitureName, model.Price, model.Id);
|
||||
|
||||
var element = _furnitureStorage.GetElement(new FurnitureSearchModel
|
||||
{
|
||||
FurnitureName = model.FurnitureName,
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Изделие с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
158
FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs
Normal file
158
FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs
Normal file
@ -0,0 +1,158 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic
|
||||
{
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id:{Id}", model?.Id);
|
||||
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (model.Status != OrderStatus.Неизвестен)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed, incorrect order status");
|
||||
return false;
|
||||
}
|
||||
|
||||
model.Status = OrderStatus.Принят;
|
||||
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
{
|
||||
model.Status = OrderStatus.Неизвестен;
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Готов);
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выдан);
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("В заказе не может быть 0 заготовок", nameof(model.Count));
|
||||
}
|
||||
|
||||
if (model.Sum <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Суммарная стоимость заказа должна быть больше 0", nameof(model.Sum));
|
||||
}
|
||||
|
||||
if (model.FurnitureId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный id у заготовки", nameof(model.FurnitureId));
|
||||
}
|
||||
|
||||
if (model.DateCreate > model.DateImplement)
|
||||
{
|
||||
throw new InvalidOperationException("Дата создания должна быть более ранней, нежели дата завершения");
|
||||
}
|
||||
|
||||
_logger.LogInformation("Order. OrderId:{Id}, Sum:{Sum}. FurnitureId:{Id}", model.Id, model.Sum, model.FurnitureId);
|
||||
}
|
||||
|
||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newOrderStatus)
|
||||
{
|
||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
|
||||
if (viewModel == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (viewModel.Status + 1 != newOrderStatus)
|
||||
{
|
||||
_logger.LogWarning("Status update operation failed. New status " + newOrderStatus.ToString() + "incorrect");
|
||||
return false;
|
||||
}
|
||||
|
||||
model.Status = newOrderStatus;
|
||||
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.DateImplement = viewModel.DateImplement;
|
||||
}
|
||||
|
||||
CheckModel(model, false);
|
||||
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
|
||||
_logger.LogWarning("Update operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
202
FurnitureAssembly/FurnitureAssemblyBusinessLogic/ShopLogic.cs
Normal file
202
FurnitureAssembly/FurnitureAssemblyBusinessLogic/ShopLogic.cs
Normal file
@ -0,0 +1,202 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic
|
||||
{
|
||||
public class ShopLogic : IShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IShopStorage _shopStorage;
|
||||
|
||||
// Конструктор
|
||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_shopStorage = shopStorage;
|
||||
}
|
||||
|
||||
// Вывод конкретного магазина
|
||||
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ShopName:{ShopName}. Id:{Id}", model.ShopName, model.Id);
|
||||
var element = _shopStorage.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<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ShopName:{ShopName}. Id: {Id}", model?.ShopName, model?.Id);
|
||||
|
||||
// list хранит весь список в случае, если model пришло со значением null на вход метода
|
||||
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
// Пополнение магазина
|
||||
public bool AddFurniture(ShopSearchModel model, IFurnitureModel furniture, int count)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество добавляемых изделий должно быть больше 0", nameof(count));
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddFurniture. ShopName:{ShopName}. Id: {Id}", model?.ShopName, model?.Id);
|
||||
var shop = _shopStorage.GetElement(model);
|
||||
|
||||
if (shop == null)
|
||||
{
|
||||
_logger.LogWarning("Add Furniture operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!shop.Furnitures.ContainsKey(furniture.Id))
|
||||
{
|
||||
shop.Furnitures[furniture.Id] = (furniture, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
shop.Furnitures[furniture.Id] = (furniture, shop.Furnitures[furniture.Id].Item2 + count);
|
||||
}
|
||||
|
||||
_shopStorage.Update(new ShopBindingModel()
|
||||
{
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
DateOpen = shop.DateOpen,
|
||||
Furnitures = shop.Furnitures
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Создание магазина
|
||||
public bool Create(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_shopStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Обновление магазина
|
||||
public bool Update(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_shopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Удаление магазина
|
||||
public bool Delete(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_shopStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Проверка входного аргумента для методов Insert, Update и Delete
|
||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
// При удалении передаём как параметр false
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверка на наличие названия магазина
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
throw new ArgumentNullException("Отсутствует названия магазина", nameof(model.ShopName));
|
||||
}
|
||||
|
||||
// Проверка на наличие адреса у магазина
|
||||
if (string.IsNullOrEmpty(model.Address))
|
||||
{
|
||||
throw new ArgumentNullException("Отсутствует адреса магазина", nameof(model.Address));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Shop. ShopName:{ShopName}. Address:{Address}. Id: {Id}", model.ShopName, model.Address, model.Id);
|
||||
|
||||
// Проверка на наличие такого же магазина в списке
|
||||
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
ShopName = model.ShopName
|
||||
});
|
||||
|
||||
// Если элемент найден и его Id не совпадает с Id переданного объекта
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class WorkpieceLogic : IWorkpieceLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkpieceStorage _workpieceStorage;
|
||||
public WorkpieceLogic(ILogger<WorkpieceLogic> logger, IWorkpieceStorage workpieceStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_workpieceStorage = workpieceStorage;
|
||||
}
|
||||
public List<WorkpieceViewModel>? ReadList(WorkpieceSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. WorkpieceName:{WorkpieceName}.Id:{ Id} ", model?.WorkpieceName, model?.Id);
|
||||
var list = model == null ? _workpieceStorage.GetFullList() : _workpieceStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public WorkpieceViewModel? ReadElement(WorkpieceSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. WorkpieceName:{WorkpieceName}.Id:{ Id}", model.WorkpieceName, model.Id);
|
||||
var element = _workpieceStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(WorkpieceBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_workpieceStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(WorkpieceBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_workpieceStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(WorkpieceBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_workpieceStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(WorkpieceBindingModel model, bool withParams =
|
||||
true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.WorkpieceName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия компонента",
|
||||
nameof(model.WorkpieceName));
|
||||
}
|
||||
if (model.Cost <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
||||
}
|
||||
_logger.LogInformation("Workpiece. WorkpieceName:{WorkpieceName}.Cost:{ Cost}. Id: { Id}", model.WorkpieceName, model.Cost, model.Id);
|
||||
var element = _workpieceStorage.GetElement(new WorkpieceSearchModel {WorkpieceName = model.WorkpieceName});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class FurnitureBindingModel : IFurnitureModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FurnitureName { get; set; } = string.Empty;
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IWorkpieceModel, int)> FurnitureWorkpieces {get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int FurnitureId { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class ShopBindingModel : IShopModel
|
||||
{
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new();
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class WorkpieceBindingModel : IWorkpieceModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string WorkpieceName { get; set; } = String.Empty;
|
||||
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IFurnitureLogic
|
||||
{
|
||||
List<FurnitureViewModel>? ReadList(FurnitureSearchModel? model);
|
||||
FurnitureViewModel? ReadElement(FurnitureSearchModel model);
|
||||
bool Create(FurnitureBindingModel model);
|
||||
bool Update(FurnitureBindingModel model);
|
||||
bool Delete(FurnitureBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
bool DeliveryOrder(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IShopLogic
|
||||
{
|
||||
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||
|
||||
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||
|
||||
bool Create(ShopBindingModel model);
|
||||
|
||||
bool Update(ShopBindingModel model);
|
||||
|
||||
bool Delete(ShopBindingModel model);
|
||||
|
||||
bool AddFurniture(ShopSearchModel model, IFurnitureModel furniture, int count);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWorkpieceLogic
|
||||
{
|
||||
List<WorkpieceViewModel>? ReadList(WorkpieceSearchModel? model);
|
||||
WorkpieceViewModel? ReadElement(WorkpieceSearchModel model);
|
||||
bool Create(WorkpieceBindingModel model);
|
||||
bool Update(WorkpieceBindingModel model);
|
||||
bool Delete(WorkpieceBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class FurnitureSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? FurnitureName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ShopName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class WorkpieceSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? WorkpieceName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
public interface IFurnitureStorage
|
||||
{
|
||||
List<FurnitureViewModel> GetFullList();
|
||||
List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model);
|
||||
FurnitureViewModel? GetElement(FurnitureSearchModel model);
|
||||
FurnitureViewModel? Insert(FurnitureBindingModel model);
|
||||
FurnitureViewModel? Update(FurnitureBindingModel model);
|
||||
FurnitureViewModel? Delete(FurnitureBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
public interface IShopStorage
|
||||
{
|
||||
List<ShopViewModel> GetFullList();
|
||||
|
||||
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||
|
||||
ShopViewModel? GetElement(ShopSearchModel model);
|
||||
|
||||
ShopViewModel? Insert(ShopBindingModel model);
|
||||
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
public interface IWorkpieceStorage
|
||||
{
|
||||
List<WorkpieceViewModel> GetFullList();
|
||||
List<WorkpieceViewModel> GetFilteredList(WorkpieceSearchModel model);
|
||||
WorkpieceViewModel? GetElement(WorkpieceSearchModel model);
|
||||
WorkpieceViewModel? Insert(WorkpieceBindingModel model);
|
||||
WorkpieceViewModel? Update(WorkpieceBindingModel model);
|
||||
WorkpieceViewModel? Delete(WorkpieceBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class FurnitureViewModel : IFurnitureModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название мебели")]
|
||||
public string FurnitureName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IWorkpieceModel, int)> FurnitureWorkpieces { get; set;} = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int FurnitureId { get; set; }
|
||||
|
||||
[DisplayName("Изделие")]
|
||||
public string FurnitureName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Дата выполнения")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название магазина")]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
[DisplayName("Адрес магазина")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class WorkpieceViewModel : IWorkpieceModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название заготовки")]
|
||||
public string WorkpieceName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Enums
|
||||
{
|
||||
public enum OrderStatus
|
||||
{
|
||||
Неизвестен = -1,
|
||||
Принят = 0,
|
||||
Выполняется = 1,
|
||||
Готов = 2,
|
||||
Выдан = 3
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
13
FurnitureAssembly/FurnitureAssemblyDataModels/IId.cs
Normal file
13
FurnitureAssembly/FurnitureAssemblyDataModels/IId.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IFurnitureModel : IId
|
||||
{
|
||||
string FurnitureName { get; }
|
||||
double Price { get; }
|
||||
|
||||
Dictionary<int,(IWorkpieceModel, int)> FurnitureWorkpieces { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
int FurnitureId { get; }
|
||||
|
||||
int Count { get; }
|
||||
|
||||
double Sum { get; }
|
||||
|
||||
OrderStatus Status { get; }
|
||||
|
||||
DateTime DateCreate { get; }
|
||||
|
||||
DateTime? DateImplement { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IShopModel : IId
|
||||
{
|
||||
string ShopName { get; }
|
||||
string Address { get; }
|
||||
DateTime DateOpen { get; }
|
||||
Dictionary<int, (IFurnitureModel, int)> Furnitures { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IWorkpieceModel : IId
|
||||
{
|
||||
string WorkpieceName { get; }
|
||||
|
||||
double Cost { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using FurnitureAssemblyListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Formats.Asn1.AsnWriter;
|
||||
|
||||
namespace FurnitureAssemblyListImplement
|
||||
{
|
||||
internal class DataListSingleton
|
||||
{
|
||||
private static DataListSingleton? _instance;
|
||||
public List<Workpiece> Workpieces { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Furniture> Furnitures { get; set; }
|
||||
public List<Shop> Shops { get; set; }
|
||||
|
||||
private DataListSingleton()
|
||||
{
|
||||
Workpieces = new List<Workpiece>();
|
||||
Orders = new List<Order>();
|
||||
Furnitures = new List<Furniture>();
|
||||
Shops = new List<Shop>();
|
||||
}
|
||||
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new DataListSingleton();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||
<ProjectReference Include="..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,129 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyListImplement.Implements
|
||||
{
|
||||
public class FurnitureStorage : IFurnitureStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
|
||||
public FurnitureStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<FurnitureViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<FurnitureViewModel>();
|
||||
|
||||
foreach (var furniture in _source.Furnitures)
|
||||
{
|
||||
result.Add(furniture.GetViewModel);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model)
|
||||
{
|
||||
var result = new List<FurnitureViewModel>();
|
||||
|
||||
if (string.IsNullOrEmpty(model.FurnitureName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var furniture in _source.Furnitures)
|
||||
{
|
||||
if (furniture.FurnitureName.Contains(model.FurnitureName))
|
||||
{
|
||||
result.Add(furniture.GetViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? GetElement(FurnitureSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FurnitureName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var furniture in _source.Furnitures)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.FurnitureName) && furniture.FurnitureName == model.FurnitureName) ||
|
||||
(model.Id.HasValue && furniture.Id == model.Id))
|
||||
{
|
||||
return furniture.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Insert(FurnitureBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
foreach (var furniture in _source.Furnitures)
|
||||
{
|
||||
if (model.Id <= furniture.Id)
|
||||
{
|
||||
model.Id = furniture.Id + 1;
|
||||
}
|
||||
}
|
||||
|
||||
var newFurniture = Furniture.Create(model);
|
||||
|
||||
if (newFurniture == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_source.Furnitures.Add(newFurniture);
|
||||
|
||||
return newFurniture.GetViewModel;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Update(FurnitureBindingModel model)
|
||||
{
|
||||
foreach (var furniture in _source.Furnitures)
|
||||
{
|
||||
if (furniture.Id == model.Id)
|
||||
{
|
||||
furniture.Update(model);
|
||||
|
||||
return furniture.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Delete(FurnitureBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Furnitures.Count; ++i)
|
||||
{
|
||||
if (_source.Furnitures[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Furnitures[i];
|
||||
_source.Furnitures.RemoveAt(i);
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyListImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public OrderStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
{
|
||||
return GetViewModel(order);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
|
||||
foreach (var furniture in _source.Furnitures)
|
||||
{
|
||||
if (furniture.Id == order.FurnitureId)
|
||||
{
|
||||
viewModel.FurnitureName = furniture.FurnitureName;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Id <= order.Id)
|
||||
{
|
||||
model.Id = order.Id + 1;
|
||||
}
|
||||
}
|
||||
|
||||
var newOrder = Order.Create(model);
|
||||
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_source.Orders.Add(newOrder);
|
||||
|
||||
return GetViewModel(newOrder);
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
order.Update(model);
|
||||
|
||||
return GetViewModel(order);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Orders.Count; i++)
|
||||
{
|
||||
if (_source.Orders[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Orders[i];
|
||||
_source.Orders.RemoveAt(i);
|
||||
|
||||
return GetViewModel(element);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyListImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id))
|
||||
{
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.ShopName.Contains(model.ShopName))
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (model.Id <= shop.Id)
|
||||
{
|
||||
model.Id = shop.Id + 1;
|
||||
}
|
||||
}
|
||||
|
||||
var newShop = Shop.Create(model);
|
||||
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_source.Shops.Add(newShop);
|
||||
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.Id == model.Id)
|
||||
{
|
||||
shop.Update(model);
|
||||
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||
{
|
||||
if (_source.Shops[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Shops[i];
|
||||
_source.Shops.RemoveAt(i);
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyListImplement.Implements
|
||||
{
|
||||
public class WorkpieceStorage : IWorkpieceStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public WorkpieceStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<WorkpieceViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<WorkpieceViewModel>();
|
||||
foreach (var Workpiece in _source.Workpieces)
|
||||
{
|
||||
result.Add(Workpiece.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<WorkpieceViewModel> GetFilteredList(WorkpieceSearchModel model)
|
||||
{
|
||||
var result = new List<WorkpieceViewModel>();
|
||||
if (string.IsNullOrEmpty(model.WorkpieceName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var Workpiece in _source.Workpieces)
|
||||
{
|
||||
if (Workpiece.WorkpieceName.Contains(model.WorkpieceName))
|
||||
{
|
||||
result.Add(Workpiece.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public WorkpieceViewModel? GetElement(WorkpieceSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.WorkpieceName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var Workpiece in _source.Workpieces)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.WorkpieceName) &&
|
||||
Workpiece.WorkpieceName == model.WorkpieceName) ||
|
||||
(model.Id.HasValue && Workpiece.Id == model.Id))
|
||||
{
|
||||
return Workpiece.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public WorkpieceViewModel? Insert(WorkpieceBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var Workpiece in _source.Workpieces)
|
||||
{
|
||||
if (model.Id <= Workpiece.Id)
|
||||
{
|
||||
model.Id = Workpiece.Id + 1;
|
||||
}
|
||||
}
|
||||
var newWorkpiece = Workpiece.Create(model);
|
||||
if (newWorkpiece == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Workpieces.Add(newWorkpiece);
|
||||
return newWorkpiece.GetViewModel;
|
||||
}
|
||||
public WorkpieceViewModel? Update(WorkpieceBindingModel model)
|
||||
{
|
||||
foreach (var Workpiece in _source.Workpieces)
|
||||
{
|
||||
if (Workpiece.Id == model.Id)
|
||||
{
|
||||
Workpiece.Update(model);
|
||||
return Workpiece.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public WorkpieceViewModel? Delete(WorkpieceBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Workpieces.Count; ++i)
|
||||
{
|
||||
if (_source.Workpieces[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Workpieces[i];
|
||||
_source.Workpieces.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyListImplement.Models
|
||||
{
|
||||
public class Furniture : IFurnitureModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string FurnitureName { get; private set; } = string.Empty;
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, (IWorkpieceModel, int)> FurnitureWorkpieces
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = new Dictionary<int, (IWorkpieceModel, int)>();
|
||||
public static Furniture? Create(FurnitureBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Furniture()
|
||||
{
|
||||
Id = model.Id,
|
||||
FurnitureName = model.FurnitureName,
|
||||
Price = model.Price,
|
||||
FurnitureWorkpieces = model.FurnitureWorkpieces
|
||||
};
|
||||
}
|
||||
public void Update(FurnitureBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FurnitureName = model.FurnitureName;
|
||||
Price = model.Price;
|
||||
FurnitureWorkpieces = model.FurnitureWorkpieces;
|
||||
}
|
||||
public FurnitureViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FurnitureName = FurnitureName,
|
||||
Price = Price,
|
||||
FurnitureWorkpieces = FurnitureWorkpieces
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyListImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int FurnitureId { get; private set; }
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public double Sum { get; private set; }
|
||||
|
||||
public OrderStatus Status { get; private set; }
|
||||
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
FurnitureId = model.FurnitureId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FurnitureId = FurnitureId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyListImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
|
||||
public DateTime DateOpen { get; private set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; private set; } =
|
||||
new Dictionary<int, (IFurnitureModel, int)>();
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpen = model.DateOpen,
|
||||
Furnitures = model.Furnitures
|
||||
};
|
||||
}
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpen = model.DateOpen;
|
||||
Furnitures = model.Furnitures;
|
||||
}
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpen = DateOpen,
|
||||
Furnitures = Furnitures
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyListImplement.Models
|
||||
{
|
||||
internal class Workpiece : IWorkpieceModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string WorkpieceName { get; private set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public static Workpiece? Create(WorkpieceBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Workpiece()
|
||||
{
|
||||
Id = model.Id,
|
||||
WorkpieceName = model.WorkpieceName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public void Update(WorkpieceBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
WorkpieceName = model.WorkpieceName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public WorkpieceViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
WorkpieceName = WorkpieceName,
|
||||
Cost = Cost
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user