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

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
{
partial class FormCreateClient
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
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);
}
/// <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
#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 = "FormClient";
Load += FormCreateClient_Load;
ResumeLayout(false);
PerformLayout();
}
/// <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
#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;
}
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

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

View File

@ -1,96 +1,96 @@
namespace TransportCompany
{
partial class FormCreateTransport
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
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);
}
/// <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
#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 = "FormCreateTransport";
Load += FormCreateTransport_Load;
ResumeLayout(false);
PerformLayout();
}
/// <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
#endregion
private Label label1;
private TextBox textBoxTransport;
private Button buttonCreate;
private Button buttonCancel;
}
private Label label1;
private TextBox textBoxTransport;
private Button buttonCreate;
private Button buttonCancel;
}
}

View File

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

View File

@ -1,232 +1,232 @@
namespace TransportCompany
{
partial class FormCreateTrucking
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
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);
}
/// <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
#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 = "FormCreateTrucking";
Load += FormCreateTrucking_Load;
ResumeLayout(false);
PerformLayout();
}
/// <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
#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;
}
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

@ -14,163 +14,163 @@ using TransportCompanyContracts.SearchModels;
namespace TransportCompany
{
public partial class FormCreateTrucking : Form
{
private readonly ILogger _logger;
public partial class FormCreateTrucking : Form
{
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,
IClientLogic logicCl, ITransportLogic logicTransport, ITransportationLogic logicTransportation)
{
InitializeComponent();
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;
}
_logger = logger;
_logic = logic;
_logicCargo = logicCargo;
_logicCl = logicCl;
_logicTransport = logicTransport;
_logicTransportation = logicTransportation;
}
private void FormCreateTrucking_Load(object sender, EventArgs e)
{
try
{
_logger.LogInformation("Получение сводки по перевозке");
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 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 });
//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 (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 (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 (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, "Ошибка получения сводки по перевозке");
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);
}
}
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);
private void ButtonCreate_Click(object sender, EventArgs e)
{
if (dateTimePickerStart.Value > dateTimePickerEnd.Value)
{
MessageBox.Show("Дата начала транспортировки не может быть позже её конца", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
return;
}
if (comboBoxClients.SelectedValue == null)
{
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (comboBoxClients.SelectedValue == null)
{
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
return;
}
if (comboBoxCargos.SelectedValue == null)
{
MessageBox.Show("Выберите груз", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (comboBoxCargos.SelectedValue == null)
{
MessageBox.Show("Выберите груз", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
return;
}
if (comboBoxTransports.SelectedValue == null)
{
MessageBox.Show("Выберите транспорт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (comboBoxTransports.SelectedValue == null)
{
MessageBox.Show("Выберите транспорт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
return;
}
if (comboBoxTypeTransportations.SelectedValue == null)
{
MessageBox.Show("Выберите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (comboBoxTypeTransportations.SelectedValue == null)
{
MessageBox.Show("Выберите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
return;
}
_logger.LogInformation("Создание сводки по перевозке");
_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
});
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("Ошибка при создании сводки по перевозке. Дополнительная информация в логах.");
}
if (!operationResult)
{
throw new Exception("Ошибка при создании сводки по перевозке. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания сводки по перевозке");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания сводки по перевозке");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -1,230 +1,243 @@
namespace TransportCompany
{
partial class FormTrucking
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
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);
}
/// <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
#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();
((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 });
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(541, 35);
checkBoxSorted.Name = "checkBoxSorted";
checkBoxSorted.Size = new Size(239, 24);
checkBoxSorted.TabIndex = 10;
checkBoxSorted.Text = "Сортировать по возрастанию";
checkBoxSorted.UseVisualStyleBackColor = true;
checkBoxSorted.CheckedChanged += CheckBoxSorted_CheckedChanged;
//
// FormTrucking
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1297, 496);
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();
}
/// <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();
((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 });
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;
//
// 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
#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 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;
}
}

View File

@ -1,159 +1,169 @@
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;
public partial class FormTrucking : Form
{
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)
{
InitializeComponent();
public FormTrucking(ILogger<FormTrucking> logger, ITruckingLogic truckingLogic, IClientLogic clientLogic)
{
InitializeComponent();
_logger = logger;
_truckingLogic = truckingLogic;
_clientLogic = clientLogic;
}
_logger = logger;
_truckingLogic = truckingLogic;
_clientLogic = clientLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
_logger.LogInformation("Çàãðóçêà ïåðåâîçîê");
private void LoadData()
{
_logger.LogInformation("Çàãðóçêà ïåðåâîçîê");
try
{
var list = _truckingLogic.ReadList(null);
try
{
var list = _truckingLogic.ReadList(null);
var listClients = _clientLogic.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 (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;
}
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);
}
}
_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));
private void ButtonCreateTrucking_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTrucking));
if (service is FormCreateTrucking form)
{
form.ShowDialog();
LoadData();
}
}
if (service is FormCreateTrucking form)
{
form.ShowDialog();
LoadData();
}
}
private void TransportToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTransport));
private void TransportToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTransport));
if (service is FormTransport form)
{
form.ShowDialog();
LoadData();
}
}
if (service is FormTransport form)
{
form.ShowDialog();
LoadData();
}
}
private void CargoToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCargo));
private void CargoToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCargo));
if (service is FormCargo form)
{
form.ShowDialog();
LoadData();
}
}
if (service is FormCargo form)
{
form.ShowDialog();
LoadData();
}
}
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
LoadData();
}
}
if (service is FormClients form)
{
form.ShowDialog();
LoadData();
}
}
private void TypeTransportationToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTypeTransportation));
private void TypeTransportationToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTypeTransportation));
if (service is FormTypeTransportation form)
{
form.ShowDialog();
LoadData();
}
}
if (service is FormTypeTransportation form)
{
form.ShowDialog();
LoadData();
}
}
private void GenerationClientsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateClient));
private void GenerationClientsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateClient));
if (service is FormRandomCreateClient form)
{
form.ShowDialog();
LoadData();
}
}
if (service is FormRandomCreateClient form)
{
form.ShowDialog();
LoadData();
}
}
private void GenerationTruckingsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateTrucking));
private void GenerationTruckingsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateTrucking));
if (service is FormRandomCreateTrucking form)
{
form.ShowDialog();
LoadData();
}
}
if (service is FormRandomCreateTrucking form)
{
form.ShowDialog();
LoadData();
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
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)
{
//dataGridView. Sort(dataGridView.Columns[7], ListSortDirection.Ascending);
}
}
private void CheckBoxSorted_CheckedChanged(object sender, EventArgs e)
{
dataGridView.DataSource = _truckingLogic.ReadList(null).OrderByDescending(x => x.Price).ToList();
}
}
}