PIbd-22. Shabunov O.A. Lab work 06 #9

Closed
olshab wants to merge 10 commits from Lab6 into Lab5
9 changed files with 850 additions and 42 deletions
Showing only changes of commit 26eadb9fd4 - Show all commits

View File

@ -0,0 +1,173 @@
namespace AutoWorkshopView.Forms
{
partial class FormImplementer
{
/// <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()
{
FioTextBox = new TextBox();
FioLabel = new Label();
PasswordTextBox = new TextBox();
PasswordLabel = new Label();
WorkExperienceLabel = new Label();
WorkExperienceNumericUpDown = new NumericUpDown();
QualificationNumericUpDown = new NumericUpDown();
QualificationLabel = new Label();
CancelButton = new Button();
SaveButton = new Button();
((System.ComponentModel.ISupportInitialize)WorkExperienceNumericUpDown).BeginInit();
((System.ComponentModel.ISupportInitialize)QualificationNumericUpDown).BeginInit();
SuspendLayout();
//
// FioTextBox
//
FioTextBox.Location = new Point(137, 9);
FioTextBox.Margin = new Padding(3, 2, 3, 2);
FioTextBox.Name = "FioTextBox";
FioTextBox.Size = new Size(335, 23);
FioTextBox.TabIndex = 3;
//
// FioLabel
//
FioLabel.AutoSize = true;
FioLabel.Location = new Point(10, 12);
FioLabel.Name = "FioLabel";
FioLabel.Size = new Size(112, 15);
FioLabel.TabIndex = 2;
FioLabel.Text = "ФИО исполнителя:";
//
// PasswordTextBox
//
PasswordTextBox.Location = new Point(137, 40);
PasswordTextBox.Margin = new Padding(3, 2, 3, 2);
PasswordTextBox.Name = "PasswordTextBox";
PasswordTextBox.Size = new Size(335, 23);
PasswordTextBox.TabIndex = 5;
//
// PasswordLabel
//
PasswordLabel.AutoSize = true;
PasswordLabel.Location = new Point(10, 43);
PasswordLabel.Name = "PasswordLabel";
PasswordLabel.Size = new Size(52, 15);
PasswordLabel.TabIndex = 4;
PasswordLabel.Text = "Пароль:";
//
// WorkExperienceLabel
//
WorkExperienceLabel.AutoSize = true;
WorkExperienceLabel.Location = new Point(10, 75);
WorkExperienceLabel.Name = "WorkExperienceLabel";
WorkExperienceLabel.Size = new Size(84, 15);
WorkExperienceLabel.TabIndex = 6;
WorkExperienceLabel.Text = "Опыт работы:";
//
// WorkExperienceNumericUpDown
//
WorkExperienceNumericUpDown.Location = new Point(137, 73);
WorkExperienceNumericUpDown.Margin = new Padding(3, 2, 3, 2);
WorkExperienceNumericUpDown.Name = "WorkExperienceNumericUpDown";
WorkExperienceNumericUpDown.Size = new Size(108, 23);
WorkExperienceNumericUpDown.TabIndex = 8;
//
// QualificationNumericUpDown
//
QualificationNumericUpDown.Location = new Point(137, 106);
QualificationNumericUpDown.Margin = new Padding(3, 2, 3, 2);
QualificationNumericUpDown.Name = "QualificationNumericUpDown";
QualificationNumericUpDown.Size = new Size(108, 23);
QualificationNumericUpDown.TabIndex = 10;
//
// QualificationLabel
//
QualificationLabel.AutoSize = true;
QualificationLabel.Location = new Point(10, 108);
QualificationLabel.Name = "QualificationLabel";
QualificationLabel.Size = new Size(91, 15);
QualificationLabel.TabIndex = 9;
QualificationLabel.Text = "Квалификация:";
//
// CancelButton
//
CancelButton.Location = new Point(353, 142);
CancelButton.Margin = new Padding(3, 2, 3, 2);
CancelButton.Name = "CancelButton";
CancelButton.Size = new Size(119, 30);
CancelButton.TabIndex = 12;
CancelButton.Text = "Отмена";
CancelButton.UseVisualStyleBackColor = true;
CancelButton.Click += CancelButton_Click;
//
// SaveButton
//
SaveButton.Location = new Point(233, 142);
SaveButton.Margin = new Padding(3, 2, 3, 2);
SaveButton.Name = "SaveButton";
SaveButton.Size = new Size(114, 30);
SaveButton.TabIndex = 11;
SaveButton.Text = "Сохранить";
SaveButton.UseVisualStyleBackColor = true;
SaveButton.Click += SaveButton_Click;
//
// FormImplementer
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(482, 183);
Controls.Add(CancelButton);
Controls.Add(SaveButton);
Controls.Add(QualificationNumericUpDown);
Controls.Add(QualificationLabel);
Controls.Add(WorkExperienceNumericUpDown);
Controls.Add(WorkExperienceLabel);
Controls.Add(PasswordTextBox);
Controls.Add(PasswordLabel);
Controls.Add(FioTextBox);
Controls.Add(FioLabel);
Margin = new Padding(3, 2, 3, 2);
Name = "FormImplementer";
Text = "Исполнитель";
Load += FormImplementer_Load;
((System.ComponentModel.ISupportInitialize)WorkExperienceNumericUpDown).EndInit();
((System.ComponentModel.ISupportInitialize)QualificationNumericUpDown).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox FioTextBox;
private Label FioLabel;
private TextBox PasswordTextBox;
private Label PasswordLabel;
private Label WorkExperienceLabel;
private NumericUpDown WorkExperienceNumericUpDown;
private NumericUpDown QualificationNumericUpDown;
private Label QualificationLabel;
private Button CancelButton;
private Button SaveButton;
}
}

View File

@ -0,0 +1,105 @@
using AutoWorkshopContracts.BindingModels;
using AutoWorkshopContracts.BusinessLogicsContracts;
using AutoWorkshopContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace AutoWorkshopView.Forms
{
public partial class FormImplementer : Form
{
private readonly ILogger _logger;
private readonly IImplementerLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormImplementer(ILogger<FormImplementer> Logger, IImplementerLogic Logic)
{
InitializeComponent();
_logger = Logger;
_logic = Logic;
}
private void FormImplementer_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение исполнителя");
var View = _logic.ReadElement(new ImplementerSearchModel
{
Id = _id.Value
});
if (View != null)
{
FioTextBox.Text = View.ImplementerFIO;
PasswordTextBox.Text = View.Password;
WorkExperienceNumericUpDown.Value = View.WorkExperience;
QualificationNumericUpDown.Value = View.Qualification;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void SaveButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(FioTextBox.Text))
{
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(PasswordTextBox.Text))
{
MessageBox.Show("Заполните пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение исполнителя");
try
{
var Model = new ImplementerBindingModel
{
Id = _id ?? 0,
ImplementerFIO = FioTextBox.Text,
Password = PasswordTextBox.Text,
WorkExperience = (int)WorkExperienceNumericUpDown.Value,
Qualification = (int)QualificationNumericUpDown.Value
};
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 CancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,136 @@
namespace AutoWorkshopView.Forms
{
partial class FormImplementers
{
/// <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()
{
ToolsPanel = new Panel();
RefreshButton = new Button();
DeleteButton = new Button();
UpdateButton = new Button();
AddButton = new Button();
DataGridView = new DataGridView();
ToolsPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
SuspendLayout();
//
// ToolsPanel
//
ToolsPanel.Controls.Add(RefreshButton);
ToolsPanel.Controls.Add(DeleteButton);
ToolsPanel.Controls.Add(UpdateButton);
ToolsPanel.Controls.Add(AddButton);
ToolsPanel.Location = new Point(532, 9);
ToolsPanel.Margin = new Padding(3, 2, 3, 2);
ToolsPanel.Name = "ToolsPanel";
ToolsPanel.Size = new Size(116, 320);
ToolsPanel.TabIndex = 3;
//
// RefreshButton
//
RefreshButton.Location = new Point(3, 126);
RefreshButton.Margin = new Padding(3, 2, 3, 2);
RefreshButton.Name = "RefreshButton";
RefreshButton.Size = new Size(110, 27);
RefreshButton.TabIndex = 3;
RefreshButton.Text = "Обновить";
RefreshButton.UseVisualStyleBackColor = true;
RefreshButton.Click += RefreshButton_Click;
//
// DeleteButton
//
DeleteButton.Location = new Point(3, 84);
DeleteButton.Margin = new Padding(3, 2, 3, 2);
DeleteButton.Name = "DeleteButton";
DeleteButton.Size = new Size(110, 27);
DeleteButton.TabIndex = 2;
DeleteButton.Text = "Удалить";
DeleteButton.UseVisualStyleBackColor = true;
DeleteButton.Click += DeleteButton_Click;
//
// UpdateButton
//
UpdateButton.Location = new Point(3, 42);
UpdateButton.Margin = new Padding(3, 2, 3, 2);
UpdateButton.Name = "UpdateButton";
UpdateButton.Size = new Size(110, 27);
UpdateButton.TabIndex = 1;
UpdateButton.Text = "Изменить";
UpdateButton.UseVisualStyleBackColor = true;
UpdateButton.Click += UpdateButton_Click;
//
// AddButton
//
AddButton.Location = new Point(3, 2);
AddButton.Margin = new Padding(3, 2, 3, 2);
AddButton.Name = "AddButton";
AddButton.Size = new Size(110, 27);
AddButton.TabIndex = 0;
AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// DataGridView
//
DataGridView.AllowUserToAddRows = false;
DataGridView.AllowUserToDeleteRows = false;
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
DataGridView.Location = new Point(10, 9);
DataGridView.Margin = new Padding(3, 2, 3, 2);
DataGridView.Name = "DataGridView";
DataGridView.ReadOnly = true;
DataGridView.RowHeadersWidth = 51;
DataGridView.RowTemplate.Height = 29;
DataGridView.Size = new Size(516, 320);
DataGridView.TabIndex = 2;
//
// FormImplementers
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(653, 338);
Controls.Add(ToolsPanel);
Controls.Add(DataGridView);
Margin = new Padding(3, 2, 3, 2);
Name = "FormImplementers";
Text = "Исполнители";
Load += FormImplementers_Load;
ToolsPanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel ToolsPanel;
private Button RefreshButton;
private Button DeleteButton;
private Button UpdateButton;
private Button AddButton;
private DataGridView DataGridView;
}
}

View File

@ -0,0 +1,111 @@
using AutoWorkshopContracts.BindingModels;
using AutoWorkshopContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace AutoWorkshopView.Forms
{
public partial class FormImplementers : Form
{
private readonly ILogger _logger;
private readonly IImplementerLogic _implementerLogic;
public FormImplementers(ILogger<FormImplementers> Logger, IImplementerLogic ImplementerLogic)
{
InitializeComponent();
_logger = Logger;
_implementerLogic = ImplementerLogic;
}
private void LoadData()
{
try
{
var List = _implementerLogic.ReadList(null);
if (List != null)
{
DataGridView.DataSource = List;
DataGridView.Columns["Id"].Visible = false;
DataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка исполнителей");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки исполнителей");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormImplementers_Load(object sender, EventArgs e)
{
LoadData();
}
private void AddButton_Click(object sender, EventArgs e)
{
var Service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (Service is FormImplementer Form)
{
if (Form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void UpdateButton_Click(object sender, EventArgs e)
{
if (DataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer Form)
{
Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
if (Form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void DeleteButton_Click(object sender, EventArgs e)
{
if (DataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление исполнителя");
try
{
if (!_implementerLogic.Delete(new ImplementerBindingModel
{
Id = Id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void RefreshButton_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -32,11 +32,13 @@
ToolStripMenu = new ToolStripMenuItem();
ComponentsStripMenuItem = new ToolStripMenuItem();
RepairStripMenuItem = new ToolStripMenuItem();
ClientsToolStripMenuItem = new ToolStripMenuItem();
ReportsToolStripMenuItem = new ToolStripMenuItem();
ClientsToolStripMenuItem = new ToolStripMenuItem();
ImplementersToolStripMenuItem = new ToolStripMenuItem();
ReportsToolStripMenuItem = new ToolStripMenuItem();
ComponentsToolStripMenuItem1 = new ToolStripMenuItem();
ComponentRepairToolStripMenuItem1 = new ToolStripMenuItem();
OrdersToolStripMenuItem = new ToolStripMenuItem();
WorkStartToolStripMenuItem = new ToolStripMenuItem();
DataGridView = new DataGridView();
CreateOrderButton = new Button();
TakeInWorkButton = new Button();
@ -50,17 +52,17 @@
// MenuStrip
//
MenuStrip.ImageScalingSize = new Size(20, 20);
MenuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenu, ReportsToolStripMenuItem });
MenuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenu, ReportsToolStripMenuItem, WorkStartToolStripMenuItem });
MenuStrip.Location = new Point(0, 0);
MenuStrip.Name = "MenuStrip";
MenuStrip.Padding = new Padding(5, 2, 0, 2);
MenuStrip.Size = new Size(1134, 24);
MenuStrip.Size = new Size(1356, 24);
MenuStrip.TabIndex = 0;
MenuStrip.Text = "TopMenuStrip";
//
// ToolStripMenu
//
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { ComponentsStripMenuItem, RepairStripMenuItem, ClientsToolStripMenuItem });
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { ComponentsStripMenuItem, RepairStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem });
ToolStripMenu.Name = "ToolStripMenu";
ToolStripMenu.Size = new Size(94, 20);
ToolStripMenu.Text = "Справочники";
@ -68,30 +70,34 @@
// ComponentsStripMenuItem
//
ComponentsStripMenuItem.Name = "ComponentsStripMenuItem";
ComponentsStripMenuItem.Size = new Size(145, 22);
ComponentsStripMenuItem.Size = new Size(149, 22);
ComponentsStripMenuItem.Text = "Компоненты";
ComponentsStripMenuItem.Click += ComponentsStripMenuItem_Click;
//
// RepairStripMenuItem
//
RepairStripMenuItem.Name = "RepairStripMenuItem";
RepairStripMenuItem.Size = new Size(145, 22);
RepairStripMenuItem.Size = new Size(149, 22);
RepairStripMenuItem.Text = "Ремонты";
RepairStripMenuItem.Click += RepairsStripMenuItem_Click;
//
// ClientsToolStripMenuItem
//
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
ClientsToolStripMenuItem.Size = new Size(182, 26);
ClientsToolStripMenuItem.Text = "Клиенты";
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
//
// ReportsToolStripMenuItem
//
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] {
ComponentsToolStripMenuItem1,
ComponentRepairToolStripMenuItem1,
OrdersToolStripMenuItem});
//
// ClientsToolStripMenuItem
//
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
ClientsToolStripMenuItem.Size = new Size(149, 22);
ClientsToolStripMenuItem.Text = "Клиенты";
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
//
// ImplementersToolStripMenuItem
//
ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem";
ImplementersToolStripMenuItem.Size = new Size(149, 22);
ImplementersToolStripMenuItem.Text = "Исполнители";
ImplementersToolStripMenuItem.Click += EmployersToolStripMenuItem_Click;
//
// ReportsToolStripMenuItem
//
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem1, ComponentRepairToolStripMenuItem1, OrdersToolStripMenuItem });
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
ReportsToolStripMenuItem.Size = new Size(60, 20);
ReportsToolStripMenuItem.Text = "Отчёты";
@ -99,23 +105,30 @@
// ComponentsToolStripMenuItem1
//
ComponentsToolStripMenuItem1.Name = "ComponentsToolStripMenuItem1";
ComponentsToolStripMenuItem1.Size = new Size(205, 22);
ComponentsToolStripMenuItem1.Size = new Size(210, 22);
ComponentsToolStripMenuItem1.Text = "Ремонты";
ComponentsToolStripMenuItem1.Click += new EventHandler(ComponentsToolStripMenuItem_Click);
ComponentsToolStripMenuItem1.Click += ComponentsToolStripMenuItem_Click;
//
// ComponentRepairToolStripMenuItem1
//
ComponentRepairToolStripMenuItem1.Name = "ComponentRepairToolStripMenuItem1";
ComponentRepairToolStripMenuItem1.Size = new Size(205, 22);
ComponentRepairToolStripMenuItem1.Size = new Size(210, 22);
ComponentRepairToolStripMenuItem1.Text = "Ремонт с компонентами";
ComponentRepairToolStripMenuItem1.Click += new EventHandler(ComponentRepairToolStripMenuItem_Click);
ComponentRepairToolStripMenuItem1.Click += ComponentRepairToolStripMenuItem_Click;
//
// OrdersToolStripMenuItem
//
OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
OrdersToolStripMenuItem.Size = new Size(205, 22);
OrdersToolStripMenuItem.Size = new Size(210, 22);
OrdersToolStripMenuItem.Text = "Заказы";
OrdersToolStripMenuItem.Click += new EventHandler(OrdersToolStripMenuItem_Click);
OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
//
// WorkStartToolStripMenuItem
//
WorkStartToolStripMenuItem.Name = "WorkStartToolStripMenuItem";
WorkStartToolStripMenuItem.Size = new Size(92, 20);
WorkStartToolStripMenuItem.Text = "Запуск работ";
WorkStartToolStripMenuItem.Click += StartWorkToolStripMenuItem_Click;
//
// DataGridView
//
@ -124,12 +137,12 @@
DataGridView.Margin = new Padding(3, 2, 3, 2);
DataGridView.Name = "DataGridView";
DataGridView.RowHeadersWidth = 51;
DataGridView.Size = new Size(881, 305);
DataGridView.Size = new Size(1101, 358);
DataGridView.TabIndex = 1;
//
// CreateOrderButton
//
CreateOrderButton.Location = new Point(897, 23);
CreateOrderButton.Location = new Point(1117, 26);
CreateOrderButton.Margin = new Padding(3, 2, 3, 2);
CreateOrderButton.Name = "CreateOrderButton";
CreateOrderButton.Size = new Size(227, 30);
@ -140,7 +153,7 @@
//
// TakeInWorkButton
//
TakeInWorkButton.Location = new Point(897, 57);
TakeInWorkButton.Location = new Point(1117, 60);
TakeInWorkButton.Margin = new Padding(3, 2, 3, 2);
TakeInWorkButton.Name = "TakeInWorkButton";
TakeInWorkButton.Size = new Size(227, 30);
@ -151,7 +164,7 @@
//
// ReadyButton
//
ReadyButton.Location = new Point(897, 91);
ReadyButton.Location = new Point(1117, 94);
ReadyButton.Margin = new Padding(3, 2, 3, 2);
ReadyButton.Name = "ReadyButton";
ReadyButton.Size = new Size(227, 30);
@ -162,7 +175,7 @@
//
// IssuedButton
//
IssuedButton.Location = new Point(897, 125);
IssuedButton.Location = new Point(1117, 128);
IssuedButton.Margin = new Padding(3, 2, 3, 2);
IssuedButton.Name = "IssuedButton";
IssuedButton.Size = new Size(227, 30);
@ -173,7 +186,7 @@
//
// RefreshButton
//
RefreshButton.Location = new Point(897, 159);
RefreshButton.Location = new Point(1117, 162);
RefreshButton.Margin = new Padding(3, 2, 3, 2);
RefreshButton.Name = "RefreshButton";
RefreshButton.Size = new Size(227, 30);
@ -186,7 +199,7 @@
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1134, 338);
ClientSize = new Size(1356, 392);
Controls.Add(RefreshButton);
Controls.Add(IssuedButton);
Controls.Add(ReadyButton);
@ -223,5 +236,7 @@
private ToolStripMenuItem ComponentRepairToolStripMenuItem1;
private ToolStripMenuItem OrdersToolStripMenuItem;
private ToolStripMenuItem ClientsToolStripMenuItem;
}
private ToolStripMenuItem ImplementersToolStripMenuItem;
private ToolStripMenuItem WorkStartToolStripMenuItem;
}
}

View File

@ -1,7 +1,9 @@
using AutoWorkshopContracts.BindingModels;
using AutoWorkshopContracts.BusinessLogicContracts;
using AutoWorkshopContracts.BusinessLogicsContracts;
using AutoWorkshopView.Forms;
using Microsoft.Extensions.Logging;
using System.Windows.Forms;
namespace AutoWorkshopView
{
@ -10,14 +12,16 @@ namespace AutoWorkshopView
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
public MainForm(ILogger<MainForm> Logger, IOrderLogic OrderLogic, IReportLogic ReportLogic)
private readonly IWorkProcess _workProcess;
public MainForm(ILogger<MainForm> Logger, IOrderLogic OrderLogic, IReportLogic ReportLogic, IWorkProcess WorkProcess)
{
InitializeComponent();
_logger = Logger;
_orderLogic = OrderLogic;
_reportLogic = ReportLogic;
_workProcess = WorkProcess;
}
private void MainForm_Load(object sender, EventArgs e)
@ -38,7 +42,8 @@ namespace AutoWorkshopView
DataGridView.DataSource = List;
DataGridView.Columns["RepairId"].Visible = false;
DataGridView.Columns["ClientId"].Visible = false;
DataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
DataGridView.Columns["ImplementerId"].Visible = false;
DataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка заказов");
@ -209,5 +214,22 @@ namespace AutoWorkshopView
Form.ShowDialog();
}
}
}
private void EmployersToolStripMenuItem_Click(object sender, EventArgs e)
{
var Service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
if (Service is FormImplementers Form)
{
Form.ShowDialog();
}
}
private void StartWorkToolStripMenuItem_Click(object sender, EventArgs e)
{
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

View File

@ -8,6 +8,7 @@ using AutoWorkshopView.Forms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using AutoWorkshopContracts.BusinessLogicsContracts;
namespace AutoWorkshopView
{
@ -39,13 +40,16 @@ namespace AutoWorkshopView
Services.AddTransient<IComponentStorage, ComponentStorage>();
Services.AddTransient<IOrderStorage, OrderStorage>();
Services.AddTransient<IRepairStorage, RepairStorage>();
Services.AddTransient<IClientStorage, ClientStorage>();
Services.AddTransient<IImplementerStorage, ImplementerStorage>();
Services.AddTransient<IComponentLogic, ComponentLogic>();
Services.AddTransient<IOrderLogic, OrderLogic>();
Services.AddTransient<IRepairLogic, RepairLogic>();
Services.AddTransient<IReportLogic, ReportLogic>();
Services.AddTransient<IClientLogic, ClientLogic>();
Services.AddTransient<IClientStorage, ClientStorage>();
Services.AddTransient<IImplementerLogic, ImplementerLogic>();
Services.AddTransient<IWorkProcess, WorkModeling>();
Services.AddTransient<AbstractSaveToWord, SaveToWord>();
Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
@ -61,6 +65,8 @@ namespace AutoWorkshopView
Services.AddTransient<FormReportRepairComponents>();
Services.AddTransient<FormReportOrders>();
Services.AddTransient<FormClients>();
}
Services.AddTransient<FormImplementers>();
Services.AddTransient<FormImplementer>();
}
}
}