Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
976498e495 | |||
b6bdd6deb4 | |||
327d0a1759 | |||
e81483d3cd | |||
b3c5c0d89b | |||
c69fd4d684 |
127
FurnitureAssembly/FormComponent.Designer.cs
generated
Normal file
127
FurnitureAssembly/FormComponent.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
namespace FurnitureAssembly
|
||||||
|
{
|
||||||
|
partial class FormComponent
|
||||||
|
{
|
||||||
|
/// <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.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelName = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxCost = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelCost = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(257, 71);
|
||||||
|
this.buttonCancel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(88, 27);
|
||||||
|
this.buttonCancel.TabIndex = 5;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(162, 71);
|
||||||
|
this.buttonSave.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(88, 27);
|
||||||
|
this.buttonSave.TabIndex = 4;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(91, 7);
|
||||||
|
this.textBoxName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(252, 23);
|
||||||
|
this.textBoxName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
this.labelName.AutoSize = true;
|
||||||
|
this.labelName.Location = new System.Drawing.Point(14, 10);
|
||||||
|
this.labelName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
|
this.labelName.Name = "labelName";
|
||||||
|
this.labelName.Size = new System.Drawing.Size(62, 15);
|
||||||
|
this.labelName.TabIndex = 0;
|
||||||
|
this.labelName.Text = "Название:";
|
||||||
|
//
|
||||||
|
// textBoxCost
|
||||||
|
//
|
||||||
|
this.textBoxCost.Location = new System.Drawing.Point(91, 36);
|
||||||
|
this.textBoxCost.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.textBoxCost.Name = "textBoxCost";
|
||||||
|
this.textBoxCost.Size = new System.Drawing.Size(129, 23);
|
||||||
|
this.textBoxCost.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelCost
|
||||||
|
//
|
||||||
|
this.labelCost.AutoSize = true;
|
||||||
|
this.labelCost.Location = new System.Drawing.Point(14, 39);
|
||||||
|
this.labelCost.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
|
this.labelCost.Name = "labelCost";
|
||||||
|
this.labelCost.Size = new System.Drawing.Size(38, 15);
|
||||||
|
this.labelCost.TabIndex = 2;
|
||||||
|
this.labelCost.Text = "Цена:";
|
||||||
|
//
|
||||||
|
// FormComponent
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(360, 110);
|
||||||
|
this.Controls.Add(this.textBoxCost);
|
||||||
|
this.Controls.Add(this.labelCost);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.labelName);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
|
this.Name = "FormComponent";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Компонент";
|
||||||
|
this.Load += new System.EventHandler(this.FormComponent_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button buttonCancel;
|
||||||
|
private System.Windows.Forms.Button buttonSave;
|
||||||
|
private System.Windows.Forms.TextBox textBoxName;
|
||||||
|
private System.Windows.Forms.Label labelName;
|
||||||
|
private TextBox textBoxCost;
|
||||||
|
private Label labelCost;
|
||||||
|
}
|
||||||
|
}
|
94
FurnitureAssembly/FormComponent.cs
Normal file
94
FurnitureAssembly/FormComponent.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
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 FurnitureAssembly
|
||||||
|
{
|
||||||
|
public partial class FormComponent : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IComponentLogic _logic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormComponent(ILogger<FormComponent> logger, IComponentLogic 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 ComponentSearchModel { Id = _id.Value });
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.ComponentName;
|
||||||
|
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 ComponentBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ComponentName = 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FurnitureAssembly/FormComponent.resx
Normal file
120
FurnitureAssembly/FormComponent.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>
|
122
FurnitureAssembly/FormComponents.Designer.cs
generated
Normal file
122
FurnitureAssembly/FormComponents.Designer.cs
generated
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
namespace FurnitureAssembly
|
||||||
|
{
|
||||||
|
partial class FormComponents
|
||||||
|
{
|
||||||
|
/// <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.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.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonRef
|
||||||
|
//
|
||||||
|
this.buttonRef.Location = new System.Drawing.Point(370, 132);
|
||||||
|
this.buttonRef.Name = "buttonRef";
|
||||||
|
this.buttonRef.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonRef.TabIndex = 4;
|
||||||
|
this.buttonRef.Text = "Обновить";
|
||||||
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(370, 91);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonDel.TabIndex = 3;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(370, 50);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonUpd.TabIndex = 2;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(370, 12);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonAdd.TabIndex = 1;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
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.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(350, 312);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// FormComponents
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(464, 312);
|
||||||
|
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 = "FormComponents";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Компоненты";
|
||||||
|
this.Load += new System.EventHandler(this.FormComponents_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button buttonRef;
|
||||||
|
private System.Windows.Forms.Button buttonDel;
|
||||||
|
private System.Windows.Forms.Button buttonUpd;
|
||||||
|
private System.Windows.Forms.Button buttonAdd;
|
||||||
|
private System.Windows.Forms.DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
112
FurnitureAssembly/FormComponents.cs
Normal file
112
FurnitureAssembly/FormComponents.cs
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
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 FurnitureAssembly
|
||||||
|
{
|
||||||
|
public partial class FormComponents : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IComponentLogic _logic;
|
||||||
|
|
||||||
|
public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormComponents_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["ComponentName"].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(FormComponent));
|
||||||
|
if (service is FormComponent 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(FormComponent));
|
||||||
|
if (service is FormComponent 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 ComponentBindingModel { 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FurnitureAssembly/FormComponents.resx
Normal file
120
FurnitureAssembly/FormComponents.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>
|
146
FurnitureAssembly/FormCreateOrder.Designer.cs
generated
Normal file
146
FurnitureAssembly/FormCreateOrder.Designer.cs
generated
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
namespace FurnitureAssembly
|
||||||
|
{
|
||||||
|
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.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxProduct = new System.Windows.Forms.ComboBox();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelProduct = new System.Windows.Forms.Label();
|
||||||
|
this.labelSum = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxSum = new System.Windows.Forms.TextBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(12, 36);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(69, 13);
|
||||||
|
this.labelCount.TabIndex = 2;
|
||||||
|
this.labelCount.Text = "Количество:";
|
||||||
|
//
|
||||||
|
// comboBoxProduct
|
||||||
|
//
|
||||||
|
this.comboBoxProduct.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxProduct.FormattingEnabled = true;
|
||||||
|
this.comboBoxProduct.Location = new System.Drawing.Point(87, 6);
|
||||||
|
this.comboBoxProduct.Name = "comboBoxProduct";
|
||||||
|
this.comboBoxProduct.Size = new System.Drawing.Size(217, 21);
|
||||||
|
this.comboBoxProduct.TabIndex = 1;
|
||||||
|
this.comboBoxProduct.SelectedIndexChanged += new System.EventHandler(this.ProductComboBox_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(219, 85);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCancel.TabIndex = 7;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(138, 85);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonSave.TabIndex = 6;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.SaveButton_Click);
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(87, 33);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(217, 20);
|
||||||
|
this.textBoxCount.TabIndex = 3;
|
||||||
|
this.textBoxCount.TextChanged += new System.EventHandler(this.CountTextBox_TextChanged);
|
||||||
|
//
|
||||||
|
// labelProduct
|
||||||
|
//
|
||||||
|
this.labelProduct.AutoSize = true;
|
||||||
|
this.labelProduct.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.labelProduct.Name = "labelProduct";
|
||||||
|
this.labelProduct.Size = new System.Drawing.Size(54, 13);
|
||||||
|
this.labelProduct.TabIndex = 0;
|
||||||
|
this.labelProduct.Text = "Изделие:";
|
||||||
|
//
|
||||||
|
// labelSum
|
||||||
|
//
|
||||||
|
this.labelSum.AutoSize = true;
|
||||||
|
this.labelSum.Location = new System.Drawing.Point(12, 62);
|
||||||
|
this.labelSum.Name = "labelSum";
|
||||||
|
this.labelSum.Size = new System.Drawing.Size(44, 13);
|
||||||
|
this.labelSum.TabIndex = 4;
|
||||||
|
this.labelSum.Text = "Сумма:";
|
||||||
|
//
|
||||||
|
// textBoxSum
|
||||||
|
//
|
||||||
|
this.textBoxSum.Location = new System.Drawing.Point(87, 59);
|
||||||
|
this.textBoxSum.Name = "textBoxSum";
|
||||||
|
this.textBoxSum.ReadOnly = true;
|
||||||
|
this.textBoxSum.Size = new System.Drawing.Size(217, 20);
|
||||||
|
this.textBoxSum.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormCreateOrder
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(318, 118);
|
||||||
|
this.Controls.Add(this.labelSum);
|
||||||
|
this.Controls.Add(this.textBoxSum);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.comboBoxProduct);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.labelProduct);
|
||||||
|
this.Name = "FormCreateOrder";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Заказ";
|
||||||
|
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private System.Windows.Forms.Label labelCount;
|
||||||
|
private System.Windows.Forms.ComboBox comboBoxProduct;
|
||||||
|
private System.Windows.Forms.Button buttonCancel;
|
||||||
|
private System.Windows.Forms.Button buttonSave;
|
||||||
|
private System.Windows.Forms.TextBox textBoxCount;
|
||||||
|
private System.Windows.Forms.Label labelProduct;
|
||||||
|
private System.Windows.Forms.Label labelSum;
|
||||||
|
private System.Windows.Forms.TextBox textBoxSum;
|
||||||
|
}
|
||||||
|
}
|
143
FurnitureAssembly/FormCreateOrder.cs
Normal file
143
FurnitureAssembly/FormCreateOrder.cs
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
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 FurnitureAssembly
|
||||||
|
{
|
||||||
|
public partial class FormCreateOrder : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IProductLogic _logicP;
|
||||||
|
private readonly IOrderLogic _logicO;
|
||||||
|
|
||||||
|
public FormCreateOrder(ILogger<FormCreateOrder> logger, IProductLogic logicP, IOrderLogic logicO)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicP = logicP;
|
||||||
|
_logicO = logicO;
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка изделий для заказа");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicP.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxProduct.DisplayMember = "ProductName";
|
||||||
|
comboBoxProduct.ValueMember = "Id";
|
||||||
|
comboBoxProduct.DataSource = list;
|
||||||
|
comboBoxProduct.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка изделий");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CalcSum()
|
||||||
|
{
|
||||||
|
if (comboBoxProduct.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(comboBoxProduct.SelectedValue);
|
||||||
|
|
||||||
|
var Product = _logicP.ReadElement(new ProductSearchModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
});
|
||||||
|
|
||||||
|
int count = Convert.ToInt32(textBoxCount.Text);
|
||||||
|
textBoxSum.Text = Math.Round(count * (Product?.Price ?? 0), 2).ToString();
|
||||||
|
_logger.LogInformation("Расчет суммы заказа");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CountTextBox_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CalcSum();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProductComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CalcSum();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (comboBoxProduct.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Создание заказа");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
ProductId = Convert.ToInt32(comboBoxProduct.SelectedValue),
|
||||||
|
ProductName = comboBoxProduct.Text,
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FurnitureAssembly/FormCreateOrder.resx
Normal file
120
FurnitureAssembly/FormCreateOrder.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>
|
185
FurnitureAssembly/FormMain.Designer.cs
generated
Normal file
185
FurnitureAssembly/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
namespace FurnitureAssembly
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
this.MenuStrip = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.СправочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.CreateOrderButton = new System.Windows.Forms.Button();
|
||||||
|
this.TakeOrderInWorkButton = new System.Windows.Forms.Button();
|
||||||
|
this.OrderReadyButton = new System.Windows.Forms.Button();
|
||||||
|
this.IssuedOrderButton = new System.Windows.Forms.Button();
|
||||||
|
this.UpdateListButton = new System.Windows.Forms.Button();
|
||||||
|
this.MenuStrip.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// MenuStrip
|
||||||
|
//
|
||||||
|
this.MenuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
|
this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.СправочникиToolStripMenuItem});
|
||||||
|
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.MenuStrip.Name = "MenuStrip";
|
||||||
|
this.MenuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
|
||||||
|
this.MenuStrip.Size = new System.Drawing.Size(989, 30);
|
||||||
|
this.MenuStrip.TabIndex = 0;
|
||||||
|
this.MenuStrip.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// СправочникиToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.СправочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.ИзделияToolStripMenuItem,
|
||||||
|
this.КомпонентыToolStripMenuItem});
|
||||||
|
this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
||||||
|
this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
|
||||||
|
this.СправочникиToolStripMenuItem.Text = "Cправочники";
|
||||||
|
//
|
||||||
|
// ИзделияToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
||||||
|
this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.ИзделияToolStripMenuItem.Text = "Компоненты";
|
||||||
|
this.ИзделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// КомпонентыToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
||||||
|
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.КомпонентыToolStripMenuItem.Text = "Изделие";
|
||||||
|
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// DataGridView
|
||||||
|
//
|
||||||
|
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.DataGridView.Location = new System.Drawing.Point(0, 36);
|
||||||
|
this.DataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.DataGridView.Name = "DataGridView";
|
||||||
|
this.DataGridView.RowHeadersWidth = 51;
|
||||||
|
this.DataGridView.RowTemplate.Height = 25;
|
||||||
|
this.DataGridView.Size = new System.Drawing.Size(825, 561);
|
||||||
|
this.DataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// CreateOrderButton
|
||||||
|
//
|
||||||
|
this.CreateOrderButton.Location = new System.Drawing.Point(832, 37);
|
||||||
|
this.CreateOrderButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.CreateOrderButton.Name = "CreateOrderButton";
|
||||||
|
this.CreateOrderButton.Size = new System.Drawing.Size(143, 44);
|
||||||
|
this.CreateOrderButton.TabIndex = 2;
|
||||||
|
this.CreateOrderButton.Text = "Создать заказ";
|
||||||
|
this.CreateOrderButton.UseVisualStyleBackColor = true;
|
||||||
|
this.CreateOrderButton.Click += new System.EventHandler(this.CreateOrderButton_Click);
|
||||||
|
//
|
||||||
|
// TakeOrderInWorkButton
|
||||||
|
//
|
||||||
|
this.TakeOrderInWorkButton.Location = new System.Drawing.Point(832, 111);
|
||||||
|
this.TakeOrderInWorkButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.TakeOrderInWorkButton.Name = "TakeOrderInWorkButton";
|
||||||
|
this.TakeOrderInWorkButton.Size = new System.Drawing.Size(143, 52);
|
||||||
|
this.TakeOrderInWorkButton.TabIndex = 3;
|
||||||
|
this.TakeOrderInWorkButton.Text = "Отдать на выполнение";
|
||||||
|
this.TakeOrderInWorkButton.UseVisualStyleBackColor = true;
|
||||||
|
this.TakeOrderInWorkButton.Click += new System.EventHandler(this.TakeOrderInWorkButton_Click);
|
||||||
|
//
|
||||||
|
// OrderReadyButton
|
||||||
|
//
|
||||||
|
this.OrderReadyButton.Location = new System.Drawing.Point(832, 195);
|
||||||
|
this.OrderReadyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.OrderReadyButton.Name = "OrderReadyButton";
|
||||||
|
this.OrderReadyButton.Size = new System.Drawing.Size(143, 44);
|
||||||
|
this.OrderReadyButton.TabIndex = 4;
|
||||||
|
this.OrderReadyButton.Text = "Заказ готов";
|
||||||
|
this.OrderReadyButton.UseVisualStyleBackColor = true;
|
||||||
|
this.OrderReadyButton.Click += new System.EventHandler(this.OrderReadyButton_Click);
|
||||||
|
//
|
||||||
|
// IssuedOrderButton
|
||||||
|
//
|
||||||
|
this.IssuedOrderButton.Location = new System.Drawing.Point(832, 272);
|
||||||
|
this.IssuedOrderButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.IssuedOrderButton.Name = "IssuedOrderButton";
|
||||||
|
this.IssuedOrderButton.Size = new System.Drawing.Size(143, 44);
|
||||||
|
this.IssuedOrderButton.TabIndex = 5;
|
||||||
|
this.IssuedOrderButton.Text = "Заказ выдан";
|
||||||
|
this.IssuedOrderButton.UseVisualStyleBackColor = true;
|
||||||
|
this.IssuedOrderButton.Click += new System.EventHandler(this.IssuedOrderButton_Click);
|
||||||
|
//
|
||||||
|
// UpdateListButton
|
||||||
|
//
|
||||||
|
this.UpdateListButton.Location = new System.Drawing.Point(832, 349);
|
||||||
|
this.UpdateListButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.UpdateListButton.Name = "UpdateListButton";
|
||||||
|
this.UpdateListButton.Size = new System.Drawing.Size(143, 44);
|
||||||
|
this.UpdateListButton.TabIndex = 6;
|
||||||
|
this.UpdateListButton.Text = "Обновить список";
|
||||||
|
this.UpdateListButton.UseVisualStyleBackColor = true;
|
||||||
|
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(989, 600);
|
||||||
|
this.Controls.Add(this.UpdateListButton);
|
||||||
|
this.Controls.Add(this.IssuedOrderButton);
|
||||||
|
this.Controls.Add(this.OrderReadyButton);
|
||||||
|
this.Controls.Add(this.TakeOrderInWorkButton);
|
||||||
|
this.Controls.Add(this.CreateOrderButton);
|
||||||
|
this.Controls.Add(this.DataGridView);
|
||||||
|
this.Controls.Add(this.MenuStrip);
|
||||||
|
this.MainMenuStrip = this.MenuStrip;
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormMain";
|
||||||
|
this.Text = "Ремонтные Работы";
|
||||||
|
this.MenuStrip.ResumeLayout(false);
|
||||||
|
this.MenuStrip.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
private MenuStrip MenuStrip;
|
||||||
|
private ToolStripMenuItem СправочникиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ИзделияToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem КомпонентыToolStripMenuItem;
|
||||||
|
private DataGridView DataGridView;
|
||||||
|
private Button CreateOrderButton;
|
||||||
|
private Button TakeOrderInWorkButton;
|
||||||
|
private Button OrderReadyButton;
|
||||||
|
private Button IssuedOrderButton;
|
||||||
|
private Button UpdateListButton;
|
||||||
|
}
|
||||||
|
}
|
234
FurnitureAssembly/FormMain.cs
Normal file
234
FurnitureAssembly/FormMain.cs
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||||
|
using FurnitureAssemblyDataModels.Enums;
|
||||||
|
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 FurnitureAssembly
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IOrderLogic _orderLogic;
|
||||||
|
private readonly IReportLogic _reportLogic;
|
||||||
|
|
||||||
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_orderLogic = orderLogic;
|
||||||
|
_reportLogic = reportLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
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["ProductId"].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(FormProducts));
|
||||||
|
|
||||||
|
if (service is FormProducts form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||||
|
|
||||||
|
if (service is FormComponents form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||||
|
|
||||||
|
if (service is FormCreateOrder form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TakeOrderInWorkButton_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,
|
||||||
|
ProductId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ProductId"].Value),
|
||||||
|
ProductName = DataGridView.SelectedRows[0].Cells["ProductName"].Value.ToString(),
|
||||||
|
Status = Enum.Parse<OrderStatus>(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||||
|
Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||||
|
Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||||
|
DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void IssuedOrderButton_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,
|
||||||
|
ProductId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ProductId"].Value),
|
||||||
|
ProductName = DataGridView.SelectedRows[0].Cells["ProductName"].Value.ToString(),
|
||||||
|
Status = Enum.Parse<OrderStatus>(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||||
|
Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||||
|
Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||||
|
DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OrderReadyButton_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,
|
||||||
|
ProductId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ProductId"].Value),
|
||||||
|
ProductName = DataGridView.SelectedRows[0].Cells["ProductName"].Value.ToString(),
|
||||||
|
Status = Enum.Parse<OrderStatus>(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||||
|
Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||||
|
Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||||
|
DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||||
|
});
|
||||||
|
|
||||||
|
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 UpdateListButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void списокИзделийToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_reportLogic.SaveProductsToWordFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = dialog.FileName
|
||||||
|
});
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void компонентыПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportProductComponents));
|
||||||
|
if (service is FormReportProductComponents form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||||
|
if (service is FormReportOrders form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FurnitureAssembly/FormMain.resx
Normal file
120
FurnitureAssembly/FormMain.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>
|
252
FurnitureAssembly/FormProduct.Designer.cs
generated
Normal file
252
FurnitureAssembly/FormProduct.Designer.cs
generated
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
namespace FurnitureAssembly
|
||||||
|
{
|
||||||
|
partial class FormProduct
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||||
|
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||||
|
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||||
|
this.ProductNameLabel = new System.Windows.Forms.Label();
|
||||||
|
this.PriceLabel = new System.Windows.Forms.Label();
|
||||||
|
this.ProductNameTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.PriceTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.ComponentsGroupBox = new System.Windows.Forms.GroupBox();
|
||||||
|
this.UpdateButton = new System.Windows.Forms.Button();
|
||||||
|
this.DeleteButton = new System.Windows.Forms.Button();
|
||||||
|
this.ChangeButton = new System.Windows.Forms.Button();
|
||||||
|
this.AddButton = new System.Windows.Forms.Button();
|
||||||
|
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.ComponentNameField = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.CountField = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.SaveButton = new System.Windows.Forms.Button();
|
||||||
|
this.ComponentsGroupBox.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// ProductNameLabel
|
||||||
|
//
|
||||||
|
this.ProductNameLabel.AutoSize = true;
|
||||||
|
this.ProductNameLabel.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.ProductNameLabel.Name = "ProductNameLabel";
|
||||||
|
this.ProductNameLabel.Size = new System.Drawing.Size(65, 15);
|
||||||
|
this.ProductNameLabel.TabIndex = 0;
|
||||||
|
this.ProductNameLabel.Text = "Название: ";
|
||||||
|
//
|
||||||
|
// PriceLabel
|
||||||
|
//
|
||||||
|
this.PriceLabel.AutoSize = true;
|
||||||
|
this.PriceLabel.Location = new System.Drawing.Point(12, 43);
|
||||||
|
this.PriceLabel.Name = "PriceLabel";
|
||||||
|
this.PriceLabel.Size = new System.Drawing.Size(73, 15);
|
||||||
|
this.PriceLabel.TabIndex = 1;
|
||||||
|
this.PriceLabel.Text = "Стоимость: ";
|
||||||
|
//
|
||||||
|
// ProductNameTextBox
|
||||||
|
//
|
||||||
|
this.ProductNameTextBox.Location = new System.Drawing.Point(83, 6);
|
||||||
|
this.ProductNameTextBox.Name = "ProductNameTextBox";
|
||||||
|
this.ProductNameTextBox.Size = new System.Drawing.Size(283, 23);
|
||||||
|
this.ProductNameTextBox.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// PriceTextBox
|
||||||
|
//
|
||||||
|
this.PriceTextBox.Location = new System.Drawing.Point(83, 40);
|
||||||
|
this.PriceTextBox.Name = "PriceTextBox";
|
||||||
|
this.PriceTextBox.Size = new System.Drawing.Size(283, 23);
|
||||||
|
this.PriceTextBox.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// ComponentsGroupBox
|
||||||
|
//
|
||||||
|
this.ComponentsGroupBox.Controls.Add(this.UpdateButton);
|
||||||
|
this.ComponentsGroupBox.Controls.Add(this.DeleteButton);
|
||||||
|
this.ComponentsGroupBox.Controls.Add(this.ChangeButton);
|
||||||
|
this.ComponentsGroupBox.Controls.Add(this.AddButton);
|
||||||
|
this.ComponentsGroupBox.Controls.Add(this.DataGridView);
|
||||||
|
this.ComponentsGroupBox.Location = new System.Drawing.Point(12, 80);
|
||||||
|
this.ComponentsGroupBox.Name = "ComponentsGroupBox";
|
||||||
|
this.ComponentsGroupBox.Size = new System.Drawing.Size(722, 350);
|
||||||
|
this.ComponentsGroupBox.TabIndex = 5;
|
||||||
|
this.ComponentsGroupBox.TabStop = false;
|
||||||
|
this.ComponentsGroupBox.Text = "Компоненты";
|
||||||
|
//
|
||||||
|
// UpdateButton
|
||||||
|
//
|
||||||
|
this.UpdateButton.Location = new System.Drawing.Point(590, 203);
|
||||||
|
this.UpdateButton.Name = "UpdateButton";
|
||||||
|
this.UpdateButton.Size = new System.Drawing.Size(110, 38);
|
||||||
|
this.UpdateButton.TabIndex = 4;
|
||||||
|
this.UpdateButton.Text = "Обновить";
|
||||||
|
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||||
|
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||||
|
//
|
||||||
|
// DeleteButton
|
||||||
|
//
|
||||||
|
this.DeleteButton.Location = new System.Drawing.Point(590, 143);
|
||||||
|
this.DeleteButton.Name = "DeleteButton";
|
||||||
|
this.DeleteButton.Size = new System.Drawing.Size(110, 38);
|
||||||
|
this.DeleteButton.TabIndex = 3;
|
||||||
|
this.DeleteButton.Text = "Удалить";
|
||||||
|
this.DeleteButton.UseVisualStyleBackColor = true;
|
||||||
|
this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
|
||||||
|
//
|
||||||
|
// ChangeButton
|
||||||
|
//
|
||||||
|
this.ChangeButton.Location = new System.Drawing.Point(590, 82);
|
||||||
|
this.ChangeButton.Name = "ChangeButton";
|
||||||
|
this.ChangeButton.Size = new System.Drawing.Size(110, 38);
|
||||||
|
this.ChangeButton.TabIndex = 2;
|
||||||
|
this.ChangeButton.Text = "Изменить";
|
||||||
|
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||||
|
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||||
|
//
|
||||||
|
// AddButton
|
||||||
|
//
|
||||||
|
this.AddButton.Location = new System.Drawing.Point(590, 22);
|
||||||
|
this.AddButton.Name = "AddButton";
|
||||||
|
this.AddButton.Size = new System.Drawing.Size(110, 38);
|
||||||
|
this.AddButton.TabIndex = 1;
|
||||||
|
this.AddButton.Text = "Добавить";
|
||||||
|
this.AddButton.UseVisualStyleBackColor = true;
|
||||||
|
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||||
|
//
|
||||||
|
// DataGridView
|
||||||
|
//
|
||||||
|
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||||
|
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
|
||||||
|
dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||||
|
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||||
|
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||||
|
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||||
|
this.DataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
|
||||||
|
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.DataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.ID,
|
||||||
|
this.ComponentNameField,
|
||||||
|
this.CountField});
|
||||||
|
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||||
|
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
|
||||||
|
dataGridViewCellStyle2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||||
|
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||||
|
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||||
|
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
||||||
|
this.DataGridView.DefaultCellStyle = dataGridViewCellStyle2;
|
||||||
|
this.DataGridView.Location = new System.Drawing.Point(6, 22);
|
||||||
|
this.DataGridView.Name = "DataGridView";
|
||||||
|
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||||
|
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
|
||||||
|
dataGridViewCellStyle3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||||
|
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||||
|
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||||
|
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||||
|
this.DataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
|
||||||
|
this.DataGridView.RowTemplate.Height = 25;
|
||||||
|
this.DataGridView.Size = new System.Drawing.Size(561, 322);
|
||||||
|
this.DataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ID
|
||||||
|
//
|
||||||
|
this.ID.HeaderText = "ID";
|
||||||
|
this.ID.Name = "ID";
|
||||||
|
this.ID.Visible = false;
|
||||||
|
//
|
||||||
|
// ComponentNameField
|
||||||
|
//
|
||||||
|
this.ComponentNameField.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
this.ComponentNameField.HeaderText = "Компонент";
|
||||||
|
this.ComponentNameField.Name = "ComponentNameField";
|
||||||
|
//
|
||||||
|
// CountField
|
||||||
|
//
|
||||||
|
this.CountField.HeaderText = "Количество";
|
||||||
|
this.CountField.Name = "CountField";
|
||||||
|
//
|
||||||
|
// ButtonCancel
|
||||||
|
//
|
||||||
|
this.ButtonCancel.Location = new System.Drawing.Point(602, 446);
|
||||||
|
this.ButtonCancel.Name = "ButtonCancel";
|
||||||
|
this.ButtonCancel.Size = new System.Drawing.Size(110, 34);
|
||||||
|
this.ButtonCancel.TabIndex = 7;
|
||||||
|
this.ButtonCancel.Text = "Отмена";
|
||||||
|
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// SaveButton
|
||||||
|
//
|
||||||
|
this.SaveButton.Location = new System.Drawing.Point(486, 446);
|
||||||
|
this.SaveButton.Name = "SaveButton";
|
||||||
|
this.SaveButton.Size = new System.Drawing.Size(110, 34);
|
||||||
|
this.SaveButton.TabIndex = 8;
|
||||||
|
this.SaveButton.Text = "Сохранить";
|
||||||
|
this.SaveButton.UseVisualStyleBackColor = true;
|
||||||
|
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||||
|
//
|
||||||
|
// FormProduct
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(746, 498);
|
||||||
|
this.Controls.Add(this.SaveButton);
|
||||||
|
this.Controls.Add(this.ButtonCancel);
|
||||||
|
this.Controls.Add(this.ComponentsGroupBox);
|
||||||
|
this.Controls.Add(this.PriceTextBox);
|
||||||
|
this.Controls.Add(this.ProductNameTextBox);
|
||||||
|
this.Controls.Add(this.PriceLabel);
|
||||||
|
this.Controls.Add(this.ProductNameLabel);
|
||||||
|
this.Name = "FormProduct";
|
||||||
|
this.Text = "Изделие";
|
||||||
|
this.ComponentsGroupBox.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
private Label ProductNameLabel;
|
||||||
|
private Label PriceLabel;
|
||||||
|
private TextBox ProductNameTextBox;
|
||||||
|
private TextBox PriceTextBox;
|
||||||
|
private GroupBox ComponentsGroupBox;
|
||||||
|
private Button UpdateButton;
|
||||||
|
private Button DeleteButton;
|
||||||
|
private Button ChangeButton;
|
||||||
|
private Button AddButton;
|
||||||
|
private DataGridView DataGridView;
|
||||||
|
private DataGridViewTextBoxColumn ID;
|
||||||
|
private DataGridViewTextBoxColumn ComponentNameField;
|
||||||
|
private DataGridViewTextBoxColumn CountField;
|
||||||
|
private Button ButtonCancel;
|
||||||
|
private Button SaveButton;
|
||||||
|
}
|
||||||
|
}
|
237
FurnitureAssembly/FormProduct.cs
Normal file
237
FurnitureAssembly/FormProduct.cs
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
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 FurnitureAssembly
|
||||||
|
{
|
||||||
|
public partial class FormProduct : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IProductLogic _logic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
|
||||||
|
private Dictionary<int, (IComponentModel, int)> _productComponents;
|
||||||
|
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public FormProduct(ILogger<FormProduct> logger, IProductLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
_productComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||||
|
}
|
||||||
|
private void FormProduct_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка изделия");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logic.ReadElement(new ProductSearchModel
|
||||||
|
{
|
||||||
|
Id = _id.Value
|
||||||
|
});
|
||||||
|
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
ProductNameTextBox.Text = view.ProductName;
|
||||||
|
PriceTextBox.Text = view.Price.ToString();
|
||||||
|
_productComponents = view.ProductComponents ?? new Dictionary<int, (IComponentModel, int)>();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки изделия");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка компонент изделия");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_productComponents != null)
|
||||||
|
{
|
||||||
|
DataGridView.Rows.Clear();
|
||||||
|
foreach (var pc in _productComponents)
|
||||||
|
{
|
||||||
|
DataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
||||||
|
}
|
||||||
|
PriceTextBox.Text = CalcPrice().ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent));
|
||||||
|
|
||||||
|
if (service is FormProductComponent form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.ComponentModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||||
|
|
||||||
|
if (_productComponents.ContainsKey(form.Id))
|
||||||
|
{
|
||||||
|
_productComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_productComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent));
|
||||||
|
|
||||||
|
if (service is FormProductComponent form)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
form.Id = id;
|
||||||
|
form.Count = _productComponents[id].Item2;
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.ComponentModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||||
|
_productComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", DataGridView.SelectedRows[0].Cells[1].Value);
|
||||||
|
_productComponents?.Remove(Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ProductNameTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(PriceTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_productComponents == null || _productComponents.Count == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Сохранение изделия");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ProductBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ProductName = ProductNameTextBox.Text,
|
||||||
|
Price = Convert.ToDouble(PriceTextBox.Text),
|
||||||
|
ProductComponents = _productComponents
|
||||||
|
};
|
||||||
|
|
||||||
|
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 _productComponents)
|
||||||
|
{
|
||||||
|
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.Round(price * 1.1, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FurnitureAssembly/FormProduct.resx
Normal file
120
FurnitureAssembly/FormProduct.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>
|
121
FurnitureAssembly/FormProductComponent.Designer.cs
generated
Normal file
121
FurnitureAssembly/FormProductComponent.Designer.cs
generated
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
namespace FurnitureAssembly
|
||||||
|
{
|
||||||
|
partial class FormProductComponent
|
||||||
|
{
|
||||||
|
/// <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.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.labelComponent = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.comboBoxComponent = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(218, 59);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCancel.TabIndex = 5;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(137, 59);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonSave.TabIndex = 4;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// labelComponent
|
||||||
|
//
|
||||||
|
this.labelComponent.AutoSize = true;
|
||||||
|
this.labelComponent.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.labelComponent.Name = "labelComponent";
|
||||||
|
this.labelComponent.Size = new System.Drawing.Size(66, 13);
|
||||||
|
this.labelComponent.TabIndex = 0;
|
||||||
|
this.labelComponent.Text = "Компонент:";
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(87, 33);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(217, 20);
|
||||||
|
this.textBoxCount.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// comboBoxComponent
|
||||||
|
//
|
||||||
|
this.comboBoxComponent.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxComponent.FormattingEnabled = true;
|
||||||
|
this.comboBoxComponent.Location = new System.Drawing.Point(87, 6);
|
||||||
|
this.comboBoxComponent.Name = "comboBoxComponent";
|
||||||
|
this.comboBoxComponent.Size = new System.Drawing.Size(217, 21);
|
||||||
|
this.comboBoxComponent.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(12, 36);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(69, 13);
|
||||||
|
this.labelCount.TabIndex = 2;
|
||||||
|
this.labelCount.Text = "Количество:";
|
||||||
|
//
|
||||||
|
// FormProductComponent
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(320, 96);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.comboBoxComponent);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.labelComponent);
|
||||||
|
this.Name = "FormProductComponent";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Компонент изделия";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button buttonCancel;
|
||||||
|
private System.Windows.Forms.Button buttonSave;
|
||||||
|
private System.Windows.Forms.Label labelComponent;
|
||||||
|
private System.Windows.Forms.TextBox textBoxCount;
|
||||||
|
private System.Windows.Forms.ComboBox comboBoxComponent;
|
||||||
|
private System.Windows.Forms.Label labelCount;
|
||||||
|
}
|
||||||
|
}
|
80
FurnitureAssembly/FormProductComponent.cs
Normal file
80
FurnitureAssembly/FormProductComponent.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
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 FurnitureAssembly
|
||||||
|
{
|
||||||
|
public partial class FormProductComponent : Form
|
||||||
|
{
|
||||||
|
private readonly List<ComponentViewModel>? _list;
|
||||||
|
|
||||||
|
public int Id { get { return Convert.ToInt32(comboBoxComponent.SelectedValue); } set { comboBoxComponent.SelectedValue = value; } }
|
||||||
|
|
||||||
|
public IComponentModel? ComponentModel
|
||||||
|
{
|
||||||
|
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 FormProductComponent(IComponentLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_list = logic.ReadList(null);
|
||||||
|
if (_list != null)
|
||||||
|
{
|
||||||
|
comboBoxComponent.DisplayMember = "ComponentName";
|
||||||
|
comboBoxComponent.ValueMember = "Id";
|
||||||
|
comboBoxComponent.DataSource = _list;
|
||||||
|
comboBoxComponent.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxComponent.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FurnitureAssembly/FormProductComponent.resx
Normal file
120
FurnitureAssembly/FormProductComponent.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>
|
113
FurnitureAssembly/FormProducts.Designer.cs
generated
Normal file
113
FurnitureAssembly/FormProducts.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
namespace FurnitureAssembly
|
||||||
|
{
|
||||||
|
partial class FormProducts
|
||||||
|
{
|
||||||
|
/// <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.AddButton = new System.Windows.Forms.Button();
|
||||||
|
this.ChangeButton = new System.Windows.Forms.Button();
|
||||||
|
this.DeleteButton = new System.Windows.Forms.Button();
|
||||||
|
this.UpdateButton = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// DataGridView
|
||||||
|
//
|
||||||
|
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.DataGridView.Location = new System.Drawing.Point(1, 1);
|
||||||
|
this.DataGridView.Name = "DataGridView";
|
||||||
|
this.DataGridView.RowTemplate.Height = 25;
|
||||||
|
this.DataGridView.Size = new System.Drawing.Size(562, 495);
|
||||||
|
this.DataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// AddButton
|
||||||
|
//
|
||||||
|
this.AddButton.Location = new System.Drawing.Point(585, 12);
|
||||||
|
this.AddButton.Name = "AddButton";
|
||||||
|
this.AddButton.Size = new System.Drawing.Size(120, 41);
|
||||||
|
this.AddButton.TabIndex = 1;
|
||||||
|
this.AddButton.Text = "Добавить";
|
||||||
|
this.AddButton.UseVisualStyleBackColor = true;
|
||||||
|
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||||
|
//
|
||||||
|
// ChangeButton
|
||||||
|
//
|
||||||
|
this.ChangeButton.Location = new System.Drawing.Point(585, 71);
|
||||||
|
this.ChangeButton.Name = "ChangeButton";
|
||||||
|
this.ChangeButton.Size = new System.Drawing.Size(120, 41);
|
||||||
|
this.ChangeButton.TabIndex = 2;
|
||||||
|
this.ChangeButton.Text = "Изменить";
|
||||||
|
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||||
|
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||||
|
//
|
||||||
|
// DeleteButton
|
||||||
|
//
|
||||||
|
this.DeleteButton.Location = new System.Drawing.Point(585, 130);
|
||||||
|
this.DeleteButton.Name = "DeleteButton";
|
||||||
|
this.DeleteButton.Size = new System.Drawing.Size(120, 41);
|
||||||
|
this.DeleteButton.TabIndex = 3;
|
||||||
|
this.DeleteButton.Text = "Удалить";
|
||||||
|
this.DeleteButton.UseVisualStyleBackColor = true;
|
||||||
|
this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
|
||||||
|
//
|
||||||
|
// UpdateButton
|
||||||
|
//
|
||||||
|
this.UpdateButton.Location = new System.Drawing.Point(585, 191);
|
||||||
|
this.UpdateButton.Name = "UpdateButton";
|
||||||
|
this.UpdateButton.Size = new System.Drawing.Size(120, 41);
|
||||||
|
this.UpdateButton.TabIndex = 4;
|
||||||
|
this.UpdateButton.Text = "Обновить";
|
||||||
|
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||||
|
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||||
|
//
|
||||||
|
// FormProducts
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(717, 502);
|
||||||
|
this.Controls.Add(this.UpdateButton);
|
||||||
|
this.Controls.Add(this.DeleteButton);
|
||||||
|
this.Controls.Add(this.ChangeButton);
|
||||||
|
this.Controls.Add(this.AddButton);
|
||||||
|
this.Controls.Add(this.DataGridView);
|
||||||
|
this.Name = "FormProducts";
|
||||||
|
this.Text = "Изделия";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.Load += new System.EventHandler(this.FormProducts_Load);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView DataGridView;
|
||||||
|
private Button AddButton;
|
||||||
|
private Button ChangeButton;
|
||||||
|
private Button DeleteButton;
|
||||||
|
private Button UpdateButton;
|
||||||
|
}
|
||||||
|
}
|
120
FurnitureAssembly/FormProducts.cs
Normal file
120
FurnitureAssembly/FormProducts.cs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
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 FurnitureAssembly
|
||||||
|
{
|
||||||
|
public partial class FormProducts : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IProductLogic _logic;
|
||||||
|
|
||||||
|
public FormProducts(ILogger<FormProducts> logger, IProductLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormProducts_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["ProductName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
DataGridView.Columns["ProductComponents"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Загрузка изделий");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки изделий");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
|
||||||
|
|
||||||
|
if (service is FormProduct form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ChangeButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
|
||||||
|
|
||||||
|
if (service is FormProduct form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void DeleteButton_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 ProductBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления изделия");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void UpdateButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FurnitureAssembly/FormProducts.resx
Normal file
120
FurnitureAssembly/FormProducts.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>
|
131
FurnitureAssembly/FormReportOrders.Designer.cs
generated
Normal file
131
FurnitureAssembly/FormReportOrders.Designer.cs
generated
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
namespace FurnitureAssembly
|
||||||
|
{
|
||||||
|
partial class FormReportOrders
|
||||||
|
{
|
||||||
|
/// <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.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.MakeButton = new System.Windows.Forms.Button();
|
||||||
|
this.ToPdfButton = new System.Windows.Forms.Button();
|
||||||
|
this.panel = new System.Windows.Forms.Panel();
|
||||||
|
this.panel.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dateTimePickerFrom
|
||||||
|
//
|
||||||
|
this.dateTimePickerFrom.Location = new System.Drawing.Point(43, 12);
|
||||||
|
this.dateTimePickerFrom.Name = "dateTimePickerFrom";
|
||||||
|
this.dateTimePickerFrom.Size = new System.Drawing.Size(200, 23);
|
||||||
|
this.dateTimePickerFrom.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// dateTimePickerTo
|
||||||
|
//
|
||||||
|
this.dateTimePickerTo.Location = new System.Drawing.Point(276, 12);
|
||||||
|
this.dateTimePickerTo.Name = "dateTimePickerTo";
|
||||||
|
this.dateTimePickerTo.Size = new System.Drawing.Size(200, 23);
|
||||||
|
this.dateTimePickerTo.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(22, 18);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(15, 15);
|
||||||
|
this.label1.TabIndex = 2;
|
||||||
|
this.label1.Text = "С";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(249, 18);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(21, 15);
|
||||||
|
this.label2.TabIndex = 3;
|
||||||
|
this.label2.Text = "по";
|
||||||
|
//
|
||||||
|
// MakeButton
|
||||||
|
//
|
||||||
|
this.MakeButton.Location = new System.Drawing.Point(517, 12);
|
||||||
|
this.MakeButton.Name = "MakeButton";
|
||||||
|
this.MakeButton.Size = new System.Drawing.Size(105, 23);
|
||||||
|
this.MakeButton.TabIndex = 4;
|
||||||
|
this.MakeButton.Text = "Сформировать";
|
||||||
|
this.MakeButton.UseVisualStyleBackColor = true;
|
||||||
|
this.MakeButton.Click += new System.EventHandler(this.MakeButton_Click);
|
||||||
|
//
|
||||||
|
// ToPdfButton
|
||||||
|
//
|
||||||
|
this.ToPdfButton.Location = new System.Drawing.Point(684, 12);
|
||||||
|
this.ToPdfButton.Name = "ToPdfButton";
|
||||||
|
this.ToPdfButton.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.ToPdfButton.TabIndex = 5;
|
||||||
|
this.ToPdfButton.Text = "В Pdf";
|
||||||
|
this.ToPdfButton.UseVisualStyleBackColor = true;
|
||||||
|
this.ToPdfButton.Click += new System.EventHandler(this.ToPdfButton_Click);
|
||||||
|
//
|
||||||
|
// panel
|
||||||
|
//
|
||||||
|
this.panel.Controls.Add(this.label2);
|
||||||
|
this.panel.Controls.Add(this.ToPdfButton);
|
||||||
|
this.panel.Controls.Add(this.label1);
|
||||||
|
this.panel.Controls.Add(this.MakeButton);
|
||||||
|
this.panel.Controls.Add(this.dateTimePickerFrom);
|
||||||
|
this.panel.Controls.Add(this.dateTimePickerTo);
|
||||||
|
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.panel.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.panel.Name = "panel";
|
||||||
|
this.panel.Size = new System.Drawing.Size(800, 52);
|
||||||
|
this.panel.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// FormReportOrders
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.panel);
|
||||||
|
this.Name = "FormReportOrders";
|
||||||
|
this.Text = "Заказы";
|
||||||
|
this.panel.ResumeLayout(false);
|
||||||
|
this.panel.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DateTimePicker dateTimePickerFrom;
|
||||||
|
private DateTimePicker dateTimePickerTo;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Button MakeButton;
|
||||||
|
private Button ToPdfButton;
|
||||||
|
private Panel panel;
|
||||||
|
}
|
||||||
|
}
|
98
FurnitureAssembly/FormReportOrders.cs
Normal file
98
FurnitureAssembly/FormReportOrders.cs
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Reporting.WinForms;
|
||||||
|
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 FurnitureAssembly
|
||||||
|
{
|
||||||
|
public partial class FormReportOrders : Form
|
||||||
|
{
|
||||||
|
private readonly ReportViewer reportViewer;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IReportLogic _logic;
|
||||||
|
public FormReportOrders(ILogger<FormReportOrders> logger, IReportLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
reportViewer = new ReportViewer
|
||||||
|
{
|
||||||
|
Dock = DockStyle.Fill
|
||||||
|
};
|
||||||
|
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open));
|
||||||
|
Controls.Clear();
|
||||||
|
Controls.Add(reportViewer);
|
||||||
|
Controls.Add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MakeButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dataSource = _logic.GetOrders(new ReportBindingModel
|
||||||
|
{
|
||||||
|
DateFrom = dateTimePickerFrom.Value,
|
||||||
|
DateTo = dateTimePickerTo.Value
|
||||||
|
});
|
||||||
|
var source = new ReportDataSource("DataSetOrders", dataSource);
|
||||||
|
reportViewer.LocalReport.DataSources.Clear();
|
||||||
|
reportViewer.LocalReport.DataSources.Add(source);
|
||||||
|
var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
|
||||||
|
reportViewer.LocalReport.SetParameters(parameters);
|
||||||
|
reportViewer.RefreshReport();
|
||||||
|
_logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка заказов на период");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToPdfButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "pdf|*.pdf"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.SaveOrdersToPdfFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = dialog.FileName,
|
||||||
|
DateFrom = dateTimePickerFrom.Value,
|
||||||
|
DateTo = dateTimePickerTo.Value
|
||||||
|
});
|
||||||
|
_logger.LogInformation("Сохранение списка заказов на период { From} - { To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения списка заказов на период");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FurnitureAssembly/FormReportOrders.resx
Normal file
120
FurnitureAssembly/FormReportOrders.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>
|
102
FurnitureAssembly/FormReportProductComponents.Designer.cs
generated
Normal file
102
FurnitureAssembly/FormReportProductComponents.Designer.cs
generated
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
namespace FurnitureAssembly
|
||||||
|
{
|
||||||
|
partial class FormReportProductComponents
|
||||||
|
{
|
||||||
|
/// <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.SaveToExcelButton = new System.Windows.Forms.Button();
|
||||||
|
this.ComponentColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.ProductColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.CountColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.ComponentColumn,
|
||||||
|
this.ProductColumn,
|
||||||
|
this.CountColumn});
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 38);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(607, 400);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// SaveToExcelButton
|
||||||
|
//
|
||||||
|
this.SaveToExcelButton.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.SaveToExcelButton.Name = "SaveToExcelButton";
|
||||||
|
this.SaveToExcelButton.Size = new System.Drawing.Size(119, 23);
|
||||||
|
this.SaveToExcelButton.TabIndex = 1;
|
||||||
|
this.SaveToExcelButton.Text = "Сохранить в Excel";
|
||||||
|
this.SaveToExcelButton.UseVisualStyleBackColor = true;
|
||||||
|
this.SaveToExcelButton.Click += new System.EventHandler(this.SaveToExcelButton_Click);
|
||||||
|
//
|
||||||
|
// ComponentColumn
|
||||||
|
//
|
||||||
|
this.ComponentColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
this.ComponentColumn.HeaderText = "Компонент";
|
||||||
|
this.ComponentColumn.Name = "ComponentColumn";
|
||||||
|
//
|
||||||
|
// ProductColumn
|
||||||
|
//
|
||||||
|
this.ProductColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
this.ProductColumn.HeaderText = "Изделие";
|
||||||
|
this.ProductColumn.Name = "ProductColumn";
|
||||||
|
//
|
||||||
|
// CountColumn
|
||||||
|
//
|
||||||
|
this.CountColumn.HeaderText = "Количество";
|
||||||
|
this.CountColumn.Name = "CountColumn";
|
||||||
|
//
|
||||||
|
// FormReportProductComponents
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(631, 450);
|
||||||
|
this.Controls.Add(this.SaveToExcelButton);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormReportProductComponents";
|
||||||
|
this.Text = "Компоненты по Изделиям";
|
||||||
|
this.Load += new System.EventHandler(this.FormReportProductComponents_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private DataGridViewTextBoxColumn ComponentColumn;
|
||||||
|
private DataGridViewTextBoxColumn ProductColumn;
|
||||||
|
private DataGridViewTextBoxColumn CountColumn;
|
||||||
|
private Button SaveToExcelButton;
|
||||||
|
}
|
||||||
|
}
|
80
FurnitureAssembly/FormReportProductComponents.cs
Normal file
80
FurnitureAssembly/FormReportProductComponents.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
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 FurnitureAssembly
|
||||||
|
{
|
||||||
|
public partial class FormReportProductComponents : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IReportLogic _logic;
|
||||||
|
public FormReportProductComponents(ILogger<FormReportProductComponents> logger, IReportLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveToExcelButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "xlsx|*.xlsx"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.SaveProductComponentToExcelFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = dialog.FileName
|
||||||
|
});
|
||||||
|
_logger.LogInformation("Сохранение списка изделий по компонентам");
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormReportProductComponents_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dict = _logic.GetProductComponent();
|
||||||
|
if (dict != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var elem in dict)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { elem.ProductName, "", "" });
|
||||||
|
foreach (var listElem in elem.Components)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||||
|
}
|
||||||
|
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
|
||||||
|
dataGridView.Rows.Add(Array.Empty<object>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка списка изделий по компонентам");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FurnitureAssembly/FormReportProductComponents.resx
Normal file
120
FurnitureAssembly/FormReportProductComponents.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>
|
30
FurnitureAssembly/FurnitureAssembly.csproj
Normal file
30
FurnitureAssembly/FurnitureAssembly.csproj
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<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>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
|
||||||
|
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\FurnitureAssemblyFileImplement\FurnitureAssemblyFileImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
61
FurnitureAssembly/FurnitureAssembly.sln
Normal file
61
FurnitureAssembly/FurnitureAssembly.sln
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.3.32929.385
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssembly", "FurnitureAssembly.csproj", "{E1C559D9-85DE-4173-A6C5-FE75B2C9A261}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyDataModels", "..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj", "{C610F257-6EF1-49B7-A6B1-53B0531A1D94}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyContracts", "..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj", "{AD9F4632-FB53-45E2-8B1B-0A6C406C57FA}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyListImplement", "..\FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj", "{D6524F12-93DE-4983-81AD-9703A3488B95}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyBusinessLogic", "..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj", "{95752DB2-8672-4A78-96CF-3F87E83C27B2}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyFileImplement", "..\FurnitureAssemblyFileImplement\FurnitureAssemblyFileImplement.csproj", "{A55CCB0B-73D1-4887-9B25-9747F1E2DFC4}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyDatabaseImplement", "..\FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj", "{FD269542-C15E-4C26-BC6C-FDB93C20D8B5}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{E1C559D9-85DE-4173-A6C5-FE75B2C9A261}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E1C559D9-85DE-4173-A6C5-FE75B2C9A261}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E1C559D9-85DE-4173-A6C5-FE75B2C9A261}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E1C559D9-85DE-4173-A6C5-FE75B2C9A261}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C610F257-6EF1-49B7-A6B1-53B0531A1D94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C610F257-6EF1-49B7-A6B1-53B0531A1D94}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C610F257-6EF1-49B7-A6B1-53B0531A1D94}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C610F257-6EF1-49B7-A6B1-53B0531A1D94}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AD9F4632-FB53-45E2-8B1B-0A6C406C57FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AD9F4632-FB53-45E2-8B1B-0A6C406C57FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AD9F4632-FB53-45E2-8B1B-0A6C406C57FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AD9F4632-FB53-45E2-8B1B-0A6C406C57FA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D6524F12-93DE-4983-81AD-9703A3488B95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D6524F12-93DE-4983-81AD-9703A3488B95}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D6524F12-93DE-4983-81AD-9703A3488B95}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D6524F12-93DE-4983-81AD-9703A3488B95}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{95752DB2-8672-4A78-96CF-3F87E83C27B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{95752DB2-8672-4A78-96CF-3F87E83C27B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{95752DB2-8672-4A78-96CF-3F87E83C27B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{95752DB2-8672-4A78-96CF-3F87E83C27B2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A55CCB0B-73D1-4887-9B25-9747F1E2DFC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A55CCB0B-73D1-4887-9B25-9747F1E2DFC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A55CCB0B-73D1-4887-9B25-9747F1E2DFC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A55CCB0B-73D1-4887-9B25-9747F1E2DFC4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FD269542-C15E-4C26-BC6C-FDB93C20D8B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FD269542-C15E-4C26-BC6C-FDB93C20D8B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FD269542-C15E-4C26-BC6C-FDB93C20D8B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FD269542-C15E-4C26-BC6C-FDB93C20D8B5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {62C4C0F8-6233-4C7D-8958-82D15F880C32}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
57
FurnitureAssembly/Program.cs
Normal file
57
FurnitureAssembly/Program.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using FurnitureAssemblyBusinessLogic.BusinessLogic;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.Implements;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage;
|
||||||
|
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyDatabaseImplement.Implements;
|
||||||
|
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;
|
||||||
|
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
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<IComponentStorage, ComponentStorage>();
|
||||||
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
|
services.AddTransient<IProductStorage, ProductStorage>();
|
||||||
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
|
services.AddTransient<IProductLogic, ProductLogic>();
|
||||||
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
|
services.AddTransient<FormMain>();
|
||||||
|
services.AddTransient<FormComponent>();
|
||||||
|
services.AddTransient<FormComponents>();
|
||||||
|
services.AddTransient<FormCreateOrder>();
|
||||||
|
services.AddTransient<FormProduct>();
|
||||||
|
services.AddTransient<FormProductComponent>();
|
||||||
|
services.AddTransient<FormProducts>();
|
||||||
|
services.AddTransient<FormReportOrders>();
|
||||||
|
services.AddTransient<FormReportProductComponents>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
609
FurnitureAssembly/ReportOrders.rdlc
Normal file
609
FurnitureAssembly/ReportOrders.rdlc
Normal file
@ -0,0 +1,609 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
|
||||||
|
<AutoRefresh>0</AutoRefresh>
|
||||||
|
<DataSources>
|
||||||
|
<DataSource Name="MotorPlantContracts.ViewModels">
|
||||||
|
<ConnectionProperties>
|
||||||
|
<DataProvider>System.Data.DataSet</DataProvider>
|
||||||
|
<ConnectString>/* Local Connection */</ConnectString>
|
||||||
|
</ConnectionProperties>
|
||||||
|
<rd:DataSourceID>bf577a27-98a7-43b2-8beb-1a37d37ce5cd</rd:DataSourceID>
|
||||||
|
</DataSource>
|
||||||
|
</DataSources>
|
||||||
|
<DataSets>
|
||||||
|
<DataSet Name="DataSetOrders">
|
||||||
|
<Query>
|
||||||
|
<DataSourceName>MotorPlantContractsViewModels</DataSourceName>
|
||||||
|
<CommandText>/* Local Query */</CommandText>
|
||||||
|
</Query>
|
||||||
|
<Fields>
|
||||||
|
<Field Name="Id">
|
||||||
|
<DataField>Id</DataField>
|
||||||
|
<rd:TypeName>System.Int32</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
<Field Name="DateCreate">
|
||||||
|
<DataField>DateCreate</DataField>
|
||||||
|
<rd:TypeName>System.DateTime</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
<Field Name="PackageName">
|
||||||
|
<DataField>PackageName</DataField>
|
||||||
|
<rd:TypeName>System.String</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
<Field Name="Sum">
|
||||||
|
<DataField>Sum</DataField>
|
||||||
|
<rd:TypeName>System.Decimal</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
<Field Name="Status">
|
||||||
|
<DataField>Status</DataField>
|
||||||
|
<rd:TypeName>System.String</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
</Fields>
|
||||||
|
<rd:DataSetInfo>
|
||||||
|
<rd:DataSetName>MotorPlantContracts.ViewModels</rd:DataSetName>
|
||||||
|
<rd:TableName>ReportOrderViewModel</rd:TableName>
|
||||||
|
<rd:ObjectDataSourceType>MotorPlantContracts.ViewModels.ReportOrderViewModel, MotorPlantContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
||||||
|
</rd:DataSetInfo>
|
||||||
|
</DataSet>
|
||||||
|
</DataSets>
|
||||||
|
<ReportSections>
|
||||||
|
<ReportSection>
|
||||||
|
<Body>
|
||||||
|
<ReportItems>
|
||||||
|
<Textbox Name="Textbox1">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Заказы</Value>
|
||||||
|
<Style>
|
||||||
|
<FontSize>20pt</FontSize>
|
||||||
|
<FontWeight>Bold</FontWeight>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Textbox1</rd:DefaultName>
|
||||||
|
<Height>0.94396cm</Height>
|
||||||
|
<Width>19.01cm</Width>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
<Textbox Name="ReportParameterPeriod">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Parameters!ReportParameterPeriod.Value</Value>
|
||||||
|
<Style>
|
||||||
|
<FontSize>16pt</FontSize>
|
||||||
|
<FontWeight>Bold</FontWeight>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
|
||||||
|
<Top>0.97924cm</Top>
|
||||||
|
<Height>0.83812cm</Height>
|
||||||
|
<Width>19.01cm</Width>
|
||||||
|
<ZIndex>1</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
<Tablix Name="Tablix1">
|
||||||
|
<TablixBody>
|
||||||
|
<TablixColumns>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>5.20245cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>5.20245cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>3.90599cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>2.19911cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>2.5cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
</TablixColumns>
|
||||||
|
<TablixRows>
|
||||||
|
<TablixRow>
|
||||||
|
<Height>0.79844cm</Height>
|
||||||
|
<TablixCells>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="Textbox2">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Номер</Value>
|
||||||
|
<Style>
|
||||||
|
<FontSize>12pt</FontSize>
|
||||||
|
<FontWeight>Bold</FontWeight>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Textbox2</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="Textbox4">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Дата создания</Value>
|
||||||
|
<Style>
|
||||||
|
<FontSize>12pt</FontSize>
|
||||||
|
<FontWeight>Bold</FontWeight>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Textbox4</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="Textbox6">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Изделие</Value>
|
||||||
|
<Style>
|
||||||
|
<FontSize>12pt</FontSize>
|
||||||
|
<FontWeight>Bold</FontWeight>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Textbox6</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="Textbox8">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Сумма</Value>
|
||||||
|
<Style>
|
||||||
|
<FontSize>12pt</FontSize>
|
||||||
|
<FontWeight>Bold</FontWeight>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Textbox8</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="Textbox3">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Статус</Value>
|
||||||
|
<Style>
|
||||||
|
<FontSize>12pt</FontSize>
|
||||||
|
<FontWeight>Bold</FontWeight>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Textbox3</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
</TablixCells>
|
||||||
|
</TablixRow>
|
||||||
|
<TablixRow>
|
||||||
|
<Height>0.79844cm</Height>
|
||||||
|
<TablixCells>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="Id">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!Id.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Id</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="DateCreate">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!DateCreate.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>DateCreate</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="PackageName">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!PackageName.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>PackageName</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="Sum">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!Sum.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Sum</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="Status">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!Status.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Status</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
</TablixCells>
|
||||||
|
</TablixRow>
|
||||||
|
</TablixRows>
|
||||||
|
</TablixBody>
|
||||||
|
<TablixColumnHierarchy>
|
||||||
|
<TablixMembers>
|
||||||
|
<TablixMember />
|
||||||
|
<TablixMember />
|
||||||
|
<TablixMember />
|
||||||
|
<TablixMember />
|
||||||
|
<TablixMember />
|
||||||
|
</TablixMembers>
|
||||||
|
</TablixColumnHierarchy>
|
||||||
|
<TablixRowHierarchy>
|
||||||
|
<TablixMembers>
|
||||||
|
<TablixMember>
|
||||||
|
<KeepWithGroup>After</KeepWithGroup>
|
||||||
|
</TablixMember>
|
||||||
|
<TablixMember>
|
||||||
|
<Group Name="Подробности" />
|
||||||
|
</TablixMember>
|
||||||
|
</TablixMembers>
|
||||||
|
</TablixRowHierarchy>
|
||||||
|
<DataSetName>DataSetOrders</DataSetName>
|
||||||
|
<Top>1.88792cm</Top>
|
||||||
|
<Height>1.59688cm</Height>
|
||||||
|
<Width>19.01cm</Width>
|
||||||
|
<ZIndex>2</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
</Style>
|
||||||
|
</Tablix>
|
||||||
|
<Textbox Name="Textbox10">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Итого: </Value>
|
||||||
|
<Style>
|
||||||
|
<FontSize>12pt</FontSize>
|
||||||
|
<FontWeight>Bold</FontWeight>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Right</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Textbox10</rd:DefaultName>
|
||||||
|
<Top>4.01849cm</Top>
|
||||||
|
<Left>10.4049cm</Left>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<Width>2.5cm</Width>
|
||||||
|
<ZIndex>3</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
<Textbox Name="Textbox11">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Sum(Fields!Sum.Value, "DataSetOrders")</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Textbox11</rd:DefaultName>
|
||||||
|
<Top>4.01849cm</Top>
|
||||||
|
<Left>13.08128cm</Left>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<Width>2.5cm</Width>
|
||||||
|
<ZIndex>4</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</ReportItems>
|
||||||
|
<Height>2in</Height>
|
||||||
|
<Style />
|
||||||
|
</Body>
|
||||||
|
<Width>7.48425in</Width>
|
||||||
|
<Page>
|
||||||
|
<PageHeight>29.7cm</PageHeight>
|
||||||
|
<PageWidth>21cm</PageWidth>
|
||||||
|
<LeftMargin>2cm</LeftMargin>
|
||||||
|
<RightMargin>2cm</RightMargin>
|
||||||
|
<TopMargin>2cm</TopMargin>
|
||||||
|
<BottomMargin>2cm</BottomMargin>
|
||||||
|
<ColumnSpacing>0.13cm</ColumnSpacing>
|
||||||
|
<Style />
|
||||||
|
</Page>
|
||||||
|
</ReportSection>
|
||||||
|
</ReportSections>
|
||||||
|
<ReportParameters>
|
||||||
|
<ReportParameter Name="ReportParameterPeriod">
|
||||||
|
<DataType>String</DataType>
|
||||||
|
<Nullable>true</Nullable>
|
||||||
|
<Prompt>ReportParameter1</Prompt>
|
||||||
|
</ReportParameter>
|
||||||
|
</ReportParameters>
|
||||||
|
<ReportParametersLayout>
|
||||||
|
<GridLayoutDefinition>
|
||||||
|
<NumberOfColumns>4</NumberOfColumns>
|
||||||
|
<NumberOfRows>2</NumberOfRows>
|
||||||
|
<CellDefinitions>
|
||||||
|
<CellDefinition>
|
||||||
|
<ColumnIndex>0</ColumnIndex>
|
||||||
|
<RowIndex>0</RowIndex>
|
||||||
|
<ParameterName>ReportParameterPeriod</ParameterName>
|
||||||
|
</CellDefinition>
|
||||||
|
</CellDefinitions>
|
||||||
|
</GridLayoutDefinition>
|
||||||
|
</ReportParametersLayout>
|
||||||
|
<rd:ReportUnitType>Cm</rd:ReportUnitType>
|
||||||
|
<rd:ReportID>ca70f6d0-455a-4c36-b883-afc108848da4</rd:ReportID>
|
||||||
|
</Report>
|
15
FurnitureAssembly/nlog.config
Normal file
15
FurnitureAssembly/nlog.config
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?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="log-${shortdate}.log" />
|
||||||
|
</targets>
|
||||||
|
|
||||||
|
<rules>
|
||||||
|
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||||
|
</rules>
|
||||||
|
</nlog>
|
||||||
|
</configuration>
|
120
FurnitureAssemblyBusinessLogic/BusinessLogic/ComponentLogic.cs
Normal file
120
FurnitureAssemblyBusinessLogic/BusinessLogic/ComponentLogic.cs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
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.BusinessLogic
|
||||||
|
{
|
||||||
|
public class ComponentLogic : IComponentLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IComponentStorage _componentStorage;
|
||||||
|
|
||||||
|
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage componentStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_componentStorage = componentStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{Id}", model?.ComponentName, model?.Id);
|
||||||
|
var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? ReadElement(ComponentSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{Id}", model.ComponentName, model.Id);
|
||||||
|
var element = _componentStorage.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(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_componentStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_componentStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_componentStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ComponentBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ComponentName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName));
|
||||||
|
}
|
||||||
|
if (model.Cost <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{Cost}. Id:{Id}", model.ComponentName, model.Cost, model.Id);
|
||||||
|
var element = _componentStorage.GetElement(new ComponentSearchModel
|
||||||
|
{
|
||||||
|
ComponentName = model.ComponentName
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
136
FurnitureAssemblyBusinessLogic/BusinessLogic/OrderLogic.cs
Normal file
136
FurnitureAssemblyBusinessLogic/BusinessLogic/OrderLogic.cs
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
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.BusinessLogic
|
||||||
|
{
|
||||||
|
public class OrderLogic : IOrderLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
|
||||||
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_orderStorage = orderStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
|
||||||
|
if (model.Status != OrderStatus.Неизвестен)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed. Order status incorrect.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
model.Status = OrderStatus.Принят;
|
||||||
|
|
||||||
|
if (_orderStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
model.Status = OrderStatus.Неизвестен;
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
|
||||||
|
if (model.Status + 1 != newStatus)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
model.Status = newStatus;
|
||||||
|
|
||||||
|
if (model.Status == OrderStatus.Выдан)
|
||||||
|
model.DateImplement = DateTime.Now;
|
||||||
|
|
||||||
|
if (_orderStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
model.Status--;
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TakeOrderInWork(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeliveryOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
return StatusUpdate(model, OrderStatus.Готов);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool FinishOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
return StatusUpdate(model, OrderStatus.Выдан);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Order. OrderId:{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;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.ProductId < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.ProductId));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.Count <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.Sum <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. PackageId: { PackageId}", model.Id, model.Sum, model.ProductId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
142
FurnitureAssemblyBusinessLogic/BusinessLogic/ProductLogic.cs
Normal file
142
FurnitureAssemblyBusinessLogic/BusinessLogic/ProductLogic.cs
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
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.BusinessLogic
|
||||||
|
{
|
||||||
|
public class ProductLogic : IProductLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IProductStorage _productStorage;
|
||||||
|
|
||||||
|
public ProductLogic(ILogger<ProductLogic> logger, IProductStorage productStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_productStorage = productStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
|
||||||
|
if (_productStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
|
||||||
|
if (_productStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? ReadElement(ProductSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement. ProductName:{ProductName}.Id:{ Id}", model.ProductName, model.Id);
|
||||||
|
|
||||||
|
var element = _productStorage.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<ProductViewModel>? ReadList(ProductSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. ProductName:{ProductName}.Id:{ Id}", model?.ProductName, model?.Id);
|
||||||
|
|
||||||
|
var list = model == null ? _productStorage.GetFullList() : _productStorage.GetFilteredList(model);
|
||||||
|
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
|
||||||
|
if (_productStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ProductBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(model.ProductName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия изделия", nameof(model.ProductName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.Price <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Product. ProductName:{ProductName}.Price:{ Cost}. Id: { Id}", model.ProductName, model.Price, model.Id);
|
||||||
|
|
||||||
|
var element = _productStorage.GetElement(new ProductSearchModel
|
||||||
|
{
|
||||||
|
ProductName = model.ProductName
|
||||||
|
});
|
||||||
|
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Изделие с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
107
FurnitureAssemblyBusinessLogic/BusinessLogic/ReportLogic.cs
Normal file
107
FurnitureAssemblyBusinessLogic/BusinessLogic/ReportLogic.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage;
|
||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class ReportLogic : IReportLogic
|
||||||
|
{
|
||||||
|
private readonly IComponentStorage _componentStorage;
|
||||||
|
private readonly IProductStorage _productStorage;
|
||||||
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
|
private readonly AbstractSaveToWord _saveToWord;
|
||||||
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
|
public ReportLogic(IProductStorage productStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||||
|
{
|
||||||
|
_productStorage = productStorage;
|
||||||
|
_componentStorage = componentStorage;
|
||||||
|
_orderStorage = orderStorage;
|
||||||
|
_saveToExcel = saveToExcel;
|
||||||
|
_saveToWord = saveToWord;
|
||||||
|
_saveToPdf = saveToPdf;
|
||||||
|
}
|
||||||
|
public List<ReportProductComponentViewModel> GetProductComponent()
|
||||||
|
{
|
||||||
|
var components = _componentStorage.GetFullList();
|
||||||
|
var products = _productStorage.GetFullList();
|
||||||
|
var list = new List<ReportProductComponentViewModel>();
|
||||||
|
foreach (var product in products)
|
||||||
|
{
|
||||||
|
var record = new ReportProductComponentViewModel
|
||||||
|
{
|
||||||
|
ProductName = product.ProductName,
|
||||||
|
Components = new List<Tuple<string, int>>(),
|
||||||
|
TotalCount = 0
|
||||||
|
};
|
||||||
|
foreach (var component in components)
|
||||||
|
{
|
||||||
|
if (product.ProductComponents.ContainsKey(component.Id))
|
||||||
|
{
|
||||||
|
record.Components.Add(new Tuple<string, int>(component.ComponentName, product.ProductComponents[component.Id].Item2));
|
||||||
|
record.TotalCount += product.ProductComponents[component.Id].Item2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.Add(record);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
return _orderStorage.GetFilteredList(new OrderSearchModel
|
||||||
|
{
|
||||||
|
DateFrom = model.DateFrom,
|
||||||
|
DateTo = model.DateTo
|
||||||
|
})
|
||||||
|
.Select(x => new ReportOrdersViewModel
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
DateCreate = x.DateCreate,
|
||||||
|
ProductName = x.ProductName,
|
||||||
|
Sum = x.Sum,
|
||||||
|
Status = x.Status.ToString(),
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public void SaveProductsToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToWord.CreateDoc(new WordInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список изделий",
|
||||||
|
Products = _productStorage.GetFullList()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveProductComponentToExcelFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToExcel.CreateReport(new ExcelInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список изделий",
|
||||||
|
ProductComponents = GetProductComponent()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToPdf.CreateDoc(new PdfInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список заказов",
|
||||||
|
DateFrom = model.DateFrom!.Value,
|
||||||
|
DateTo = model.DateTo!.Value,
|
||||||
|
Orders = GetOrders(model)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||||
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,97 @@
|
|||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public abstract class AbstractSaveToExcel
|
||||||
|
{
|
||||||
|
public void CreateReport(ExcelInfo info)
|
||||||
|
{
|
||||||
|
CreateExcel(info);
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = 1,
|
||||||
|
Text = info.Title,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Title
|
||||||
|
});
|
||||||
|
|
||||||
|
MergeCells(new ExcelMergeParameters
|
||||||
|
{
|
||||||
|
CellFromName = "A1",
|
||||||
|
CellToName = "C1"
|
||||||
|
});
|
||||||
|
|
||||||
|
uint rowIndex = 2;
|
||||||
|
|
||||||
|
foreach (var pc in info.ProductComponents)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = pc.ProductName,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
|
||||||
|
rowIndex++;
|
||||||
|
|
||||||
|
foreach (var component in pc.Components)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "B",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = component.Item1,
|
||||||
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||||
|
});
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "C",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = component.Item2.ToString(),
|
||||||
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||||
|
});
|
||||||
|
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = "Итого",
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "C",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = pc.TotalCount.ToString(),
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveExcel(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void CreateExcel(ExcelInfo info);
|
||||||
|
|
||||||
|
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||||
|
|
||||||
|
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||||
|
|
||||||
|
protected abstract void SaveExcel(ExcelInfo info);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public abstract class AbstractSaveToPdf
|
||||||
|
{
|
||||||
|
public void CreateDoc(PdfInfo info)
|
||||||
|
{
|
||||||
|
CreatePdf(info);
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = info.Title,
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма", "Статус" },
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
foreach (var order in info.Orders)
|
||||||
|
{
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ProductName, order.Sum.ToString(), order.Status },
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
}
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t",
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Rigth
|
||||||
|
});
|
||||||
|
SavePdf(info);
|
||||||
|
}
|
||||||
|
protected abstract void CreatePdf(PdfInfo info);
|
||||||
|
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||||
|
protected abstract void CreateTable(List<string> columns);
|
||||||
|
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||||
|
protected abstract void SavePdf(PdfInfo info);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public abstract class AbstractSaveToWord
|
||||||
|
{
|
||||||
|
public void CreateDoc(WordInfo info)
|
||||||
|
{
|
||||||
|
CreateWord(info);
|
||||||
|
|
||||||
|
CreateParagraph(new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var product in info.Products)
|
||||||
|
{
|
||||||
|
CreateParagraph(new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)>
|
||||||
|
{ (product.ProductName+" - ", new WordTextProperties { Size = "24", Bold=true}),
|
||||||
|
(product.Price.ToString(), new WordTextProperties { Size = "24", })},
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Both
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
SaveWord(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void CreateWord(WordInfo info);
|
||||||
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||||
|
protected abstract void SaveWord(WordInfo info);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums
|
||||||
|
{
|
||||||
|
public enum ExcelStyleInfoType
|
||||||
|
{
|
||||||
|
Title,
|
||||||
|
Text,
|
||||||
|
TextWithBroder
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums
|
||||||
|
{
|
||||||
|
public enum PdfParagraphAlignmentType
|
||||||
|
{
|
||||||
|
Center,
|
||||||
|
Left,
|
||||||
|
Rigth
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums
|
||||||
|
{
|
||||||
|
public enum WordJustificationType
|
||||||
|
{
|
||||||
|
Center,
|
||||||
|
Both
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class ExcelCellParameters
|
||||||
|
{
|
||||||
|
public string ColumnName { get; set; } = string.Empty;
|
||||||
|
public uint RowIndex { get; set; }
|
||||||
|
public string Text { get; set; } = string.Empty;
|
||||||
|
public string CellReference => $"{ColumnName}{RowIndex}";
|
||||||
|
public ExcelStyleInfoType StyleInfo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class ExcelInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<ReportProductComponentViewModel> ProductComponents
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class ExcelMergeParameters
|
||||||
|
{
|
||||||
|
public string CellFromName { get; set; } = string.Empty;
|
||||||
|
public string CellToName { get; set; } = string.Empty;
|
||||||
|
public string Merge => $"{CellFromName}:{CellToName}";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class PdfInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public DateTime DateFrom { get; set; }
|
||||||
|
public DateTime DateTo { get; set; }
|
||||||
|
public List<ReportOrdersViewModel> Orders { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class PdfParagraph
|
||||||
|
{
|
||||||
|
public string Text { get; set; } = string.Empty;
|
||||||
|
public string Style { get; set; } = string.Empty;
|
||||||
|
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class PdfRowParameters
|
||||||
|
{
|
||||||
|
public List<string> Texts { get; set; } = new();
|
||||||
|
public string Style { get; set; } = string.Empty;
|
||||||
|
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<ProductViewModel> Products { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordParagraph
|
||||||
|
{
|
||||||
|
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
||||||
|
public WordTextProperties? TextProperties { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordTextProperties
|
||||||
|
{
|
||||||
|
public string Size { get; set; } = string.Empty;
|
||||||
|
public bool Bold { get; set; }
|
||||||
|
public WordJustificationType JustificationType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,330 @@
|
|||||||
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
|
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
||||||
|
{
|
||||||
|
public class SaveToExcel : AbstractSaveToExcel
|
||||||
|
{
|
||||||
|
|
||||||
|
private SpreadsheetDocument? _spreadsheetDocument;
|
||||||
|
private SharedStringTablePart? _shareStringPart;
|
||||||
|
private Worksheet? _worksheet;
|
||||||
|
|
||||||
|
private static void CreateStyles(WorkbookPart workbookpart)
|
||||||
|
{
|
||||||
|
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
||||||
|
sp.Stylesheet = new Stylesheet();
|
||||||
|
|
||||||
|
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
||||||
|
|
||||||
|
var fontUsual = new Font();
|
||||||
|
fontUsual.Append(new FontSize() { Val = 12D });
|
||||||
|
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||||
|
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
||||||
|
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
||||||
|
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||||
|
|
||||||
|
var fontTitle = new Font();
|
||||||
|
fontTitle.Append(new Bold());
|
||||||
|
fontTitle.Append(new FontSize() { Val = 14D });
|
||||||
|
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||||
|
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
||||||
|
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||||
|
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||||
|
|
||||||
|
fonts.Append(fontUsual);
|
||||||
|
fonts.Append(fontTitle);
|
||||||
|
|
||||||
|
var fills = new Fills() { Count = 2U };
|
||||||
|
|
||||||
|
var fill1 = new Fill();
|
||||||
|
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||||
|
|
||||||
|
var fill2 = new Fill();
|
||||||
|
fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
||||||
|
|
||||||
|
fills.Append(fill1);
|
||||||
|
fills.Append(fill2);
|
||||||
|
|
||||||
|
var borders = new Borders() { Count = 2U };
|
||||||
|
|
||||||
|
var borderNoBorder = new Border();
|
||||||
|
borderNoBorder.Append(new LeftBorder());
|
||||||
|
borderNoBorder.Append(new RightBorder());
|
||||||
|
borderNoBorder.Append(new TopBorder());
|
||||||
|
borderNoBorder.Append(new BottomBorder());
|
||||||
|
borderNoBorder.Append(new DiagonalBorder());
|
||||||
|
|
||||||
|
var borderThin = new Border();
|
||||||
|
|
||||||
|
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||||
|
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
|
|
||||||
|
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
|
||||||
|
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
|
|
||||||
|
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
||||||
|
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
|
|
||||||
|
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
|
||||||
|
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
|
|
||||||
|
borderThin.Append(leftBorder);
|
||||||
|
borderThin.Append(rightBorder);
|
||||||
|
borderThin.Append(topBorder);
|
||||||
|
borderThin.Append(bottomBorder);
|
||||||
|
borderThin.Append(new DiagonalBorder());
|
||||||
|
|
||||||
|
borders.Append(borderNoBorder);
|
||||||
|
borders.Append(borderThin);
|
||||||
|
|
||||||
|
var cellStyleFormats = new CellStyleFormats()
|
||||||
|
{
|
||||||
|
Count = 1U
|
||||||
|
};
|
||||||
|
var cellFormatStyle = new CellFormat()
|
||||||
|
{
|
||||||
|
NumberFormatId = 0U,
|
||||||
|
FontId = 0U,
|
||||||
|
FillId = 0U,
|
||||||
|
BorderId = 0U
|
||||||
|
};
|
||||||
|
|
||||||
|
cellStyleFormats.Append(cellFormatStyle);
|
||||||
|
|
||||||
|
var cellFormats = new CellFormats()
|
||||||
|
{
|
||||||
|
Count = 3U
|
||||||
|
};
|
||||||
|
var cellFormatFont = new CellFormat()
|
||||||
|
{
|
||||||
|
NumberFormatId = 0U,
|
||||||
|
FontId = 0U,
|
||||||
|
FillId = 0U,
|
||||||
|
BorderId = 0U,
|
||||||
|
FormatId = 0U,
|
||||||
|
ApplyFont = true
|
||||||
|
};
|
||||||
|
var cellFormatFontAndBorder = new CellFormat()
|
||||||
|
{
|
||||||
|
NumberFormatId = 0U,
|
||||||
|
FontId = 0U,
|
||||||
|
FillId = 0U,
|
||||||
|
BorderId = 1U,
|
||||||
|
FormatId = 0U,
|
||||||
|
ApplyFont = true,
|
||||||
|
ApplyBorder = true
|
||||||
|
};
|
||||||
|
var cellFormatTitle = new CellFormat()
|
||||||
|
{
|
||||||
|
NumberFormatId = 0U,
|
||||||
|
FontId = 1U,
|
||||||
|
FillId = 0U,
|
||||||
|
BorderId = 0U,
|
||||||
|
FormatId = 0U,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true,
|
||||||
|
Horizontal = HorizontalAlignmentValues.Center
|
||||||
|
},
|
||||||
|
ApplyFont = true
|
||||||
|
};
|
||||||
|
cellFormats.Append(cellFormatFont);
|
||||||
|
cellFormats.Append(cellFormatFontAndBorder);
|
||||||
|
cellFormats.Append(cellFormatTitle);
|
||||||
|
var cellStyles = new CellStyles() { Count = 1U };
|
||||||
|
cellStyles.Append(new CellStyle()
|
||||||
|
{
|
||||||
|
Name = "Normal",
|
||||||
|
FormatId = 0U,
|
||||||
|
BuiltinId = 0U
|
||||||
|
});
|
||||||
|
var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
|
||||||
|
{
|
||||||
|
Count = 0U
|
||||||
|
};
|
||||||
|
|
||||||
|
var tableStyles = new TableStyles()
|
||||||
|
{
|
||||||
|
Count = 0U,
|
||||||
|
DefaultTableStyle = "TableStyleMedium2",
|
||||||
|
DefaultPivotStyle = "PivotStyleLight16"
|
||||||
|
};
|
||||||
|
var stylesheetExtensionList = new StylesheetExtensionList();
|
||||||
|
var stylesheetExtension1 = new StylesheetExtension()
|
||||||
|
{
|
||||||
|
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
|
||||||
|
};
|
||||||
|
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||||
|
stylesheetExtension1.Append(new SlicerStyles()
|
||||||
|
{
|
||||||
|
DefaultSlicerStyle = "SlicerStyleLight1"
|
||||||
|
});
|
||||||
|
var stylesheetExtension2 = new StylesheetExtension()
|
||||||
|
{
|
||||||
|
Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
|
||||||
|
};
|
||||||
|
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||||
|
stylesheetExtension2.Append(new TimelineStyles()
|
||||||
|
{
|
||||||
|
DefaultTimelineStyle = "TimeSlicerStyleLight1"
|
||||||
|
});
|
||||||
|
|
||||||
|
stylesheetExtensionList.Append(stylesheetExtension1);
|
||||||
|
stylesheetExtensionList.Append(stylesheetExtension2);
|
||||||
|
|
||||||
|
sp.Stylesheet.Append(fonts);
|
||||||
|
sp.Stylesheet.Append(fills);
|
||||||
|
sp.Stylesheet.Append(borders);
|
||||||
|
sp.Stylesheet.Append(cellStyleFormats);
|
||||||
|
sp.Stylesheet.Append(cellFormats);
|
||||||
|
sp.Stylesheet.Append(cellStyles);
|
||||||
|
sp.Stylesheet.Append(differentialFormats);
|
||||||
|
sp.Stylesheet.Append(tableStyles);
|
||||||
|
sp.Stylesheet.Append(stylesheetExtensionList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
||||||
|
{
|
||||||
|
return styleInfo switch
|
||||||
|
{
|
||||||
|
ExcelStyleInfoType.Title => 2U,
|
||||||
|
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||||
|
ExcelStyleInfoType.Text => 0U,
|
||||||
|
_ => 0U,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
protected override void CreateExcel(ExcelInfo info)
|
||||||
|
{
|
||||||
|
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||||
|
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||||
|
workbookpart.Workbook = new Workbook();
|
||||||
|
CreateStyles(workbookpart);
|
||||||
|
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any() ? _spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First() : _spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||||
|
|
||||||
|
if (_shareStringPart.SharedStringTable == null)
|
||||||
|
{
|
||||||
|
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||||
|
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||||
|
|
||||||
|
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||||
|
var sheet = new Sheet()
|
||||||
|
{
|
||||||
|
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||||
|
SheetId = 1,
|
||||||
|
Name = "Лист"
|
||||||
|
};
|
||||||
|
sheets.Append(sheet);
|
||||||
|
_worksheet = worksheetPart.Worksheet;
|
||||||
|
}
|
||||||
|
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
||||||
|
{
|
||||||
|
if (_worksheet == null || _shareStringPart == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sheetData = _worksheet.GetFirstChild<SheetData>();
|
||||||
|
|
||||||
|
if (sheetData == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Row row;
|
||||||
|
|
||||||
|
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
||||||
|
{
|
||||||
|
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
row = new Row() { RowIndex = excelParams.RowIndex };
|
||||||
|
sheetData.Append(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cell cell;
|
||||||
|
|
||||||
|
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
||||||
|
{
|
||||||
|
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Cell? refCell = null;
|
||||||
|
foreach (Cell rowCell in row.Elements<Cell>())
|
||||||
|
{
|
||||||
|
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
|
||||||
|
{
|
||||||
|
refCell = rowCell;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var newCell = new Cell()
|
||||||
|
{
|
||||||
|
CellReference = excelParams.CellReference
|
||||||
|
};
|
||||||
|
row.InsertBefore(newCell, refCell);
|
||||||
|
cell = newCell;
|
||||||
|
}
|
||||||
|
|
||||||
|
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
||||||
|
_shareStringPart.SharedStringTable.Save();
|
||||||
|
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
||||||
|
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||||
|
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
||||||
|
}
|
||||||
|
protected override void MergeCells(ExcelMergeParameters excelParams)
|
||||||
|
{
|
||||||
|
if (_worksheet == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MergeCells mergeCells;
|
||||||
|
if (_worksheet.Elements<MergeCells>().Any())
|
||||||
|
{
|
||||||
|
mergeCells = _worksheet.Elements<MergeCells>().First();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mergeCells = new MergeCells();
|
||||||
|
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||||
|
{
|
||||||
|
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().First());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var mergeCell = new MergeCell()
|
||||||
|
{
|
||||||
|
Reference = new StringValue(excelParams.Merge)
|
||||||
|
};
|
||||||
|
mergeCells.Append(mergeCell);
|
||||||
|
}
|
||||||
|
protected override void SaveExcel(ExcelInfo info)
|
||||||
|
{
|
||||||
|
if (_spreadsheetDocument == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||||
|
_spreadsheetDocument.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.DocumentObjectModel.Tables;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
||||||
|
{
|
||||||
|
public class SaveToPdf : AbstractSaveToPdf
|
||||||
|
{
|
||||||
|
private Document? _document;
|
||||||
|
private Section? _section;
|
||||||
|
private Table? _table;
|
||||||
|
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||||
|
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||||
|
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
|
||||||
|
_ => ParagraphAlignment.Justify,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
private static void DefineStyles(Document document)
|
||||||
|
{
|
||||||
|
var style = document.Styles["Normal"];
|
||||||
|
style.Font.Name = "Times New Roman";
|
||||||
|
style.Font.Size = 14;
|
||||||
|
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||||
|
style.Font.Bold = true;
|
||||||
|
}
|
||||||
|
protected override void CreatePdf(PdfInfo info)
|
||||||
|
{
|
||||||
|
_document = new Document();
|
||||||
|
DefineStyles(_document);
|
||||||
|
_section = _document.AddSection();
|
||||||
|
}
|
||||||
|
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||||
|
{
|
||||||
|
if (_section == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||||
|
paragraph.Format.SpaceAfter = "1cm";
|
||||||
|
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||||
|
paragraph.Style = pdfParagraph.Style;
|
||||||
|
}
|
||||||
|
protected override void CreateTable(List<string> columns)
|
||||||
|
{
|
||||||
|
if (_document == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_table = _document.LastSection.AddTable();
|
||||||
|
foreach (var elem in columns)
|
||||||
|
{
|
||||||
|
_table.AddColumn(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||||
|
{
|
||||||
|
if (_table == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var row = _table.AddRow();
|
||||||
|
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||||
|
{
|
||||||
|
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||||
|
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||||
|
{
|
||||||
|
row.Cells[i].Style = rowParameters.Style;
|
||||||
|
}
|
||||||
|
Unit borderWidth = 0.5;
|
||||||
|
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||||
|
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||||
|
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected override void SavePdf(PdfInfo info)
|
||||||
|
{
|
||||||
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
|
{
|
||||||
|
Document = _document
|
||||||
|
};
|
||||||
|
renderer.RenderDocument();
|
||||||
|
renderer.PdfDocument.Save(info.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,129 @@
|
|||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
||||||
|
{
|
||||||
|
public class SaveToWord : AbstractSaveToWord
|
||||||
|
{
|
||||||
|
private WordprocessingDocument? _wordDocument;
|
||||||
|
private Body? _docBody;
|
||||||
|
private static JustificationValues GetJustificationValues(WordJustificationType type)
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
WordJustificationType.Both => JustificationValues.Both,
|
||||||
|
WordJustificationType.Center => JustificationValues.Center,
|
||||||
|
_ => JustificationValues.Left,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SectionProperties CreateSectionProperties()
|
||||||
|
{
|
||||||
|
var properties = new SectionProperties();
|
||||||
|
var pageSize = new PageSize
|
||||||
|
{
|
||||||
|
Orient = PageOrientationValues.Portrait
|
||||||
|
};
|
||||||
|
properties.AppendChild(pageSize);
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
||||||
|
{
|
||||||
|
if (paragraphProperties == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var properties = new ParagraphProperties();
|
||||||
|
|
||||||
|
properties.AppendChild(new Justification()
|
||||||
|
{
|
||||||
|
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
||||||
|
});
|
||||||
|
|
||||||
|
properties.AppendChild(new SpacingBetweenLines
|
||||||
|
{
|
||||||
|
LineRule = LineSpacingRuleValues.Auto
|
||||||
|
});
|
||||||
|
|
||||||
|
properties.AppendChild(new Indentation());
|
||||||
|
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||||
|
{
|
||||||
|
paragraphMarkRunProperties.AppendChild(new FontSize
|
||||||
|
{
|
||||||
|
Val = paragraphProperties.Size
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
properties.AppendChild(paragraphMarkRunProperties);
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateWord(WordInfo info)
|
||||||
|
{
|
||||||
|
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||||
|
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||||
|
mainPart.Document = new Document();
|
||||||
|
_docBody = mainPart.Document.AppendChild(new Body());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateParagraph(WordParagraph paragraph)
|
||||||
|
{
|
||||||
|
if (_docBody == null || paragraph == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var docParagraph = new Paragraph();
|
||||||
|
|
||||||
|
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||||
|
|
||||||
|
foreach (var run in paragraph.Texts)
|
||||||
|
{
|
||||||
|
var docRun = new Run();
|
||||||
|
var properties = new RunProperties();
|
||||||
|
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||||
|
|
||||||
|
if (run.Item2.Bold)
|
||||||
|
{
|
||||||
|
properties.AppendChild(new Bold());
|
||||||
|
}
|
||||||
|
|
||||||
|
docRun.AppendChild(properties);
|
||||||
|
|
||||||
|
docRun.AppendChild(new Text
|
||||||
|
{
|
||||||
|
Text = run.Item1,
|
||||||
|
Space = SpaceProcessingModeValues.Preserve
|
||||||
|
});
|
||||||
|
|
||||||
|
docParagraph.AppendChild(docRun);
|
||||||
|
}
|
||||||
|
_docBody.AppendChild(docParagraph);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SaveWord(WordInfo info)
|
||||||
|
{
|
||||||
|
if (_docBody == null || _wordDocument == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_docBody.AppendChild(CreateSectionProperties());
|
||||||
|
_wordDocument.MainDocumentPart!.Document.Save();
|
||||||
|
_wordDocument.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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 ComponentBindingModel : IComponentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public double Cost { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
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 string ProductName { get; set; }
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int ProductId { 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,20 @@
|
|||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ProductBindingModel : IProductModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public double Price { get; set; }
|
||||||
|
|
||||||
|
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ReportBindingModel
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
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 IComponentLogic
|
||||||
|
{
|
||||||
|
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
|
||||||
|
|
||||||
|
ComponentViewModel? ReadElement(ComponentSearchModel model);
|
||||||
|
|
||||||
|
bool Create(ComponentBindingModel model);
|
||||||
|
|
||||||
|
bool Update(ComponentBindingModel model);
|
||||||
|
|
||||||
|
bool Delete(ComponentBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
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,24 @@
|
|||||||
|
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 IProductLogic
|
||||||
|
{
|
||||||
|
List<ProductViewModel>? ReadList(ProductSearchModel? model);
|
||||||
|
|
||||||
|
ProductViewModel? ReadElement(ProductSearchModel model);
|
||||||
|
|
||||||
|
bool Create(ProductBindingModel model);
|
||||||
|
|
||||||
|
bool Update(ProductBindingModel model);
|
||||||
|
|
||||||
|
bool Delete(ProductBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IReportLogic
|
||||||
|
{
|
||||||
|
List<ReportProductComponentViewModel> GetProductComponent();
|
||||||
|
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||||
|
void SaveProductsToWordFile(ReportBindingModel model);
|
||||||
|
void SaveProductComponentToExcelFile(ReportBindingModel model);
|
||||||
|
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
13
FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj
Normal file
13
FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj
Normal file
@ -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,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ComponentSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
|
||||||
|
public string? ComponentName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs
Normal file
15
FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
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; }
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ProductSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
|
||||||
|
public string? ProductName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -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 IComponentStorage
|
||||||
|
{
|
||||||
|
List<ComponentViewModel> GetFullList();
|
||||||
|
|
||||||
|
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
|
||||||
|
|
||||||
|
ComponentViewModel? GetElement(ComponentSearchModel model);
|
||||||
|
|
||||||
|
ComponentViewModel? Insert(ComponentBindingModel model);
|
||||||
|
|
||||||
|
ComponentViewModel? Update(ComponentBindingModel model);
|
||||||
|
|
||||||
|
ComponentViewModel? Delete(ComponentBindingModel 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 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 IProductStorage
|
||||||
|
{
|
||||||
|
List<ProductViewModel> GetFullList();
|
||||||
|
|
||||||
|
List<ProductViewModel> GetFilteredList(ProductSearchModel model);
|
||||||
|
|
||||||
|
ProductViewModel? GetElement(ProductSearchModel model);
|
||||||
|
|
||||||
|
ProductViewModel? Insert(ProductBindingModel model);
|
||||||
|
|
||||||
|
ProductViewModel? Update(ProductBindingModel model);
|
||||||
|
|
||||||
|
ProductViewModel? Delete(ProductBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
21
FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs
Normal file
21
FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
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 ComponentViewModel : IComponentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Название компонента")]
|
||||||
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Цена")]
|
||||||
|
public double Cost { get; set; }
|
||||||
|
}
|
||||||
|
}
|
37
FurnitureAssemblyContracts/ViewModels/OrderViewModels.cs
Normal file
37
FurnitureAssemblyContracts/ViewModels/OrderViewModels.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using FurnitureAssemblyDataModels.Enums;
|
||||||
|
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 OrderViewModel : IOrderModel
|
||||||
|
{
|
||||||
|
[DisplayName("Номер")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Изделие")]
|
||||||
|
public string ProductName { 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; }
|
||||||
|
}
|
||||||
|
}
|
23
FurnitureAssemblyContracts/ViewModels/ProductViewModel.cs
Normal file
23
FurnitureAssemblyContracts/ViewModels/ProductViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
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 ProductViewModel : IProductModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Название изделия")]
|
||||||
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Цена")]
|
||||||
|
public double Price { get; set; }
|
||||||
|
|
||||||
|
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportOrdersViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public DateTime DateCreate { get; set; }
|
||||||
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
public double Sum { get; set; }
|
||||||
|
public String Status { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportProductComponentViewModel
|
||||||
|
{
|
||||||
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
public int TotalCount { get; set; }
|
||||||
|
public List<Tuple<string, int>> Components { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
21
FurnitureAssemblyDataModels/Enums/OrderStatus.cs
Normal file
21
FurnitureAssemblyDataModels/Enums/OrderStatus.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
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
FurnitureAssemblyDataModels/IId.cs
Normal file
13
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; }
|
||||||
|
}
|
||||||
|
}
|
15
FurnitureAssemblyDataModels/Models/IComponentModel.cs
Normal file
15
FurnitureAssemblyDataModels/Models/IComponentModel.cs
Normal file
@ -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 IComponentModel : IId
|
||||||
|
{
|
||||||
|
string ComponentName { get; }
|
||||||
|
|
||||||
|
double Cost { get; }
|
||||||
|
}
|
||||||
|
}
|
24
FurnitureAssemblyDataModels/Models/IOrderModel.cs
Normal file
24
FurnitureAssemblyDataModels/Models/IOrderModel.cs
Normal file
@ -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 ProductId { get; }
|
||||||
|
|
||||||
|
int Count { get; }
|
||||||
|
|
||||||
|
double Sum { get; }
|
||||||
|
|
||||||
|
OrderStatus Status { get; }
|
||||||
|
|
||||||
|
DateTime DateCreate { get; }
|
||||||
|
|
||||||
|
DateTime? DateImplement { get; }
|
||||||
|
}
|
||||||
|
}
|
17
FurnitureAssemblyDataModels/Models/IProductModel.cs
Normal file
17
FurnitureAssemblyDataModels/Models/IProductModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IProductModel : IId
|
||||||
|
{
|
||||||
|
string ProductName { get; }
|
||||||
|
|
||||||
|
double Price { get; }
|
||||||
|
|
||||||
|
Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using FurnitureAssemblyDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement
|
||||||
|
{
|
||||||
|
public class FurnitureAssemblyDataBase : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-KVE3KO9;Initial Catalog=FurnitureAssemblyDataBaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
public virtual DbSet<Component> Components { set; get; }
|
||||||
|
public virtual DbSet<Product> Products { set; get; }
|
||||||
|
public virtual DbSet<ProductComponent> ProductComponents { set; get; }
|
||||||
|
public virtual DbSet<Order> Orders { set; get; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,97 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ComponentStorage : IComponentStorage
|
||||||
|
{
|
||||||
|
public ComponentViewModel? Delete(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
var element = context.Components.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Components.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
return context.Components.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ComponentName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
return context.Components.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ComponentViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
return context.Components.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? Insert(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
var newComponent = Component.Create(model);
|
||||||
|
|
||||||
|
if (newComponent == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
context.Components.Add(newComponent);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
return newComponent.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? Update(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
var component = context.Components.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class OrderStorage : IOrderStorage
|
||||||
|
{
|
||||||
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Orders.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
return context.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
return context.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
return context.Orders.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
var newOrder = Order.Create(model);
|
||||||
|
|
||||||
|
if (newOrder == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
context.Orders.Add(newOrder);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
return newOrder.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
order.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
return order.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
111
FurnitureAssemblyDatabaseImplement/Implements/ProductStorage.cs
Normal file
111
FurnitureAssemblyDatabaseImplement/Implements/ProductStorage.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ProductStorage : IProductStorage
|
||||||
|
{
|
||||||
|
public ProductViewModel? Delete(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
var element = context.Products.Include(x => x.Components).FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Products.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? GetElement(ProductSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ProductName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
return context.Products.Include(x => x.Components).ThenInclude(x => x.Component).FirstOrDefault(x => (!string.IsNullOrEmpty(model.ProductName) && x.ProductName == model.ProductName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ProductName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
return context.Products.Include(x => x.Components).ThenInclude(x => x.Component).Where(x => x.ProductName.Contains(model.ProductName)).ToList().Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProductViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
return context.Products.Include(x => x.Components).ThenInclude(x => x.Component).ToList().Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? Insert(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
var newProduct = Product.Create(context, model);
|
||||||
|
|
||||||
|
if (newProduct == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Products.Add(newProduct);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
return newProduct.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? Update(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDataBase();
|
||||||
|
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var product = context.Products.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
|
||||||
|
if (product == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
product.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
product.UpdateComponents(context, model);
|
||||||
|
transaction.Commit();
|
||||||
|
|
||||||
|
return product.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
175
FurnitureAssemblyDatabaseImplement/Migrations/20230521172613_InitMigration.Designer.cs
generated
Normal file
175
FurnitureAssemblyDatabaseImplement/Migrations/20230521172613_InitMigration.Designer.cs
generated
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using FurnitureAssemblyDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(FurnitureAssemblyDataBase))]
|
||||||
|
[Migration("20230521172613_InitMigration")]
|
||||||
|
partial class InitMigration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.5")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("ProductId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.ProductComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ProductId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("ProductComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.ProductComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("PackageComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("PackageComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,126 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitMigration : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Components",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Cost = table.Column<double>(type: "float", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Components", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Products",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ProductName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Price = table.Column<double>(type: "float", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Products", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Orders",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ProductId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ProductName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Sum = table.Column<double>(type: "float", nullable: false),
|
||||||
|
Status = table.Column<int>(type: "int", nullable: false),
|
||||||
|
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Orders_Products_ProductId",
|
||||||
|
column: x => x.ProductId,
|
||||||
|
principalTable: "Products",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ProductComponents",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ProductId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ComponentId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ProductComponents", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ProductComponents_Components_ComponentId",
|
||||||
|
column: x => x.ComponentId,
|
||||||
|
principalTable: "Components",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ProductComponents_Products_ProductId",
|
||||||
|
column: x => x.ProductId,
|
||||||
|
principalTable: "Products",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ProductId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ProductId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ProductComponents_ComponentId",
|
||||||
|
table: "ProductComponents",
|
||||||
|
column: "ComponentId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ProductComponents_ProductId",
|
||||||
|
table: "ProductComponents",
|
||||||
|
column: "ProductId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ProductComponents");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Components");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Products");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,172 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using FurnitureAssemblyDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(FurnitureAssemblyDataBase))]
|
||||||
|
partial class FurnitureAssemblyDataBaseModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.5")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("ProductId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.ProductComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ProductId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("ProductComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.ProductComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("PackageComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("PackageComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
65
FurnitureAssemblyDatabaseImplement/Models/Component.cs
Normal file
65
FurnitureAssemblyDatabaseImplement/Models/Component.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Component : IComponentModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public double Cost { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("ComponentId")]
|
||||||
|
public virtual List<ProductComponent> PackageComponents { get; set; } = new();
|
||||||
|
|
||||||
|
public static Component? Create(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Component()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ComponentName = model.ComponentName,
|
||||||
|
Cost = model.Cost
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Component Create(ComponentViewModel model)
|
||||||
|
{
|
||||||
|
return new Component
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ComponentName = model.ComponentName,
|
||||||
|
Cost = model.Cost
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ComponentName = model.ComponentName;
|
||||||
|
Cost = model.Cost;
|
||||||
|
}
|
||||||
|
public ComponentViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ComponentName = ComponentName,
|
||||||
|
Cost = Cost
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
86
FurnitureAssemblyDatabaseImplement/Models/Order.cs
Normal file
86
FurnitureAssemblyDatabaseImplement/Models/Order.cs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Enums;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Order : IOrderModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int ProductId { get; private set; }
|
||||||
|
|
||||||
|
public string ProductName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public double Sum { get; private set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
|
public virtual Product Product { get; set; }
|
||||||
|
|
||||||
|
public static Order? Create(OrderBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Order()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ProductId = model.ProductId,
|
||||||
|
ProductName = model.ProductName,
|
||||||
|
Count = model.Count,
|
||||||
|
Sum = model.Sum,
|
||||||
|
Status = model.Status,
|
||||||
|
DateCreate = model.DateCreate,
|
||||||
|
DateImplement = model.DateImplement
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(OrderBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProductId = model.ProductId;
|
||||||
|
ProductName = model.ProductName;
|
||||||
|
Count = model.Count;
|
||||||
|
Sum = model.Sum;
|
||||||
|
Status = model.Status;
|
||||||
|
DateCreate = model.DateCreate;
|
||||||
|
DateImplement = model.DateImplement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ProductId = ProductId,
|
||||||
|
ProductName = ProductName,
|
||||||
|
Count = Count,
|
||||||
|
Sum = Sum,
|
||||||
|
Status = Status,
|
||||||
|
DateCreate = DateCreate,
|
||||||
|
DateImplement = DateImplement
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
106
FurnitureAssemblyDatabaseImplement/Models/Product.cs
Normal file
106
FurnitureAssemblyDatabaseImplement/Models/Product.cs
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Product : IProductModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public double Price { get; set; }
|
||||||
|
|
||||||
|
private Dictionary<int, (IComponentModel, int)>? _productComponents = null;
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, (IComponentModel, int)> ProductComponents
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_productComponents == null)
|
||||||
|
{
|
||||||
|
_productComponents = Components.ToDictionary(recPC => recPC.ComponentId, recPC => (recPC.Component as IComponentModel, recPC.Count));
|
||||||
|
}
|
||||||
|
return _productComponents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ForeignKey("ProductId")]
|
||||||
|
public virtual List<ProductComponent> Components { get; set; } = new();
|
||||||
|
|
||||||
|
[ForeignKey("ProductId")]
|
||||||
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
|
||||||
|
public static Product Create(FurnitureAssemblyDataBase context, ProductBindingModel model)
|
||||||
|
{
|
||||||
|
return new Product()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ProductName = model.ProductName,
|
||||||
|
Price = model.Price,
|
||||||
|
Components = model.ProductComponents.Select(x => new ProductComponent
|
||||||
|
{
|
||||||
|
Component = context.Components.First(y => y.Id == x.Key),
|
||||||
|
Count = x.Value.Item2
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
ProductName = model.ProductName;
|
||||||
|
Price = model.Price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ProductName = ProductName,
|
||||||
|
Price = Price,
|
||||||
|
ProductComponents = ProductComponents
|
||||||
|
};
|
||||||
|
|
||||||
|
public void UpdateComponents(FurnitureAssemblyDataBase context, ProductBindingModel model)
|
||||||
|
{
|
||||||
|
var productComponents = context.ProductComponents.Where(rec => rec.ProductId == model.Id).ToList();
|
||||||
|
|
||||||
|
if (productComponents != null && productComponents.Count > 0)
|
||||||
|
{ // удалили те, которых нет в модели
|
||||||
|
context.ProductComponents.RemoveRange(productComponents.Where(rec => !model.ProductComponents.ContainsKey(rec.ComponentId)));
|
||||||
|
context.SaveChanges();
|
||||||
|
// обновили количество у существующих записей
|
||||||
|
foreach (var updateComponent in productComponents)
|
||||||
|
{
|
||||||
|
updateComponent.Count = model.ProductComponents[updateComponent.ComponentId].Item2;
|
||||||
|
model.ProductComponents.Remove(updateComponent.ComponentId);
|
||||||
|
}
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
var product = context.Products.First(x => x.Id == Id);
|
||||||
|
|
||||||
|
foreach (var pc in model.ProductComponents)
|
||||||
|
{
|
||||||
|
context.ProductComponents.Add(new ProductComponent
|
||||||
|
{
|
||||||
|
Product = product,
|
||||||
|
Component = context.Components.First(x => x.Id == pc.Key),
|
||||||
|
Count = pc.Value.Item2
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_productComponents = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class ProductComponent
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int ComponentId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
public virtual Component Component { get; set; } = new();
|
||||||
|
public virtual Product Product { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
61
FurnitureAssemblyFileImplement/DateFileSingleton.cs
Normal file
61
FurnitureAssemblyFileImplement/DateFileSingleton.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
using FurnitureAssemblyFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyFileImplement
|
||||||
|
{
|
||||||
|
internal class DataFileSingleton
|
||||||
|
{
|
||||||
|
private static DataFileSingleton? instance;
|
||||||
|
|
||||||
|
private readonly string ComponentFileName = "Component.xml";
|
||||||
|
private readonly string OrderFileName = "Order.xml";
|
||||||
|
private readonly string ProductFileName = "Product.xml";
|
||||||
|
|
||||||
|
public List<Component> Components { get; private set; }
|
||||||
|
public List<Order> Orders { get; private set; }
|
||||||
|
public List<Product> Products { get; private set; }
|
||||||
|
|
||||||
|
public static DataFileSingleton GetInstance()
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
{
|
||||||
|
instance = new DataFileSingleton();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||||
|
public void SaveProducts() => SaveData(Products, ProductFileName, "Products", x => x.GetXElement);
|
||||||
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
|
|
||||||
|
private DataFileSingleton()
|
||||||
|
{
|
||||||
|
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||||
|
Products = LoadData(ProductFileName, "Product", x => Product.Create(x)!)!;
|
||||||
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
|
{
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
return XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new List<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName, Func<T, XElement> selectFunction)
|
||||||
|
{
|
||||||
|
if (data != null)
|
||||||
|
{
|
||||||
|
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,94 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class ComponentStorage : IComponentStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
|
||||||
|
public ComponentStorage()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? Delete(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
var element = source.Components.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
source.Components.Remove(element);
|
||||||
|
source.SaveComponents();
|
||||||
|
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return source.Components.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ComponentName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
return source.Components.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ComponentViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return source.Components.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? Insert(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = source.Components.Count > 0 ? source.Components.Max(x => x.Id) + 1 : 1;
|
||||||
|
var newComponent = Component.Create(model);
|
||||||
|
|
||||||
|
if (newComponent == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
source.Components.Add(newComponent);
|
||||||
|
source.SaveComponents();
|
||||||
|
|
||||||
|
return newComponent.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel? Update(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
var component = source.Components.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
component.Update(model);
|
||||||
|
source.SaveComponents();
|
||||||
|
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
94
FurnitureAssemblyFileImplement/Implements/OrderStorage.cs
Normal file
94
FurnitureAssemblyFileImplement/Implements/OrderStorage.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class OrderStorage : IOrderStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
|
||||||
|
public OrderStorage()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
var element = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
source.Orders.Remove(element);
|
||||||
|
source.SaveOrders();
|
||||||
|
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
return source.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return source.Orders.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1;
|
||||||
|
var newOrder = Order.Create(model);
|
||||||
|
|
||||||
|
if (newOrder == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
source.Orders.Add(newOrder);
|
||||||
|
source.SaveOrders();
|
||||||
|
|
||||||
|
return newOrder.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
order.Update(model);
|
||||||
|
source.SaveOrders();
|
||||||
|
|
||||||
|
return order.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
94
FurnitureAssemblyFileImplement/Implements/ProductStorage.cs
Normal file
94
FurnitureAssemblyFileImplement/Implements/ProductStorage.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using FurnitureAssemblyContracts.BindingModels;
|
||||||
|
using FurnitureAssemblyContracts.SearchModels;
|
||||||
|
using FurnitureAssemblyContracts.StoragesContracts;
|
||||||
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
|
using FurnitureAssemblyFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class ProductStorage : IProductStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
|
||||||
|
public ProductStorage()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? Delete(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
var element = source.Products.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
source.Products.Remove(element);
|
||||||
|
source.SaveProducts();
|
||||||
|
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? GetElement(ProductSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ProductName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return source.Products.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ProductName) && x.ProductName == model.ProductName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ProductName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
return source.Products.Where(x => x.ProductName.Contains(model.ProductName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProductViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return source.Products.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? Insert(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = source.Products.Count > 0 ? source.Products.Max(x => x.Id) + 1 : 1;
|
||||||
|
var newProduct = Product.Create(model);
|
||||||
|
|
||||||
|
if (newProduct == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
source.Products.Add(newProduct);
|
||||||
|
source.SaveProducts();
|
||||||
|
|
||||||
|
return newProduct.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductViewModel? Update(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
var product = source.Products.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
|
if (product == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
product.Update(model);
|
||||||
|
source.SaveProducts();
|
||||||
|
|
||||||
|
return product.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
71
FurnitureAssemblyFileImplement/Models/Component.cs
Normal file
71
FurnitureAssemblyFileImplement/Models/Component.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
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;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyFileImplement.Models
|
||||||
|
{
|
||||||
|
internal class Component : IComponentModel
|
||||||
|
{
|
||||||
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public double Cost { get; set; }
|
||||||
|
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public static Component? Create(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Component()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ComponentName = model.ComponentName,
|
||||||
|
Cost = model.Cost
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Component()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ComponentName = element.Element("ComponentName")!.Value,
|
||||||
|
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ComponentName = model.ComponentName;
|
||||||
|
Cost = model.Cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComponentViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ComponentName = ComponentName,
|
||||||
|
Cost = Cost
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Component",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("ComponentName", ComponentName),
|
||||||
|
new XElement("Cost", Cost.ToString()));
|
||||||
|
}
|
||||||
|
}
|
112
FurnitureAssemblyFileImplement/Models/Order.cs
Normal file
112
FurnitureAssemblyFileImplement/Models/Order.cs
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
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;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyFileImplement.Models
|
||||||
|
{
|
||||||
|
internal class Order : IOrderModel
|
||||||
|
{
|
||||||
|
public int ProductId { get; private set; }
|
||||||
|
|
||||||
|
public string ProductName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
public double Sum { get; private set; }
|
||||||
|
|
||||||
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public static Order? Create(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Order()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ProductId = model.ProductId,
|
||||||
|
ProductName = model.ProductName,
|
||||||
|
Count = model.Count,
|
||||||
|
Sum = model.Sum,
|
||||||
|
Status = model.Status,
|
||||||
|
DateCreate = model.DateCreate,
|
||||||
|
DateImplement = model.DateImplement
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Order? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var order = new Order()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ProductId = Convert.ToInt32(element.Element("ProductId")!.Value),
|
||||||
|
ProductName = element.Element("ProductName")!.Value,
|
||||||
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
|
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||||
|
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null)
|
||||||
|
};
|
||||||
|
|
||||||
|
DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl);
|
||||||
|
order.DateImplement = dateImpl;
|
||||||
|
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ProductId = model.ProductId;
|
||||||
|
ProductName = model.ProductName;
|
||||||
|
Count = model.Count;
|
||||||
|
Sum = model.Sum;
|
||||||
|
Status = model.Status;
|
||||||
|
DateCreate = model.DateCreate;
|
||||||
|
DateImplement = model.DateImplement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ProductId = ProductId,
|
||||||
|
ProductName = ProductName,
|
||||||
|
Count = Count,
|
||||||
|
Sum = Sum,
|
||||||
|
Status = Status,
|
||||||
|
DateCreate = DateCreate,
|
||||||
|
DateImplement = DateImplement
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Order",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("ProductName", ProductName),
|
||||||
|
new XElement("ProductId", ProductId.ToString()),
|
||||||
|
new XElement("Count", Count.ToString()),
|
||||||
|
new XElement("Sum", Sum.ToString()),
|
||||||
|
new XElement("Status", Status.ToString()),
|
||||||
|
new XElement("DateCreate", DateCreate.ToString()),
|
||||||
|
new XElement("DateImplement", DateImplement.ToString()));
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user