Compare commits
No commits in common. "bcabf2053472fe233224da6482ae7f6ff9a403fa" and "707fe27294f910b134431e1b9e5257f42c7f8561" have entirely different histories.
bcabf20534
...
707fe27294
@ -13,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairBusinessLogic
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairListImplement", "PlumbingRepairListImplement\PlumbingRepairListImplement.csproj", "{E89CA82F-2FEA-4235-93A2-E5A412D0116F}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairListImplement", "PlumbingRepairListImplement\PlumbingRepairListImplement.csproj", "{E89CA82F-2FEA-4235-93A2-E5A412D0116F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepairFileImplement", "PlumbingRepairFileImplement\PlumbingRepairFileImplement.csproj", "{CF58BB85-A6FB-4581-940D-BB7D1AB815CD}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -41,10 +39,6 @@ Global
|
|||||||
{E89CA82F-2FEA-4235-93A2-E5A412D0116F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E89CA82F-2FEA-4235-93A2-E5A412D0116F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E89CA82F-2FEA-4235-93A2-E5A412D0116F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E89CA82F-2FEA-4235-93A2-E5A412D0116F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E89CA82F-2FEA-4235-93A2-E5A412D0116F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E89CA82F-2FEA-4235-93A2-E5A412D0116F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{CF58BB85-A6FB-4581-940D-BB7D1AB815CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{CF58BB85-A6FB-4581-940D-BB7D1AB815CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{CF58BB85-A6FB-4581-940D-BB7D1AB815CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{CF58BB85-A6FB-4581-940D-BB7D1AB815CD}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
//
|
//
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(10, 8);
|
dataGridView.Location = new Point(10, 8);
|
||||||
dataGridView.Margin = new Padding(2);
|
dataGridView.Margin = new Padding(2, 2, 2, 2);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowHeadersWidth = 62;
|
dataGridView.RowHeadersWidth = 62;
|
||||||
dataGridView.RowTemplate.Height = 33;
|
dataGridView.RowTemplate.Height = 33;
|
||||||
@ -50,7 +50,7 @@
|
|||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
buttonAdd.Location = new Point(547, 33);
|
buttonAdd.Location = new Point(547, 33);
|
||||||
buttonAdd.Margin = new Padding(2);
|
buttonAdd.Margin = new Padding(2, 2, 2, 2);
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(108, 27);
|
buttonAdd.Size = new Size(108, 27);
|
||||||
buttonAdd.TabIndex = 1;
|
buttonAdd.TabIndex = 1;
|
||||||
@ -61,7 +61,7 @@
|
|||||||
// buttonDel
|
// buttonDel
|
||||||
//
|
//
|
||||||
buttonDel.Location = new Point(547, 85);
|
buttonDel.Location = new Point(547, 85);
|
||||||
buttonDel.Margin = new Padding(2);
|
buttonDel.Margin = new Padding(2, 2, 2, 2);
|
||||||
buttonDel.Name = "buttonDel";
|
buttonDel.Name = "buttonDel";
|
||||||
buttonDel.Size = new Size(108, 27);
|
buttonDel.Size = new Size(108, 27);
|
||||||
buttonDel.TabIndex = 2;
|
buttonDel.TabIndex = 2;
|
||||||
@ -72,7 +72,7 @@
|
|||||||
// buttonChange
|
// buttonChange
|
||||||
//
|
//
|
||||||
buttonChange.Location = new Point(547, 147);
|
buttonChange.Location = new Point(547, 147);
|
||||||
buttonChange.Margin = new Padding(2);
|
buttonChange.Margin = new Padding(2, 2, 2, 2);
|
||||||
buttonChange.Name = "buttonChange";
|
buttonChange.Name = "buttonChange";
|
||||||
buttonChange.Size = new Size(108, 27);
|
buttonChange.Size = new Size(108, 27);
|
||||||
buttonChange.TabIndex = 3;
|
buttonChange.TabIndex = 3;
|
||||||
@ -83,7 +83,7 @@
|
|||||||
// buttonRef
|
// buttonRef
|
||||||
//
|
//
|
||||||
buttonRef.Location = new Point(547, 209);
|
buttonRef.Location = new Point(547, 209);
|
||||||
buttonRef.Margin = new Padding(2);
|
buttonRef.Margin = new Padding(2, 2, 2, 2);
|
||||||
buttonRef.Name = "buttonRef";
|
buttonRef.Name = "buttonRef";
|
||||||
buttonRef.Size = new Size(108, 27);
|
buttonRef.Size = new Size(108, 27);
|
||||||
buttonRef.TabIndex = 4;
|
buttonRef.TabIndex = 4;
|
||||||
@ -101,10 +101,9 @@
|
|||||||
Controls.Add(buttonDel);
|
Controls.Add(buttonDel);
|
||||||
Controls.Add(buttonAdd);
|
Controls.Add(buttonAdd);
|
||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Margin = new Padding(2);
|
Margin = new Padding(2, 2, 2, 2);
|
||||||
Name = "FormComponents";
|
Name = "FormComponents";
|
||||||
Text = "Компоненты";
|
Text = "Компоненты";
|
||||||
Load += FormComponents_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ namespace PlumbingRepairView
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
LoadData();
|
|
||||||
}
|
}
|
||||||
private void FormComponents_Load(object sender, EventArgs e)
|
private void FormComponents_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
//
|
//
|
||||||
buttonTakeOrderInWork.Location = new Point(850, 135);
|
buttonTakeOrderInWork.Location = new Point(850, 135);
|
||||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||||
buttonTakeOrderInWork.Size = new Size(170, 50);
|
buttonTakeOrderInWork.Size = new Size(170, 29);
|
||||||
buttonTakeOrderInWork.TabIndex = 3;
|
buttonTakeOrderInWork.TabIndex = 3;
|
||||||
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||||
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||||
|
156
PlumbingRepair/PlumbingRepair/FormWorks.Designer.cs
generated
156
PlumbingRepair/PlumbingRepair/FormWorks.Designer.cs
generated
@ -26,85 +26,85 @@
|
|||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
dataGridView = new DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
buttonAdd = new Button();
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
buttonUpd = new Button();
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
buttonDel = new Button();
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
buttonRef = new Button();
|
this.buttonRef = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(1, 0);
|
this.dataGridView.Location = new System.Drawing.Point(1, 0);
|
||||||
dataGridView.Name = "dataGridView";
|
this.dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowHeadersWidth = 51;
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
dataGridView.RowTemplate.Height = 29;
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
dataGridView.Size = new Size(611, 449);
|
this.dataGridView.Size = new System.Drawing.Size(611, 449);
|
||||||
dataGridView.TabIndex = 0;
|
this.dataGridView.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
buttonAdd.Location = new Point(670, 23);
|
this.buttonAdd.Location = new System.Drawing.Point(670, 23);
|
||||||
buttonAdd.Name = "buttonAdd";
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(94, 29);
|
this.buttonAdd.Size = new System.Drawing.Size(94, 29);
|
||||||
buttonAdd.TabIndex = 1;
|
this.buttonAdd.TabIndex = 1;
|
||||||
buttonAdd.Text = "Добавить";
|
this.buttonAdd.Text = "Добавить";
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
buttonAdd.Click += AddButton_Click;
|
this.buttonAdd.Click += new System.EventHandler(this.AddButton_Click);
|
||||||
//
|
//
|
||||||
// buttonUpd
|
// buttonUpd
|
||||||
//
|
//
|
||||||
buttonUpd.Location = new Point(670, 75);
|
this.buttonUpd.Location = new System.Drawing.Point(670, 75);
|
||||||
buttonUpd.Name = "buttonUpd";
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
buttonUpd.Size = new Size(94, 29);
|
this.buttonUpd.Size = new System.Drawing.Size(94, 29);
|
||||||
buttonUpd.TabIndex = 2;
|
this.buttonUpd.TabIndex = 2;
|
||||||
buttonUpd.Text = "Изменить";
|
this.buttonUpd.Text = "Изменить";
|
||||||
buttonUpd.UseVisualStyleBackColor = true;
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
buttonUpd.Click += ChangeButton_Click;
|
this.buttonUpd.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||||
//
|
//
|
||||||
// buttonDel
|
// buttonDel
|
||||||
//
|
//
|
||||||
buttonDel.Location = new Point(670, 132);
|
this.buttonDel.Location = new System.Drawing.Point(670, 132);
|
||||||
buttonDel.Name = "buttonDel";
|
this.buttonDel.Name = "buttonDel";
|
||||||
buttonDel.Size = new Size(94, 29);
|
this.buttonDel.Size = new System.Drawing.Size(94, 29);
|
||||||
buttonDel.TabIndex = 3;
|
this.buttonDel.TabIndex = 3;
|
||||||
buttonDel.Text = "Удалить";
|
this.buttonDel.Text = "Удалить";
|
||||||
buttonDel.UseVisualStyleBackColor = true;
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
buttonDel.Click += DeleteButton_Click;
|
this.buttonDel.Click += new System.EventHandler(this.DeleteButton_Click);
|
||||||
//
|
//
|
||||||
// buttonRef
|
// buttonRef
|
||||||
//
|
//
|
||||||
buttonRef.Location = new Point(670, 188);
|
this.buttonRef.Location = new System.Drawing.Point(670, 188);
|
||||||
buttonRef.Name = "buttonRef";
|
this.buttonRef.Name = "buttonRef";
|
||||||
buttonRef.Size = new Size(94, 29);
|
this.buttonRef.Size = new System.Drawing.Size(94, 29);
|
||||||
buttonRef.TabIndex = 4;
|
this.buttonRef.TabIndex = 4;
|
||||||
buttonRef.Text = "Обновить";
|
this.buttonRef.Text = "Обновить";
|
||||||
buttonRef.UseVisualStyleBackColor = true;
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
buttonRef.Click += UpdateButton_Click;
|
this.buttonRef.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||||
//
|
//
|
||||||
// FormWorks
|
// FormWorks
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
Controls.Add(buttonRef);
|
this.Controls.Add(this.buttonRef);
|
||||||
Controls.Add(buttonDel);
|
this.Controls.Add(this.buttonDel);
|
||||||
Controls.Add(buttonUpd);
|
this.Controls.Add(this.buttonUpd);
|
||||||
Controls.Add(buttonAdd);
|
this.Controls.Add(this.buttonAdd);
|
||||||
Controls.Add(dataGridView);
|
this.Controls.Add(this.dataGridView);
|
||||||
Name = "FormWorks";
|
this.Name = "FormWorks";
|
||||||
Text = "Работы";
|
this.Text = "Работы";
|
||||||
Load += FormComponents_Load;
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
this.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private Button buttonAdd;
|
private Button buttonAdd;
|
||||||
private Button buttonUpd;
|
private Button buttonUpd;
|
||||||
|
@ -1,120 +1,120 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
|
|
||||||
Version 2.0
|
Version 2.0
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
The primary goals of this format is to allow a simple XML format
|
||||||
that is mostly human readable. The generation and parsing of the
|
that is mostly human readable. The generation and parsing of the
|
||||||
various data types are done through the TypeConverter classes
|
various data types are done through the TypeConverter classes
|
||||||
associated with the data types.
|
associated with the data types.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
... ado.net/XML headers & schema ...
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
<resheader name="version">2.0</resheader>
|
<resheader name="version">2.0</resheader>
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, 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="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="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<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>
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
<comment>This is a comment</comment>
|
<comment>This is a comment</comment>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
There are any number of "resheader" rows that contain simple
|
||||||
name/value pairs.
|
name/value pairs.
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
Each data row contains a name, and value. The row also contains a
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
text/value conversion through the TypeConverter architecture.
|
text/value conversion through the TypeConverter architecture.
|
||||||
Classes that don't support this are serialized and stored with the
|
Classes that don't support this are serialized and stored with the
|
||||||
mimetype set.
|
mimetype set.
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
The mimetype is used for serialized objects, and tells the
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
read any of the formats listed below.
|
read any of the formats listed below.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
value : The object must be serialized into a byte array
|
value : The object must be serialized into a byte array
|
||||||
: using a System.ComponentModel.TypeConverter
|
: using a System.ComponentModel.TypeConverter
|
||||||
: and then encoded with base64 encoding.
|
: 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: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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
<xsd:choice maxOccurs="unbounded">
|
<xsd:choice maxOccurs="unbounded">
|
||||||
<xsd:element name="metadata">
|
<xsd:element name="metadata">
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
<xsd:attribute ref="xml:space" />
|
<xsd:attribute ref="xml:space" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
<xsd:element name="assembly">
|
<xsd:element name="assembly">
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
<xsd:element name="data">
|
<xsd:element name="data">
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
<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:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
<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="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
<xsd:attribute ref="xml:space" />
|
<xsd:attribute ref="xml:space" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
<xsd:element name="resheader">
|
<xsd:element name="resheader">
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
</xsd:choice>
|
</xsd:choice>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
</xsd:schema>
|
</xsd:schema>
|
||||||
<resheader name="resmimetype">
|
<resheader name="resmimetype">
|
||||||
<value>text/microsoft-resx</value>
|
<value>text/microsoft-resx</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="version">
|
<resheader name="version">
|
||||||
<value>2.0</value>
|
<value>2.0</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="reader">
|
<resheader name="reader">
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
</root>
|
</root>
|
@ -15,7 +15,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PlumbingRepairBusinessLogic\PlumbingRepairBusinessLogic.csproj" />
|
<ProjectReference Include="..\PlumbingRepairBusinessLogic\PlumbingRepairBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\PlumbingRepairContracts\PlumbingRepairContracts.csproj" />
|
<ProjectReference Include="..\PlumbingRepairContracts\PlumbingRepairContracts.csproj" />
|
||||||
<ProjectReference Include="..\PlumbingRepairFileImplement\PlumbingRepairFileImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\PlumbingRepairListImplement\PlumbingRepairListImplement.csproj" />
|
<ProjectReference Include="..\PlumbingRepairListImplement\PlumbingRepairListImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
using PlumbingRepairContracts.StoragesContracts;
|
||||||
using PlumbingRepairFileImplement.Implements;
|
using PlumbingRepairListImplement.Implements;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
|
@ -17,15 +17,11 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
private readonly IStoreLogic _storeLogic;
|
|
||||||
private readonly IWorkStorage _workStorage;
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage
|
||||||
orderStorage, IStoreLogic storeLogic, IWorkStorage workStorage)
|
orderStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
_storeLogic = storeLogic;
|
|
||||||
_workStorage = workStorage;
|
|
||||||
}
|
}
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
@ -78,12 +74,8 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||||
{
|
{
|
||||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
CheckModel(model);
|
||||||
if (viewModel == null)
|
if (model.Status + 1 != newStatus)
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (viewModel.Status + 1 != newStatus)
|
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
||||||
return false;
|
return false;
|
||||||
@ -91,27 +83,8 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
model.Status = newStatus;
|
model.Status = newStatus;
|
||||||
|
|
||||||
if (model.Status == OrderStatus.Готов)
|
if (model.Status == OrderStatus.Выдан)
|
||||||
{
|
|
||||||
model.DateImplement = DateTime.Now;
|
model.DateImplement = DateTime.Now;
|
||||||
var work = _workStorage.GetElement(new() { Id = viewModel.WorkId });
|
|
||||||
|
|
||||||
if (work == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(work));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_storeLogic.AddWork(work, viewModel.Count))
|
|
||||||
{
|
|
||||||
throw new Exception($"AddWork operation failed. Store is full.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
model.DateImplement = viewModel.DateImplement;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckModel(model, false);
|
|
||||||
|
|
||||||
if (_orderStorage.Update(model) == null)
|
if (_orderStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
|
@ -31,30 +31,29 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
if (quantity <= 0)
|
if (quantity <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Количество изделий должно быть больше 0", nameof(quantity));
|
throw new ArgumentException("Количество добавляемого изделия должно быть больше 0", nameof(quantity));
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("AddWork. StoreName:{StoreName}.Id:{ Id}", model.StoreName, model.Id);
|
_logger.LogInformation("AddWorkInStore. StoreName:{StoreName}.Id:{ Id}", model.StoreName, model.Id);
|
||||||
var element = _storeStorage.GetElement(model);
|
var element = _storeStorage.GetElement(model);
|
||||||
|
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("AddWork element not found");
|
_logger.LogWarning("AddWorkInStore element not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (element.WorkMaxCount - element.StoreWorks.Select(x => x.Value.Item2).Sum() < quantity)
|
|
||||||
|
_logger.LogInformation("AddWorkInStore find. Id:{Id}", element.Id);
|
||||||
|
|
||||||
|
if (element.Works.TryGetValue(work.Id, out var pair))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Магазин переполнен", nameof(quantity));
|
element.Works[work.Id] = (work, quantity + pair.Item2);
|
||||||
}
|
_logger.LogInformation("AddWorkInStore. Has been added {quantity} {work} in {StoreName}", quantity, work.WorkName, element.StoreName);
|
||||||
if (element.StoreWorks.TryGetValue(work.Id, out var pair))
|
|
||||||
{
|
|
||||||
element.StoreWorks[work.Id] = (work, quantity + pair.Item2);
|
|
||||||
_logger.LogInformation("AddWork. Added {quantity} {work} to '{StoreName}' store", quantity, work.WorkName, element.StoreName);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
element.StoreWorks[work.Id] = (work, quantity);
|
element.Works[work.Id] = (work, quantity);
|
||||||
_logger.LogInformation("AddWork. Added {quantity} new package {package} to '{StoreName}' store", quantity, work.WorkName, element.StoreName);
|
_logger.LogInformation("AddWorkInShop. Has been added {quantity} new Work {work} in {StoreName}", quantity, work.WorkName, element.StoreName);
|
||||||
}
|
}
|
||||||
|
|
||||||
_storeStorage.Update(new()
|
_storeStorage.Update(new()
|
||||||
@ -63,63 +62,15 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
StoreAdress = element.StoreAdress,
|
StoreAdress = element.StoreAdress,
|
||||||
StoreName = element.StoreName,
|
StoreName = element.StoreName,
|
||||||
OpeningDate = element.OpeningDate,
|
OpeningDate = element.OpeningDate,
|
||||||
WorkMaxCount = element.WorkMaxCount,
|
Works = element.Works
|
||||||
StoreWorks = element.StoreWorks
|
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AddWork(IWorkModel work, int quantity)
|
|
||||||
{
|
|
||||||
if (work == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(work));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (quantity <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Количество добавляемого изделия должно быть больше 0", nameof(quantity));
|
|
||||||
}
|
|
||||||
|
|
||||||
var freePlaces = _storeStorage.GetFullList()
|
|
||||||
.Select(x => x.WorkMaxCount - x.StoreWorks
|
|
||||||
.Select(p => p.Value.Item2).Sum()).Sum() - quantity;
|
|
||||||
|
|
||||||
if (freePlaces < 0)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("AddWork. Failed to add work to store. It's full.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var store in _storeStorage.GetFullList())
|
|
||||||
{
|
|
||||||
var temp = Math.Min(quantity, store.WorkMaxCount - store.StoreWorks.Select(x => x.Value.Item2).Sum());
|
|
||||||
|
|
||||||
if (temp <= 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!AddWork(new() { Id = store.Id }, work, temp))
|
|
||||||
{
|
|
||||||
_logger.LogWarning("An error occurred while adding work to stores");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
quantity -= temp;
|
|
||||||
|
|
||||||
if (quantity == 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(StoreBindingModel model)
|
public bool Create(StoreBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
model.StoreWorks = new();
|
model.Works = new();
|
||||||
|
|
||||||
if (_storeStorage.Insert(model) == null)
|
if (_storeStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
@ -179,10 +130,6 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
public bool SellWork(IWorkModel work, int quantity)
|
|
||||||
{
|
|
||||||
return _storeStorage.SellWork(work, quantity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(StoreBindingModel model)
|
public bool Update(StoreBindingModel model)
|
||||||
{
|
{
|
||||||
@ -218,11 +165,6 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
throw new ArgumentNullException("Нет названия магазина", nameof(model.StoreName));
|
throw new ArgumentNullException("Нет названия магазина", nameof(model.StoreName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.WorkMaxCount < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Максимальное количество изделий в магазине не может быть меньше нуля", nameof(model.WorkMaxCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Store. StoreName:{0}.StoreAdress:{1}. Id: {2}", model.StoreName, model.StoreAdress, model.Id);
|
_logger.LogInformation("Store. StoreName:{0}.StoreAdress:{1}. Id: {2}", model.StoreName, model.StoreAdress, model.Id);
|
||||||
var element = _storeStorage.GetElement(new StoreSearchModel
|
var element = _storeStorage.GetElement(new StoreSearchModel
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,6 @@ namespace PlumbingRepairContracts.BindingModels
|
|||||||
public string StoreName { get; set; } = string.Empty;
|
public string StoreName { get; set; } = string.Empty;
|
||||||
public string StoreAdress { get; set; } = string.Empty;
|
public string StoreAdress { get; set; } = string.Empty;
|
||||||
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||||
public Dictionary<int, (IWorkModel, int)> StoreWorks { get; set; } = new();
|
public Dictionary<int, (IWorkModel, int)> Works { get; set; } = new();
|
||||||
public int WorkMaxCount { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,5 @@ namespace PlumbingRepairContracts.BusinessLogicsContracts
|
|||||||
bool Update(StoreBindingModel model);
|
bool Update(StoreBindingModel model);
|
||||||
bool Delete(StoreBindingModel model);
|
bool Delete(StoreBindingModel model);
|
||||||
bool AddWork(StoreSearchModel model, IWorkModel work, int quantity);
|
bool AddWork(StoreSearchModel model, IWorkModel work, int quantity);
|
||||||
bool AddWork(IWorkModel package, int quantity);
|
|
||||||
bool SellWork(IWorkModel package, int quantity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
using PlumbingRepairContracts.BindingModels;
|
||||||
using PlumbingRepairContracts.SearchModels;
|
using PlumbingRepairContracts.SearchModels;
|
||||||
using PlumbingRepairContracts.ViewModels;
|
using PlumbingRepairContracts.ViewModels;
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -18,6 +17,5 @@ namespace PlumbingRepairContracts.StoragesContracts
|
|||||||
StoreViewModel? Insert(StoreBindingModel model);
|
StoreViewModel? Insert(StoreBindingModel model);
|
||||||
StoreViewModel? Update(StoreBindingModel model);
|
StoreViewModel? Update(StoreBindingModel model);
|
||||||
StoreViewModel? Delete(StoreBindingModel model);
|
StoreViewModel? Delete(StoreBindingModel model);
|
||||||
bool SellWork(IWorkModel model, int quantity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace PlumbingRepairContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class StoreViewModel : IStoreModel
|
public class StoreViewModel : IStoreModel
|
||||||
{
|
{
|
||||||
public Dictionary<int, (IWorkModel, int)> StoreWorks { get; set; } = new();
|
public Dictionary<int, (IWorkModel, int)> Works { get; set; } = new();
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("Название магазина")]
|
[DisplayName("Название магазина")]
|
||||||
@ -19,7 +19,5 @@ namespace PlumbingRepairContracts.ViewModels
|
|||||||
public string StoreAdress { get; set; } = string.Empty;
|
public string StoreAdress { get; set; } = string.Empty;
|
||||||
[DisplayName("Дата открытия")]
|
[DisplayName("Дата открытия")]
|
||||||
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||||
[DisplayName("Вместимость магазина")]
|
|
||||||
public int WorkMaxCount { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ namespace PlumbingRepairDataModels.Models
|
|||||||
string StoreName { get; }
|
string StoreName { get; }
|
||||||
string StoreAdress { get; }
|
string StoreAdress { get; }
|
||||||
DateTime OpeningDate { get; }
|
DateTime OpeningDate { get; }
|
||||||
Dictionary<int, (IWorkModel, int)> StoreWorks { get; }
|
Dictionary<int, (IWorkModel, int)> Works { get; }
|
||||||
public int WorkMaxCount { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
using PlumbingRepairFileImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement
|
|
||||||
{
|
|
||||||
internal class DataFileSingleton
|
|
||||||
{
|
|
||||||
private static DataFileSingleton? instance;
|
|
||||||
private readonly string ComponentFileName = "Component.xml";
|
|
||||||
private readonly string OrderFileName = "Order.xml";
|
|
||||||
private readonly string WorkFileName = "Work.xml";
|
|
||||||
private readonly string StoreFileName = "Store.xml";
|
|
||||||
public List<Component> Components { get; private set; }
|
|
||||||
public List<Order> Orders { get; private set; }
|
|
||||||
public List<Work> Works { get; private set; }
|
|
||||||
public List<Store> Stores { 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 SaveWorks() => SaveData(Works, WorkFileName,
|
|
||||||
"Works", x => x.GetXElement);
|
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName,
|
|
||||||
"Orders", x => x.GetXElement);
|
|
||||||
public void SaveStores() => SaveData(Stores, StoreFileName,
|
|
||||||
"Stores", x => x.GetXElement);
|
|
||||||
private DataFileSingleton()
|
|
||||||
{
|
|
||||||
Components = LoadData(ComponentFileName, "Component", x =>
|
|
||||||
Component.Create(x)!)!;
|
|
||||||
Works = LoadData(WorkFileName, "Work", x =>
|
|
||||||
Work.Create(x)!)!;
|
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
|
||||||
Stores = LoadData(StoreFileName, "Store", x => Store.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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairFileImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class ComponentStorage : IComponentStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
public ComponentStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Components
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
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 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 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;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairFileImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
|
|
||||||
public OrderStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Orders.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
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 OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using PlumbingRepairFileImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class StoreStorage : IStoreStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
|
|
||||||
public StoreStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public StoreViewModel? GetElement(StoreSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.StoreName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return source.Stores.FirstOrDefault(x =>
|
|
||||||
(!string.IsNullOrEmpty(model.StoreName) && x.StoreName ==
|
|
||||||
model.StoreName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<StoreViewModel> GetFilteredList(StoreSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.StoreName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
return source.Stores.Where(x =>
|
|
||||||
x.StoreName.Contains(model.StoreName)).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<StoreViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Stores.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public StoreViewModel? Insert(StoreBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Stores.Count > 0 ? source.Stores.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newStore = Store.Create(model);
|
|
||||||
if (newStore == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
source.Stores.Add(newStore);
|
|
||||||
source.SaveStores();
|
|
||||||
return newStore.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StoreViewModel? Update(StoreBindingModel model)
|
|
||||||
{
|
|
||||||
var store = source.Stores.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (store == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
store.Update(model);
|
|
||||||
source.SaveStores();
|
|
||||||
return store.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StoreViewModel? Delete(StoreBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Stores.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Stores.Remove(element);
|
|
||||||
source.SaveStores();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SellWork(IWorkModel model, int quantity)
|
|
||||||
{
|
|
||||||
if (source.Stores.Select(x => x.StoreWorks.FirstOrDefault(y => y.Key == model.Id).Value.Item2).Sum() < quantity)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
foreach (var store in source.Stores.Where(x => x.StoreWorks.ContainsKey(model.Id)))
|
|
||||||
{
|
|
||||||
int QuantityInCurrentShop = store.StoreWorks[model.Id].Item2;
|
|
||||||
if (QuantityInCurrentShop <= quantity)
|
|
||||||
{
|
|
||||||
store.StoreWorks.Remove(model.Id);
|
|
||||||
quantity -= QuantityInCurrentShop;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
store.StoreWorks[model.Id] = (store.StoreWorks[model.Id].Item1, QuantityInCurrentShop - quantity);
|
|
||||||
quantity = 0;
|
|
||||||
}
|
|
||||||
if (quantity == 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairFileImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class WorkStorage : IWorkStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
|
|
||||||
public WorkStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WorkViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Works.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WorkViewModel> GetFilteredList(WorkSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.WorkName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.Works.Where(x => x.WorkName.Contains(model.WorkName)).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? GetElement(WorkSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.WorkName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.Works.FirstOrDefault(x => (!string.IsNullOrEmpty(model.WorkName) && x.WorkName == model.WorkName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? Insert(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Works.Count > 0 ? source.Works.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newWork = Work.Create(model);
|
|
||||||
|
|
||||||
if (newWork == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
source.Works.Add(newWork);
|
|
||||||
source.SaveWorks();
|
|
||||||
|
|
||||||
return newWork.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? Update(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
var work = source.Works.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (work == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
work.Update(model);
|
|
||||||
source.SaveWorks();
|
|
||||||
|
|
||||||
return work.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? Delete(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Works.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Works.Remove(element);
|
|
||||||
source.SaveWorks();
|
|
||||||
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Component : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
|
||||||
public double Cost { get; 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()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Enums;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public int WorkId { get; private set; }
|
|
||||||
public String WorkName { 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 static Order? Create(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
WorkId = model.WorkId,
|
|
||||||
WorkName = model.WorkName,
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
WorkId = Convert.ToInt32(element.Element("WorkId")!.Value),
|
|
||||||
WorkName = element.Element("WorkName")!.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 = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
|
||||||
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null
|
|
||||||
: Convert.ToDateTime(element.Element("DateImplement")!.Value)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Count = model.Count;
|
|
||||||
Sum = model.Sum;
|
|
||||||
Status = model.Status;
|
|
||||||
DateCreate = model.DateCreate;
|
|
||||||
DateImplement = model.DateImplement;
|
|
||||||
}
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
WorkId = WorkId,
|
|
||||||
WorkName = WorkName,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
Status = Status,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement,
|
|
||||||
};
|
|
||||||
public XElement GetXElement => new("Order",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("WorkName", WorkName),
|
|
||||||
new XElement("WorkId", WorkId.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()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Store : IStoreModel
|
|
||||||
{
|
|
||||||
public string StoreName { get; private set; } = string.Empty;
|
|
||||||
public string StoreAdress { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public DateTime OpeningDate { get; private set; }
|
|
||||||
public Dictionary<int, int> Works { get; private set; } = new();
|
|
||||||
|
|
||||||
public Dictionary<int, (IWorkModel, int)> _storeWorks = null;
|
|
||||||
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int WorkMaxCount { get; private set; }
|
|
||||||
|
|
||||||
public Dictionary<int, (IWorkModel, int)> StoreWorks
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_storeWorks == null)
|
|
||||||
{
|
|
||||||
var source = DataFileSingleton.GetInstance();
|
|
||||||
_storeWorks = Works.ToDictionary(x => x.Key, y => ((source.Works.FirstOrDefault(z => z.Id == y.Key) as IWorkModel)!, y.Value));
|
|
||||||
}
|
|
||||||
return _storeWorks;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Store? Create(StoreBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Store()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
StoreName = model.StoreName,
|
|
||||||
StoreAdress = model.StoreAdress,
|
|
||||||
WorkMaxCount = model.WorkMaxCount,
|
|
||||||
OpeningDate = model.OpeningDate,
|
|
||||||
Works = model.StoreWorks.ToDictionary(x => x.Key, x => x.Value.Item2)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static Store? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
StoreName = element.Element("StoreName")!.Value,
|
|
||||||
StoreAdress = element.Element("StoreAdress")!.Value,
|
|
||||||
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
|
|
||||||
WorkMaxCount = Convert.ToInt32(element.Element("WorkMaxCount")!.Value),
|
|
||||||
Works = element.Element("StoreWorks")!.Elements("Work").ToDictionary(
|
|
||||||
x => Convert.ToInt32(x.Element("Key")?.Value),
|
|
||||||
x => Convert.ToInt32(x.Element("Value")?.Value))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(StoreBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
StoreName = model.StoreName;
|
|
||||||
StoreAdress = model.StoreAdress;
|
|
||||||
OpeningDate = model.OpeningDate;
|
|
||||||
WorkMaxCount = model.WorkMaxCount;
|
|
||||||
Works = model.StoreWorks.ToDictionary(x => x.Key, x => x.Value.Item2);
|
|
||||||
_storeWorks = null;
|
|
||||||
}
|
|
||||||
public StoreViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
StoreName = StoreName,
|
|
||||||
StoreAdress = StoreAdress,
|
|
||||||
StoreWorks = StoreWorks,
|
|
||||||
OpeningDate = OpeningDate,
|
|
||||||
WorkMaxCount = WorkMaxCount,
|
|
||||||
};
|
|
||||||
public XElement GetXElement => new("Store",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("StoreName", StoreName),
|
|
||||||
new XElement("StoreAdress", StoreAdress),
|
|
||||||
new XElement("OpeningDate", OpeningDate),
|
|
||||||
new XElement("WorkMaxCount", WorkMaxCount),
|
|
||||||
new XElement("StoreWorks", Works
|
|
||||||
.Select(x => new XElement("Work",
|
|
||||||
new XElement("Key", x.Key),
|
|
||||||
new XElement("Value", x.Value))
|
|
||||||
).ToArray()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Work : IWorkModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string WorkName { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
public Dictionary<int, int> Components { get; private set; } = new();
|
|
||||||
private Dictionary<int, (IComponentModel, int)>? _workComponents = null;
|
|
||||||
public Dictionary<int, (IComponentModel, int)> WorkComponents
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if(_workComponents == null)
|
|
||||||
{
|
|
||||||
var source = DataFileSingleton.GetInstance();
|
|
||||||
_workComponents = Components.ToDictionary(x => x.Key, y =>
|
|
||||||
((source.Components.FirstOrDefault(z => z.Id == y.Key)
|
|
||||||
as IComponentModel)!, y.Value));
|
|
||||||
}
|
|
||||||
return _workComponents;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static Work? Create(WorkBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Work()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
WorkName = model.WorkName,
|
|
||||||
Price = model.Price,
|
|
||||||
Components = model.WorkComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static Work? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Work()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
WorkName = element.Element("WorkName")!.Value,
|
|
||||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
|
||||||
Components = element.Element("WorkComponents")!.Elements("WorkComponent")
|
|
||||||
.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(WorkBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WorkName = model.WorkName;
|
|
||||||
Price = model.Price;
|
|
||||||
Components = model.WorkComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
|
|
||||||
_workComponents = null;
|
|
||||||
}
|
|
||||||
public WorkViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
WorkName = WorkName,
|
|
||||||
Price = Price,
|
|
||||||
WorkComponents = WorkComponents
|
|
||||||
};
|
|
||||||
public XElement GetXElement => new("Work",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("WorkName", WorkName),
|
|
||||||
new XElement("Price", Price.ToString()),
|
|
||||||
new XElement("WorkComponents", Components.Select(x =>
|
|
||||||
new XElement("WorkComponent",
|
|
||||||
new XElement("Key", x.Key),
|
|
||||||
new XElement("Value", x.Value))).ToArray()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\PlumbingRepairContracts\PlumbingRepairContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\PlumbingRepairDataModels\PlumbingRepairDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -2,7 +2,6 @@
|
|||||||
using PlumbingRepairContracts.SearchModels;
|
using PlumbingRepairContracts.SearchModels;
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
using PlumbingRepairContracts.StoragesContracts;
|
||||||
using PlumbingRepairContracts.ViewModels;
|
using PlumbingRepairContracts.ViewModels;
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using PlumbingRepairListImplement.Models;
|
using PlumbingRepairListImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -106,10 +105,7 @@ namespace PlumbingRepairListImplement.Implements
|
|||||||
|
|
||||||
return newStore.GetViewModel;
|
return newStore.GetViewModel;
|
||||||
}
|
}
|
||||||
public bool SellWork(IWorkModel model, int quantity)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
public StoreViewModel? Update(StoreBindingModel model)
|
public StoreViewModel? Update(StoreBindingModel model)
|
||||||
{
|
{
|
||||||
foreach (var store in _source.Stores)
|
foreach (var store in _source.Stores)
|
||||||
|
@ -16,7 +16,7 @@ namespace PlumbingRepairListImplement.Models
|
|||||||
|
|
||||||
public DateTime OpeningDate { get; private set; }
|
public DateTime OpeningDate { get; private set; }
|
||||||
|
|
||||||
public Dictionary<int, (IWorkModel, int)> StoreWorks { get; private set; } = new();
|
public Dictionary<int, (IWorkModel, int)> Works { get; private set; } = new();
|
||||||
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ namespace PlumbingRepairListImplement.Models
|
|||||||
StoreName = model.StoreName,
|
StoreName = model.StoreName,
|
||||||
StoreAdress = model.StoreAdress,
|
StoreAdress = model.StoreAdress,
|
||||||
OpeningDate = model.OpeningDate,
|
OpeningDate = model.OpeningDate,
|
||||||
StoreWorks = new()
|
Works = new()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ namespace PlumbingRepairListImplement.Models
|
|||||||
StoreName = model.StoreName;
|
StoreName = model.StoreName;
|
||||||
StoreAdress = model.StoreAdress;
|
StoreAdress = model.StoreAdress;
|
||||||
OpeningDate = model.OpeningDate;
|
OpeningDate = model.OpeningDate;
|
||||||
StoreWorks = model.StoreWorks;
|
Works = model.Works;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StoreViewModel GetViewModel => new()
|
public StoreViewModel GetViewModel => new()
|
||||||
@ -54,8 +54,7 @@ namespace PlumbingRepairListImplement.Models
|
|||||||
StoreName = StoreName,
|
StoreName = StoreName,
|
||||||
StoreAdress = StoreAdress,
|
StoreAdress = StoreAdress,
|
||||||
OpeningDate = OpeningDate,
|
OpeningDate = OpeningDate,
|
||||||
StoreWorks = StoreWorks
|
Works = Works
|
||||||
};
|
};
|
||||||
public int WorkMaxCount => throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user