Вроде почти всё :)

This commit is contained in:
Programmist73 2023-04-25 23:47:33 +04:00
parent 9c00ec5694
commit 2aed31b3c5
8 changed files with 1148 additions and 1125 deletions

View File

@ -1,184 +1,184 @@
namespace TransportCompany namespace TransportCompany
{ {
partial class FormCreateClient partial class FormCreateClient
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
labelName = new Label(); labelName = new Label();
labelSurname = new Label(); labelSurname = new Label();
labelPatronymic = new Label(); labelPatronymic = new Label();
labelTelephone = new Label(); labelTelephone = new Label();
labelEmail = new Label(); labelEmail = new Label();
textBoxName = new TextBox(); textBoxName = new TextBox();
textBoxSurname = new TextBox(); textBoxSurname = new TextBox();
textBoxPatronymic = new TextBox(); textBoxPatronymic = new TextBox();
textBoxTelephone = new TextBox(); textBoxTelephone = new TextBox();
textBoxEmail = new TextBox(); textBoxEmail = new TextBox();
buttonCreate = new Button(); buttonCreate = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
SuspendLayout(); SuspendLayout();
// //
// labelName // labelName
// //
labelName.AutoSize = true; labelName.AutoSize = true;
labelName.Location = new Point(36, 51); labelName.Location = new Point(36, 51);
labelName.Name = "labelName"; labelName.Name = "labelName";
labelName.Size = new Size(42, 20); labelName.Size = new Size(42, 20);
labelName.TabIndex = 0; labelName.TabIndex = 0;
labelName.Text = "Имя:"; labelName.Text = "Имя:";
// //
// labelSurname // labelSurname
// //
labelSurname.AutoSize = true; labelSurname.AutoSize = true;
labelSurname.Location = new Point(36, 100); labelSurname.Location = new Point(36, 100);
labelSurname.Name = "labelSurname"; labelSurname.Name = "labelSurname";
labelSurname.Size = new Size(76, 20); labelSurname.Size = new Size(76, 20);
labelSurname.TabIndex = 1; labelSurname.TabIndex = 1;
labelSurname.Text = "Фамилия:"; labelSurname.Text = "Фамилия:";
// //
// labelPatronymic // labelPatronymic
// //
labelPatronymic.AutoSize = true; labelPatronymic.AutoSize = true;
labelPatronymic.Location = new Point(36, 152); labelPatronymic.Location = new Point(36, 152);
labelPatronymic.Name = "labelPatronymic"; labelPatronymic.Name = "labelPatronymic";
labelPatronymic.Size = new Size(75, 20); labelPatronymic.Size = new Size(75, 20);
labelPatronymic.TabIndex = 2; labelPatronymic.TabIndex = 2;
labelPatronymic.Text = "Отчество:"; labelPatronymic.Text = "Отчество:";
// //
// labelTelephone // labelTelephone
// //
labelTelephone.AutoSize = true; labelTelephone.AutoSize = true;
labelTelephone.Location = new Point(36, 206); labelTelephone.Location = new Point(36, 206);
labelTelephone.Name = "labelTelephone"; labelTelephone.Name = "labelTelephone";
labelTelephone.Size = new Size(138, 20); labelTelephone.Size = new Size(138, 20);
labelTelephone.TabIndex = 3; labelTelephone.TabIndex = 3;
labelTelephone.Text = "Номера телефона:"; labelTelephone.Text = "Номера телефона:";
// //
// labelEmail // labelEmail
// //
labelEmail.AutoSize = true; labelEmail.AutoSize = true;
labelEmail.Location = new Point(36, 260); labelEmail.Location = new Point(36, 260);
labelEmail.Name = "labelEmail"; labelEmail.Name = "labelEmail";
labelEmail.Size = new Size(54, 20); labelEmail.Size = new Size(54, 20);
labelEmail.TabIndex = 4; labelEmail.TabIndex = 4;
labelEmail.Text = "Почта:"; labelEmail.Text = "Почта:";
// //
// textBoxName // textBoxName
// //
textBoxName.Location = new Point(195, 48); textBoxName.Location = new Point(195, 48);
textBoxName.Name = "textBoxName"; textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(394, 27); textBoxName.Size = new Size(394, 27);
textBoxName.TabIndex = 5; textBoxName.TabIndex = 5;
// //
// textBoxSurname // textBoxSurname
// //
textBoxSurname.Location = new Point(195, 97); textBoxSurname.Location = new Point(195, 97);
textBoxSurname.Name = "textBoxSurname"; textBoxSurname.Name = "textBoxSurname";
textBoxSurname.Size = new Size(394, 27); textBoxSurname.Size = new Size(394, 27);
textBoxSurname.TabIndex = 6; textBoxSurname.TabIndex = 6;
// //
// textBoxPatronymic // textBoxPatronymic
// //
textBoxPatronymic.Location = new Point(195, 149); textBoxPatronymic.Location = new Point(195, 149);
textBoxPatronymic.Name = "textBoxPatronymic"; textBoxPatronymic.Name = "textBoxPatronymic";
textBoxPatronymic.Size = new Size(394, 27); textBoxPatronymic.Size = new Size(394, 27);
textBoxPatronymic.TabIndex = 7; textBoxPatronymic.TabIndex = 7;
// //
// textBoxTelephone // textBoxTelephone
// //
textBoxTelephone.Location = new Point(195, 203); textBoxTelephone.Location = new Point(195, 203);
textBoxTelephone.Name = "textBoxTelephone"; textBoxTelephone.Name = "textBoxTelephone";
textBoxTelephone.Size = new Size(394, 27); textBoxTelephone.Size = new Size(394, 27);
textBoxTelephone.TabIndex = 8; textBoxTelephone.TabIndex = 8;
// //
// textBoxEmail // textBoxEmail
// //
textBoxEmail.Location = new Point(195, 257); textBoxEmail.Location = new Point(195, 257);
textBoxEmail.Name = "textBoxEmail"; textBoxEmail.Name = "textBoxEmail";
textBoxEmail.Size = new Size(394, 27); textBoxEmail.Size = new Size(394, 27);
textBoxEmail.TabIndex = 9; textBoxEmail.TabIndex = 9;
// //
// buttonCreate // buttonCreate
// //
buttonCreate.Location = new Point(309, 318); buttonCreate.Location = new Point(309, 318);
buttonCreate.Name = "buttonCreate"; buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(131, 29); buttonCreate.Size = new Size(131, 29);
buttonCreate.TabIndex = 10; buttonCreate.TabIndex = 10;
buttonCreate.Text = "Создать"; buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true; buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click; buttonCreate.Click += ButtonCreate_Click;
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(458, 318); buttonCancel.Location = new Point(458, 318);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(131, 29); buttonCancel.Size = new Size(131, 29);
buttonCancel.TabIndex = 11; buttonCancel.TabIndex = 11;
buttonCancel.Text = "Отмена"; buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click; buttonCancel.Click += ButtonCancel_Click;
// //
// FormCreateClient // FormCreateClient
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(623, 372); ClientSize = new Size(623, 372);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonCreate); Controls.Add(buttonCreate);
Controls.Add(textBoxEmail); Controls.Add(textBoxEmail);
Controls.Add(textBoxTelephone); Controls.Add(textBoxTelephone);
Controls.Add(textBoxPatronymic); Controls.Add(textBoxPatronymic);
Controls.Add(textBoxSurname); Controls.Add(textBoxSurname);
Controls.Add(textBoxName); Controls.Add(textBoxName);
Controls.Add(labelEmail); Controls.Add(labelEmail);
Controls.Add(labelTelephone); Controls.Add(labelTelephone);
Controls.Add(labelPatronymic); Controls.Add(labelPatronymic);
Controls.Add(labelSurname); Controls.Add(labelSurname);
Controls.Add(labelName); Controls.Add(labelName);
Name = "FormCreateClient"; Name = "FormCreateClient";
Text = "FormClient"; Text = "Клиент";
Load += FormCreateClient_Load; Load += FormCreateClient_Load;
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
#endregion #endregion
private Label labelName; private Label labelName;
private Label labelSurname; private Label labelSurname;
private Label labelPatronymic; private Label labelPatronymic;
private Label labelTelephone; private Label labelTelephone;
private Label labelEmail; private Label labelEmail;
private TextBox textBoxName; private TextBox textBoxName;
private TextBox textBoxSurname; private TextBox textBoxSurname;
private TextBox textBoxPatronymic; private TextBox textBoxPatronymic;
private TextBox textBoxTelephone; private TextBox textBoxTelephone;
private TextBox textBoxEmail; private TextBox textBoxEmail;
private Button buttonCreate; private Button buttonCreate;
private Button buttonCancel; private Button buttonCancel;
} }
} }

View File

@ -14,124 +14,124 @@ using TransportCompanyContracts.SearchModels;
namespace TransportCompany namespace TransportCompany
{ {
public partial class FormCreateClient : Form public partial class FormCreateClient : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IClientLogic _logicC; private readonly IClientLogic _logicC;
private int? _id; private int? _id;
public int Id { set { _id = value; } } public int Id { set { _id = value; } }
public FormCreateClient(ILogger<FormCreateClient> logger, IClientLogic logicC) public FormCreateClient(ILogger<FormCreateClient> logger, IClientLogic logicC)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logicC = logicC; _logicC = logicC;
} }
//для загрузки данных при редактировании //для загрузки данных при редактировании
private void FormCreateClient_Load(object sender, EventArgs e) private void FormCreateClient_Load(object sender, EventArgs e)
{ {
//проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран //проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
if (_id.HasValue) if (_id.HasValue)
{ {
try try
{ {
_logger.LogInformation("Получение клиента"); _logger.LogInformation("Получение клиента");
var view = _logicC.ReadElement(new ClientSearchModel { Id = _id.Value }); var view = _logicC.ReadElement(new ClientSearchModel { Id = _id.Value });
if (view != null) if (view != null)
{ {
textBoxName.Text = view.Name; textBoxName.Text = view.Name;
textBoxSurname.Text = view.Surname; textBoxSurname.Text = view.Surname;
textBoxPatronymic.Text = view.Patronymic; textBoxPatronymic.Text = view.Patronymic;
textBoxTelephone.Text = view.Telephone; textBoxTelephone.Text = view.Telephone;
textBoxEmail.Text = view.Email; textBoxEmail.Text = view.Email;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка получения компонента"); _logger.LogError(ex, "Ошибка получения компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
private void ButtonCreate_Click(object sender, EventArgs e) private void ButtonCreate_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(textBoxName.Text)) if (string.IsNullOrEmpty(textBoxName.Text))
{ {
MessageBox.Show("Введите своё имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Введите своё имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (string.IsNullOrEmpty(textBoxSurname.Text)) if (string.IsNullOrEmpty(textBoxSurname.Text))
{ {
MessageBox.Show("Введите свою фамилию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Введите свою фамилию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (string.IsNullOrEmpty(textBoxPatronymic.Text)) if (string.IsNullOrEmpty(textBoxPatronymic.Text))
{ {
MessageBox.Show("Введите своё отчество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Введите своё отчество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (string.IsNullOrEmpty(textBoxTelephone.Text)) if (string.IsNullOrEmpty(textBoxTelephone.Text))
{ {
MessageBox.Show("Введите свой телефон", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Введите свой телефон", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (string.IsNullOrEmpty(textBoxEmail.Text)) if (string.IsNullOrEmpty(textBoxEmail.Text))
{ {
MessageBox.Show("Введите свою почту", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Введите свою почту", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
_logger.LogInformation("Добавление клиента"); _logger.LogInformation("Добавление клиента");
try try
{ {
var model = new ClientBindingModel var model = new ClientBindingModel
{ {
Id = 0, Id = 0,
Name = textBoxName.Text, Name = textBoxName.Text,
Surname = textBoxSurname.Text, Surname = textBoxSurname.Text,
Patronymic = textBoxPatronymic.Text, Patronymic = textBoxPatronymic.Text,
Telephone = textBoxTelephone.Text, Telephone = textBoxTelephone.Text,
Email = textBoxEmail.Text Email = textBoxEmail.Text
}; };
var operationResult = _id.HasValue ? _logicC.Update(model) : _logicC.Create(model); var operationResult = _id.HasValue ? _logicC.Update(model) : _logicC.Create(model);
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах.");
} }
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка сохранения клиента"); _logger.LogError(ex, "Ошибка сохранения клиента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonCancel_Click(object sender, EventArgs e) private void ButtonCancel_Click(object sender, EventArgs e)
{ {
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
} }
} }

View File

@ -1,96 +1,96 @@
namespace TransportCompany namespace TransportCompany
{ {
partial class FormCreateTransport partial class FormCreateTransport
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
label1 = new Label(); label1 = new Label();
textBoxTransport = new TextBox(); textBoxTransport = new TextBox();
buttonCreate = new Button(); buttonCreate = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
SuspendLayout(); SuspendLayout();
// //
// label1 // label1
// //
label1.AutoSize = true; label1.AutoSize = true;
label1.Location = new Point(36, 43); label1.Location = new Point(36, 43);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new Size(122, 20); label1.Size = new Size(122, 20);
label1.TabIndex = 0; label1.TabIndex = 0;
label1.Text = "Тип транспорта:"; label1.Text = "Тип транспорта:";
// //
// textBoxTransport // textBoxTransport
// //
textBoxTransport.Location = new Point(215, 40); textBoxTransport.Location = new Point(215, 40);
textBoxTransport.Name = "textBoxTransport"; textBoxTransport.Name = "textBoxTransport";
textBoxTransport.Size = new Size(254, 27); textBoxTransport.Size = new Size(254, 27);
textBoxTransport.TabIndex = 1; textBoxTransport.TabIndex = 1;
// //
// buttonCreate // buttonCreate
// //
buttonCreate.Location = new Point(262, 92); buttonCreate.Location = new Point(262, 92);
buttonCreate.Name = "buttonCreate"; buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(94, 29); buttonCreate.Size = new Size(94, 29);
buttonCreate.TabIndex = 2; buttonCreate.TabIndex = 2;
buttonCreate.Text = "Создать"; buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true; buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click; buttonCreate.Click += ButtonCreate_Click;
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(375, 92); buttonCancel.Location = new Point(375, 92);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29); buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3; buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена"; buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click; buttonCancel.Click += ButtonCancel_Click;
// //
// FormCreateTransport // FormCreateTransport
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(527, 155); ClientSize = new Size(527, 155);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonCreate); Controls.Add(buttonCreate);
Controls.Add(textBoxTransport); Controls.Add(textBoxTransport);
Controls.Add(label1); Controls.Add(label1);
Name = "FormCreateTransport"; Name = "FormCreateTransport";
Text = "FormCreateTransport"; Text = "Транспорт";
Load += FormCreateTransport_Load; Load += FormCreateTransport_Load;
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
#endregion #endregion
private Label label1; private Label label1;
private TextBox textBoxTransport; private TextBox textBoxTransport;
private Button buttonCreate; private Button buttonCreate;
private Button buttonCancel; private Button buttonCancel;
} }
} }

View File

@ -14,91 +14,91 @@ using TransportCompanyContracts.SearchModels;
namespace TransportCompany namespace TransportCompany
{ {
public partial class FormCreateTransport : Form public partial class FormCreateTransport : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ITransportLogic _logicT; private readonly ITransportLogic _logicT;
private int? _id; private int? _id;
public int Id { set { _id = value; } } public int Id { set { _id = value; } }
public FormCreateTransport(ILogger<FormCreateTransport> logger, ITransportLogic logicT) public FormCreateTransport(ILogger<FormCreateTransport> logger, ITransportLogic logicT)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logicT = logicT; _logicT = logicT;
} }
private void FormCreateTransport_Load(object sender, EventArgs e) private void FormCreateTransport_Load(object sender, EventArgs e)
{ {
//проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран //проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
if (_id.HasValue) if (_id.HasValue)
{ {
try try
{ {
_logger.LogInformation("Получение транспорта"); _logger.LogInformation("Получение транспорта");
var view = _logicT.ReadElement(new TransportSearchModel { Id = _id.Value }); var view = _logicT.ReadElement(new TransportSearchModel { Id = _id.Value });
if (view != null) if (view != null)
{ {
textBoxTransport.Text = view.Tranport; textBoxTransport.Text = view.Tranport;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка получения транспорта"); _logger.LogError(ex, "Ошибка получения транспорта");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
private void ButtonCreate_Click(object sender, EventArgs e) private void ButtonCreate_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(textBoxTransport.Text)) if (string.IsNullOrEmpty(textBoxTransport.Text))
{ {
MessageBox.Show("Введите тип транспорта", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Введите тип транспорта", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
_logger.LogInformation("Добавление транспорта"); _logger.LogInformation("Добавление транспорта");
try try
{ {
var model = new TransportBindingModel var model = new TransportBindingModel
{ {
Id = 0, Id = 0,
Tranport = textBoxTransport.Text, Tranport = textBoxTransport.Text,
}; };
var operationResult = _id.HasValue ? _logicT.Update(model) : _logicT.Create(model); var operationResult = _id.HasValue ? _logicT.Update(model) : _logicT.Create(model);
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах.");
} }
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка сохранения транспорта"); _logger.LogError(ex, "Ошибка сохранения транспорта");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonCancel_Click(object sender, EventArgs e) private void ButtonCancel_Click(object sender, EventArgs e)
{ {
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
} }
} }

View File

@ -1,232 +1,232 @@
namespace TransportCompany namespace TransportCompany
{ {
partial class FormCreateTrucking partial class FormCreateTrucking
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
labelCLient = new Label(); labelCLient = new Label();
label1 = new Label(); label1 = new Label();
label2 = new Label(); label2 = new Label();
label3 = new Label(); label3 = new Label();
label4 = new Label(); label4 = new Label();
label5 = new Label(); label5 = new Label();
comboBoxClients = new ComboBox(); comboBoxClients = new ComboBox();
comboBoxCargos = new ComboBox(); comboBoxCargos = new ComboBox();
comboBoxTransports = new ComboBox(); comboBoxTransports = new ComboBox();
comboBoxTypeTransportations = new ComboBox(); comboBoxTypeTransportations = new ComboBox();
dateTimePickerStart = new DateTimePicker(); dateTimePickerStart = new DateTimePicker();
dateTimePickerEnd = new DateTimePicker(); dateTimePickerEnd = new DateTimePicker();
buttonCreate = new Button(); buttonCreate = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
label6 = new Label(); label6 = new Label();
textBoxPrice = new TextBox(); textBoxPrice = new TextBox();
SuspendLayout(); SuspendLayout();
// //
// labelCLient // labelCLient
// //
labelCLient.AutoSize = true; labelCLient.AutoSize = true;
labelCLient.Location = new Point(37, 30); labelCLient.Location = new Point(37, 30);
labelCLient.Name = "labelCLient"; labelCLient.Name = "labelCLient";
labelCLient.Size = new Size(140, 20); labelCLient.Size = new Size(140, 20);
labelCLient.TabIndex = 0; labelCLient.TabIndex = 0;
labelCLient.Text = "Выберите клиента:"; labelCLient.Text = "Выберите клиента:";
// //
// label1 // label1
// //
label1.AutoSize = true; label1.AutoSize = true;
label1.Location = new Point(37, 81); label1.Location = new Point(37, 81);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new Size(150, 20); label1.Size = new Size(150, 20);
label1.TabIndex = 1; label1.TabIndex = 1;
label1.Text = "Выберите тип груза:"; label1.Text = "Выберите тип груза:";
// //
// label2 // label2
// //
label2.AutoSize = true; label2.AutoSize = true;
label2.Location = new Point(37, 135); label2.Location = new Point(37, 135);
label2.Name = "label2"; label2.Name = "label2";
label2.Size = new Size(157, 20); label2.Size = new Size(157, 20);
label2.TabIndex = 2; label2.TabIndex = 2;
label2.Text = "Выберите транспорт:"; label2.Text = "Выберите транспорт:";
// //
// label3 // label3
// //
label3.AutoSize = true; label3.AutoSize = true;
label3.Location = new Point(37, 237); label3.Location = new Point(37, 237);
label3.Name = "label3"; label3.Name = "label3";
label3.Size = new Size(224, 20); label3.Size = new Size(224, 20);
label3.TabIndex = 3; label3.TabIndex = 3;
label3.Text = "Дата начала транспортировки:"; label3.Text = "Дата начала транспортировки:";
// //
// label4 // label4
// //
label4.AutoSize = true; label4.AutoSize = true;
label4.Location = new Point(37, 288); label4.Location = new Point(37, 288);
label4.Name = "label4"; label4.Name = "label4";
label4.Size = new Size(217, 20); label4.Size = new Size(217, 20);
label4.TabIndex = 4; label4.TabIndex = 4;
label4.Text = "Дата конца транспортировки:"; label4.Text = "Дата конца транспортировки:";
// //
// label5 // label5
// //
label5.AutoSize = true; label5.AutoSize = true;
label5.Location = new Point(37, 187); label5.Location = new Point(37, 187);
label5.Name = "label5"; label5.Name = "label5";
label5.Size = new Size(236, 20); label5.Size = new Size(236, 20);
label5.TabIndex = 5; label5.TabIndex = 5;
label5.Text = "Выберите тип транспортировки:"; label5.Text = "Выберите тип транспортировки:";
// //
// comboBoxClients // comboBoxClients
// //
comboBoxClients.FormattingEnabled = true; comboBoxClients.FormattingEnabled = true;
comboBoxClients.Location = new Point(307, 27); comboBoxClients.Location = new Point(307, 27);
comboBoxClients.Name = "comboBoxClients"; comboBoxClients.Name = "comboBoxClients";
comboBoxClients.Size = new Size(319, 28); comboBoxClients.Size = new Size(319, 28);
comboBoxClients.TabIndex = 6; comboBoxClients.TabIndex = 6;
// //
// comboBoxCargos // comboBoxCargos
// //
comboBoxCargos.FormattingEnabled = true; comboBoxCargos.FormattingEnabled = true;
comboBoxCargos.Location = new Point(307, 78); comboBoxCargos.Location = new Point(307, 78);
comboBoxCargos.Name = "comboBoxCargos"; comboBoxCargos.Name = "comboBoxCargos";
comboBoxCargos.Size = new Size(319, 28); comboBoxCargos.Size = new Size(319, 28);
comboBoxCargos.TabIndex = 7; comboBoxCargos.TabIndex = 7;
// //
// comboBoxTransports // comboBoxTransports
// //
comboBoxTransports.FormattingEnabled = true; comboBoxTransports.FormattingEnabled = true;
comboBoxTransports.Location = new Point(307, 127); comboBoxTransports.Location = new Point(307, 127);
comboBoxTransports.Name = "comboBoxTransports"; comboBoxTransports.Name = "comboBoxTransports";
comboBoxTransports.Size = new Size(319, 28); comboBoxTransports.Size = new Size(319, 28);
comboBoxTransports.TabIndex = 8; comboBoxTransports.TabIndex = 8;
// //
// comboBoxTypeTransportations // comboBoxTypeTransportations
// //
comboBoxTypeTransportations.FormattingEnabled = true; comboBoxTypeTransportations.FormattingEnabled = true;
comboBoxTypeTransportations.Location = new Point(307, 184); comboBoxTypeTransportations.Location = new Point(307, 184);
comboBoxTypeTransportations.Name = "comboBoxTypeTransportations"; comboBoxTypeTransportations.Name = "comboBoxTypeTransportations";
comboBoxTypeTransportations.Size = new Size(319, 28); comboBoxTypeTransportations.Size = new Size(319, 28);
comboBoxTypeTransportations.TabIndex = 9; comboBoxTypeTransportations.TabIndex = 9;
// //
// dateTimePickerStart // dateTimePickerStart
// //
dateTimePickerStart.Location = new Point(307, 237); dateTimePickerStart.Location = new Point(307, 237);
dateTimePickerStart.Name = "dateTimePickerStart"; dateTimePickerStart.Name = "dateTimePickerStart";
dateTimePickerStart.Size = new Size(319, 27); dateTimePickerStart.Size = new Size(319, 27);
dateTimePickerStart.TabIndex = 10; dateTimePickerStart.TabIndex = 10;
// //
// dateTimePickerEnd // dateTimePickerEnd
// //
dateTimePickerEnd.Location = new Point(307, 283); dateTimePickerEnd.Location = new Point(307, 283);
dateTimePickerEnd.Name = "dateTimePickerEnd"; dateTimePickerEnd.Name = "dateTimePickerEnd";
dateTimePickerEnd.Size = new Size(319, 27); dateTimePickerEnd.Size = new Size(319, 27);
dateTimePickerEnd.TabIndex = 11; dateTimePickerEnd.TabIndex = 11;
// //
// buttonCreate // buttonCreate
// //
buttonCreate.Location = new Point(373, 392); buttonCreate.Location = new Point(373, 392);
buttonCreate.Name = "buttonCreate"; buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(120, 29); buttonCreate.Size = new Size(120, 29);
buttonCreate.TabIndex = 12; buttonCreate.TabIndex = 12;
buttonCreate.Text = "Создать"; buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true; buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click; buttonCreate.Click += ButtonCreate_Click;
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(513, 392); buttonCancel.Location = new Point(513, 392);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(113, 29); buttonCancel.Size = new Size(113, 29);
buttonCancel.TabIndex = 13; buttonCancel.TabIndex = 13;
buttonCancel.Text = "Отмена"; buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click; buttonCancel.Click += ButtonCancel_Click;
// //
// label6 // label6
// //
label6.AutoSize = true; label6.AutoSize = true;
label6.Location = new Point(37, 346); label6.Location = new Point(37, 346);
label6.Name = "label6"; label6.Name = "label6";
label6.Size = new Size(86, 20); label6.Size = new Size(86, 20);
label6.TabIndex = 14; label6.TabIndex = 14;
label6.Text = "Стоимость:"; label6.Text = "Стоимость:";
// //
// textBoxPrice // textBoxPrice
// //
textBoxPrice.Location = new Point(307, 343); textBoxPrice.Location = new Point(307, 343);
textBoxPrice.Name = "textBoxPrice"; textBoxPrice.Name = "textBoxPrice";
textBoxPrice.Size = new Size(319, 27); textBoxPrice.Size = new Size(319, 27);
textBoxPrice.TabIndex = 15; textBoxPrice.TabIndex = 15;
// //
// FormCreateTrucking // FormCreateTrucking
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(666, 438); ClientSize = new Size(666, 438);
Controls.Add(textBoxPrice); Controls.Add(textBoxPrice);
Controls.Add(label6); Controls.Add(label6);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonCreate); Controls.Add(buttonCreate);
Controls.Add(dateTimePickerEnd); Controls.Add(dateTimePickerEnd);
Controls.Add(dateTimePickerStart); Controls.Add(dateTimePickerStart);
Controls.Add(comboBoxTypeTransportations); Controls.Add(comboBoxTypeTransportations);
Controls.Add(comboBoxTransports); Controls.Add(comboBoxTransports);
Controls.Add(comboBoxCargos); Controls.Add(comboBoxCargos);
Controls.Add(comboBoxClients); Controls.Add(comboBoxClients);
Controls.Add(label5); Controls.Add(label5);
Controls.Add(label4); Controls.Add(label4);
Controls.Add(label3); Controls.Add(label3);
Controls.Add(label2); Controls.Add(label2);
Controls.Add(label1); Controls.Add(label1);
Controls.Add(labelCLient); Controls.Add(labelCLient);
Name = "FormCreateTrucking"; Name = "FormCreateTrucking";
Text = "FormCreateTrucking"; Text = "Перевозка";
Load += FormCreateTrucking_Load; Load += FormCreateTrucking_Load;
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
#endregion #endregion
private Label labelCLient; private Label labelCLient;
private Label label1; private Label label1;
private Label label2; private Label label2;
private Label label3; private Label label3;
private Label label4; private Label label4;
private Label label5; private Label label5;
private ComboBox comboBoxClients; private ComboBox comboBoxClients;
private ComboBox comboBoxCargos; private ComboBox comboBoxCargos;
private ComboBox comboBoxTransports; private ComboBox comboBoxTransports;
private ComboBox comboBoxTypeTransportations; private ComboBox comboBoxTypeTransportations;
private DateTimePicker dateTimePickerStart; private DateTimePicker dateTimePickerStart;
private DateTimePicker dateTimePickerEnd; private DateTimePicker dateTimePickerEnd;
private Button buttonCreate; private Button buttonCreate;
private Button buttonCancel; private Button buttonCancel;
private Label label6; private Label label6;
private TextBox textBoxPrice; private TextBox textBoxPrice;
} }
} }

View File

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

View File

@ -1,230 +1,243 @@
namespace TransportCompany namespace TransportCompany
{ {
partial class FormTrucking partial class FormTrucking
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
dataGridView = new DataGridView(); dataGridView = new DataGridView();
buttonCreateTrucking = new Button(); buttonCreateTrucking = new Button();
menuStrip = new MenuStrip(); menuStrip = new MenuStrip();
toolStripMenuItem = new ToolStripMenuItem(); toolStripMenuItem = new ToolStripMenuItem();
transportToolStripMenuItem = new ToolStripMenuItem(); transportToolStripMenuItem = new ToolStripMenuItem();
typeTransportationToolStripMenuItem = new ToolStripMenuItem(); typeTransportationToolStripMenuItem = new ToolStripMenuItem();
cargoToolStripMenuItem = new ToolStripMenuItem(); cargoToolStripMenuItem = new ToolStripMenuItem();
clientToolStripMenuItem = new ToolStripMenuItem(); clientToolStripMenuItem = new ToolStripMenuItem();
rndGenerationToolStripMenuItem = new ToolStripMenuItem(); rndGenerationToolStripMenuItem = new ToolStripMenuItem();
generationClientsToolStripMenuItem = new ToolStripMenuItem(); generationClientsToolStripMenuItem = new ToolStripMenuItem();
generationTruckingsToolStripMenuItem = new ToolStripMenuItem(); generationTruckingsToolStripMenuItem = new ToolStripMenuItem();
buttonUpdate = new Button(); buttonUpdate = new Button();
comboBoxEmails = new ComboBox(); comboBoxEmails = new ComboBox();
label1 = new Label(); label1 = new Label();
checkBoxSorted = new CheckBox(); checkBoxSorted = new CheckBox();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); checkBoxForFilterMode = new CheckBox();
menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); menuStrip.SuspendLayout();
// SuspendLayout();
// dataGridView //
// // dataGridView
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; //
dataGridView.Location = new Point(11, 67); dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Name = "dataGridView"; dataGridView.Location = new Point(11, 67);
dataGridView.RowHeadersWidth = 51; dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 29; dataGridView.RowHeadersWidth = 51;
dataGridView.Size = new Size(937, 417); dataGridView.RowTemplate.Height = 29;
dataGridView.TabIndex = 0; dataGridView.Size = new Size(937, 417);
// dataGridView.TabIndex = 0;
// buttonCreateTrucking //
// // buttonCreateTrucking
buttonCreateTrucking.Location = new Point(1014, 67); //
buttonCreateTrucking.Name = "buttonCreateTrucking"; buttonCreateTrucking.Location = new Point(1014, 67);
buttonCreateTrucking.Size = new Size(235, 29); buttonCreateTrucking.Name = "buttonCreateTrucking";
buttonCreateTrucking.TabIndex = 1; buttonCreateTrucking.Size = new Size(235, 29);
buttonCreateTrucking.Text = "Создать перевозку"; buttonCreateTrucking.TabIndex = 1;
buttonCreateTrucking.UseVisualStyleBackColor = true; buttonCreateTrucking.Text = "Создать перевозку";
buttonCreateTrucking.Click += ButtonCreateTrucking_Click; buttonCreateTrucking.UseVisualStyleBackColor = true;
// buttonCreateTrucking.Click += ButtonCreateTrucking_Click;
// menuStrip //
// // menuStrip
menuStrip.ImageScalingSize = new Size(20, 20); //
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, rndGenerationToolStripMenuItem }); menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Location = new Point(0, 0); menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, rndGenerationToolStripMenuItem });
menuStrip.Name = "menuStrip"; menuStrip.Location = new Point(0, 0);
menuStrip.Padding = new Padding(6, 3, 0, 3); menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1297, 30); menuStrip.Padding = new Padding(6, 3, 0, 3);
menuStrip.TabIndex = 6; menuStrip.Size = new Size(1297, 30);
menuStrip.Text = "menuStrip1"; menuStrip.TabIndex = 6;
// menuStrip.Text = "menuStrip1";
// toolStripMenuItem //
// // toolStripMenuItem
toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transportToolStripMenuItem, typeTransportationToolStripMenuItem, cargoToolStripMenuItem, clientToolStripMenuItem }); //
toolStripMenuItem.Name = "toolStripMenuItem"; toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transportToolStripMenuItem, typeTransportationToolStripMenuItem, cargoToolStripMenuItem, clientToolStripMenuItem });
toolStripMenuItem.Size = new Size(117, 24); toolStripMenuItem.Name = "toolStripMenuItem";
toolStripMenuItem.Text = "Справочники"; toolStripMenuItem.Size = new Size(117, 24);
// toolStripMenuItem.Text = "Справочники";
// transportToolStripMenuItem //
// // transportToolStripMenuItem
transportToolStripMenuItem.Name = "transportToolStripMenuItem"; //
transportToolStripMenuItem.Size = new Size(245, 26); transportToolStripMenuItem.Name = "transportToolStripMenuItem";
transportToolStripMenuItem.Text = "Транспорт"; transportToolStripMenuItem.Size = new Size(245, 26);
transportToolStripMenuItem.Click += TransportToolStripMenuItem_Click; transportToolStripMenuItem.Text = "Транспорт";
// transportToolStripMenuItem.Click += TransportToolStripMenuItem_Click;
// typeTransportationToolStripMenuItem //
// // typeTransportationToolStripMenuItem
typeTransportationToolStripMenuItem.Name = "typeTransportationToolStripMenuItem"; //
typeTransportationToolStripMenuItem.Size = new Size(245, 26); typeTransportationToolStripMenuItem.Name = "typeTransportationToolStripMenuItem";
typeTransportationToolStripMenuItem.Text = "Тип транспортировки"; typeTransportationToolStripMenuItem.Size = new Size(245, 26);
typeTransportationToolStripMenuItem.Click += TypeTransportationToolStripMenuItem_Click; typeTransportationToolStripMenuItem.Text = "Тип транспортировки";
// typeTransportationToolStripMenuItem.Click += TypeTransportationToolStripMenuItem_Click;
// cargoToolStripMenuItem //
// // cargoToolStripMenuItem
cargoToolStripMenuItem.Name = "cargoToolStripMenuItem"; //
cargoToolStripMenuItem.Size = new Size(245, 26); cargoToolStripMenuItem.Name = "cargoToolStripMenuItem";
cargoToolStripMenuItem.Text = "Груз"; cargoToolStripMenuItem.Size = new Size(245, 26);
cargoToolStripMenuItem.Click += CargoToolStripMenuItem_Click; cargoToolStripMenuItem.Text = "Груз";
// cargoToolStripMenuItem.Click += CargoToolStripMenuItem_Click;
// clientToolStripMenuItem //
// // clientToolStripMenuItem
clientToolStripMenuItem.Name = "clientToolStripMenuItem"; //
clientToolStripMenuItem.Size = new Size(245, 26); clientToolStripMenuItem.Name = "clientToolStripMenuItem";
clientToolStripMenuItem.Text = "Клиенты"; clientToolStripMenuItem.Size = new Size(245, 26);
clientToolStripMenuItem.Click += ClientToolStripMenuItem_Click; clientToolStripMenuItem.Text = "Клиенты";
// clientToolStripMenuItem.Click += ClientToolStripMenuItem_Click;
// rndGenerationToolStripMenuItem //
// // rndGenerationToolStripMenuItem
rndGenerationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { generationClientsToolStripMenuItem, generationTruckingsToolStripMenuItem }); //
rndGenerationToolStripMenuItem.Name = "rndGenerationToolStripMenuItem"; rndGenerationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { generationClientsToolStripMenuItem, generationTruckingsToolStripMenuItem });
rndGenerationToolStripMenuItem.Size = new Size(179, 24); rndGenerationToolStripMenuItem.Name = "rndGenerationToolStripMenuItem";
rndGenerationToolStripMenuItem.Text = "Рандомная генерация"; rndGenerationToolStripMenuItem.Size = new Size(179, 24);
// rndGenerationToolStripMenuItem.Text = "Рандомная генерация";
// generationClientsToolStripMenuItem //
// // generationClientsToolStripMenuItem
generationClientsToolStripMenuItem.Name = "generationClientsToolStripMenuItem"; //
generationClientsToolStripMenuItem.Size = new Size(245, 26); generationClientsToolStripMenuItem.Name = "generationClientsToolStripMenuItem";
generationClientsToolStripMenuItem.Text = "Генерация клиентов"; generationClientsToolStripMenuItem.Size = new Size(245, 26);
generationClientsToolStripMenuItem.Click += GenerationClientsToolStripMenuItem_Click; generationClientsToolStripMenuItem.Text = "Генерация клиентов";
// generationClientsToolStripMenuItem.Click += GenerationClientsToolStripMenuItem_Click;
// generationTruckingsToolStripMenuItem //
// // generationTruckingsToolStripMenuItem
generationTruckingsToolStripMenuItem.Name = "generationTruckingsToolStripMenuItem"; //
generationTruckingsToolStripMenuItem.Size = new Size(245, 26); generationTruckingsToolStripMenuItem.Name = "generationTruckingsToolStripMenuItem";
generationTruckingsToolStripMenuItem.Text = "Генерация перевозок"; generationTruckingsToolStripMenuItem.Size = new Size(245, 26);
generationTruckingsToolStripMenuItem.Click += GenerationTruckingsToolStripMenuItem_Click; generationTruckingsToolStripMenuItem.Text = "Генерация перевозок";
// generationTruckingsToolStripMenuItem.Click += GenerationTruckingsToolStripMenuItem_Click;
// buttonUpdate //
// // buttonUpdate
buttonUpdate.Location = new Point(1014, 138); //
buttonUpdate.Name = "buttonUpdate"; buttonUpdate.Location = new Point(1014, 138);
buttonUpdate.Size = new Size(235, 29); buttonUpdate.Name = "buttonUpdate";
buttonUpdate.TabIndex = 7; buttonUpdate.Size = new Size(235, 29);
buttonUpdate.Text = "Обновить"; buttonUpdate.TabIndex = 7;
buttonUpdate.UseVisualStyleBackColor = true; buttonUpdate.Text = "Обновить";
buttonUpdate.Click += ButtonUpdate_Click; buttonUpdate.UseVisualStyleBackColor = true;
// buttonUpdate.Click += ButtonUpdate_Click;
// comboBoxEmails //
// // comboBoxEmails
comboBoxEmails.FormattingEnabled = true; //
comboBoxEmails.Location = new Point(142, 33); comboBoxEmails.FormattingEnabled = true;
comboBoxEmails.Name = "comboBoxEmails"; comboBoxEmails.Location = new Point(142, 33);
comboBoxEmails.Size = new Size(208, 28); comboBoxEmails.Name = "comboBoxEmails";
comboBoxEmails.TabIndex = 8; comboBoxEmails.Size = new Size(208, 28);
comboBoxEmails.SelectedIndexChanged += ComboBoxEmails_SelectedIndexChanged; comboBoxEmails.TabIndex = 8;
// comboBoxEmails.SelectedIndexChanged += ComboBoxEmails_SelectedIndexChanged;
// label1 //
// // label1
label1.AutoSize = true; //
label1.Location = new Point(12, 36); label1.AutoSize = true;
label1.Name = "label1"; label1.Location = new Point(12, 36);
label1.Size = new Size(124, 20); label1.Name = "label1";
label1.TabIndex = 9; label1.Size = new Size(124, 20);
label1.Text = "Выберите почту:"; label1.TabIndex = 9;
// label1.Text = "Выберите почту:";
// checkBoxSorted //
// // checkBoxSorted
checkBoxSorted.AutoSize = true; //
checkBoxSorted.Location = new Point(541, 35); checkBoxSorted.AutoSize = true;
checkBoxSorted.Name = "checkBoxSorted"; checkBoxSorted.Location = new Point(632, 35);
checkBoxSorted.Size = new Size(239, 24); checkBoxSorted.Name = "checkBoxSorted";
checkBoxSorted.TabIndex = 10; checkBoxSorted.Size = new Size(316, 24);
checkBoxSorted.Text = "Сортировать по возрастанию"; checkBoxSorted.TabIndex = 10;
checkBoxSorted.UseVisualStyleBackColor = true; checkBoxSorted.Text = "Сортировать по возрастанию стоимости";
checkBoxSorted.CheckedChanged += CheckBoxSorted_CheckedChanged; checkBoxSorted.UseVisualStyleBackColor = true;
// checkBoxSorted.CheckedChanged += CheckBoxSorted_CheckedChanged;
// FormTrucking //
// // checkBoxForFilterMode
AutoScaleDimensions = new SizeF(8F, 20F); //
AutoScaleMode = AutoScaleMode.Font; checkBoxForFilterMode.AutoSize = true;
ClientSize = new Size(1297, 496); checkBoxForFilterMode.Location = new Point(370, 35);
Controls.Add(checkBoxSorted); checkBoxForFilterMode.Name = "checkBoxForFilterMode";
Controls.Add(label1); checkBoxForFilterMode.Size = new Size(212, 24);
Controls.Add(comboBoxEmails); checkBoxForFilterMode.TabIndex = 11;
Controls.Add(buttonUpdate); checkBoxForFilterMode.Text = "Включить режим фильтра";
Controls.Add(buttonCreateTrucking); checkBoxForFilterMode.UseVisualStyleBackColor = true;
Controls.Add(dataGridView); //
Controls.Add(menuStrip); // FormTrucking
MainMenuStrip = menuStrip; //
Name = "FormTrucking"; AutoScaleDimensions = new SizeF(8F, 20F);
Text = "Перевозки"; AutoScaleMode = AutoScaleMode.Font;
Load += FormMain_Load; ClientSize = new Size(1297, 496);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); Controls.Add(checkBoxForFilterMode);
menuStrip.ResumeLayout(false); Controls.Add(checkBoxSorted);
menuStrip.PerformLayout(); Controls.Add(label1);
ResumeLayout(false); Controls.Add(comboBoxEmails);
PerformLayout(); 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 #endregion
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonCreateTrucking; private Button buttonCreateTrucking;
private Button buttonTakeOrderInWork; private Button buttonTakeOrderInWork;
private Button buttonOrderReady; private Button buttonOrderReady;
private Button buttonIssuedOrder; private Button buttonIssuedOrder;
private Button buttonRef; private Button buttonRef;
private MenuStrip menuStrip; private MenuStrip menuStrip;
private ToolStripMenuItem toolStripMenuItem; private ToolStripMenuItem toolStripMenuItem;
private ToolStripMenuItem transportToolStripMenuItem; private ToolStripMenuItem transportToolStripMenuItem;
private ToolStripMenuItem workPieceToolStripMenuItem; private ToolStripMenuItem workPieceToolStripMenuItem;
private ToolStripMenuItem typeTransportationToolStripMenuItem; private ToolStripMenuItem typeTransportationToolStripMenuItem;
private ToolStripMenuItem cargoToolStripMenuItem; private ToolStripMenuItem cargoToolStripMenuItem;
private ToolStripMenuItem clientToolStripMenuItem; private ToolStripMenuItem clientToolStripMenuItem;
private ToolStripMenuItem shopToolStripMenuItem; private ToolStripMenuItem shopToolStripMenuItem;
private ToolStripMenuItem addManufactureToolStripMenuItem; private ToolStripMenuItem addManufactureToolStripMenuItem;
private Button buttonSellManufacture; private Button buttonSellManufacture;
private ToolStripMenuItem reportToolStripMenuItem; private ToolStripMenuItem reportToolStripMenuItem;
private ToolStripMenuItem groupedOrdersReportToolStripMenuItem; private ToolStripMenuItem groupedOrdersReportToolStripMenuItem;
private ToolStripMenuItem ordersReportToolStripMenuItem; private ToolStripMenuItem ordersReportToolStripMenuItem;
private ToolStripMenuItem manufactureWorkPiecesReportToolStripMenuItem; private ToolStripMenuItem manufactureWorkPiecesReportToolStripMenuItem;
private ToolStripMenuItem shopsReportToolStripMenuItem; private ToolStripMenuItem shopsReportToolStripMenuItem;
private ToolStripMenuItem rndGenerationToolStripMenuItem; private ToolStripMenuItem rndGenerationToolStripMenuItem;
private ToolStripMenuItem generationClientsToolStripMenuItem; private ToolStripMenuItem generationClientsToolStripMenuItem;
private ToolStripMenuItem generationTruckingsToolStripMenuItem; private ToolStripMenuItem generationTruckingsToolStripMenuItem;
private Button buttonUpdate; private Button buttonUpdate;
private ComboBox comboBoxEmails; private ComboBox comboBoxEmails;
private Label label1; private Label label1;
private CheckBox checkBoxSorted; private CheckBox checkBoxSorted;
} private CheckBox checkBoxForFilterMode;
}
} }

View File

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