Compare commits

..

No commits in common. "AddForms" and "main" have entirely different histories.

94 changed files with 0 additions and 6891 deletions

View File

@ -1,49 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompany", "TransportCompany\TransportCompany.csproj", "{0512F64B-00F5-49BA-9613-7A396C075C0C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyDataModels", "TransportCompanyDataModels\TransportCompanyDataModels.csproj", "{C57B4449-A725-4804-833D-7CE33965F001}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyContracts", "TransportCompanyContracts\TransportCompanyContracts.csproj", "{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyBusinessLogic", "TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj", "{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransportCompanyDatabaseImplements", "TransportCompanyDatabaseImplements\TransportCompanyDatabaseImplements.csproj", "{E421890B-5501-4A4D-931A-1B8139FDDB24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0512F64B-00F5-49BA-9613-7A396C075C0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0512F64B-00F5-49BA-9613-7A396C075C0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0512F64B-00F5-49BA-9613-7A396C075C0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0512F64B-00F5-49BA-9613-7A396C075C0C}.Release|Any CPU.Build.0 = Release|Any CPU
{C57B4449-A725-4804-833D-7CE33965F001}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C57B4449-A725-4804-833D-7CE33965F001}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C57B4449-A725-4804-833D-7CE33965F001}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C57B4449-A725-4804-833D-7CE33965F001}.Release|Any CPU.Build.0 = Release|Any CPU
{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}.Release|Any CPU.Build.0 = Release|Any CPU
{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Release|Any CPU.Build.0 = Release|Any CPU
{E421890B-5501-4A4D-931A-1B8139FDDB24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E421890B-5501-4A4D-931A-1B8139FDDB24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E421890B-5501-4A4D-931A-1B8139FDDB24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E421890B-5501-4A4D-931A-1B8139FDDB24}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AAEBEE78-0520-4BC3-A684-3326238BD705}
EndGlobalSection
EndGlobal

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="connectToDb" value="Host=192.168.56.101;Port=6000;Database=elegev;Username=elegev;Password=user"/>
</appSettings>
</configuration>

View File

@ -1,114 +0,0 @@
namespace TransportCompany
{
partial class FormCargo
{
/// <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()
{
dataGridView = new DataGridView();
buttonCreate = new Button();
buttonUpdate = new Button();
buttonDelete = new Button();
buttonReload = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 12);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(523, 426);
dataGridView.TabIndex = 0;
//
// buttonCreate
//
buttonCreate.Location = new Point(590, 33);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(129, 29);
buttonCreate.TabIndex = 1;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(590, 108);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(129, 29);
buttonUpdate.TabIndex = 2;
buttonUpdate.Text = "Изменить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(590, 179);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(129, 29);
buttonDelete.TabIndex = 3;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonReload
//
buttonReload.Location = new Point(590, 251);
buttonReload.Name = "buttonReload";
buttonReload.Size = new Size(129, 29);
buttonReload.TabIndex = 4;
buttonReload.Text = "Обновить";
buttonReload.UseVisualStyleBackColor = true;
buttonReload.Click += ButtonReload_Click;
//
// FormCargo
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(766, 450);
Controls.Add(buttonReload);
Controls.Add(buttonDelete);
Controls.Add(buttonUpdate);
Controls.Add(buttonCreate);
Controls.Add(dataGridView);
Name = "FormCargo";
Text = "FormCargo";
Load += FormCargo_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonCreate;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonReload;
}
}

View File

@ -1,126 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
namespace TransportCompany
{
public partial class FormCargo : Form
{
private readonly ILogger _logger;
private readonly ICargoLogic _logicC;
public FormCargo(ILogger<FormCargo> logger, ICargoLogic logicC)
{
InitializeComponent();
_logger = logger;
_logicC = logicC;
}
private void FormCargo_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logicC.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка типов грузов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки типов грузов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateCargo));
if (service is FormCreateCargo form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateCargo));
if (service is FormCreateCargo form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_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 (!_logicC.Delete(new CargoBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления типа груза");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonReload_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,114 +0,0 @@
namespace TransportCompany
{
partial class FormClients
{
/// <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()
{
dataGridView = new DataGridView();
buttonCreate = new Button();
buttonUpdate = new Button();
buttonDelete = new Button();
buttonReload = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 12);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(1024, 426);
dataGridView.TabIndex = 0;
//
// buttonCreate
//
buttonCreate.Location = new Point(1081, 36);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(150, 29);
buttonCreate.TabIndex = 1;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(1081, 110);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(150, 29);
buttonUpdate.TabIndex = 2;
buttonUpdate.Text = "Изменить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(1081, 182);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(150, 29);
buttonDelete.TabIndex = 3;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonReload
//
buttonReload.Location = new Point(1081, 251);
buttonReload.Name = "buttonReload";
buttonReload.Size = new Size(150, 29);
buttonReload.TabIndex = 4;
buttonReload.Text = "Обновить";
buttonReload.UseVisualStyleBackColor = true;
buttonReload.Click += ButtonReload_Click;
//
// FormClients
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1271, 450);
Controls.Add(buttonReload);
Controls.Add(buttonDelete);
Controls.Add(buttonUpdate);
Controls.Add(buttonCreate);
Controls.Add(dataGridView);
Name = "FormClients";
Text = "Клиенты";
Load += FormClients_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonCreate;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonReload;
}
}

View File

@ -1,129 +0,0 @@
using Microsoft.Extensions.Logging;
using Serilog.Core;
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;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
namespace TransportCompany
{
public partial class FormClients : Form
{
private readonly ILogger _logger;
private readonly IClientLogic _logicC;
public FormClients(ILogger<FormClients> logger, IClientLogic logicC)
{
InitializeComponent();
_logger = logger;
_logicC = logicC;
}
private void FormClients_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logicC.ReadList(null);
//растягиваем колонку Название на всю ширину, колонку Id скрываем
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки заготовок");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateClient));
if (service is FormCreateClient form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateClient));
if (service is FormCreateClient form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_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 (!_logicC.Delete(new ClientBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonReload_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,96 +0,0 @@
namespace TransportCompany
{
partial class FormCreateCargo
{
/// <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()
{
label1 = new Label();
textBoxCargo = new TextBox();
buttonCreate = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(33, 28);
label1.Name = "label1";
label1.Size = new Size(137, 20);
label1.TabIndex = 0;
label1.Text = "Введите тип груза:";
//
// textBoxCargo
//
textBoxCargo.Location = new Point(198, 25);
textBoxCargo.Name = "textBoxCargo";
textBoxCargo.Size = new Size(313, 27);
textBoxCargo.TabIndex = 1;
//
// buttonCreate
//
buttonCreate.Location = new Point(305, 73);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(94, 29);
buttonCreate.TabIndex = 2;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(417, 73);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormCreateCargo
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(571, 118);
Controls.Add(buttonCancel);
Controls.Add(buttonCreate);
Controls.Add(textBoxCargo);
Controls.Add(label1);
Name = "FormCreateCargo";
Text = "Создание груза";
Load += FormCreateCargo_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private TextBox textBoxCargo;
private Button buttonCreate;
private Button buttonCancel;
}
}

View File

@ -1,104 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
namespace TransportCompany
{
public partial class FormCreateCargo : Form
{
private readonly ILogger _logger;
private readonly ICargoLogic _logicCg;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateCargo(ILogger<FormCreateCargo> logger, ICargoLogic logicCg)
{
InitializeComponent();
_logger = logger;
_logicCg = logicCg;
}
private void FormCreateCargo_Load(object sender, EventArgs e)
{
//проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение типа груза");
var view = _logicCg.ReadElement(new CargoSearchModel { Id = _id.Value });
if (view != null)
{
textBoxCargo.Text = view.TypeCargo;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения типа груза");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxCargo.Text))
{
MessageBox.Show("Введите тип груза", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Добавление груза");
try
{
var model = new CargoBindingModel
{
Id = 0,
TypeCargo = textBoxCargo.Text
};
var operationResult = _id.HasValue ? _logicCg.Update(model) : _logicCg.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();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,184 +0,0 @@
namespace TransportCompany
{
partial class FormCreateClient
{
/// <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()
{
labelName = new Label();
labelSurname = new Label();
labelPatronymic = new Label();
labelTelephone = new Label();
labelEmail = new Label();
textBoxName = new TextBox();
textBoxSurname = new TextBox();
textBoxPatronymic = new TextBox();
textBoxTelephone = new TextBox();
textBoxEmail = new TextBox();
buttonCreate = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(36, 51);
labelName.Name = "labelName";
labelName.Size = new Size(42, 20);
labelName.TabIndex = 0;
labelName.Text = "Имя:";
//
// labelSurname
//
labelSurname.AutoSize = true;
labelSurname.Location = new Point(36, 100);
labelSurname.Name = "labelSurname";
labelSurname.Size = new Size(76, 20);
labelSurname.TabIndex = 1;
labelSurname.Text = "Фамилия:";
//
// labelPatronymic
//
labelPatronymic.AutoSize = true;
labelPatronymic.Location = new Point(36, 152);
labelPatronymic.Name = "labelPatronymic";
labelPatronymic.Size = new Size(75, 20);
labelPatronymic.TabIndex = 2;
labelPatronymic.Text = "Отчество:";
//
// labelTelephone
//
labelTelephone.AutoSize = true;
labelTelephone.Location = new Point(36, 206);
labelTelephone.Name = "labelTelephone";
labelTelephone.Size = new Size(138, 20);
labelTelephone.TabIndex = 3;
labelTelephone.Text = "Номера телефона:";
//
// labelEmail
//
labelEmail.AutoSize = true;
labelEmail.Location = new Point(36, 260);
labelEmail.Name = "labelEmail";
labelEmail.Size = new Size(54, 20);
labelEmail.TabIndex = 4;
labelEmail.Text = "Почта:";
//
// textBoxName
//
textBoxName.Location = new Point(195, 48);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(394, 27);
textBoxName.TabIndex = 5;
//
// textBoxSurname
//
textBoxSurname.Location = new Point(195, 97);
textBoxSurname.Name = "textBoxSurname";
textBoxSurname.Size = new Size(394, 27);
textBoxSurname.TabIndex = 6;
//
// textBoxPatronymic
//
textBoxPatronymic.Location = new Point(195, 149);
textBoxPatronymic.Name = "textBoxPatronymic";
textBoxPatronymic.Size = new Size(394, 27);
textBoxPatronymic.TabIndex = 7;
//
// textBoxTelephone
//
textBoxTelephone.Location = new Point(195, 203);
textBoxTelephone.Name = "textBoxTelephone";
textBoxTelephone.Size = new Size(394, 27);
textBoxTelephone.TabIndex = 8;
//
// textBoxEmail
//
textBoxEmail.Location = new Point(195, 257);
textBoxEmail.Name = "textBoxEmail";
textBoxEmail.Size = new Size(394, 27);
textBoxEmail.TabIndex = 9;
//
// buttonCreate
//
buttonCreate.Location = new Point(309, 318);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(131, 29);
buttonCreate.TabIndex = 10;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(458, 318);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(131, 29);
buttonCancel.TabIndex = 11;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormCreateClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(623, 372);
Controls.Add(buttonCancel);
Controls.Add(buttonCreate);
Controls.Add(textBoxEmail);
Controls.Add(textBoxTelephone);
Controls.Add(textBoxPatronymic);
Controls.Add(textBoxSurname);
Controls.Add(textBoxName);
Controls.Add(labelEmail);
Controls.Add(labelTelephone);
Controls.Add(labelPatronymic);
Controls.Add(labelSurname);
Controls.Add(labelName);
Name = "FormCreateClient";
Text = "Клиент";
Load += FormCreateClient_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelName;
private Label labelSurname;
private Label labelPatronymic;
private Label labelTelephone;
private Label labelEmail;
private TextBox textBoxName;
private TextBox textBoxSurname;
private TextBox textBoxPatronymic;
private TextBox textBoxTelephone;
private TextBox textBoxEmail;
private Button buttonCreate;
private Button buttonCancel;
}
}

View File

@ -1,137 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
namespace TransportCompany
{
public partial class FormCreateClient : Form
{
private readonly ILogger _logger;
private readonly IClientLogic _logicC;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateClient(ILogger<FormCreateClient> logger, IClientLogic logicC)
{
InitializeComponent();
_logger = logger;
_logicC = logicC;
}
//для загрузки данных при редактировании
private void FormCreateClient_Load(object sender, EventArgs e)
{
//проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение клиента");
var view = _logicC.ReadElement(new ClientSearchModel { Id = _id.Value });
if (view != null)
{
textBoxName.Text = view.Name;
textBoxSurname.Text = view.Surname;
textBoxPatronymic.Text = view.Patronymic;
textBoxTelephone.Text = view.Telephone;
textBoxEmail.Text = view.Email;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Введите своё имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxSurname.Text))
{
MessageBox.Show("Введите свою фамилию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxPatronymic.Text))
{
MessageBox.Show("Введите своё отчество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxTelephone.Text))
{
MessageBox.Show("Введите свой телефон", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxEmail.Text))
{
MessageBox.Show("Введите свою почту", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Добавление клиента");
try
{
var model = new ClientBindingModel
{
Id = 0,
Name = textBoxName.Text,
Surname = textBoxSurname.Text,
Patronymic = textBoxPatronymic.Text,
Telephone = textBoxTelephone.Text,
Email = textBoxEmail.Text
};
var operationResult = _id.HasValue ? _logicC.Update(model) : _logicC.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();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,96 +0,0 @@
namespace TransportCompany
{
partial class FormCreateTransport
{
/// <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()
{
label1 = new Label();
textBoxTransport = new TextBox();
buttonCreate = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(36, 43);
label1.Name = "label1";
label1.Size = new Size(122, 20);
label1.TabIndex = 0;
label1.Text = "Тип транспорта:";
//
// textBoxTransport
//
textBoxTransport.Location = new Point(215, 40);
textBoxTransport.Name = "textBoxTransport";
textBoxTransport.Size = new Size(254, 27);
textBoxTransport.TabIndex = 1;
//
// buttonCreate
//
buttonCreate.Location = new Point(262, 92);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(94, 29);
buttonCreate.TabIndex = 2;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(375, 92);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormCreateTransport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(527, 155);
Controls.Add(buttonCancel);
Controls.Add(buttonCreate);
Controls.Add(textBoxTransport);
Controls.Add(label1);
Name = "FormCreateTransport";
Text = "Транспорт";
Load += FormCreateTransport_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private TextBox textBoxTransport;
private Button buttonCreate;
private Button buttonCancel;
}
}

View File

@ -1,104 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
namespace TransportCompany
{
public partial class FormCreateTransport : Form
{
private readonly ILogger _logger;
private readonly ITransportLogic _logicT;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateTransport(ILogger<FormCreateTransport> logger, ITransportLogic logicT)
{
InitializeComponent();
_logger = logger;
_logicT = logicT;
}
private void FormCreateTransport_Load(object sender, EventArgs e)
{
//проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение транспорта");
var view = _logicT.ReadElement(new TransportSearchModel { Id = _id.Value });
if (view != null)
{
textBoxTransport.Text = view.Tranport;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения транспорта");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxTransport.Text))
{
MessageBox.Show("Введите тип транспорта", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Добавление транспорта");
try
{
var model = new TransportBindingModel
{
Id = 0,
Tranport = textBoxTransport.Text,
};
var operationResult = _id.HasValue ? _logicT.Update(model) : _logicT.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();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,232 +0,0 @@
namespace TransportCompany
{
partial class FormCreateTrucking
{
/// <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()
{
labelCLient = new Label();
label1 = new Label();
label2 = new Label();
label3 = new Label();
label4 = new Label();
label5 = new Label();
comboBoxClients = new ComboBox();
comboBoxCargos = new ComboBox();
comboBoxTransports = new ComboBox();
comboBoxTypeTransportations = new ComboBox();
dateTimePickerStart = new DateTimePicker();
dateTimePickerEnd = new DateTimePicker();
buttonCreate = new Button();
buttonCancel = new Button();
label6 = new Label();
textBoxPrice = new TextBox();
SuspendLayout();
//
// labelCLient
//
labelCLient.AutoSize = true;
labelCLient.Location = new Point(37, 30);
labelCLient.Name = "labelCLient";
labelCLient.Size = new Size(140, 20);
labelCLient.TabIndex = 0;
labelCLient.Text = "Выберите клиента:";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(37, 81);
label1.Name = "label1";
label1.Size = new Size(150, 20);
label1.TabIndex = 1;
label1.Text = "Выберите тип груза:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(37, 135);
label2.Name = "label2";
label2.Size = new Size(157, 20);
label2.TabIndex = 2;
label2.Text = "Выберите транспорт:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(37, 237);
label3.Name = "label3";
label3.Size = new Size(224, 20);
label3.TabIndex = 3;
label3.Text = "Дата начала транспортировки:";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(37, 288);
label4.Name = "label4";
label4.Size = new Size(217, 20);
label4.TabIndex = 4;
label4.Text = "Дата конца транспортировки:";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(37, 187);
label5.Name = "label5";
label5.Size = new Size(236, 20);
label5.TabIndex = 5;
label5.Text = "Выберите тип транспортировки:";
//
// comboBoxClients
//
comboBoxClients.FormattingEnabled = true;
comboBoxClients.Location = new Point(307, 27);
comboBoxClients.Name = "comboBoxClients";
comboBoxClients.Size = new Size(319, 28);
comboBoxClients.TabIndex = 6;
//
// comboBoxCargos
//
comboBoxCargos.FormattingEnabled = true;
comboBoxCargos.Location = new Point(307, 78);
comboBoxCargos.Name = "comboBoxCargos";
comboBoxCargos.Size = new Size(319, 28);
comboBoxCargos.TabIndex = 7;
//
// comboBoxTransports
//
comboBoxTransports.FormattingEnabled = true;
comboBoxTransports.Location = new Point(307, 127);
comboBoxTransports.Name = "comboBoxTransports";
comboBoxTransports.Size = new Size(319, 28);
comboBoxTransports.TabIndex = 8;
//
// comboBoxTypeTransportations
//
comboBoxTypeTransportations.FormattingEnabled = true;
comboBoxTypeTransportations.Location = new Point(307, 184);
comboBoxTypeTransportations.Name = "comboBoxTypeTransportations";
comboBoxTypeTransportations.Size = new Size(319, 28);
comboBoxTypeTransportations.TabIndex = 9;
//
// dateTimePickerStart
//
dateTimePickerStart.Location = new Point(307, 237);
dateTimePickerStart.Name = "dateTimePickerStart";
dateTimePickerStart.Size = new Size(319, 27);
dateTimePickerStart.TabIndex = 10;
//
// dateTimePickerEnd
//
dateTimePickerEnd.Location = new Point(307, 283);
dateTimePickerEnd.Name = "dateTimePickerEnd";
dateTimePickerEnd.Size = new Size(319, 27);
dateTimePickerEnd.TabIndex = 11;
//
// buttonCreate
//
buttonCreate.Location = new Point(373, 392);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(120, 29);
buttonCreate.TabIndex = 12;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(513, 392);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(113, 29);
buttonCancel.TabIndex = 13;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(37, 346);
label6.Name = "label6";
label6.Size = new Size(86, 20);
label6.TabIndex = 14;
label6.Text = "Стоимость:";
//
// textBoxPrice
//
textBoxPrice.Location = new Point(307, 343);
textBoxPrice.Name = "textBoxPrice";
textBoxPrice.Size = new Size(319, 27);
textBoxPrice.TabIndex = 15;
//
// FormCreateTrucking
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(666, 438);
Controls.Add(textBoxPrice);
Controls.Add(label6);
Controls.Add(buttonCancel);
Controls.Add(buttonCreate);
Controls.Add(dateTimePickerEnd);
Controls.Add(dateTimePickerStart);
Controls.Add(comboBoxTypeTransportations);
Controls.Add(comboBoxTransports);
Controls.Add(comboBoxCargos);
Controls.Add(comboBoxClients);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(labelCLient);
Name = "FormCreateTrucking";
Text = "Перевозка";
Load += FormCreateTrucking_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelCLient;
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private Label label5;
private ComboBox comboBoxClients;
private ComboBox comboBoxCargos;
private ComboBox comboBoxTransports;
private ComboBox comboBoxTypeTransportations;
private DateTimePicker dateTimePickerStart;
private DateTimePicker dateTimePickerEnd;
private Button buttonCreate;
private Button buttonCancel;
private Label label6;
private TextBox textBoxPrice;
}
}

View File

@ -1,176 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
namespace TransportCompany
{
public partial class FormCreateTrucking : Form
{
private readonly ILogger _logger;
private readonly IClientLogic _logicCl;
private readonly ITransportLogic _logicTransport;
private readonly ITransportationLogic _logicTransportation;
private readonly ICargoLogic _logicCargo;
private readonly ITruckingLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateTrucking(ILogger<FormCreateTrucking> logger, ITruckingLogic logic, ICargoLogic logicCargo,
IClientLogic logicCl, ITransportLogic logicTransport, ITransportationLogic logicTransportation)
{
InitializeComponent();
_logger = logger;
_logic = logic;
_logicCargo = logicCargo;
_logicCl = logicCl;
_logicTransport = logicTransport;
_logicTransportation = logicTransportation;
}
private void FormCreateTrucking_Load(object sender, EventArgs e)
{
try
{
_logger.LogInformation("Получение сводки по перевозке");
var viewClient = _logicCl.ReadList(null);
var viewCargo = _logicCargo.ReadList(null);
var viewTransport = _logicTransport.ReadList(null);
var viewTransportation = _logicTransportation.ReadList(null);
//var view = _logic.ReadElement(new TruckingSearchModel { Id = _id.Value });
if (viewClient != null)
{
comboBoxClients.DisplayMember = "Email";
comboBoxClients.ValueMember = "Id";
comboBoxClients.DataSource = viewClient;
comboBoxClients.SelectedItem = null;
}
if (viewCargo != null)
{
comboBoxCargos.DisplayMember = "TypeCargo";
comboBoxCargos.ValueMember = "Id";
comboBoxCargos.DataSource = viewCargo;
comboBoxCargos.SelectedItem = null;
}
if (viewTransport != null)
{
comboBoxTransports.DisplayMember = "Tranport";
comboBoxTransports.ValueMember = "Id";
comboBoxTransports.DataSource = viewTransport;
comboBoxTransports.SelectedItem = null;
}
if (viewTransportation != null)
{
comboBoxTypeTransportations.DisplayMember = "TransportationType";
comboBoxTypeTransportations.ValueMember = "Id";
comboBoxTypeTransportations.DataSource = viewTransportation;
comboBoxTypeTransportations.SelectedItem = null;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения сводки по перевозке");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
if (dateTimePickerStart.Value > dateTimePickerEnd.Value)
{
MessageBox.Show("Дата начала транспортировки не может быть позже её конца", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxClients.SelectedValue == null)
{
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxCargos.SelectedValue == null)
{
MessageBox.Show("Выберите груз", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxTransports.SelectedValue == null)
{
MessageBox.Show("Выберите транспорт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxTypeTransportations.SelectedValue == null)
{
MessageBox.Show("Выберите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание сводки по перевозке");
try
{
var operationResult = _logic.Create(new TruckingBindingModel
{
ClientId = Convert.ToInt32(comboBoxClients.SelectedValue),
CargoId = Convert.ToInt32(comboBoxCargos.SelectedValue),
TransportId = Convert.ToInt32(comboBoxTransports.SelectedValue),
TransportationId = Convert.ToInt32(comboBoxTypeTransportations.SelectedValue),
Price = Convert.ToInt32(textBoxPrice.Text),
DateStart = dateTimePickerStart.Value,
DateEnd = dateTimePickerEnd.Value
});
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();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,96 +0,0 @@
namespace TransportCompany
{
partial class FormCreateTypeTransportation
{
/// <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()
{
label1 = new Label();
textBoxTypeTransportation = new TextBox();
buttonCreate = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(24, 36);
label1.Name = "label1";
label1.Size = new Size(165, 20);
label1.TabIndex = 0;
label1.Text = "Тип транспортировки:";
//
// textBoxTypeTransportation
//
textBoxTypeTransportation.Location = new Point(232, 33);
textBoxTypeTransportation.Name = "textBoxTypeTransportation";
textBoxTypeTransportation.Size = new Size(330, 27);
textBoxTypeTransportation.TabIndex = 1;
//
// buttonCreate
//
buttonCreate.Location = new Point(355, 83);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(94, 29);
buttonCreate.TabIndex = 2;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(468, 83);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormCreateTypeTransportation
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(617, 138);
Controls.Add(buttonCancel);
Controls.Add(buttonCreate);
Controls.Add(textBoxTypeTransportation);
Controls.Add(label1);
Name = "FormCreateTypeTransportation";
Text = "FormCreateTypeTransportation";
Load += FormCreateTypeTransportation_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private TextBox textBoxTypeTransportation;
private Button buttonCreate;
private Button buttonCancel;
}
}

View File

@ -1,104 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
namespace TransportCompany
{
public partial class FormCreateTypeTransportation : Form
{
private readonly ILogger _logger;
private readonly ITransportationLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateTypeTransportation(ILogger<FormCreateTypeTransportation> logger, ITransportationLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormCreateTypeTransportation_Load(object sender, EventArgs e)
{
//проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение типа транспортировки");
var view = _logic.ReadElement(new TransportationSearchModel { Id = _id.Value });
if (view != null)
{
textBoxTypeTransportation.Text = view.TransportationType;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения типа транспортировки");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxTypeTransportation.Text))
{
MessageBox.Show("Введите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Добавление типа транспортировки");
try
{
var model = new TransportationBindingModel
{
Id = 0,
TransportationType = textBoxTypeTransportation.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();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,117 +0,0 @@
namespace TransportCompany
{
partial class FormRandomCreateClient
{
/// <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()
{
labelCount = new Label();
textBoxCount = new TextBox();
buttonStart = new Button();
buttonCancel = new Button();
label1 = new Label();
textBoxTimeWork = new TextBox();
SuspendLayout();
//
// labelCount
//
labelCount.AutoSize = true;
labelCount.Location = new Point(21, 25);
labelCount.Name = "labelCount";
labelCount.Size = new Size(93, 20);
labelCount.TabIndex = 0;
labelCount.Text = "Количество:";
//
// textBoxCount
//
textBoxCount.Location = new Point(158, 22);
textBoxCount.Name = "textBoxCount";
textBoxCount.Size = new Size(217, 27);
textBoxCount.TabIndex = 1;
//
// buttonStart
//
buttonStart.Location = new Point(147, 162);
buttonStart.Name = "buttonStart";
buttonStart.Size = new Size(110, 29);
buttonStart.TabIndex = 2;
buttonStart.Text = "Генерация";
buttonStart.UseVisualStyleBackColor = true;
buttonStart.Click += ButtonStart_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(281, 162);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(21, 101);
label1.Name = "label1";
label1.Size = new Size(113, 20);
label1.TabIndex = 4;
label1.Text = "Время работы:";
//
// textBoxTimeWork
//
textBoxTimeWork.Location = new Point(158, 98);
textBoxTimeWork.Name = "textBoxTimeWork";
textBoxTimeWork.Size = new Size(217, 27);
textBoxTimeWork.TabIndex = 5;
//
// FormRandomCreateClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(412, 220);
Controls.Add(textBoxTimeWork);
Controls.Add(label1);
Controls.Add(buttonCancel);
Controls.Add(buttonStart);
Controls.Add(textBoxCount);
Controls.Add(labelCount);
Name = "FormRandomCreateClient";
Text = "Случайная генерация клиентов";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelCount;
private TextBox textBoxCount;
private Button buttonStart;
private Button buttonCancel;
private Label label1;
private TextBox textBoxTimeWork;
}
}

View File

@ -1,70 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
namespace TransportCompany
{
public partial class FormRandomCreateClient : Form
{
private readonly IClientLogic _logicC;
Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
private string[] _names = { "Иван", "Егор", "Роман", "Денис", "Игнат", "Ренат", "Никита", "Павел", "Данил", "Максим", "Николай", "Дмитрий", "Владислав", "Марк", "Булат", "Марсель", "Назар", "Багир", "Кирилл", "Всеволод", "Ярослав", "Юрий", "Виталий" };
private string[] _surnames = { "Иванов", "Елисеев", "Марков", "Негин", "Мусоев", "Сегреев", "Распаев", "Минаров", "Захарченко", "Пятаков", "Юдаков", "Карташев", "Селин", "Марков", "Захаров", "Никитин", "Распаев", "Алексанян", "Скалкин", "Строев", "Горшков", "Каримов", "Кочкадаев", "Ершов", "Алиакберов", "Закуанов", "Пахомов" };
private string[] _patronymics = { "Иванович", "Евгеньевич", "Егорович", "Николаевич", "Дмитриевич", "Владиславович", "Юрьевич", "Кириллович", "Артемиевич", "Павлович", "Максимович", "Назарович", "Багирович", "Булатович", "Всеволодович", "Витальевич", "Евгеньевич", "Романович", "Ярославович", "Данилович", "Зульфия", "Марсельевич", "Маркович", };
private string[] _telephones = { "89529876316", "88804293534", "84508874804", "82035754008", "80926246994", "83316923921", "88497436387", "82372606638", "81582656294", "83605675249", "87978864427", "81882538381", "83432311066", "80220603131", "82166498710", "80271945648", "83581821702", "84911615179", "89993116947", "80830482909", "89463846784", "84817550460", "81785373218", "80654035595", "81304432863", "85601863128" };
private string[] _emails = { "deffabuttiprei-5025@yopmail.com", "quiquoucrobrilla-7902@yopmail.com", "tucoffokexoi-9537@yopmail.com", "nebroijulleinne-7231@yopmail.com", "xedeujezoilli-1668@yopmail.com", "foikoussoidouhau-5112@yopmail.com", "pruddougoddeda-2757@yopmail.com", "keidevoillaga-5758@yopmail.com", "palemeinnacra-4165@yopmail.com", "capribukoippa-8523@yopmail.com", "truwauheineita-8708@yopmail.com", "mudebralanu-3594@yopmail.com", "nuxauttisoibri-7020@yopmail.com", "dufenosatte-4543@yopmail.com", "xullusaquilou-9479@yopmail.com", "broixifrommelle-3859@yopmail.com", "yimozofreixeu-4046@yopmail.com", "wetrouddemoro-9168@yopmail.com", "crepropretaji-6969@yopmail.com", "pahoufforutre-6805@yopmail.com", "gretreidineuba-8655@yopmail.com", "koullinnorulli-5851@yopmail.com", "bougreigewetto-3164@yopmail.com", "brocoffanauba-5102@yopmail.com", "kaddasumetre-7742@yopmail.com", "heussouprogromu-7061@yopmail.com", "teresitruffe-8881@yopmail.com", "kejicrouzazei-9377@yopmail.com", "zoicaquaugrili-2744@yopmail.com", "quepifrucragrou-8404@yopmail.com", "graditilladdi-7217@yopmail.com", "doboijifammeu-4816@yopmail.com", "tobrograusessoi-6295@yopmail.com", "xeifeuffiyoka-8243@yopmail.com", "greuquekucaju-9438@yopmail.com", "prisseproittunne-3785@yopmail.com", "vuppeiyatrare-8690@yopmail.com", "pennibexewa-9132@yopmail.com", "gayufeppaucu-4744@yopmail.com", "boicegreisussa-1695@yopmail.com" };
public FormRandomCreateClient(IClientLogic logicC)
{
InitializeComponent();
_logicC = logicC;
}
private void ButtonStart_Click(object sender, EventArgs e)
{
try
{
ChangeList(_telephones);
ChangeList(_emails);
textBoxTimeWork.Text = _logicC.TestRandomCreate(Convert.ToInt32(textBoxCount.Text), _names, _surnames, _patronymics, _telephones, _emails);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void ChangeList(string[] _strings)
{
for(int i = 0; i < _strings.Length; i++)
{
_strings[i] = Convert.ToString(rnd.Next(0, 800000)) + _strings[i];
}
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,117 +0,0 @@
namespace TransportCompany
{
partial class FormRandomCreateTrucking
{
/// <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()
{
labelClient = new Label();
textBoxCount = new TextBox();
buttonCreate = new Button();
buttonCancel = new Button();
label1 = new Label();
textBoxCheckTest = new TextBox();
SuspendLayout();
//
// labelClient
//
labelClient.AutoSize = true;
labelClient.Location = new Point(32, 33);
labelClient.Name = "labelClient";
labelClient.Size = new Size(151, 20);
labelClient.TabIndex = 0;
labelClient.Text = "Введите количество:";
//
// textBoxCount
//
textBoxCount.Location = new Point(221, 30);
textBoxCount.Name = "textBoxCount";
textBoxCount.Size = new Size(280, 27);
textBoxCount.TabIndex = 1;
//
// buttonCreate
//
buttonCreate.Location = new Point(237, 148);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(123, 29);
buttonCreate.TabIndex = 2;
buttonCreate.Text = "Генерация";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(382, 148);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(119, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(32, 99);
label1.Name = "label1";
label1.Size = new Size(145, 20);
label1.TabIndex = 4;
label1.Text = "Время добавления:";
//
// textBoxCheckTest
//
textBoxCheckTest.Location = new Point(221, 96);
textBoxCheckTest.Name = "textBoxCheckTest";
textBoxCheckTest.Size = new Size(280, 27);
textBoxCheckTest.TabIndex = 5;
//
// FormRandomCreateTrucking
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(548, 215);
Controls.Add(textBoxCheckTest);
Controls.Add(label1);
Controls.Add(buttonCancel);
Controls.Add(buttonCreate);
Controls.Add(textBoxCount);
Controls.Add(labelClient);
Name = "FormRandomCreateTrucking";
Text = "Генерация перевозок";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelClient;
private TextBox textBoxCount;
private Button buttonCreate;
private Button buttonCancel;
private Label label1;
private TextBox textBoxCheckTest;
}
}

View File

@ -1,64 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
namespace TransportCompany
{
public partial class FormRandomCreateTrucking : Form
{
private readonly IClientLogic _logicCl;
private readonly ITransportLogic _logicTransport;
private readonly ITransportationLogic _logicTransportation;
private readonly ICargoLogic _logicCargo;
private readonly ITruckingLogic _logic;
public FormRandomCreateTrucking(ILogger<FormRandomCreateTrucking> logger, ITruckingLogic logic, ICargoLogic logicCargo,
IClientLogic logicCl, ITransportLogic logicTransport, ITransportationLogic logicTransportation)
{
InitializeComponent();
_logic = logic;
_logicCargo = logicCargo;
_logicCl = logicCl;
_logicTransport = logicTransport;
_logicTransportation = logicTransportation;
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
var viewClient = _logicCl.ReadList(null);
var viewCargo = _logicCargo.ReadList(null);
var viewTransport = _logicTransport.ReadList(null);
var viewTransportation = _logicTransportation.ReadList(null);
try
{
textBoxCheckTest.Text = _logic.TestRandomCreate(Convert.ToInt32(textBoxCount.Text), viewClient, viewCargo, viewTransport, viewTransportation);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,117 +0,0 @@
namespace TransportCompany
{
partial class FormTimeCheck
{
/// <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()
{
buttonStartTest = new Button();
buttonCancel = new Button();
label1 = new Label();
textBoxCount = new TextBox();
label2 = new Label();
textBoxTimeWork = new TextBox();
SuspendLayout();
//
// buttonStartTest
//
buttonStartTest.Location = new Point(123, 22);
buttonStartTest.Name = "buttonStartTest";
buttonStartTest.Size = new Size(257, 75);
buttonStartTest.TabIndex = 0;
buttonStartTest.Text = "Запуск теста";
buttonStartTest.UseVisualStyleBackColor = true;
buttonStartTest.Click += ButtonStartTest_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(361, 241);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 30);
buttonCancel.TabIndex = 1;
buttonCancel.Text = "Закрыть";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(25, 131);
label1.Name = "label1";
label1.Size = new Size(230, 20);
label1.TabIndex = 2;
label1.Text = "Кол-во считываемых значений:";
//
// textBoxCount
//
textBoxCount.Location = new Point(284, 128);
textBoxCount.Name = "textBoxCount";
textBoxCount.Size = new Size(171, 27);
textBoxCount.TabIndex = 3;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(25, 186);
label2.Name = "label2";
label2.Size = new Size(113, 20);
label2.TabIndex = 4;
label2.Text = "Время работы:";
//
// textBoxTimeWork
//
textBoxTimeWork.Location = new Point(284, 183);
textBoxTimeWork.Name = "textBoxTimeWork";
textBoxTimeWork.Size = new Size(171, 27);
textBoxTimeWork.TabIndex = 5;
//
// FormTimeCheck
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(480, 285);
Controls.Add(textBoxTimeWork);
Controls.Add(label2);
Controls.Add(textBoxCount);
Controls.Add(label1);
Controls.Add(buttonCancel);
Controls.Add(buttonStartTest);
Name = "FormTimeCheck";
Text = "Тест скорости чтения записей перевозок";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonStartTest;
private Button buttonCancel;
private Label label1;
private TextBox textBoxCount;
private Label label2;
private TextBox textBoxTimeWork;
}
}

View File

@ -1,51 +0,0 @@
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;
using TransportCompanyBusinessLogic.BusinessLogic;
using TransportCompanyContracts.BusinessLogicsContracts;
namespace TransportCompany
{
//форма за измерения времени считывания значений
public partial class FormTimeCheck : Form
{
private readonly ITruckingLogic _truckingLogic;
public FormTimeCheck(ITruckingLogic truckingLogic)
{
InitializeComponent();
_truckingLogic = truckingLogic;
}
private void ButtonStartTest_Click(object sender, EventArgs e)
{
try
{
var result = _truckingLogic.TestReadList();
string[] parameters = result.Split(' ');
textBoxCount.Text = parameters[0];
textBoxTimeWork.Text = parameters[1];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,114 +0,0 @@
namespace TransportCompany
{
partial class FormTransport
{
/// <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()
{
dataGridView = new DataGridView();
buttonCreate = new Button();
buttonUpdate = new Button();
buttonReload = new Button();
buttonDelete = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 12);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(455, 426);
dataGridView.TabIndex = 0;
//
// buttonCreate
//
buttonCreate.Location = new Point(521, 39);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(138, 29);
buttonCreate.TabIndex = 1;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(521, 112);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(138, 29);
buttonUpdate.TabIndex = 2;
buttonUpdate.Text = "Изменить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonReload
//
buttonReload.Location = new Point(521, 258);
buttonReload.Name = "buttonReload";
buttonReload.Size = new Size(138, 29);
buttonReload.TabIndex = 4;
buttonReload.Text = "Обновить";
buttonReload.UseVisualStyleBackColor = true;
buttonReload.Click += ButtonReload_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(521, 184);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(138, 29);
buttonDelete.TabIndex = 5;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// FormTransport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(703, 450);
Controls.Add(buttonDelete);
Controls.Add(buttonReload);
Controls.Add(buttonUpdate);
Controls.Add(buttonCreate);
Controls.Add(dataGridView);
Name = "FormTransport";
Text = "FormTransports";
Load += FormTransport_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonCreate;
private Button buttonUpdate;
private Button buttonReload;
private Button buttonDelete;
}
}

View File

@ -1,131 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
namespace TransportCompany
{
public partial class FormTransport : Form
{
private readonly ILogger _logger;
private readonly ITransportLogic _logic;
public FormTransport(ILogger<FormTransport> logger, ITransportLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormClients_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
//растягиваем колонку Название на всю ширину, колонку Id скрываем
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка транспортных средств");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки транспортных средств");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormTransport_Load(object sender, EventArgs e)
{
LoadData();
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTransport));
if (service is FormCreateTransport form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTransport));
if (service is FormCreateTransport form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_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 TransportBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления транспорта");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonReload_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,252 +0,0 @@
namespace TransportCompany
{
partial class FormTrucking
{
/// <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()
{
dataGridView = new DataGridView();
buttonCreateTrucking = new Button();
menuStrip = new MenuStrip();
toolStripMenuItem = new ToolStripMenuItem();
transportToolStripMenuItem = new ToolStripMenuItem();
typeTransportationToolStripMenuItem = new ToolStripMenuItem();
cargoToolStripMenuItem = new ToolStripMenuItem();
clientToolStripMenuItem = new ToolStripMenuItem();
rndGenerationToolStripMenuItem = new ToolStripMenuItem();
generationClientsToolStripMenuItem = new ToolStripMenuItem();
generationTruckingsToolStripMenuItem = new ToolStripMenuItem();
buttonUpdate = new Button();
comboBoxEmails = new ComboBox();
label1 = new Label();
checkBoxSorted = new CheckBox();
checkBoxForFilterMode = new CheckBox();
testTimeGetDataToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
menuStrip.SuspendLayout();
SuspendLayout();
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(11, 67);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(937, 417);
dataGridView.TabIndex = 0;
//
// buttonCreateTrucking
//
buttonCreateTrucking.Location = new Point(1014, 67);
buttonCreateTrucking.Name = "buttonCreateTrucking";
buttonCreateTrucking.Size = new Size(235, 29);
buttonCreateTrucking.TabIndex = 1;
buttonCreateTrucking.Text = "Создать перевозку";
buttonCreateTrucking.UseVisualStyleBackColor = true;
buttonCreateTrucking.Click += ButtonCreateTrucking_Click;
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, rndGenerationToolStripMenuItem, testTimeGetDataToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Padding = new Padding(6, 3, 0, 3);
menuStrip.Size = new Size(1297, 30);
menuStrip.TabIndex = 6;
menuStrip.Text = "menuStrip1";
//
// toolStripMenuItem
//
toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transportToolStripMenuItem, typeTransportationToolStripMenuItem, cargoToolStripMenuItem, clientToolStripMenuItem });
toolStripMenuItem.Name = "toolStripMenuItem";
toolStripMenuItem.Size = new Size(117, 24);
toolStripMenuItem.Text = "Справочники";
//
// transportToolStripMenuItem
//
transportToolStripMenuItem.Name = "transportToolStripMenuItem";
transportToolStripMenuItem.Size = new Size(245, 26);
transportToolStripMenuItem.Text = "Транспорт";
transportToolStripMenuItem.Click += TransportToolStripMenuItem_Click;
//
// typeTransportationToolStripMenuItem
//
typeTransportationToolStripMenuItem.Name = "typeTransportationToolStripMenuItem";
typeTransportationToolStripMenuItem.Size = new Size(245, 26);
typeTransportationToolStripMenuItem.Text = "Тип транспортировки";
typeTransportationToolStripMenuItem.Click += TypeTransportationToolStripMenuItem_Click;
//
// cargoToolStripMenuItem
//
cargoToolStripMenuItem.Name = "cargoToolStripMenuItem";
cargoToolStripMenuItem.Size = new Size(245, 26);
cargoToolStripMenuItem.Text = "Груз";
cargoToolStripMenuItem.Click += CargoToolStripMenuItem_Click;
//
// clientToolStripMenuItem
//
clientToolStripMenuItem.Name = "clientToolStripMenuItem";
clientToolStripMenuItem.Size = new Size(245, 26);
clientToolStripMenuItem.Text = "Клиенты";
clientToolStripMenuItem.Click += ClientToolStripMenuItem_Click;
//
// rndGenerationToolStripMenuItem
//
rndGenerationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { generationClientsToolStripMenuItem, generationTruckingsToolStripMenuItem });
rndGenerationToolStripMenuItem.Name = "rndGenerationToolStripMenuItem";
rndGenerationToolStripMenuItem.Size = new Size(179, 24);
rndGenerationToolStripMenuItem.Text = "Рандомная генерация";
//
// generationClientsToolStripMenuItem
//
generationClientsToolStripMenuItem.Name = "generationClientsToolStripMenuItem";
generationClientsToolStripMenuItem.Size = new Size(245, 26);
generationClientsToolStripMenuItem.Text = "Генерация клиентов";
generationClientsToolStripMenuItem.Click += GenerationClientsToolStripMenuItem_Click;
//
// generationTruckingsToolStripMenuItem
//
generationTruckingsToolStripMenuItem.Name = "generationTruckingsToolStripMenuItem";
generationTruckingsToolStripMenuItem.Size = new Size(245, 26);
generationTruckingsToolStripMenuItem.Text = "Генерация перевозок";
generationTruckingsToolStripMenuItem.Click += GenerationTruckingsToolStripMenuItem_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(1014, 138);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(235, 29);
buttonUpdate.TabIndex = 7;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// comboBoxEmails
//
comboBoxEmails.FormattingEnabled = true;
comboBoxEmails.Location = new Point(142, 33);
comboBoxEmails.Name = "comboBoxEmails";
comboBoxEmails.Size = new Size(208, 28);
comboBoxEmails.TabIndex = 8;
comboBoxEmails.SelectedIndexChanged += ComboBoxEmails_SelectedIndexChanged;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 36);
label1.Name = "label1";
label1.Size = new Size(124, 20);
label1.TabIndex = 9;
label1.Text = "Выберите почту:";
//
// checkBoxSorted
//
checkBoxSorted.AutoSize = true;
checkBoxSorted.Location = new Point(632, 35);
checkBoxSorted.Name = "checkBoxSorted";
checkBoxSorted.Size = new Size(316, 24);
checkBoxSorted.TabIndex = 10;
checkBoxSorted.Text = "Сортировать по возрастанию стоимости";
checkBoxSorted.UseVisualStyleBackColor = true;
checkBoxSorted.CheckedChanged += CheckBoxSorted_CheckedChanged;
//
// checkBoxForFilterMode
//
checkBoxForFilterMode.AutoSize = true;
checkBoxForFilterMode.Location = new Point(370, 35);
checkBoxForFilterMode.Name = "checkBoxForFilterMode";
checkBoxForFilterMode.Size = new Size(212, 24);
checkBoxForFilterMode.TabIndex = 11;
checkBoxForFilterMode.Text = "Включить режим фильтра";
checkBoxForFilterMode.UseVisualStyleBackColor = true;
//
// testTimeGetDataToolStripMenuItem
//
testTimeGetDataToolStripMenuItem.Name = "testTimeGetDataToolStripMenuItem";
testTimeGetDataToolStripMenuItem.Size = new Size(227, 24);
testTimeGetDataToolStripMenuItem.Text = "Тест скорости чтения данных";
testTimeGetDataToolStripMenuItem.Click += TestTimeGetDataToolStripMenuItem_Click;
//
// FormTrucking
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1297, 496);
Controls.Add(checkBoxForFilterMode);
Controls.Add(checkBoxSorted);
Controls.Add(label1);
Controls.Add(comboBoxEmails);
Controls.Add(buttonUpdate);
Controls.Add(buttonCreateTrucking);
Controls.Add(dataGridView);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormTrucking";
Text = "Перевозки";
Load += FormMain_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private DataGridView dataGridView;
private Button buttonCreateTrucking;
private Button buttonTakeOrderInWork;
private Button buttonOrderReady;
private Button buttonIssuedOrder;
private Button buttonRef;
private MenuStrip menuStrip;
private ToolStripMenuItem toolStripMenuItem;
private ToolStripMenuItem transportToolStripMenuItem;
private ToolStripMenuItem workPieceToolStripMenuItem;
private ToolStripMenuItem typeTransportationToolStripMenuItem;
private ToolStripMenuItem cargoToolStripMenuItem;
private ToolStripMenuItem clientToolStripMenuItem;
private ToolStripMenuItem shopToolStripMenuItem;
private ToolStripMenuItem addManufactureToolStripMenuItem;
private Button buttonSellManufacture;
private ToolStripMenuItem reportToolStripMenuItem;
private ToolStripMenuItem groupedOrdersReportToolStripMenuItem;
private ToolStripMenuItem ordersReportToolStripMenuItem;
private ToolStripMenuItem manufactureWorkPiecesReportToolStripMenuItem;
private ToolStripMenuItem shopsReportToolStripMenuItem;
private ToolStripMenuItem rndGenerationToolStripMenuItem;
private ToolStripMenuItem generationClientsToolStripMenuItem;
private ToolStripMenuItem generationTruckingsToolStripMenuItem;
private Button buttonUpdate;
private ComboBox comboBoxEmails;
private Label label1;
private CheckBox checkBoxSorted;
private CheckBox checkBoxForFilterMode;
private ToolStripMenuItem testTimeGetDataToolStripMenuItem;
}
}

View File

@ -1,180 +0,0 @@
using Microsoft.Extensions.Logging;
using System.ComponentModel;
using System.Reflection;
using System.Windows.Forms;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace TransportCompany
{
public partial class FormTrucking : Form
{
private readonly ILogger _logger;
private readonly ITruckingLogic _truckingLogic;
private readonly IClientLogic _clientLogic;
public FormTrucking(ILogger<FormTrucking> logger, ITruckingLogic truckingLogic, IClientLogic clientLogic)
{
InitializeComponent();
_logger = logger;
_truckingLogic = truckingLogic;
_clientLogic = clientLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
_logger.LogInformation("Çàãðóçêà ïåðåâîçîê");
try
{
var list = _truckingLogic.ReadList(null);
var listClients = _clientLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["CargoId"].Visible = false;
dataGridView.Columns["TransportId"].Visible = false;
dataGridView.Columns["TransportationId"].Visible = false;
}
if (listClients != null)
{
comboBoxEmails.DisplayMember = "Email";
comboBoxEmails.ValueMember = "Id";
comboBoxEmails.DataSource = listClients;
comboBoxEmails.SelectedItem = null;
}
_logger.LogInformation("Çàãðóçêà ïåðåâîçîê");
}
catch (Exception ex)
{
_logger.LogError(ex, "Îøèáêà çàãðóçêè ïåðåâîçîê");
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCreateTrucking_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTrucking));
if (service is FormCreateTrucking form)
{
form.ShowDialog();
LoadData();
}
}
private void TransportToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTransport));
if (service is FormTransport form)
{
form.ShowDialog();
LoadData();
}
}
private void CargoToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCargo));
if (service is FormCargo form)
{
form.ShowDialog();
LoadData();
}
}
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
LoadData();
}
}
private void TypeTransportationToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTypeTransportation));
if (service is FormTypeTransportation form)
{
form.ShowDialog();
LoadData();
}
}
private void GenerationClientsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateClient));
if (service is FormRandomCreateClient form)
{
form.ShowDialog();
LoadData();
}
}
private void GenerationTruckingsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateTrucking));
if (service is FormRandomCreateTrucking form)
{
form.ShowDialog();
LoadData();
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void ComboBoxEmails_SelectedIndexChanged(object sender, EventArgs e)
{
if (!checkBoxForFilterMode.Checked)
{
//dataGridView.DataSource = _truckingLogic.ReadList(null);
LoadData();
}
else
{
dataGridView.DataSource = _truckingLogic.ReadList(null).Where(x => x.ClientId == comboBoxEmails.SelectedIndex).ToList();
}
}
private void CheckBoxSorted_CheckedChanged(object sender, EventArgs e)
{
dataGridView.DataSource = _truckingLogic.ReadList(null).OrderByDescending(x => x.Price).ToList();
}
private void TestTimeGetDataToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTimeCheck));
if (service is FormTimeCheck form)
{
form.ShowDialog();
LoadData();
}
}
}
}

View File

@ -1,63 +0,0 @@
<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="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -1,114 +0,0 @@
namespace TransportCompany
{
partial class FormTypeTransportation
{
/// <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()
{
dataGridView = new DataGridView();
buttonCreate = new Button();
buttonUpdate = new Button();
buttonDelete = new Button();
buttonReload = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 12);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(450, 426);
dataGridView.TabIndex = 0;
//
// buttonCreate
//
buttonCreate.Location = new Point(512, 27);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(145, 29);
buttonCreate.TabIndex = 1;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(512, 93);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(145, 29);
buttonUpdate.TabIndex = 2;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(512, 160);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(145, 29);
buttonDelete.TabIndex = 3;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonReload
//
buttonReload.Location = new Point(512, 228);
buttonReload.Name = "buttonReload";
buttonReload.Size = new Size(145, 29);
buttonReload.TabIndex = 4;
buttonReload.Text = "Обновить";
buttonReload.UseVisualStyleBackColor = true;
buttonReload.Click += ButtonReload_Click;
//
// FormTypeTransportation
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(701, 450);
Controls.Add(buttonReload);
Controls.Add(buttonDelete);
Controls.Add(buttonUpdate);
Controls.Add(buttonCreate);
Controls.Add(dataGridView);
Name = "FormTypeTransportation";
Text = "Типы перевозок";
Load += FormTypeTransportation_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonCreate;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonReload;
}
}

View File

@ -1,126 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
namespace TransportCompany
{
public partial class FormTypeTransportation : Form
{
private readonly ILogger _logger;
private readonly ITransportationLogic _logic;
public FormTypeTransportation(ILogger<FormTypeTransportation> logger, ITransportationLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormTypeTransportation_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
//растягиваем колонку Название на всю ширину, колонку Id скрываем
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка типа перевозок");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки типа перевозок");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTypeTransportation));
if (service is FormCreateTypeTransportation form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTypeTransportation));
if (service is FormCreateTypeTransportation form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_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 TransportationBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления типа перевозки");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonReload_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,67 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using TransportCompanyBusinessLogic.BusinessLogic;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyDatabaseImplements.Implements;
namespace TransportCompany
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font;
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormTrucking>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<ICargoStorage, CargoStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<ITransportStorage, TransportStorage>();
services.AddTransient<ITransportationStorage, TransportationStorage>();
services.AddTransient<ITruckingStorage, TruckingStorage>();
services.AddTransient<ICargoLogic, CargoLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<ITransportLogic, TransportLogic>();
services.AddTransient<ITransportationLogic, TransportationLogic>();
services.AddTransient<ITruckingLogic, TruckingLogic>();
services.AddTransient<FormTrucking>();
services.AddTransient<FormCargo>();
services.AddTransient<FormClients>();
services.AddTransient<FormTransport>();
services.AddTransient<FormTypeTransportation>();
services.AddTransient<FormCreateCargo>();
services.AddTransient<FormCreateClient>();
services.AddTransient<FormCreateTrucking>();
services.AddTransient<FormCreateTransport>();
services.AddTransient<FormCreateTypeTransportation>();
services.AddTransient<FormRandomCreateClient>();
services.AddTransient<FormRandomCreateTrucking>();
services.AddTransient<FormTimeCheck>();
}
}
}

View File

@ -1,31 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj" />
<ProjectReference Include="..\TransportCompanyContracts\TransportCompanyContracts.csproj" />
<ProjectReference Include="..\TransportCompanyDatabaseImplements\TransportCompanyDatabaseImplements.csproj" />
<ProjectReference Include="..\TransportCompanyDataModels\TransportCompanyDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -1,149 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyBusinessLogic.BusinessLogic
{
public class CargoLogic : ICargoLogic
{
private readonly ILogger _logger;
private readonly ICargoStorage _cargoStorage;
//конструктор
public CargoLogic(ILogger<CargoLogic> logger, ICargoStorage cargoStorage)
{
_logger = logger;
_cargoStorage = cargoStorage;
}
public List<CargoViewModel>? ReadList(CargoSearchModel? model)
{
_logger.LogInformation("ReadList. TypeCargo:{TypeCargo}. Id:{Id}", model?.TypeCargo, model?.Id);
//list хранит весь список в случае, если model пришло со значением null на вход метода
var list = model == null ? _cargoStorage.GetFullList() : _cargoStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public CargoViewModel? ReadElement(CargoSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. TypeCargo:{TypeCargo}. Id:{Id}", model.TypeCargo, model.Id);
var element = _cargoStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
return element;
}
public bool Create(CargoBindingModel model)
{
CheckModel(model);
if (_cargoStorage.Insert(model) == null)
{
_logger.LogWarning("Create operation failed");
return false;
}
return true;
}
public bool Update(CargoBindingModel model)
{
CheckModel(model);
if (_cargoStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(CargoBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_cargoStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
//проверка входного аргумента для методов Insert, Update и Delete
private void CheckModel(CargoBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
//так как при удалении параметром withParams передаём false
if (!withParams)
{
return;
}
//проверка на наличие названия типа груза
if (string.IsNullOrEmpty(model.TypeCargo))
{
throw new ArgumentNullException("названия типа груза", nameof(model.TypeCargo));
}
_logger.LogInformation("Cargo. TypeCargo:{TypeCargo}. Id:{Id}",
model.TypeCargo, model.Id);
//проверка на наличие такого же типа груза в списке
var element = _cargoStorage.GetElement(new CargoSearchModel
{
TypeCargo = model.TypeCargo,
});
//если элемент найден и его Id не совпадает с Id объекта, переданного на вход
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Такой тип груза уже есть");
}
}
}
}

View File

@ -1,179 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyBusinessLogic.BusinessLogic
{
public class ClientLogic : IClientLogic
{
private readonly ILogger _logger;
private readonly IClientStorage _clientStorage;
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
{
_logger = logger;
_clientStorage = clientStorage;
}
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
{
_logger.LogInformation("ReadList. Surname:{Surname}. Id:{Id}", model?.Surname, model?.Id);
//list хранит весь список в случае, если model пришло со значением null на вход метода
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ClientViewModel? ReadElement(ClientSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Surname:{Surname}. Id:{Id}", model.Surname, model.Id);
var element = _clientStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
return element;
}
public bool Create(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Insert(model) == null)
{
_logger.LogWarning("Create operation failed");
return false;
}
return true;
}
public string TestRandomCreate(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email)
{
return _clientStorage.TestRandomInsert(count, _name, _surname, _patronymic, _telephone, _email);
}
public bool Update(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ClientBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_clientStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
//проверка входного аргумента для методов Insert, Update и Delete
private void CheckModel(ClientBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
//так как при удалении параметром withParams передаём false
if (!withParams)
{
return;
}
//проверка на наличие имени
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет имени клиента", nameof(model.Name));
}
//проверка на наличие фамилии
if (string.IsNullOrEmpty(model.Surname))
{
throw new ArgumentNullException("Нет фамилии клиента", nameof(model.Surname));
}
//проверка на наличие отчества
if (string.IsNullOrEmpty(model.Patronymic))
{
throw new ArgumentNullException("Нет отчества клиента", nameof(model.Patronymic));
}
//проверка на наличие телефонного номера
if (string.IsNullOrEmpty(model.Telephone))
{
throw new ArgumentNullException("Нет телефонного номера клиента", nameof(model.Telephone));
}
//проверка на наличие почты
if (string.IsNullOrEmpty(model.Email))
{
throw new ArgumentNullException("Нет электронной почты клиента", nameof(model.Email));
}
_logger.LogInformation("Client. Name:{Name}. Surname:{Surname}. Patronymic:{Patronymic}. " +
"TelephoneNumber:{TelephoneNumber}. Email:{Email}. Id:{Id}",
model.Name, model.Surname, model.Patronymic, model.Telephone, model.Email, model.Id);
//проверка на наличие такой же почты в списке
var element = _clientStorage.GetElement(new ClientSearchModel
{
Email = model.Email,
});
//если почта найдена и его Id не совпадает с Id объекта, переданного на вход
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Клиент с такой почтой уже есть");
}
}
}
}

View File

@ -1,148 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyBusinessLogic.BusinessLogic
{
public class TransportLogic : ITransportLogic
{
private readonly ILogger _logger;
private readonly ITransportStorage _transportStorage;
//конструктор
public TransportLogic(ILogger<TransportLogic> logger, ITransportStorage transportStorage)
{
_logger = logger;
_transportStorage = transportStorage;
}
public List<TransportViewModel>? ReadList(TransportSearchModel? model)
{
_logger.LogInformation("ReadList. Tranport:{Tranport}. Id:{Id}", model?.Tranport, model?.Id);
//list хранит весь список в случае, если model пришло со значением null на вход метода
var list = model == null ? _transportStorage.GetFullList() : _transportStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public TransportViewModel? ReadElement(TransportSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Tranport:{Tranport}. Id:{Id}", model.Tranport, model.Id);
var element = _transportStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
return element;
}
public bool Create(TransportBindingModel model)
{
CheckModel(model);
if (_transportStorage.Insert(model) == null)
{
_logger.LogWarning("Create operation failed");
return false;
}
return true;
}
public bool Update(TransportBindingModel model)
{
CheckModel(model);
if (_transportStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(TransportBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_transportStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
//проверка входного аргумента для методов Insert, Update и Delete
private void CheckModel(TransportBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
//так как при удалении параметром withParams передаём false
if (!withParams)
{
return;
}
//проверка на наличие названия транспортного средства
if (string.IsNullOrEmpty(model.Tranport))
{
throw new ArgumentNullException("Нет названия транспортного средства", nameof(model.Tranport));
}
_logger.LogInformation("Tranport. Tranport:{Tranport}. Id:{Id}", model.Tranport, model.Id);
//проверка на наличие такого же транспортного средства в списке
var element = _transportStorage.GetElement(new TransportSearchModel
{
Tranport = model.Tranport,
});
//если элемент найден и его Id не совпадает с Id объекта, переданного на вход
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Такое транспортное средство уже есть");
}
}
}
}

View File

@ -1,150 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyBusinessLogic.BusinessLogic
{
public class TransportationLogic : ITransportationLogic
{
private readonly ILogger _logger;
private readonly ITransportationStorage _transportationStorage;
//конструктор
public TransportationLogic(ILogger<TransportationLogic> logger, ITransportationStorage transportationStorage)
{
_logger = logger;
_transportationStorage = transportationStorage;
}
public List<TransportationViewModel>? ReadList(TransportationSearchModel? model)
{
_logger.LogInformation("ReadList. TransportationType:{TransportationType}. Id:{Id}", model?.TransportationType, model?.Id);
//list хранит весь список в случае, если model пришло со значением null на вход метода
var list = model == null ? _transportationStorage.GetFullList() : _transportationStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public TransportationViewModel? ReadElement(TransportationSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. TransportationType:{TransportationType}. Id:{Id}", model.TransportationType, model.Id);
var element = _transportationStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
return element;
}
public bool Create(TransportationBindingModel model)
{
CheckModel(model);
if (_transportationStorage.Insert(model) == null)
{
_logger.LogWarning("Create operation failed");
return false;
}
return true;
}
public bool Update(TransportationBindingModel model)
{
CheckModel(model);
if (_transportationStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(TransportationBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_transportationStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
//проверка входного аргумента для методов Insert, Update и Delete
private void CheckModel(TransportationBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
//так как при удалении параметром withParams передаём false
if (!withParams)
{
return;
}
//проверка на наличие типа перевозки
if (string.IsNullOrEmpty(model.TransportationType))
{
throw new ArgumentNullException("Нет названия изделия", nameof(model.TransportationType));
}
_logger.LogInformation("Transportation. TransportationType:{TransportationType}. Id:{Id}",
model.TransportationType, model.Id);
//проверка на наличие такого же типа перевозки в списке
var element = _transportationStorage.GetElement(new TransportationSearchModel
{
TransportationType = model.TransportationType,
});
//если элемент найден и его Id не совпадает с Id объекта, переданного на вход
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Такой тип перевозки уже есть");
}
}
}
}

View File

@ -1,173 +0,0 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.BusinessLogicsContracts;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyBusinessLogic.BusinessLogic
{
public class TruckingLogic : ITruckingLogic
{
private readonly ILogger _logger;
private readonly ITruckingStorage _truckingStorage;
//конструктор
public TruckingLogic(ILogger<TruckingLogic> logger, ITruckingStorage truckingStorage)
{
_logger = logger;
_truckingStorage = truckingStorage;
}
public List<TruckingViewModel>? ReadList(TruckingSearchModel? model)
{
_logger.LogInformation("ReadList. ClientId:{ClientId}. DateStart:{DateStart} Id:{Id}", model?.ClientId, model?.DateStart, model?.Id);
//list хранит весь список в случае, если model пришло со значением null на вход метода
var list = model == null ? _truckingStorage.GetFullList() : _truckingStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
//для замера времени считывания значений
public string? TestReadList()
{
return _truckingStorage.TestGetFullList();
}
public TruckingViewModel? ReadElement(TruckingSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ClientId:{ClientId}. DateStart:{DateStart} Id:{Id}", model?.ClientId, model?.DateStart, model?.Id);
var element = _truckingStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", model.Id);
return element;
}
public bool Create(TruckingBindingModel model)
{
CheckModel(model);
if (_truckingStorage.Insert(model) == null)
{
_logger.LogWarning("Create operation failed");
return false;
}
return true;
}
public string TestRandomCreate(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations)
{
return _truckingStorage.TestRandomInsert(count, clients, cargos, transports, transportations);
}
public bool Update(TruckingBindingModel model)
{
CheckModel(model);
if (_truckingStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(TruckingBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_truckingStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
//проверка входного аргумента для методов Insert, Update и Delete
private void CheckModel(TruckingBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
//так как при удалении параметром withParams передаём false
if (!withParams)
{
return;
}
//проверка на корректный id заказчика
if (model.ClientId <= 0)
{
throw new ArgumentNullException("Некорректный id заказчика", nameof(model.ClientId));
}
//проверка на корректный id груза
if (model.CargoId <= 0)
{
throw new ArgumentNullException("Некорректный id груза", nameof(model.CargoId));
}
//проверка на корректный id транспорта
if (model.TransportId <= 0)
{
throw new ArgumentNullException("Некорректный id транспорта", nameof(model.TransportId));
}
//проверка на корректный id типа транспортировки
if (model.TransportationId <= 0)
{
throw new ArgumentNullException("Некорректный id типа транспортировки", nameof(model.TransportationId));
}
//проверка на корректную дату начала транспортировки
if (model.DateStart > model.DateEnd)
{
throw new ArgumentNullException("Дата начала транспортировки должна быть раньше даты окончания перевозки", nameof(model.DateStart));
}
_logger.LogInformation("Trucking. ClientId:{ClientId}. CargoId:{CargoId}. TransportId:{TransportId}." +
"TransportationId:{TransportationId}. DateStart:{DateStart}. DateEnd:{DateEnd}. Id:{Id}",
model.ClientId, model.CargoId, model.TransportId, model.TransportationId, model.DateStart, model.DateEnd, model.Id);
}
}
}

View File

@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TransportCompanyContracts\TransportCompanyContracts.csproj" />
<ProjectReference Include="..\TransportCompanyDataModels\TransportCompanyDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.BindingModels
{
public class CargoBindingModel : ICargoModel
{
public int Id { get; set; }
public string TypeCargo { get; set; } = string.Empty;
}
}

View File

@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.BindingModels
{
public class ClientBindingModel : IClientModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string Patronymic { get; set; } = string.Empty;
public string Telephone { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.BindingModels
{
public class TransportBindingModel : ITransportModel
{
public int Id { get; set; }
public string Tranport { get; set; } = string.Empty;
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.BindingModels
{
public class TransportationBindingModel : ITransportationModel
{
public int Id {get; set;}
public string TransportationType { get; set; } = string.Empty;
}
}

View File

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.BindingModels
{
public class TruckingBindingModel : ITruckingModel
{
public int Id { get; set; }
public int ClientId { get; set; }
public int CargoId { get; set; }
public double Price { get; set; }
public DateTime DateStart { get; set; }
public DateTime DateEnd { get; set; }
public int TransportationId { get; set; }
public int TransportId { get; set; }
}
}

View File

@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.BusinessLogicsContracts
{
public interface ICargoLogic
{
List<CargoViewModel>? ReadList(CargoSearchModel? model);
CargoViewModel? ReadElement(CargoSearchModel model);
bool Create(CargoBindingModel model);
bool Update(CargoBindingModel model);
bool Delete(CargoBindingModel model);
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.BusinessLogicsContracts
{
public interface IClientLogic
{
List<ClientViewModel>? ReadList(ClientSearchModel? model);
ClientViewModel? ReadElement(ClientSearchModel model);
bool Create(ClientBindingModel model);
string TestRandomCreate(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email);
bool Update(ClientBindingModel model);
bool Delete(ClientBindingModel model);
}
}

View File

@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.BusinessLogicsContracts
{
public interface ITransportLogic
{
List<TransportViewModel>? ReadList(TransportSearchModel? model);
TransportViewModel? ReadElement(TransportSearchModel model);
bool Create(TransportBindingModel model);
bool Update(TransportBindingModel model);
bool Delete(TransportBindingModel model);
}
}

View File

@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.BusinessLogicsContracts
{
public interface ITransportationLogic
{
List<TransportationViewModel>? ReadList(TransportationSearchModel? model);
TransportationViewModel? ReadElement(TransportationSearchModel model);
bool Create(TransportationBindingModel model);
bool Update(TransportationBindingModel model);
bool Delete(TransportationBindingModel model);
}
}

View File

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.BusinessLogicsContracts
{
public interface ITruckingLogic
{
List<TruckingViewModel>? ReadList(TruckingSearchModel? model);
string? TestReadList();
TruckingViewModel? ReadElement(TruckingSearchModel model);
bool Create(TruckingBindingModel model);
string TestRandomCreate(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations);
bool Update(TruckingBindingModel model);
bool Delete(TruckingBindingModel model);
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyContracts.SearchModels
{
public class CargoSearchModel
{
public int? Id { get; set; }
public string? TypeCargo { get; set; }
}
}

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyContracts.SearchModels
{
public class ClientSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
public string? Surname { get; set; }
public string? Patronymic { get; set; }
public string? TelephoneNumber { get; set; }
public string? Email { get; set; }
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyContracts.SearchModels
{
public class TransportSearchModel
{
public int? Id { get; set; }
public string? Tranport { get; set; }
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyContracts.SearchModels
{
public class TransportationSearchModel
{
public int? Id { get; set; }
public string? TransportationType { get; set; }
}
}

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyContracts.SearchModels
{
public class TruckingSearchModel
{
public int? Id { get; set; }
public int? ClientId { get; set; }
public DateTime? DateStart { get; set; }
public DateTime? DateEnd { get; set; }
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.StoragesContracts
{
public interface ICargoStorage
{
List<CargoViewModel> GetFullList();
List<CargoViewModel> GetFilteredList(CargoSearchModel model);
CargoViewModel? GetElement(CargoSearchModel model);
CargoViewModel? Insert(CargoBindingModel model);
CargoViewModel? Update(CargoBindingModel model);
CargoViewModel? Delete(CargoBindingModel model);
}
}

View File

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.StoragesContracts
{
public interface IClientStorage
{
List<ClientViewModel> GetFullList();
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
ClientViewModel? GetElement(ClientSearchModel model);
ClientViewModel? Insert(ClientBindingModel model);
string TestRandomInsert(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email);
ClientViewModel? Update(ClientBindingModel model);
ClientViewModel? Delete(ClientBindingModel model);
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.StoragesContracts
{
public interface ITransportStorage
{
List<TransportViewModel> GetFullList();
List<TransportViewModel> GetFilteredList(TransportSearchModel model);
TransportViewModel? GetElement(TransportSearchModel model);
TransportViewModel? Insert(TransportBindingModel model);
TransportViewModel? Update(TransportBindingModel model);
TransportViewModel? Delete(TransportBindingModel model);
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.StoragesContracts
{
public interface ITransportationStorage
{
List<TransportationViewModel> GetFullList();
List<TransportationViewModel> GetFilteredList(TransportationSearchModel model);
TransportationViewModel? GetElement(TransportationSearchModel model);
TransportationViewModel? Insert(TransportationBindingModel model);
TransportationViewModel? Update(TransportationBindingModel model);
TransportationViewModel? Delete(TransportationBindingModel model);
}
}

View File

@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.StoragesContracts
{
public interface ITruckingStorage
{
List<TruckingViewModel> GetFullList();
string TestGetFullList();
List<TruckingViewModel> GetFilteredList(TruckingSearchModel model);
TruckingViewModel? GetElement(TruckingSearchModel model);
TruckingViewModel? Insert(TruckingBindingModel model);
string TestRandomInsert(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations);
TruckingViewModel? Update(TruckingBindingModel model);
TruckingViewModel? Delete(TruckingBindingModel model);
}
}

View File

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TransportCompanyDataModels\TransportCompanyDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.ViewModels
{
public class CargoViewModel : ICargoModel
{
public int Id { get; set; }
[DisplayName("Тип груза")]
public string TypeCargo {get; set; } = string.Empty;
}
}

View File

@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.ViewModels
{
public class ClientViewModel : IClientModel
{
public int Id { get; set; }
[DisplayName("Имя")]
public string Name { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string Surname { get; set; } = string.Empty;
[DisplayName("Отчество")]
public string Patronymic { get; set; } = string.Empty;
[DisplayName("Телефон")]
public string Telephone { get; set; } = string.Empty;
[DisplayName("Почта")]
public string Email { get; set; } = string.Empty;
}
}

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.ViewModels
{
public class TransportViewModel : ITransportModel
{
public int Id { get; set; }
[DisplayName("Вид транспорта")]
public string Tranport { get; set; } = string.Empty;
}
}

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.ViewModels
{
public class TransportationViewModel : ITransportationModel
{
public int Id { get; set; }
[DisplayName("Тип транспортировки")]
public string TransportationType { get; set; } = string.Empty;
}
}

View File

@ -1,50 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.ViewModels
{
public class TruckingViewModel : ITruckingModel
{
public int Id { get; set; }
public int ClientId { get; set; }
[DisplayName("Имя")]
public string ClientName { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string ClientSurname { get; set; } = string.Empty;
[DisplayName("Отчество")]
public string ClientPatronymic { get; set; } = string.Empty;
public int TransportationId { get; set; }
[DisplayName("Тип перевозки")]
public string TypeTransportation { get; set; } = string.Empty;
public int TransportId { get; set; }
[DisplayName("Тип транспорта")]
public string TransportName { get; set; } = string.Empty;
public int CargoId { get; set; }
[DisplayName("Объект перевозки")]
public string Cargo { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
[DisplayName("Дата оформления перевозки")]
public DateTime DateStart { get; set; }
[DisplayName("Дата завершения перевозки")]
public DateTime DateEnd { get; set; }
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyDataModels.Models
{
public interface ICargoModel : IId
{
//тип груза
string TypeCargo { get; }
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyDataModels.Models
{
public interface IClientModel : IId
{
string Name { get; }
string Surname { get; }
//отчество
string Patronymic { get; }
string Telephone { get; }
string Email { get; }
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyDataModels.Models
{
public interface ITransportModel : IId
{
//тип транспорта для перевозки
string Tranport { get; }
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyDataModels.Models
{
public interface ITransportationModel : IId
{
//тип транспортировки
string TransportationType { get; }
}
}

View File

@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportCompanyDataModels.Models
{
public interface ITruckingModel : IId
{
int ClientId { get; }
int CargoId { get; }
double Price { get; }
DateTime DateStart { get; }
DateTime DateEnd { get; }
int TransportationId { get; }
int TransportId { get; }
}
}

View File

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
</ItemGroup>
</Project>

View File

@ -1,167 +0,0 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.Extensions.Options;
using TransportCompanyDatabaseImplements.Models;
namespace TransportCompanyDatabaseImplements;
public partial class ElegevContext : DbContext
{
public ElegevContext()
{
}
public ElegevContext(DbContextOptions<ElegevContext> options)
: base(options)
{
}
public virtual DbSet<Cargo> Cargos { get; set; }
public virtual DbSet<Client> Clients { get; set; }
public virtual DbSet<Transport> Transports { get; set; }
public virtual DbSet<Trucking> Truckings { get; set; }
public virtual DbSet<TypeTransportation> TypeTransportations { get; set; }
string dbName = ConfigurationManager.AppSettings["connectToDb"];
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
=> optionsBuilder.UseNpgsql(dbName);
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Cargo>(entity =>
{
entity.HasKey(e => e.Id).HasName("cargo_pkey");
entity.ToTable("cargo");
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.TypeCargo)
.HasMaxLength(255)
.HasColumnName("type_cargo");
});
modelBuilder.Entity<Client>(entity =>
{
entity.HasKey(e => e.Id).HasName("client_pkey");
entity.ToTable("client");
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.Email)
.HasMaxLength(255)
.HasColumnName("email");
entity.Property(e => e.Name)
.HasMaxLength(255)
.HasColumnName("name");
entity.Property(e => e.Patronymic)
.HasMaxLength(255)
.HasColumnName("patronymic");
entity.Property(e => e.Surname)
.HasMaxLength(255)
.HasColumnName("surname");
entity.Property(e => e.Telephone)
.HasMaxLength(255)
.HasColumnName("telephone");
});
modelBuilder.Entity<Transport>(entity =>
{
entity.HasKey(e => e.Id).HasName("transport_pkey");
entity.ToTable("transport");
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.TransportType)
.HasMaxLength(255)
.HasColumnName("transport_type");
});
modelBuilder.Entity<Trucking>(entity =>
{
entity.HasKey(e => e.Id).HasName("trucking_pkey");
entity.ToTable("trucking");
entity.HasIndex(e => e.CargoId, "IX_trucking_cargo_id");
entity.HasIndex(e => e.ClientId, "IX_trucking_client_id");
entity.HasIndex(e => e.TransportId, "IX_trucking_transport_id");
entity.HasIndex(e => e.TransportationId, "IX_trucking_transportation_id");
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.CargoId).HasColumnName("cargo_id");
entity.Property(e => e.ClientId).HasColumnName("client_id");
entity.Property(e => e.DateEnd)
.HasColumnType("timestamp without time zone")
.HasColumnName("date_end");
entity.Property(e => e.DateStart)
.HasColumnType("timestamp without time zone")
.HasColumnName("date_start");
entity.Property(e => e.Price).HasColumnName("price");
entity.Property(e => e.TransportId).HasColumnName("transport_id");
entity.Property(e => e.TransportationId).HasColumnName("transportation_id");
entity.HasOne(d => d.Cargo).WithMany(p => p.Truckings)
.HasForeignKey(d => d.CargoId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("cargo_id");
entity.HasOne(d => d.Client).WithMany(p => p.Truckings)
.HasForeignKey(d => d.ClientId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("client_id");
entity.HasOne(d => d.Transport).WithMany(p => p.Truckings)
.HasForeignKey(d => d.TransportId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("transport_id");
entity.HasOne(d => d.Transportation).WithMany(p => p.Truckings)
.HasForeignKey(d => d.TransportationId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("type_transportation_id");
});
modelBuilder.Entity<TypeTransportation>(entity =>
{
entity.HasKey(e => e.Id).HasName("type_transportation_pkey");
entity.ToTable("type_transportation");
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.TransportationType)
.HasMaxLength(255)
.HasColumnName("transportation_type");
});
modelBuilder.HasSequence("seq_cargo");
modelBuilder.HasSequence("seq_client");
modelBuilder.HasSequence("seq_trucking");
modelBuilder.HasSequence("seq_type_transport");
modelBuilder.HasSequence("seq_type_transportation");
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

View File

@ -1,118 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyContracts.ViewModels;
using TransportCompanyDatabaseImplements.Models;
namespace TransportCompanyDatabaseImplements.Implements
{
public class CargoStorage : ICargoStorage
{
public CargoViewModel? Delete(CargoBindingModel model)
{
using var context = new ElegevContext();
var element = context.Cargos
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Cargos.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public CargoViewModel? GetElement(CargoSearchModel model)
{
if (string.IsNullOrEmpty(model.TypeCargo) && !model.Id.HasValue)
{
return null;
}
using var context = new ElegevContext();
return context.Cargos
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<CargoViewModel> GetFilteredList(CargoSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new ElegevContext();
return context.Cargos
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
public List<CargoViewModel> GetFullList()
{
using var context = new ElegevContext();
return context.Cargos
.Select(x => x.GetViewModel)
.ToList();
}
public CargoViewModel? Insert(CargoBindingModel model)
{
using var context = new ElegevContext();
model.Id = context.Cargos.Count() > 0 ? context.Cargos.Max(x => x.Id) + 1 : 1;
var newCargo = Cargo.Create(model);
if (newCargo == null)
{
return null;
}
context.Cargos.Add(newCargo);
context.SaveChanges();
return newCargo.GetViewModel;
}
public CargoViewModel? Update(CargoBindingModel model)
{
using var context = new ElegevContext();
using var transaction = context.Database.BeginTransaction();
try
{
var cargo = context.Cargos.FirstOrDefault(rec => rec.Id == model.Id);
if (cargo == null)
{
return null;
}
cargo.Update(model);
context.SaveChanges();
transaction.Commit();
return cargo.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -1,159 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyContracts.ViewModels;
using TransportCompanyDatabaseImplements.Models;
namespace TransportCompanyDatabaseImplements.Implements
{
public class ClientStorage : IClientStorage
{
public List<ClientViewModel> GetFullList()
{
using var context = new ElegevContext();
return context.Clients
.Select(x => x.GetViewModel)
.ToList();
}
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new ElegevContext();
return context.Clients
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
public ClientViewModel? GetElement(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new ElegevContext();
return context.Clients
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public ClientViewModel? Insert(ClientBindingModel model)
{
using var context = new ElegevContext();
model.Id = context.Clients.Count() > 0 ? context.Clients.Max(x => x.Id) + 1 : 1;
var newClient = Client.Create(model);
if (newClient == null)
{
return null;
}
context.Clients.Add(newClient);
context.SaveChanges();
return newClient.GetViewModel;
}
//метод для замера вставки большого кол-ва клиентов в бд
public string TestRandomInsert(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email)
{
using var context = new ElegevContext();
Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
int lastId = context.Clients.Count() > 0 ? context.Clients.Max(x => x.Id) + 1 : 1;
for (int i = 0; i < count; i++)
{
var model = new Client
{
Id = lastId,
Name = _name[rnd.Next(0, _name.Length)],
Surname = _surname[rnd.Next(0, _surname.Length)],
Patronymic = _patronymic[rnd.Next(0, _patronymic.Length)],
Telephone = _telephone[rnd.Next(0, _telephone.Length)],
Email = _email[rnd.Next(0, _email.Length)],
};
lastId++;
context.Clients.Add(model);
}
//старт замера времени добавления в бд
Stopwatch stopwatch = new();
stopwatch.Start();
context.SaveChanges();
stopwatch.Stop();
return stopwatch.ElapsedMilliseconds.ToString();
}
public ClientViewModel? Update(ClientBindingModel model)
{
using var context = new ElegevContext();
using var transaction = context.Database.BeginTransaction();
try
{
var client = context.Clients.FirstOrDefault(rec => rec.Id == model.Id);
if (client == null)
{
return null;
}
client.Update(model);
context.SaveChanges();
transaction.Commit();
return client.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public ClientViewModel? Delete(ClientBindingModel model)
{
using var context = new ElegevContext();
var element = context.Clients
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Clients.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -1,118 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyContracts.ViewModels;
using TransportCompanyDatabaseImplements.Models;
namespace TransportCompanyDatabaseImplements.Implements
{
public class TransportStorage : ITransportStorage
{
public TransportViewModel? Delete(TransportBindingModel model)
{
using var context = new ElegevContext();
var element = context.Transports
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Transports.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public TransportViewModel? GetElement(TransportSearchModel model)
{
if (string.IsNullOrEmpty(model.Tranport) && !model.Id.HasValue)
{
return null;
}
using var context = new ElegevContext();
return context.Transports
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<TransportViewModel> GetFilteredList(TransportSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new ElegevContext();
return context.Transports
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
public List<TransportViewModel> GetFullList()
{
using var context = new ElegevContext();
return context.Transports
.Select(x => x.GetViewModel)
.ToList();
}
public TransportViewModel? Insert(TransportBindingModel model)
{
using var context = new ElegevContext();
model.Id = context.Transports.Count() > 0 ? context.Transports.Max(x => x.Id) + 1 : 1;
var newTransport = Transport.Create(model);
if (newTransport == null)
{
return null;
}
context.Transports.Add(newTransport);
context.SaveChanges();
return newTransport.GetViewModel;
}
public TransportViewModel? Update(TransportBindingModel model)
{
using var context = new ElegevContext();
using var transaction = context.Database.BeginTransaction();
try
{
var transport = context.Transports.FirstOrDefault(rec => rec.Id == model.Id);
if (transport == null)
{
return null;
}
transport.Update(model);
context.SaveChanges();
transaction.Commit();
return transport.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -1,118 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyContracts.ViewModels;
using TransportCompanyDatabaseImplements.Models;
namespace TransportCompanyDatabaseImplements.Implements
{
public class TransportationStorage : ITransportationStorage
{
public TransportationViewModel? Delete(TransportationBindingModel model)
{
using var context = new ElegevContext();
var element = context.TypeTransportations
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.TypeTransportations.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public TransportationViewModel? GetElement(TransportationSearchModel model)
{
if (string.IsNullOrEmpty(model.TransportationType) && !model.Id.HasValue)
{
return null;
}
using var context = new ElegevContext();
return context.TypeTransportations
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<TransportationViewModel> GetFilteredList(TransportationSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new ElegevContext();
return context.TypeTransportations
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
public List<TransportationViewModel> GetFullList()
{
using var context = new ElegevContext();
return context.TypeTransportations
.Select(x => x.GetViewModel)
.ToList();
}
public TransportationViewModel? Insert(TransportationBindingModel model)
{
using var context = new ElegevContext();
model.Id = context.TypeTransportations.Count() > 0 ? context.TypeTransportations.Max(x => x.Id) + 1 : 1;
var newTypeTransportation = TypeTransportation.Create(model);
if (newTypeTransportation == null)
{
return null;
}
context.TypeTransportations.Add(newTypeTransportation);
context.SaveChanges();
return newTypeTransportation.GetViewModel;
}
public TransportationViewModel? Update(TransportationBindingModel model)
{
using var context = new ElegevContext();
using var transaction = context.Database.BeginTransaction();
try
{
var typeTransportations = context.TypeTransportations.FirstOrDefault(rec => rec.Id == model.Id);
if (typeTransportations == null)
{
return null;
}
typeTransportations.Update(model);
context.SaveChanges();
transaction.Commit();
return typeTransportations.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -1,202 +0,0 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.StoragesContracts;
using TransportCompanyContracts.ViewModels;
using TransportCompanyDatabaseImplements.Models;
namespace TransportCompanyDatabaseImplements.Implements
{
public class TruckingStorage : ITruckingStorage
{
public TruckingViewModel? Delete(TruckingBindingModel model)
{
using var context = new ElegevContext();
var element = context.Truckings
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Truckings.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public TruckingViewModel? GetElement(TruckingSearchModel model)
{
if (!model.Id.HasValue || !model.ClientId.HasValue)
{
return null;
}
using var context = new ElegevContext();
return context.Truckings
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public List<TruckingViewModel> GetFilteredList(TruckingSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new ElegevContext();
return context.Truckings
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
public List<TruckingViewModel> GetFullList()
{
using var context = new ElegevContext();
return context.Truckings
.Include(x => x.Transport)
.Include(x => x.Cargo)
.Include(x => x.Transportation)
.Include(x => x.Client)
.Select(x => x.GetViewModel)
.ToList();
}
public string TestGetFullList()
{
using var context = new ElegevContext();
string result = null;
//для замера времени считывания из бд
Stopwatch stopwatch = new();
stopwatch.Start();
List<TruckingViewModel> list = context.Truckings
.Include(x => x.Transport)
.Include(x => x.Cargo)
.Include(x => x.Transportation)
.Include(x => x.Client)
.Select(x => x.GetViewModel)
.ToList();
stopwatch.Stop();
result = list.Count.ToString();
list.Clear();
return result + " " + stopwatch.ElapsedMilliseconds.ToString();
}
public TruckingViewModel? Insert(TruckingBindingModel model)
{
using var context = new ElegevContext();
model.Id = context.Truckings.Count() > 0 ? context.Truckings.Max(x => x.Id) + 1 : 1;
var newTrucking = Trucking.Create(model);
if (newTrucking == null)
{
return null;
}
context.Truckings.Add(newTrucking);
context.SaveChanges();
return context.Truckings
.Include(x => x.Transport)
.Include(x => x.Cargo)
.Include(x => x.Transportation)
.Include(x => x.Client)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
//метод для замера вставки большого кол-ва клиентов в бд
public string TestRandomInsert(int count, List<ClientViewModel> clients, List<CargoViewModel> cargos, List<TransportViewModel> transports, List<TransportationViewModel> transportations)
{
using var context = new ElegevContext();
Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
int lastId = context.Truckings.Count() > 0 ? context.Truckings.Max(x => x.Id) + 1 : 1;
for (int i = 0; i < count; i++)
{
DateTime dateStart = new(rnd.Next(1991, 2023), rnd.Next(1, 12), rnd.Next(1, 28));
DateTime dateEnd = dateStart.AddDays(20);
var model = new Trucking
{
Id = lastId,
ClientId = clients[rnd.Next(0, clients.Count)].Id,
CargoId = cargos[rnd.Next(0, cargos.Count)].Id,
TransportId = transports[rnd.Next(0, transports.Count)].Id,
TransportationId = transportations[rnd.Next(0, transportations.Count)].Id,
DateStart = dateStart,
DateEnd = dateEnd,
Price = clients.Count * rnd.Next(100, 5000)
};
lastId++;
context.Truckings.Add(model);
}
//старт замера времени добавления в бд
Stopwatch stopwatch = new();
stopwatch.Start();
context.SaveChanges();
stopwatch.Stop();
return stopwatch.ElapsedMilliseconds.ToString();
}
public TruckingViewModel? Update(TruckingBindingModel model)
{
using var context = new ElegevContext();
using var transaction = context.Database.BeginTransaction();
try
{
var trucking = context.Truckings.FirstOrDefault(rec => rec.Id == model.Id);
if (trucking == null)
{
return null;
}
trucking.Update(model);
context.SaveChanges();
transaction.Commit();
return trucking.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyDatabaseImplements.Models;
public partial class Cargo
{
public int Id { get; set; }
public string TypeCargo { get; set; } = null!;
public virtual ICollection<Trucking> Truckings { get; set; } = new List<Trucking>();
public static Cargo Create(CargoBindingModel model)
{
return new Cargo()
{
Id = model.Id,
TypeCargo = model.TypeCargo
};
}
public void Update(CargoBindingModel model)
{
TypeCargo = model.TypeCargo;
}
public CargoViewModel GetViewModel => new()
{
Id = Id,
TypeCargo = TypeCargo
};
}

View File

@ -1,56 +0,0 @@
using System;
using System.Collections.Generic;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyDatabaseImplements.Models;
public partial class Client
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Surname { get; set; } = null!;
public string Patronymic { get; set; } = null!;
public string Telephone { get; set; } = null!;
public string Email { get; set; } = null!;
public virtual ICollection<Trucking> Truckings { get; set; } = new List<Trucking>();
public static Client Create(ClientBindingModel model)
{
return new Client()
{
Id = model.Id,
Name = model.Name,
Surname = model.Surname,
Patronymic = model.Patronymic,
Telephone = model.Telephone,
Email = model.Email,
};
}
public void Update(ClientBindingModel model)
{
Id = model.Id;
Name = model.Name;
Surname = model.Surname;
Patronymic = model.Patronymic;
Telephone = model.Telephone;
Email = model.Email;
}
public ClientViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Surname = Surname,
Patronymic = Patronymic,
Telephone = Telephone,
Email = Email
};
}

View File

@ -1,36 +0,0 @@
using System;
using System.Collections.Generic;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyDatabaseImplements.Models;
public partial class Transport
{
public int Id { get; set; }
public string TransportType { get; set; } = null!;
public virtual ICollection<Trucking> Truckings { get; set; } = new List<Trucking>();
public static Transport Create(TransportBindingModel model)
{
return new Transport()
{
Id = model.Id,
TransportType = model.Tranport
};
}
public void Update(TransportBindingModel model)
{
Id = model.Id;
TransportType = model.Tranport;
}
public TransportViewModel GetViewModel => new()
{
Id = Id,
Tranport = TransportType
};
}

View File

@ -1,88 +0,0 @@
using System;
using System.Collections.Generic;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyDatabaseImplements.Models;
public partial class Trucking
{
public int Id { get; set; }
public int ClientId { get; set; }
public int CargoId { get; set; }
public double Price { get; set; }
public DateTime DateStart { get; set; }
public DateTime DateEnd { get; set; }
public int TransportationId { get; set; }
public int TransportId { get; set; }
public virtual Cargo Cargo { get; set; } = null!;
public virtual Client Client { get; set; } = null!;
public virtual Transport Transport { get; set; } = null!;
public virtual TypeTransportation Transportation { get; set; } = null!;
public static Trucking? Create(TruckingBindingModel model)
{
if (model == null)
{
return null;
}
return new Trucking()
{
Id = model.Id,
ClientId = model.ClientId,
CargoId = model.CargoId,
Price = model.Price,
DateStart = model.DateStart,
DateEnd = model.DateEnd,
TransportationId = model.TransportationId,
TransportId = model.TransportId
};
}
public void Update(TruckingBindingModel model)
{
if (model == null)
{
return;
}
Id = model.Id;
ClientId = model.ClientId;
CargoId = model.CargoId;
Price = model.Price;
DateStart = model.DateStart;
DateEnd = model.DateEnd;
TransportationId = model.TransportationId;
TransportId = model.TransportId;
}
public TruckingViewModel GetViewModel => new()
{
Id = Id,
ClientId = ClientId,
CargoId = CargoId,
Price = Price,
DateStart = DateStart,
DateEnd = DateEnd,
TransportationId = TransportationId,
TransportId = TransportId,
ClientName = Client == null ? string.Empty : Client.Name,
ClientSurname = Client == null ? string.Empty : Client.Surname,
ClientPatronymic = Client == null ? string.Empty : Client.Patronymic,
TypeTransportation = Transportation == null ? string.Empty : Transportation.TransportationType,
TransportName = Transport == null ? string.Empty : Transport.TransportType,
Cargo = Cargo == null ? string.Empty : Cargo.TypeCargo
};
}

View File

@ -1,36 +0,0 @@
using System;
using System.Collections.Generic;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyDatabaseImplements.Models;
public partial class TypeTransportation
{
public int Id { get; set; }
public string TransportationType { get; set; } = null!;
public virtual ICollection<Trucking> Truckings { get; set; } = new List<Trucking>();
public static TypeTransportation Create(TransportationBindingModel model)
{
return new TypeTransportation()
{
Id = model.Id,
TransportationType = model.TransportationType
};
}
public void Update(TransportationBindingModel model)
{
Id = model.Id;
TransportationType = model.TransportationType;
}
public TransportationViewModel GetViewModel => new()
{
Id = Id,
TransportationType = TransportationType
};
}

View File

@ -1,28 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj" />
<ProjectReference Include="..\TransportCompanyContracts\TransportCompanyContracts.csproj" />
<ProjectReference Include="..\TransportCompanyDataModels\TransportCompanyDataModels.csproj" />
</ItemGroup>
</Project>