PIbd-22. Stroev V.M. Lab Work Hard 02 #9

Closed
StroevVladimir wants to merge 8 commits from Lab2_Hard into Lab1_Hard
12 changed files with 695 additions and 340 deletions
Showing only changes of commit 4cdaf389a5 - Show all commits

View File

@ -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, 2, 2, 2); dataGridView.Margin = new Padding(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, 2, 2, 2); buttonAdd.Margin = new Padding(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, 2, 2, 2); buttonDel.Margin = new Padding(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, 2, 2, 2); buttonChange.Margin = new Padding(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, 2, 2, 2); buttonRef.Margin = new Padding(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,9 +101,10 @@
Controls.Add(buttonDel); Controls.Add(buttonDel);
Controls.Add(buttonAdd); Controls.Add(buttonAdd);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Margin = new Padding(2, 2, 2, 2); Margin = new Padding(2);
Name = "FormComponents"; Name = "FormComponents";
Text = "Компоненты"; Text = "Компоненты";
Load += FormComponents_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }

View File

@ -97,7 +97,7 @@
// //
buttonTakeOrderInWork.Location = new Point(608, 132); buttonTakeOrderInWork.Location = new Point(608, 132);
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonTakeOrderInWork.Size = new Size(170, 29); buttonTakeOrderInWork.Size = new Size(170, 50);
buttonTakeOrderInWork.TabIndex = 3; buttonTakeOrderInWork.TabIndex = 3;
buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonTakeOrderInWork.Text = "Отдать на выполнение";
buttonTakeOrderInWork.UseVisualStyleBackColor = true; buttonTakeOrderInWork.UseVisualStyleBackColor = true;

View File

@ -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()
{ {
this.dataGridView = new System.Windows.Forms.DataGridView(); dataGridView = new DataGridView();
this.buttonAdd = new System.Windows.Forms.Button(); buttonAdd = new Button();
this.buttonUpd = new System.Windows.Forms.Button(); buttonUpd = new Button();
this.buttonDel = new System.Windows.Forms.Button(); buttonDel = new Button();
this.buttonRef = new System.Windows.Forms.Button(); buttonRef = new Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
this.SuspendLayout(); SuspendLayout();
// //
// dataGridView // dataGridView
// //
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(1, 0); dataGridView.Location = new Point(1, 0);
this.dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51; dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29; dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(611, 449); dataGridView.Size = new Size(611, 449);
this.dataGridView.TabIndex = 0; dataGridView.TabIndex = 0;
// //
// buttonAdd // buttonAdd
// //
this.buttonAdd.Location = new System.Drawing.Point(670, 23); buttonAdd.Location = new Point(670, 23);
this.buttonAdd.Name = "buttonAdd"; buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(94, 29); buttonAdd.Size = new Size(94, 29);
this.buttonAdd.TabIndex = 1; buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить"; buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true; buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.AddButton_Click); buttonAdd.Click += AddButton_Click;
// //
// buttonUpd // buttonUpd
// //
this.buttonUpd.Location = new System.Drawing.Point(670, 75); buttonUpd.Location = new Point(670, 75);
this.buttonUpd.Name = "buttonUpd"; buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(94, 29); buttonUpd.Size = new Size(94, 29);
this.buttonUpd.TabIndex = 2; buttonUpd.TabIndex = 2;
this.buttonUpd.Text = "Изменить"; buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true; buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ChangeButton_Click); buttonUpd.Click += ChangeButton_Click;
// //
// buttonDel // buttonDel
// //
this.buttonDel.Location = new System.Drawing.Point(670, 132); buttonDel.Location = new Point(670, 132);
this.buttonDel.Name = "buttonDel"; buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(94, 29); buttonDel.Size = new Size(94, 29);
this.buttonDel.TabIndex = 3; buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить"; buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true; buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.DeleteButton_Click); buttonDel.Click += DeleteButton_Click;
// //
// buttonRef // buttonRef
// //
this.buttonRef.Location = new System.Drawing.Point(670, 188); buttonRef.Location = new Point(670, 188);
this.buttonRef.Name = "buttonRef"; buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(94, 29); buttonRef.Size = new Size(94, 29);
this.buttonRef.TabIndex = 4; buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить"; buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true; buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.UpdateButton_Click); buttonRef.Click += UpdateButton_Click;
// //
// FormWorks // FormWorks
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); ClientSize = new Size(800, 450);
this.Controls.Add(this.buttonRef); Controls.Add(buttonRef);
this.Controls.Add(this.buttonDel); Controls.Add(buttonDel);
this.Controls.Add(this.buttonUpd); Controls.Add(buttonUpd);
this.Controls.Add(this.buttonAdd); Controls.Add(buttonAdd);
this.Controls.Add(this.dataGridView); Controls.Add(dataGridView);
this.Name = "FormWorks"; Name = "FormWorks";
this.Text = "Работы"; Text = "Работы";
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); Load += FormComponents_Load;
this.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
} }
#endregion #endregion
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonAdd; private Button buttonAdd;
private Button buttonUpd; private Button buttonUpd;

View File

@ -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>

View File

@ -15,6 +15,7 @@
<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>

View File

@ -1,53 +1,53 @@
using PlumbingRepairContracts.BusinessLogicsContracts; using PlumbingRepairContracts.BusinessLogicsContracts;
using PlumbingRepairContracts.StoragesContracts; using PlumbingRepairContracts.StoragesContracts;
using PlumbingRepairListImplement.Implements; using PlumbingRepairFileImplement.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;
using PlumbingRepairBusinessLogic.BusinessLogics; using PlumbingRepairBusinessLogic.BusinessLogics;
namespace PlumbingRepairView namespace PlumbingRepairView
{ {
internal static class Program internal static class Program
{ {
private static ServiceProvider? _serviceProvider; private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider; public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() static void Main()
{ {
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
var services = new ServiceCollection(); var services = new ServiceCollection();
ConfigureServices(services); ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider(); _serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>()); Application.Run(_serviceProvider.GetRequiredService<FormMain>());
} }
private static void ConfigureServices(ServiceCollection services) private static void ConfigureServices(ServiceCollection services)
{ {
services.AddLogging(option => services.AddLogging(option =>
{ {
option.SetMinimumLevel(LogLevel.Information); option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config"); option.AddNLog("nlog.config");
}); });
services.AddTransient<IComponentStorage, ComponentStorage>(); services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>(); services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IWorkStorage, WorkStorage>(); services.AddTransient<IWorkStorage, WorkStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>(); services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IWorkLogic, WorkLogic>(); services.AddTransient<IWorkLogic, WorkLogic>();
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormComponent>(); services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>(); services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>(); services.AddTransient<FormCreateOrder>();
services.AddTransient<FormWork>(); services.AddTransient<FormWork>();
services.AddTransient<FormWorkComponent>(); services.AddTransient<FormWorkComponent>();
services.AddTransient<FormWorks>(); services.AddTransient<FormWorks>();
} }
} }
} }

View File

@ -0,0 +1,62 @@
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";
public List<Component> Components { get; private set; }
public List<Order> Orders { get; private set; }
public List<Work> Works { 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);
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)!)!;
}
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);
}
}
}
}

View File

@ -0,0 +1,90 @@
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;
}
}
}

View File

@ -0,0 +1,93 @@
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;
}
}
}

View File

@ -0,0 +1,94 @@
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;
}
}
}

View File

@ -1,84 +1,95 @@
using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.BindingModels;
using PlumbingRepairContracts.ViewModels; using PlumbingRepairContracts.ViewModels;
using PlumbingRepairDataModels.Enums; using PlumbingRepairDataModels.Enums;
using PlumbingRepairDataModels.Models; using PlumbingRepairDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
namespace PlumbingRepairFileImplement.Models namespace PlumbingRepairFileImplement.Models
{ {
public class Order : IOrderModel public class Order : IOrderModel
{ {
public int Id { get; private set; } public int Id { get; private set; }
public int WorkId { get; private set; } public int WorkId { get; private set; }
public String WorkName { get; private set; } = string.Empty; public String WorkName { get; private set; } = string.Empty;
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
public OrderStatus Status { get; private set; } public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; private set; } public DateTime DateCreate { get; private set; } = DateTime.Now;
public DateTime? DateImplement { get; private set; } public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)
{ public static Order? Create(OrderBindingModel? model)
if (model == null) {
{ if (model == null)
return null; {
} return null;
return new Order() }
{ return new Order()
Id = model.Id, {
WorkId = model.WorkId, Id = model.Id,
WorkName = model.WorkName, WorkId = model.WorkId,
Count = model.Count, WorkName = model.WorkName,
Sum = model.Sum, Count = model.Count,
Status = model.Status, Sum = model.Sum,
DateCreate = model.DateCreate, Status = model.Status,
DateImplement = model.DateImplement, DateCreate = model.DateCreate,
}; DateImplement = model.DateImplement,
} };
public static Order? Create(XElement? element) }
{ public static Order? Create(XElement? element)
if (element == null) {
{ if (element == null)
return null; {
} return null;
return new Order() }
{ return new Order()
Id = Convert.ToInt32(element.Attribute("Id")!.Value), {
WorkId = Convert.ToInt32(element.Attribute("WorkId")!.Value), Id = Convert.ToInt32(element.Attribute("Id")!.Value),
WorkName = element.Element("WorkName")!.Value, WorkId = Convert.ToInt32(element.Element("WorkId")!.Value),
Count = Convert.ToInt32(element.Attribute("Count")!.Value), WorkName = element.Element("WorkName")!.Value,
Sum = Convert.ToInt32(element.Attribute("Sum")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value),
Status = model.Status, Sum = Convert.ToDouble(element.Element("Sum")!.Value),
DateCreate = model.DateCreate, Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
DateImplement = model.DateImplement, 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) public void Update(OrderBindingModel? model)
{ {
return; if (model == null)
} {
Count = model.Count; return;
Sum = model.Sum; }
Status = model.Status; Count = model.Count;
DateCreate = model.DateCreate; Sum = model.Sum;
DateImplement = model.DateImplement; Status = model.Status;
} DateCreate = model.DateCreate;
public OrderViewModel GetViewModel => new() DateImplement = model.DateImplement;
{ }
Id = Id, public OrderViewModel GetViewModel => new()
WorkId = WorkId, {
WorkName = WorkName, Id = Id,
Count = Count, WorkId = WorkId,
Sum = Sum, WorkName = WorkName,
Status = Status, Count = Count,
DateCreate = DateCreate, Sum = Sum,
DateImplement = DateImplement, 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()));
}
}

View File

@ -23,7 +23,10 @@ namespace PlumbingRepairFileImplement.Models
{ {
if(_workComponents == null) if(_workComponents == null)
{ {
// to later 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; return _workComponents;
} }
@ -75,7 +78,7 @@ namespace PlumbingRepairFileImplement.Models
Price = Price, Price = Price,
WorkComponents = WorkComponents WorkComponents = WorkComponents
}; };
public XElement GetXElement => new("Product", public XElement GetXElement => new("Work",
new XAttribute("Id", Id), new XAttribute("Id", Id),
new XElement("WorkName", WorkName), new XElement("WorkName", WorkName),
new XElement("Price", Price.ToString()), new XElement("Price", Price.ToString()),