Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
09d271632e | |||
cedda578ea | |||
500fd3241d |
@ -3,7 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32901.215
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarRepairShop", "CarRepairShop\CarRepairShop.csproj", "{59651A2B-2304-453C-B67E-91EF8353B196}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRepairShop", "CarRepairShop\CarRepairShop.csproj", "{59651A2B-2304-453C-B67E-91EF8353B196}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{853143CB-5B00-49BC-ADF2-557269EB2235} = {853143CB-5B00-49BC-ADF2-557269EB2235}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRepairShopDataModels", "CarRepairShopDataModels\CarRepairShopDataModels.csproj", "{85B7EA38-8F19-4199-B83A-B3128A145E3F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRepairShopBisinessLogic", "CarRepairShopBisinessLogic\CarRepairShopBisinessLogic.csproj", "{853143CB-5B00-49BC-ADF2-557269EB2235}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRepairShopContracts", "CarRepairShopContracts\CarRepairShopContracts.csproj", "{CE6A6A6F-A0D3-428F-B70F-E73695DD2C91}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarRepairShopListImplement", "CarRepairShopListImplement\CarRepairShopListImplement.csproj", "{7A19A758-A68B-4B08-8F70-62D42A777926}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -15,6 +26,22 @@ Global
|
||||
{59651A2B-2304-453C-B67E-91EF8353B196}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{59651A2B-2304-453C-B67E-91EF8353B196}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{59651A2B-2304-453C-B67E-91EF8353B196}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{85B7EA38-8F19-4199-B83A-B3128A145E3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{85B7EA38-8F19-4199-B83A-B3128A145E3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{85B7EA38-8F19-4199-B83A-B3128A145E3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{85B7EA38-8F19-4199-B83A-B3128A145E3F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{853143CB-5B00-49BC-ADF2-557269EB2235}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{853143CB-5B00-49BC-ADF2-557269EB2235}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{853143CB-5B00-49BC-ADF2-557269EB2235}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{853143CB-5B00-49BC-ADF2-557269EB2235}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CE6A6A6F-A0D3-428F-B70F-E73695DD2C91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CE6A6A6F-A0D3-428F-B70F-E73695DD2C91}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CE6A6A6F-A0D3-428F-B70F-E73695DD2C91}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CE6A6A6F-A0D3-428F-B70F-E73695DD2C91}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7A19A758-A68B-4B08-8F70-62D42A777926}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7A19A758-A68B-4B08-8F70-62D42A777926}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7A19A758-A68B-4B08-8F70-62D42A777926}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7A19A758-A68B-4B08-8F70-62D42A777926}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -8,4 +8,15 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CarRepairShopBisinessLogic\CarRepairShopBisinessLogic.csproj" />
|
||||
<ProjectReference Include="..\CarRepairShopListImplement\CarRepairShopListImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
39
CarRepairShop/CarRepairShop/Form1.Designer.cs
generated
39
CarRepairShop/CarRepairShop/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace CarRepairShop
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace CarRepairShop
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
230
CarRepairShop/CarRepairShop/FormCar.Designer.cs
generated
Normal file
230
CarRepairShop/CarRepairShop/FormCar.Designer.cs
generated
Normal file
@ -0,0 +1,230 @@
|
||||
namespace CarRepairShop
|
||||
{
|
||||
partial class FormCar
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.ButtonRef = new System.Windows.Forms.Button();
|
||||
this.ButtonDel = new System.Windows.Forms.Button();
|
||||
this.ButtonUpd = new System.Windows.Forms.Button();
|
||||
this.ButtonAdd = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Деталь = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Количество = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(10, 7);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(62, 15);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Название:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(10, 33);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(70, 15);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Стоимость:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(90, 4);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(235, 23);
|
||||
this.textBoxName.TabIndex = 2;
|
||||
//
|
||||
// textBoxPrice
|
||||
//
|
||||
this.textBoxPrice.Location = new System.Drawing.Point(90, 29);
|
||||
this.textBoxPrice.Name = "textBoxPrice";
|
||||
this.textBoxPrice.Size = new System.Drawing.Size(139, 23);
|
||||
this.textBoxPrice.TabIndex = 3;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.ButtonRef);
|
||||
this.groupBox1.Controls.Add(this.ButtonDel);
|
||||
this.groupBox1.Controls.Add(this.ButtonUpd);
|
||||
this.groupBox1.Controls.Add(this.ButtonAdd);
|
||||
this.groupBox1.Controls.Add(this.dataGridView);
|
||||
this.groupBox1.Location = new System.Drawing.Point(10, 54);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(679, 232);
|
||||
this.groupBox1.TabIndex = 4;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Детали";
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
this.ButtonRef.Location = new System.Drawing.Point(538, 175);
|
||||
this.ButtonRef.Name = "ButtonRef";
|
||||
this.ButtonRef.Size = new System.Drawing.Size(106, 38);
|
||||
this.ButtonRef.TabIndex = 4;
|
||||
this.ButtonRef.Text = "Обновить";
|
||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
this.ButtonDel.Location = new System.Drawing.Point(538, 121);
|
||||
this.ButtonDel.Name = "ButtonDel";
|
||||
this.ButtonDel.Size = new System.Drawing.Size(106, 38);
|
||||
this.ButtonDel.TabIndex = 3;
|
||||
this.ButtonDel.Text = "Удалить";
|
||||
this.ButtonDel.UseVisualStyleBackColor = true;
|
||||
this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
this.ButtonUpd.Location = new System.Drawing.Point(538, 69);
|
||||
this.ButtonUpd.Name = "ButtonUpd";
|
||||
this.ButtonUpd.Size = new System.Drawing.Size(106, 38);
|
||||
this.ButtonUpd.TabIndex = 2;
|
||||
this.ButtonUpd.Text = "Изменить";
|
||||
this.ButtonUpd.UseVisualStyleBackColor = true;
|
||||
this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
this.ButtonAdd.Location = new System.Drawing.Point(538, 20);
|
||||
this.ButtonAdd.Name = "ButtonAdd";
|
||||
this.ButtonAdd.Size = new System.Drawing.Size(106, 38);
|
||||
this.ButtonAdd.TabIndex = 1;
|
||||
this.ButtonAdd.Text = "Добавить";
|
||||
this.ButtonAdd.UseVisualStyleBackColor = true;
|
||||
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ID,
|
||||
this.Деталь,
|
||||
this.Количество});
|
||||
this.dataGridView.Location = new System.Drawing.Point(5, 20);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(475, 208);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ID
|
||||
//
|
||||
this.ID.HeaderText = "ID";
|
||||
this.ID.MinimumWidth = 6;
|
||||
this.ID.Name = "ID";
|
||||
this.ID.Visible = false;
|
||||
this.ID.Width = 125;
|
||||
//
|
||||
// Деталь
|
||||
//
|
||||
this.Деталь.HeaderText = "Деталь";
|
||||
this.Деталь.MinimumWidth = 6;
|
||||
this.Деталь.Name = "Деталь";
|
||||
this.Деталь.Width = 306;
|
||||
//
|
||||
// Количество
|
||||
//
|
||||
this.Количество.HeaderText = "Количество";
|
||||
this.Количество.MinimumWidth = 6;
|
||||
this.Количество.Name = "Количество";
|
||||
this.Количество.Width = 125;
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Location = new System.Drawing.Point(507, 307);
|
||||
this.ButtonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(82, 22);
|
||||
this.ButtonSave.TabIndex = 5;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(607, 307);
|
||||
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(82, 22);
|
||||
this.ButtonCancel.TabIndex = 6;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormCar
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.textBoxPrice);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "FormCar";
|
||||
this.Text = "Автомобиль";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxPrice;
|
||||
private GroupBox groupBox1;
|
||||
private Button ButtonRef;
|
||||
private Button ButtonDel;
|
||||
private Button ButtonUpd;
|
||||
private Button ButtonAdd;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn ID;
|
||||
private DataGridViewTextBoxColumn Деталь;
|
||||
private DataGridViewTextBoxColumn Количество;
|
||||
private Button ButtonSave;
|
||||
private Button ButtonCancel;
|
||||
}
|
||||
}
|
215
CarRepairShop/CarRepairShop/FormCar.cs
Normal file
215
CarRepairShop/CarRepairShop/FormCar.cs
Normal file
@ -0,0 +1,215 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using CarRepairShop;
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarRepairShop
|
||||
{
|
||||
public partial class FormCar : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarLogic _logic;
|
||||
private int? _id;
|
||||
private Dictionary<int, (IDetailModel, int)> _carDetails;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormCar(ILogger<FormCar> logger, ICarLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_carDetails = new Dictionary<int, (IDetailModel, int)>();
|
||||
}
|
||||
|
||||
private void FormCar_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделия");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new CarSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.CarName;
|
||||
textBoxPrice.Text = view.Price.ToString();
|
||||
_carDetails = view.CarDetails ?? new Dictionary<int, (IDetailModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка деталей изделия");
|
||||
try
|
||||
{
|
||||
if (_carDetails != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var pc in _carDetails)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.DetailName, pc.Value.Item2 });
|
||||
}
|
||||
textBoxPrice.Text = CalcPrice().ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCarDetail));
|
||||
if (service is FormCarDetail form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.DetailModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление нового детали:{ DetailName} - { Count}", form.DetailModel.DetailName, form.Count);
|
||||
if (_carDetails.ContainsKey(form.Id))
|
||||
{
|
||||
_carDetails[form.Id] = (form.DetailModel, form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_carDetails.Add(form.Id, (form.DetailModel, form.Count));
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCarDetail));
|
||||
if (service is FormCarDetail form)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _carDetails[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.DetailModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Изменение детали: { DetailName} - { Count}", form.DetailModel.DetailName, form.Count);
|
||||
_carDetails[form.Id] = (form.DetailModel, form.Count);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Удаление детали:{ DetailName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
|
||||
_carDetails?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (_carDetails == null || _carDetails.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение изделия");
|
||||
try
|
||||
{
|
||||
var model = new CarBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
CarName = textBoxName.Text,
|
||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||
CarDetails = _carDetails
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
private double CalcPrice()
|
||||
{
|
||||
double price = 0;
|
||||
foreach (var elem in _carDetails)
|
||||
{
|
||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||
}
|
||||
return Math.Round(price * 1.1, 2);
|
||||
}
|
||||
}
|
||||
}
|
69
CarRepairShop/CarRepairShop/FormCar.resx
Normal file
69
CarRepairShop/CarRepairShop/FormCar.resx
Normal file
@ -0,0 +1,69 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Деталь.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Количество.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
119
CarRepairShop/CarRepairShop/FormCarDetail.Designer.cs
generated
Normal file
119
CarRepairShop/CarRepairShop/FormCarDetail.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
||||
namespace CarRepairShop
|
||||
{
|
||||
partial class FormCarDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.labelDetail = new System.Windows.Forms.Label();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.comboBoxDetail = new System.Windows.Forms.ComboBox();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelDetail
|
||||
//
|
||||
this.labelDetail.AutoSize = true;
|
||||
this.labelDetail.Location = new System.Drawing.Point(10, 14);
|
||||
this.labelDetail.Name = "labelDetail";
|
||||
this.labelDetail.Size = new System.Drawing.Size(45, 15);
|
||||
this.labelDetail.TabIndex = 0;
|
||||
this.labelDetail.Text = "Деталь";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(10, 42);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(72, 15);
|
||||
this.labelCount.TabIndex = 1;
|
||||
this.labelCount.Text = "Количество";
|
||||
//
|
||||
// comboBoxDetail
|
||||
//
|
||||
this.comboBoxDetail.FormattingEnabled = true;
|
||||
this.comboBoxDetail.Location = new System.Drawing.Point(98, 12);
|
||||
this.comboBoxDetail.Name = "comboBoxDetail";
|
||||
this.comboBoxDetail.Size = new System.Drawing.Size(221, 23);
|
||||
this.comboBoxDetail.TabIndex = 2;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(98, 40);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(221, 23);
|
||||
this.textBoxCount.TabIndex = 3;
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Location = new System.Drawing.Point(141, 87);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(82, 22);
|
||||
this.ButtonSave.TabIndex = 4;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(236, 87);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(82, 22);
|
||||
this.ButtonCancel.TabIndex = 5;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormCarDetail
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(329, 118);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.comboBoxDetail);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelDetail);
|
||||
this.Name = "FormCarDetail";
|
||||
this.Text = "Деталь машины";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelDetail;
|
||||
private Label labelCount;
|
||||
private ComboBox comboBoxDetail;
|
||||
private TextBox textBoxCount;
|
||||
private Button ButtonSave;
|
||||
private Button ButtonCancel;
|
||||
}
|
||||
}
|
89
CarRepairShop/CarRepairShop/FormCarDetail.cs
Normal file
89
CarRepairShop/CarRepairShop/FormCarDetail.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using CarRepairShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarRepairShop
|
||||
{
|
||||
public partial class FormCarDetail : Form
|
||||
{
|
||||
private readonly List<DetailViewModel>? _list;
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(comboBoxDetail.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBoxDetail.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
public IDetailModel? DetailModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _list)
|
||||
{
|
||||
if (elem.Id == Id)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||
set { textBoxCount.Text = value.ToString(); }
|
||||
}
|
||||
public FormCarDetail(IDetailLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_list = logic.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
comboBoxDetail.DisplayMember = "DetailName";
|
||||
comboBoxDetail.ValueMember = "Id";
|
||||
comboBoxDetail.DataSource = _list;
|
||||
comboBoxDetail.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxDetail.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
CarRepairShop/CarRepairShop/FormCarDetail.resx
Normal file
60
CarRepairShop/CarRepairShop/FormCarDetail.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
113
CarRepairShop/CarRepairShop/FormCars.Designer.cs
generated
Normal file
113
CarRepairShop/CarRepairShop/FormCars.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
||||
namespace CarRepairShop
|
||||
{
|
||||
partial class FormCars
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ButtonAdd = new System.Windows.Forms.Button();
|
||||
this.ButtonUpd = new System.Windows.Forms.Button();
|
||||
this.ButtonDel = new System.Windows.Forms.Button();
|
||||
this.ButtonRef = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(549, 338);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
this.ButtonAdd.Location = new System.Drawing.Point(566, 34);
|
||||
this.ButtonAdd.Name = "ButtonAdd";
|
||||
this.ButtonAdd.Size = new System.Drawing.Size(123, 32);
|
||||
this.ButtonAdd.TabIndex = 1;
|
||||
this.ButtonAdd.Text = "Добавить";
|
||||
this.ButtonAdd.UseVisualStyleBackColor = true;
|
||||
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
this.ButtonUpd.Location = new System.Drawing.Point(566, 92);
|
||||
this.ButtonUpd.Name = "ButtonUpd";
|
||||
this.ButtonUpd.Size = new System.Drawing.Size(123, 32);
|
||||
this.ButtonUpd.TabIndex = 2;
|
||||
this.ButtonUpd.Text = "Изменить";
|
||||
this.ButtonUpd.UseVisualStyleBackColor = true;
|
||||
this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
this.ButtonDel.Location = new System.Drawing.Point(566, 146);
|
||||
this.ButtonDel.Name = "ButtonDel";
|
||||
this.ButtonDel.Size = new System.Drawing.Size(123, 32);
|
||||
this.ButtonDel.TabIndex = 3;
|
||||
this.ButtonDel.Text = "Удалить";
|
||||
this.ButtonDel.UseVisualStyleBackColor = true;
|
||||
this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
this.ButtonRef.Location = new System.Drawing.Point(566, 202);
|
||||
this.ButtonRef.Name = "ButtonRef";
|
||||
this.ButtonRef.Size = new System.Drawing.Size(123, 32);
|
||||
this.ButtonRef.TabIndex = 4;
|
||||
this.ButtonRef.Text = "Обновить";
|
||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// FormCars
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||
this.Controls.Add(this.ButtonRef);
|
||||
this.Controls.Add(this.ButtonDel);
|
||||
this.Controls.Add(this.ButtonUpd);
|
||||
this.Controls.Add(this.ButtonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormCars";
|
||||
this.Text = "Машины";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button ButtonAdd;
|
||||
private Button ButtonUpd;
|
||||
private Button ButtonDel;
|
||||
private Button ButtonRef;
|
||||
}
|
||||
}
|
114
CarRepairShop/CarRepairShop/FormCars.cs
Normal file
114
CarRepairShop/CarRepairShop/FormCars.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using CarRepairShop;
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarRepairShop
|
||||
{
|
||||
public partial class FormCars : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarLogic _logic;
|
||||
public FormCars(ILogger<FormCars> logger, ICarLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormCars_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["CarName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["CarDetails"].Visible = false;
|
||||
}
|
||||
_logger.LogInformation("Загрузка кораблей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки кораблей");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCar));
|
||||
if (service is FormCar form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCar));
|
||||
if (service is FormCar form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление кораблика");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new CarBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления кораблика");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
60
CarRepairShop/CarRepairShop/FormCars.resx
Normal file
60
CarRepairShop/CarRepairShop/FormCars.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
144
CarRepairShop/CarRepairShop/FormCreateOrder.Designer.cs
generated
Normal file
144
CarRepairShop/CarRepairShop/FormCreateOrder.Designer.cs
generated
Normal file
@ -0,0 +1,144 @@
|
||||
namespace CarRepairShop
|
||||
{
|
||||
partial class FormCreateOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.ComboBoxCars = new System.Windows.Forms.ComboBox();
|
||||
this.labelCar = new System.Windows.Forms.Label();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.labelPrice = new System.Windows.Forms.Label();
|
||||
this.TextBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.TextBoxSum = new System.Windows.Forms.TextBox();
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ComboBoxCars
|
||||
//
|
||||
this.ComboBoxCars.FormattingEnabled = true;
|
||||
this.ComboBoxCars.Location = new System.Drawing.Point(120, 14);
|
||||
this.ComboBoxCars.Name = "ComboBoxCars";
|
||||
this.ComboBoxCars.Size = new System.Drawing.Size(258, 23);
|
||||
this.ComboBoxCars.TabIndex = 0;
|
||||
this.ComboBoxCars.SelectedIndexChanged += new System.EventHandler(this.ComboBoxCars_SelectedIndexChanged);
|
||||
//
|
||||
// labelCar
|
||||
//
|
||||
this.labelCar.AutoSize = true;
|
||||
this.labelCar.Location = new System.Drawing.Point(29, 20);
|
||||
this.labelCar.Name = "labelCar";
|
||||
this.labelCar.Size = new System.Drawing.Size(53, 15);
|
||||
this.labelCar.TabIndex = 1;
|
||||
this.labelCar.Text = "Изделие";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(29, 52);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(72, 15);
|
||||
this.labelCount.TabIndex = 2;
|
||||
this.labelCount.Text = "Количество";
|
||||
//
|
||||
// labelPrice
|
||||
//
|
||||
this.labelPrice.AutoSize = true;
|
||||
this.labelPrice.Location = new System.Drawing.Point(29, 86);
|
||||
this.labelPrice.Name = "labelPrice";
|
||||
this.labelPrice.Size = new System.Drawing.Size(45, 15);
|
||||
this.labelPrice.TabIndex = 3;
|
||||
this.labelPrice.Text = "Сумма";
|
||||
//
|
||||
// TextBoxCount
|
||||
//
|
||||
this.TextBoxCount.Location = new System.Drawing.Point(120, 46);
|
||||
this.TextBoxCount.Name = "TextBoxCount";
|
||||
this.TextBoxCount.Size = new System.Drawing.Size(258, 23);
|
||||
this.TextBoxCount.TabIndex = 4;
|
||||
this.TextBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
||||
//
|
||||
// TextBoxSum
|
||||
//
|
||||
this.TextBoxSum.Location = new System.Drawing.Point(120, 81);
|
||||
this.TextBoxSum.Name = "TextBoxSum";
|
||||
this.TextBoxSum.Size = new System.Drawing.Size(258, 23);
|
||||
this.TextBoxSum.TabIndex = 5;
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Location = new System.Drawing.Point(218, 116);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(82, 22);
|
||||
this.ButtonSave.TabIndex = 6;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(318, 116);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(82, 22);
|
||||
this.ButtonCancel.TabIndex = 7;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormCreateOrder
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(410, 145);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Controls.Add(this.TextBoxSum);
|
||||
this.Controls.Add(this.TextBoxCount);
|
||||
this.Controls.Add(this.labelPrice);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelCar);
|
||||
this.Controls.Add(this.ComboBoxCars);
|
||||
this.Name = "FormCreateOrder";
|
||||
this.Text = "Создание заказа";
|
||||
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox ComboBoxCars;
|
||||
private Label labelCar;
|
||||
private Label labelCount;
|
||||
private Label labelPrice;
|
||||
private TextBox TextBoxCount;
|
||||
private TextBox TextBoxSum;
|
||||
private Button ButtonSave;
|
||||
private Button ButtonCancel;
|
||||
}
|
||||
}
|
127
CarRepairShop/CarRepairShop/FormCreateOrder.cs
Normal file
127
CarRepairShop/CarRepairShop/FormCreateOrder.cs
Normal file
@ -0,0 +1,127 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarRepairShop
|
||||
{
|
||||
public partial class FormCreateOrder : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarLogic _logicS;
|
||||
private readonly IOrderLogic _logicO;
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ICarLogic logicS, IOrderLogic logicO)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicS = logicS;
|
||||
_logicO = logicO;
|
||||
}
|
||||
|
||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий для заказа");
|
||||
try
|
||||
{
|
||||
var list = _logicS.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
ComboBoxCars.DisplayMember = "CarName";
|
||||
ComboBoxCars.ValueMember = "Id";
|
||||
ComboBoxCars.DataSource = list;
|
||||
ComboBoxCars.SelectedItem = null;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка кораблей");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void CalcSum()
|
||||
{
|
||||
if (ComboBoxCars.SelectedValue != null &&
|
||||
!string.IsNullOrEmpty(TextBoxCount.Text))
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(ComboBoxCars.SelectedValue);
|
||||
var product = _logicS.ReadElement(new CarSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
int count = Convert.ToInt32(TextBoxCount.Text);
|
||||
TextBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void ComboBoxCars_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(TextBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (ComboBoxCars.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание заказа");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
CarId = Convert.ToInt32(ComboBoxCars.SelectedValue),
|
||||
CarName = ComboBoxCars.Text,
|
||||
Count = Convert.ToInt32(TextBoxCount.Text),
|
||||
Sum = Convert.ToDouble(TextBoxSum.Text)
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при создании заказа.Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
CarRepairShop/CarRepairShop/FormCreateOrder.resx
Normal file
60
CarRepairShop/CarRepairShop/FormCreateOrder.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
119
CarRepairShop/CarRepairShop/FormDetail.Designer.cs
generated
Normal file
119
CarRepairShop/CarRepairShop/FormDetail.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
||||
namespace CarRepairShop
|
||||
{
|
||||
partial class FormDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxCost = new System.Windows.Forms.TextBox();
|
||||
this.LabelName = new System.Windows.Forms.Label();
|
||||
this.LabelCost = new System.Windows.Forms.Label();
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(112, 9);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(240, 23);
|
||||
this.textBoxName.TabIndex = 0;
|
||||
//
|
||||
// textBoxCost
|
||||
//
|
||||
this.textBoxCost.Location = new System.Drawing.Point(112, 40);
|
||||
this.textBoxCost.Name = "textBoxCost";
|
||||
this.textBoxCost.Size = new System.Drawing.Size(138, 23);
|
||||
this.textBoxCost.TabIndex = 1;
|
||||
//
|
||||
// LabelName
|
||||
//
|
||||
this.LabelName.AutoSize = true;
|
||||
this.LabelName.Location = new System.Drawing.Point(27, 11);
|
||||
this.LabelName.Name = "LabelName";
|
||||
this.LabelName.Size = new System.Drawing.Size(59, 15);
|
||||
this.LabelName.TabIndex = 2;
|
||||
this.LabelName.Text = "Название";
|
||||
//
|
||||
// LabelCost
|
||||
//
|
||||
this.LabelCost.AutoSize = true;
|
||||
this.LabelCost.Location = new System.Drawing.Point(27, 43);
|
||||
this.LabelCost.Name = "LabelCost";
|
||||
this.LabelCost.Size = new System.Drawing.Size(35, 15);
|
||||
this.LabelCost.TabIndex = 3;
|
||||
this.LabelCost.Text = "Цена";
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Location = new System.Drawing.Point(152, 77);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(97, 22);
|
||||
this.ButtonSave.TabIndex = 4;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(270, 77);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(82, 22);
|
||||
this.ButtonCancel.TabIndex = 5;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormDetail
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(362, 108);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Controls.Add(this.LabelCost);
|
||||
this.Controls.Add(this.LabelName);
|
||||
this.Controls.Add(this.textBoxCost);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Name = "FormDetail";
|
||||
this.Text = "Деталь";
|
||||
this.Load += new System.EventHandler(this.FormDetail_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxCost;
|
||||
private Label LabelName;
|
||||
private Label LabelCost;
|
||||
private Button ButtonSave;
|
||||
private Button ButtonCancel;
|
||||
}
|
||||
}
|
96
CarRepairShop/CarRepairShop/FormDetail.cs
Normal file
96
CarRepairShop/CarRepairShop/FormDetail.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarRepairShop
|
||||
{
|
||||
public partial class FormDetail : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDetailLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormDetail(ILogger<FormDetail> logger, IDetailLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormDetail_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение компонента");
|
||||
var view = _logic.ReadElement(new DetailSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.DetailName;
|
||||
textBoxCost.Text = view.Cost.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения компонента");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение компонента");
|
||||
try
|
||||
{
|
||||
var model = new DetailBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
DetailName = textBoxName.Text,
|
||||
Cost = Convert.ToDouble(textBoxCost.Text)
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) :
|
||||
_logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения компонента");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
CarRepairShop/CarRepairShop/FormDetail.resx
Normal file
60
CarRepairShop/CarRepairShop/FormDetail.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
113
CarRepairShop/CarRepairShop/FormDetails.Designer.cs
generated
Normal file
113
CarRepairShop/CarRepairShop/FormDetails.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
||||
namespace CarRepairShop
|
||||
{
|
||||
partial class FormDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ButtonAdd = new System.Windows.Forms.Button();
|
||||
this.ButtonUpd = new System.Windows.Forms.Button();
|
||||
this.ButtonDel = new System.Windows.Forms.Button();
|
||||
this.ButtonRef = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(549, 338);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
this.ButtonAdd.Location = new System.Drawing.Point(566, 22);
|
||||
this.ButtonAdd.Name = "ButtonAdd";
|
||||
this.ButtonAdd.Size = new System.Drawing.Size(123, 32);
|
||||
this.ButtonAdd.TabIndex = 1;
|
||||
this.ButtonAdd.Text = "Добавить";
|
||||
this.ButtonAdd.UseVisualStyleBackColor = true;
|
||||
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
this.ButtonUpd.Location = new System.Drawing.Point(566, 68);
|
||||
this.ButtonUpd.Name = "ButtonUpd";
|
||||
this.ButtonUpd.Size = new System.Drawing.Size(123, 32);
|
||||
this.ButtonUpd.TabIndex = 2;
|
||||
this.ButtonUpd.Text = "Изменить";
|
||||
this.ButtonUpd.UseVisualStyleBackColor = true;
|
||||
this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
this.ButtonDel.Location = new System.Drawing.Point(566, 113);
|
||||
this.ButtonDel.Name = "ButtonDel";
|
||||
this.ButtonDel.Size = new System.Drawing.Size(123, 32);
|
||||
this.ButtonDel.TabIndex = 3;
|
||||
this.ButtonDel.Text = "Удалить";
|
||||
this.ButtonDel.UseVisualStyleBackColor = true;
|
||||
this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
this.ButtonRef.Location = new System.Drawing.Point(566, 160);
|
||||
this.ButtonRef.Name = "ButtonRef";
|
||||
this.ButtonRef.Size = new System.Drawing.Size(123, 32);
|
||||
this.ButtonRef.TabIndex = 4;
|
||||
this.ButtonRef.Text = "Обновить";
|
||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// FormDetails
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||
this.Controls.Add(this.ButtonRef);
|
||||
this.Controls.Add(this.ButtonDel);
|
||||
this.Controls.Add(this.ButtonUpd);
|
||||
this.Controls.Add(this.ButtonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormDetails";
|
||||
this.Text = "Детали";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button ButtonAdd;
|
||||
private Button ButtonUpd;
|
||||
private Button ButtonDel;
|
||||
private Button ButtonRef;
|
||||
}
|
||||
}
|
114
CarRepairShop/CarRepairShop/FormDetails.cs
Normal file
114
CarRepairShop/CarRepairShop/FormDetails.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using CarRepairShop;
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarRepairShop
|
||||
{
|
||||
public partial class FormDetails : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDetailLogic _logic;
|
||||
public FormDetails(ILogger<FormDetails> logger, IDetailLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormDetails_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["DetailName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка деталей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки деталей");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormDetail));
|
||||
if (service is FormDetail form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormDetail));
|
||||
if (service is FormDetail form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление детали");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new DetailBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления детали");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
60
CarRepairShop/CarRepairShop/FormDetails.resx
Normal file
60
CarRepairShop/CarRepairShop/FormDetails.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
173
CarRepairShop/CarRepairShop/FormMain.Designer.cs
generated
Normal file
173
CarRepairShop/CarRepairShop/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
||||
namespace CarRepairShop
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ButtonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.ButtonTakeOrderInWork = new System.Windows.Forms.Button();
|
||||
this.ButtonOrderReady = new System.Windows.Forms.Button();
|
||||
this.ButtonIssuedOrder = new System.Windows.Forms.Button();
|
||||
this.ButtonRef = new System.Windows.Forms.Button();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ДеталиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.МашиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 24);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(816, 332);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ButtonCreateOrder
|
||||
//
|
||||
this.ButtonCreateOrder.Location = new System.Drawing.Point(822, 39);
|
||||
this.ButtonCreateOrder.Name = "ButtonCreateOrder";
|
||||
this.ButtonCreateOrder.Size = new System.Drawing.Size(181, 23);
|
||||
this.ButtonCreateOrder.TabIndex = 1;
|
||||
this.ButtonCreateOrder.Text = "Создать заказ";
|
||||
this.ButtonCreateOrder.UseVisualStyleBackColor = true;
|
||||
this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
||||
//
|
||||
// ButtonTakeOrderInWork
|
||||
//
|
||||
this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(822, 87);
|
||||
this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
|
||||
this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(181, 23);
|
||||
this.ButtonTakeOrderInWork.TabIndex = 2;
|
||||
this.ButtonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
||||
//
|
||||
// ButtonOrderReady
|
||||
//
|
||||
this.ButtonOrderReady.Location = new System.Drawing.Point(822, 137);
|
||||
this.ButtonOrderReady.Name = "ButtonOrderReady";
|
||||
this.ButtonOrderReady.Size = new System.Drawing.Size(181, 23);
|
||||
this.ButtonOrderReady.TabIndex = 3;
|
||||
this.ButtonOrderReady.Text = "Заказ готов";
|
||||
this.ButtonOrderReady.UseVisualStyleBackColor = true;
|
||||
this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
||||
//
|
||||
// ButtonIssuedOrder
|
||||
//
|
||||
this.ButtonIssuedOrder.Location = new System.Drawing.Point(822, 191);
|
||||
this.ButtonIssuedOrder.Name = "ButtonIssuedOrder";
|
||||
this.ButtonIssuedOrder.Size = new System.Drawing.Size(181, 23);
|
||||
this.ButtonIssuedOrder.TabIndex = 4;
|
||||
this.ButtonIssuedOrder.Text = "Заказ выдан";
|
||||
this.ButtonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
this.ButtonRef.Location = new System.Drawing.Point(822, 246);
|
||||
this.ButtonRef.Name = "ButtonRef";
|
||||
this.ButtonRef.Size = new System.Drawing.Size(181, 23);
|
||||
this.ButtonRef.TabIndex = 5;
|
||||
this.ButtonRef.Text = "Обновить список";
|
||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(1015, 24);
|
||||
this.menuStrip1.TabIndex = 6;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// ToolStripMenuItem
|
||||
//
|
||||
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ДеталиToolStripMenuItem,
|
||||
this.МашиныToolStripMenuItem});
|
||||
this.ToolStripMenuItem.Name = "ToolStripMenuItem";
|
||||
this.ToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||
this.ToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// ДеталиToolStripMenuItem
|
||||
//
|
||||
this.ДеталиToolStripMenuItem.Name = "ДеталиToolStripMenuItem";
|
||||
this.ДеталиToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
|
||||
this.ДеталиToolStripMenuItem.Text = "Детали";
|
||||
this.ДеталиToolStripMenuItem.Click += new System.EventHandler(this.ДеталиToolStripMenuItem_Click);
|
||||
//
|
||||
// МашиныToolStripMenuItem
|
||||
//
|
||||
this.МашиныToolStripMenuItem.Name = "МашиныToolStripMenuItem";
|
||||
this.МашиныToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
|
||||
this.МашиныToolStripMenuItem.Text = "Машины";
|
||||
this.МашиныToolStripMenuItem.Click += new System.EventHandler(this.АвтомобилиToolStripMenuItem_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1015, 356);
|
||||
this.Controls.Add(this.ButtonRef);
|
||||
this.Controls.Add(this.ButtonIssuedOrder);
|
||||
this.Controls.Add(this.ButtonOrderReady);
|
||||
this.Controls.Add(this.ButtonTakeOrderInWork);
|
||||
this.Controls.Add(this.ButtonCreateOrder);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormMain";
|
||||
this.Text = "Автомастерская";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button ButtonCreateOrder;
|
||||
private Button ButtonTakeOrderInWork;
|
||||
private Button ButtonOrderReady;
|
||||
private Button ButtonIssuedOrder;
|
||||
private Button ButtonRef;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem ToolStripMenuItem;
|
||||
private ToolStripMenuItem ДеталиToolStripMenuItem;
|
||||
private ToolStripMenuItem МашиныToolStripMenuItem;
|
||||
}
|
||||
}
|
159
CarRepairShop/CarRepairShop/FormMain.cs
Normal file
159
CarRepairShop/CarRepairShop/FormMain.cs
Normal file
@ -0,0 +1,159 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using CarRepairShop;
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using CarRepairShopDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarRepairShop
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["CarId"].Visible = false;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ДеталиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormDetails));
|
||||
if (service is FormDetails form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void АвтомобилиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCars));
|
||||
if (service is FormCars form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id, Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), CarId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CarId"].Value), CarName = dataGridView.SelectedRows[0].Cells["CarName"].Value.ToString(), DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id, Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), CarId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CarId"].Value), CarName = dataGridView.SelectedRows[0].Cells["CarName"].Value.ToString(), DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении.Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id, Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), CarId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CarId"].Value), CarName = dataGridView.SelectedRows[0].Cells["CarName"].Value.ToString(), DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
63
CarRepairShop/CarRepairShop/FormMain.resx
Normal file
63
CarRepairShop/CarRepairShop/FormMain.resx
Normal file
@ -0,0 +1,63 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,7 +1,20 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using CarRepairShopBusinessLogic.BusinessLogics;
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using CarRepairShopContracts.StoragesContracts;
|
||||
using CarRepairShopListImplement.Implements;
|
||||
using CarRepairShop;
|
||||
using System.Drawing;
|
||||
using CarRepairShopBisinessLogic.BusinessLogic;
|
||||
|
||||
namespace CarRepairShop
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -11,7 +24,35 @@ namespace CarRepairShop
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
services.AddTransient<IDetailStorage, DetailStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ICarStorage, CarStorage>();
|
||||
services.AddTransient<IDetailLogic, DetailLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<ICarLogic, CarLogic>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormDetail>();
|
||||
services.AddTransient<FormDetails>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormCar>();
|
||||
services.AddTransient<FormCarDetail>();
|
||||
services.AddTransient<FormCars>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.StoragesContracts;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class CarLogic : ICarLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarStorage _carStorage;
|
||||
public CarLogic(ILogger<CarLogic> logger, ICarStorage carStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_carStorage = carStorage;
|
||||
}
|
||||
public List<CarViewModel>? ReadList(CarSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. CarName:{CarName}. Id:{Id}", model?.CarName, model?.Id);
|
||||
var list = model == null ? _carStorage.GetFullList() : _carStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public CarViewModel? ReadElement(CarSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. CarName:{CarName}. Id:{ Id}", model.CarName, model.Id);
|
||||
var element = _carStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(CarBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_carStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(CarBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_carStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(CarBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_carStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(CarBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.CarName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия компонента",
|
||||
nameof(model.CarName));
|
||||
}
|
||||
if (model.Price <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Price));
|
||||
}
|
||||
_logger.LogInformation("Car. CarName:{CarName}. Price:{Price}. Id: {Id}", model.CarName, model.Price, model.Id);
|
||||
var element = _carStorage.GetElement(new CarSearchModel
|
||||
{
|
||||
CarName = model.CarName
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using CarRepairShopContracts.StoragesContracts;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarRepairShopBisinessLogic.BusinessLogic
|
||||
{
|
||||
public class DetailLogic : IDetailLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDetailStorage _detailStorage;
|
||||
public DetailLogic(ILogger<DetailLogic> logger, IDetailStorage detailStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_detailStorage = detailStorage;
|
||||
}
|
||||
public List<DetailViewModel>? ReadList(DetailSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. DetailName:{DetailName}. Id:{Id}", model?.DetailName, model?.Id);
|
||||
var list = model == null ? _detailStorage.GetFullList() : _detailStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public DetailViewModel? ReadElement(DetailSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. DetailName:{DetailName}. Id:{ Id}", model.DetailName, model.Id);
|
||||
var element = _detailStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(DetailBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_detailStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(DetailBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_detailStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(DetailBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_detailStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(DetailBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.DetailName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия компонента",
|
||||
nameof(model.DetailName));
|
||||
}
|
||||
if (model.Cost <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
||||
}
|
||||
_logger.LogInformation("Detail. DetailName:{DetailName}. Cost:{ Cost}. Id: { Id}", model.DetailName, model.Cost, model.Id);
|
||||
var element = _detailStorage.GetElement(new DetailSearchModel
|
||||
{
|
||||
DetailName = model.DetailName
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.StoragesContracts;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using CarRepairShopDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id:{Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (model.Status != OrderStatus.Неизвестен)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed. Order status incorrect.");
|
||||
return false;
|
||||
}
|
||||
model.Status = OrderStatus.Принят;
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.CarId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор у корабля", nameof(model.CarId));
|
||||
}
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
|
||||
}
|
||||
if (model.Sum <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
||||
}
|
||||
_logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. CarId: { CarId}", model.Id, model.Sum, model.CarId);
|
||||
}
|
||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (model.Status + 1 != newStatus)
|
||||
{
|
||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
||||
return false;
|
||||
}
|
||||
model.Status = newStatus;
|
||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выдан);
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Готов);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CarRepairShopContracts\CarRepairShopContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CarRepairShopDataModels.Models;
|
||||
|
||||
namespace CarRepairShopContracts.BindingModels
|
||||
{
|
||||
public class CarBindingModel : ICarModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string CarName { get; set; } = String.Empty;
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IDetailModel, int)> CarDetails { get; set; } = new();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CarRepairShopDataModels.Models;
|
||||
|
||||
namespace CarRepairShopContracts.BindingModels
|
||||
{
|
||||
public class DetailBindingModel : IDetailModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string DetailName { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CarRepairShopDataModels.Models;
|
||||
using CarRepairShopDataModels.Enums;
|
||||
|
||||
namespace CarRepairShopContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int CarId { get; set; }
|
||||
public string CarName { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ICarLogic
|
||||
{
|
||||
List<CarViewModel>? ReadList(CarSearchModel? model);
|
||||
CarViewModel? ReadElement(CarSearchModel model);
|
||||
bool Create(CarBindingModel model);
|
||||
bool Update(CarBindingModel model);
|
||||
bool Delete(CarBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IDetailLogic
|
||||
{
|
||||
List<DetailViewModel>? ReadList(DetailSearchModel? model);
|
||||
DetailViewModel? ReadElement(DetailSearchModel model);
|
||||
bool Create(DetailBindingModel model);
|
||||
bool Update(DetailBindingModel model);
|
||||
bool Delete(DetailBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
bool DeliveryOrder(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.SearchModels
|
||||
{
|
||||
public class CarSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? CarName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.SearchModels
|
||||
{
|
||||
public class DetailSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? DetailName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.SearchModels
|
||||
{
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.StoragesContracts
|
||||
{
|
||||
public interface ICarStorage
|
||||
{
|
||||
List<CarViewModel> GetFullList();
|
||||
List<CarViewModel> GetFilteredList(CarSearchModel model);
|
||||
CarViewModel? GetElement(CarSearchModel model);
|
||||
CarViewModel? Insert(CarBindingModel model);
|
||||
CarViewModel? Update(CarBindingModel model);
|
||||
CarViewModel? Delete(CarBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.StoragesContracts
|
||||
{
|
||||
public interface IDetailStorage
|
||||
{
|
||||
List<DetailViewModel> GetFullList();
|
||||
List<DetailViewModel> GetFilteredList(DetailSearchModel model);
|
||||
DetailViewModel? GetElement(DetailSearchModel model);
|
||||
DetailViewModel? Insert(DetailBindingModel model);
|
||||
DetailViewModel? Update(DetailBindingModel model);
|
||||
DetailViewModel? Delete(DetailBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.StoragesContracts
|
||||
{
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using CarRepairShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.ViewModels
|
||||
{
|
||||
public class CarViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название изделия")]
|
||||
public string CarName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IDetailModel, int)> CarDetails { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using CarRepairShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.ViewModels
|
||||
{
|
||||
public class DetailViewModel : IDetailModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название компонента")]
|
||||
public string DetailName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using CarRepairShopDataModels.Enums;
|
||||
using CarRepairShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel:IOrderModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int CarId { get; set; }
|
||||
[DisplayName("Изделие")]
|
||||
public string CarName { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Дата выполнения")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
17
CarRepairShop/CarRepairShopDataModels/Enums/OrderStatus.cs
Normal file
17
CarRepairShop/CarRepairShopDataModels/Enums/OrderStatus.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopDataModels.Enums
|
||||
{
|
||||
public enum OrderStatus
|
||||
{
|
||||
Неизвестен = -1,
|
||||
Принят = 0,
|
||||
Выполняется = 1,
|
||||
Готов = 2,
|
||||
Выдан = 3
|
||||
}
|
||||
}
|
13
CarRepairShop/CarRepairShopDataModels/IId.cs
Normal file
13
CarRepairShop/CarRepairShopDataModels/IId.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
15
CarRepairShop/CarRepairShopDataModels/Models/ICarModel.cs
Normal file
15
CarRepairShop/CarRepairShopDataModels/Models/ICarModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopDataModels.Models
|
||||
{
|
||||
public interface ICarModel : IId
|
||||
{
|
||||
string CarName { get; }
|
||||
double Price { get; }
|
||||
Dictionary<int, (IDetailModel, int)> CarDetails { get; }
|
||||
}
|
||||
}
|
14
CarRepairShop/CarRepairShopDataModels/Models/IDetailModel.cs
Normal file
14
CarRepairShop/CarRepairShopDataModels/Models/IDetailModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopDataModels.Models
|
||||
{
|
||||
public interface IDetailModel : IId
|
||||
{
|
||||
string DetailName { get; }
|
||||
double Cost { get; }
|
||||
}
|
||||
}
|
19
CarRepairShop/CarRepairShopDataModels/Models/IOrderModel.cs
Normal file
19
CarRepairShop/CarRepairShopDataModels/Models/IOrderModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using CarRepairShopDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
int CarId { get; }
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
OrderStatus Status { get; }
|
||||
DateTime DateCreate { get; }
|
||||
DateTime? DateImplement { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CarRepairShopContracts\CarRepairShopContracts.csproj" />
|
||||
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,26 @@
|
||||
using CarRepairShopListImplement.Models;
|
||||
|
||||
namespace CarRepairShopListImplement
|
||||
{
|
||||
public class DataListSingleton
|
||||
{
|
||||
private static DataListSingleton? _instance;
|
||||
public List<Detail> Details { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Car> Cars { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Details = new List<Detail>();
|
||||
Orders = new List<Order>();
|
||||
Cars = new List<Car>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new DataListSingleton();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.StoragesContracts;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using CarRepairShopListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopListImplement.Implements
|
||||
{
|
||||
public class CarStorage : ICarStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public CarStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<CarViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<CarViewModel>();
|
||||
foreach (var car in _source.Cars)
|
||||
{
|
||||
result.Add(car.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<CarViewModel> GetFilteredList(CarSearchModel model)
|
||||
{
|
||||
var result = new List<CarViewModel>();
|
||||
if (string.IsNullOrEmpty(model.CarName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var car in _source.Cars)
|
||||
{
|
||||
if (car.CarName.Contains(model.CarName))
|
||||
{
|
||||
result.Add(car.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public CarViewModel? GetElement(CarSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.CarName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var car in _source.Cars)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.CarName) &&
|
||||
car.CarName == model.CarName) ||
|
||||
(model.Id.HasValue && car.Id == model.Id))
|
||||
{
|
||||
return car.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public CarViewModel? Insert(CarBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var car in _source.Cars)
|
||||
{
|
||||
if (model.Id <= car.Id)
|
||||
{
|
||||
model.Id = car.Id + 1;
|
||||
}
|
||||
}
|
||||
var newCar = Car.Create(model);
|
||||
if (newCar == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Cars.Add(newCar);
|
||||
return newCar.GetViewModel;
|
||||
}
|
||||
public CarViewModel? Update(CarBindingModel model)
|
||||
{
|
||||
foreach (var car in _source.Cars)
|
||||
{
|
||||
if (car.Id == model.Id)
|
||||
{
|
||||
car.Update(model);
|
||||
return car.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public CarViewModel? Delete(CarBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Cars.Count; ++i)
|
||||
{
|
||||
if (_source.Cars[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Cars[i];
|
||||
_source.Cars.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.StoragesContracts;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using CarRepairShopListImplement.Models;
|
||||
using CarRepairShopListImplement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopListImplement.Implements
|
||||
{
|
||||
public class DetailStorage : IDetailStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public DetailStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<DetailViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<DetailViewModel>();
|
||||
foreach (var detail in _source.Details)
|
||||
{
|
||||
result.Add(detail.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<DetailViewModel> GetFilteredList(DetailSearchModel model)
|
||||
{
|
||||
var result = new List<DetailViewModel>();
|
||||
if (string.IsNullOrEmpty(model.DetailName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var detail in _source.Details)
|
||||
{
|
||||
if (detail.DetailName.Contains(model.DetailName))
|
||||
{
|
||||
result.Add(detail.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public DetailViewModel? GetElement(DetailSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.DetailName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var detail in _source.Details)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.DetailName) &&
|
||||
detail.DetailName == model.DetailName) ||
|
||||
(model.Id.HasValue && detail.Id == model.Id))
|
||||
{
|
||||
return detail.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public DetailViewModel? Insert(DetailBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var component in _source.Details)
|
||||
{
|
||||
if (model.Id <= component.Id)
|
||||
{
|
||||
model.Id = component.Id + 1;
|
||||
}
|
||||
}
|
||||
var newDetail = Detail.Create(model);
|
||||
if (newDetail == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Details.Add(newDetail);
|
||||
return newDetail.GetViewModel;
|
||||
}
|
||||
public DetailViewModel? Update(DetailBindingModel model)
|
||||
{
|
||||
foreach (var detail in _source.Details)
|
||||
{
|
||||
if (detail.Id == model.Id)
|
||||
{
|
||||
detail.Update(model);
|
||||
return detail.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public DetailViewModel? Delete(DetailBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Details.Count; ++i)
|
||||
{
|
||||
if (_source.Details[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Details[i];
|
||||
_source.Details.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.SearchModels;
|
||||
using CarRepairShopContracts.StoragesContracts;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using CarRepairShopListImplement.Models;
|
||||
using CarRepairShopListImplement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopListImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public OrderStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(order.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
result.Add(order.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
{
|
||||
return order.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Id <= order.Id)
|
||||
{
|
||||
model.Id = order.Id + 1;
|
||||
}
|
||||
}
|
||||
var newOrder = Order.Create(model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Orders.Add(newOrder);
|
||||
return newOrder.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
order.Update(model);
|
||||
return order.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Orders.Count; ++i)
|
||||
{
|
||||
if (_source.Orders[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Orders[i];
|
||||
_source.Orders.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
52
CarRepairShop/CarRepairShopListImplement/Models/Car.cs
Normal file
52
CarRepairShop/CarRepairShopListImplement/Models/Car.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using CarRepairShopDataModels.Models;
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
|
||||
namespace CarRepairShopListImplement.Models
|
||||
{
|
||||
public class Car : ICarModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string CarName { get; private set; } = string.Empty;
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, (IDetailModel, int)> CarDetails { get; private set; } = new Dictionary<int, (IDetailModel, int)>();
|
||||
public static Car? Create(CarBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Car()
|
||||
{
|
||||
Id = model.Id,
|
||||
CarName = model.CarName,
|
||||
Price = model.Price,
|
||||
CarDetails = model.CarDetails
|
||||
};
|
||||
}
|
||||
public void Update(CarBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CarName = model.CarName;
|
||||
Price = model.Price;
|
||||
CarDetails = model.CarDetails;
|
||||
}
|
||||
public CarViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CarName = CarName,
|
||||
Price = Price,
|
||||
CarDetails = CarDetails
|
||||
};
|
||||
|
||||
}
|
||||
}
|
48
CarRepairShop/CarRepairShopListImplement/Models/Detail.cs
Normal file
48
CarRepairShop/CarRepairShopListImplement/Models/Detail.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using CarRepairShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopListImplement.Models
|
||||
{
|
||||
public class Detail : IDetailModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string DetailName { get; private set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public static Detail? Create(DetailBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Detail()
|
||||
{
|
||||
Id = model.Id,
|
||||
DetailName = model.DetailName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public void Update(DetailBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DetailName = model.DetailName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public DetailViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
DetailName = DetailName,
|
||||
Cost = Cost
|
||||
};
|
||||
|
||||
}
|
||||
}
|
73
CarRepairShop/CarRepairShopListImplement/Models/Order.cs
Normal file
73
CarRepairShop/CarRepairShopListImplement/Models/Order.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using CarRepairShopContracts.BindingModels;
|
||||
using CarRepairShopContracts.ViewModels;
|
||||
using CarRepairShopDataModels.Enums;
|
||||
using CarRepairShopDataModels.Models;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarRepairShopListImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int CarId { get; private set; }
|
||||
public string CarName { get; private set; }
|
||||
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,
|
||||
CarId = model.CarId,
|
||||
CarName = model.CarName,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Id = model.Id;
|
||||
CarId = model.CarId;
|
||||
CarName = model.CarName;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CarId = CarId,
|
||||
CarName = CarName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
};
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user