diff --git a/TransportCompany/TransportCompany/Form1.Designer.cs b/TransportCompany/TransportCompany/Form1.Designer.cs
deleted file mode 100644
index e2d6f25..0000000
--- a/TransportCompany/TransportCompany/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace TransportCompany
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/Form1.cs b/TransportCompany/TransportCompany/Form1.cs
deleted file mode 100644
index 3724679..0000000
--- a/TransportCompany/TransportCompany/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace TransportCompany
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/Form1.resx b/TransportCompany/TransportCompany/Form1.resx
deleted file mode 100644
index 1af7de1..0000000
--- a/TransportCompany/TransportCompany/Form1.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCargo.Designer.cs b/TransportCompany/TransportCompany/FormCargo.Designer.cs
new file mode 100644
index 0000000..ddab350
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCargo.Designer.cs
@@ -0,0 +1,114 @@
+namespace TransportCompany
+{
+ partial class FormCargo
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ buttonCreate = new Button();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonReload = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(523, 426);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(590, 33);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(129, 29);
+ buttonCreate.TabIndex = 1;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += ButtonCreate_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(590, 108);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(129, 29);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(590, 179);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(129, 29);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonReload
+ //
+ buttonReload.Location = new Point(590, 251);
+ buttonReload.Name = "buttonReload";
+ buttonReload.Size = new Size(129, 29);
+ buttonReload.TabIndex = 4;
+ buttonReload.Text = "Обновить";
+ buttonReload.UseVisualStyleBackColor = true;
+ buttonReload.Click += ButtonReload_Click;
+ //
+ // FormCargo
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(766, 450);
+ Controls.Add(buttonReload);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreate);
+ Controls.Add(dataGridView);
+ Name = "FormCargo";
+ Text = "FormCargo";
+ Load += FormCargo_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonCreate;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonReload;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCargo.cs b/TransportCompany/TransportCompany/FormCargo.cs
new file mode 100644
index 0000000..fde8648
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCargo.cs
@@ -0,0 +1,126 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+
+namespace TransportCompany
+{
+ public partial class FormCargo : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly ICargoLogic _logicC;
+
+ public FormCargo(ILogger logger, ICargoLogic logicC)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logicC = logicC;
+ }
+
+ private void FormCargo_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logicC.ReadList(null);
+
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+
+ _logger.LogInformation("Загрузка типов грузов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки типов грузов");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateCargo));
+
+ if (service is FormCreateCargo form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateCargo));
+
+ if (service is FormCreateCargo form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ //проверяем наличие выделенной строки
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ _logger.LogInformation("Удаление типа груза");
+
+ try
+ {
+ if (!_logicC.Delete(new CargoBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления типа груза");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonReload_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormCargo.resx b/TransportCompany/TransportCompany/FormCargo.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCargo.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormClients.Designer.cs b/TransportCompany/TransportCompany/FormClients.Designer.cs
new file mode 100644
index 0000000..d183e11
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormClients.Designer.cs
@@ -0,0 +1,114 @@
+namespace TransportCompany
+{
+ partial class FormClients
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ buttonCreate = new Button();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonReload = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(1024, 426);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(1081, 36);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(150, 29);
+ buttonCreate.TabIndex = 1;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += ButtonCreate_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(1081, 110);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(150, 29);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(1081, 182);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(150, 29);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonReload
+ //
+ buttonReload.Location = new Point(1081, 251);
+ buttonReload.Name = "buttonReload";
+ buttonReload.Size = new Size(150, 29);
+ buttonReload.TabIndex = 4;
+ buttonReload.Text = "Обновить";
+ buttonReload.UseVisualStyleBackColor = true;
+ buttonReload.Click += ButtonReload_Click;
+ //
+ // FormClients
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1271, 450);
+ Controls.Add(buttonReload);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreate);
+ Controls.Add(dataGridView);
+ Name = "FormClients";
+ Text = "Клиенты";
+ Load += FormClients_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonCreate;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonReload;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormClients.cs b/TransportCompany/TransportCompany/FormClients.cs
new file mode 100644
index 0000000..01cb396
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormClients.cs
@@ -0,0 +1,129 @@
+using Microsoft.Extensions.Logging;
+using Serilog.Core;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+
+namespace TransportCompany
+{
+ public partial class FormClients : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IClientLogic _logicC;
+
+ public FormClients(ILogger logger, IClientLogic logicC)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logicC = logicC;
+ }
+
+ private void FormClients_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logicC.ReadList(null);
+
+ //растягиваем колонку Название на всю ширину, колонку Id скрываем
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+
+ _logger.LogInformation("Загрузка клиентов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заготовок");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateClient));
+
+ if (service is FormCreateClient form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateClient));
+
+ if (service is FormCreateClient form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ //проверяем наличие выделенной строки
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ _logger.LogInformation("Удаление клиента");
+
+ try
+ {
+ if (!_logicC.Delete(new ClientBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления компонента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonReload_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormClients.resx b/TransportCompany/TransportCompany/FormClients.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormClients.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCreateCargo.Designer.cs b/TransportCompany/TransportCompany/FormCreateCargo.Designer.cs
new file mode 100644
index 0000000..809d877
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateCargo.Designer.cs
@@ -0,0 +1,96 @@
+namespace TransportCompany
+{
+ partial class FormCreateCargo
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ label1 = new Label();
+ textBoxCargo = new TextBox();
+ buttonCreate = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(33, 28);
+ label1.Name = "label1";
+ label1.Size = new Size(137, 20);
+ label1.TabIndex = 0;
+ label1.Text = "Введите тип груза:";
+ //
+ // textBoxCargo
+ //
+ textBoxCargo.Location = new Point(198, 25);
+ textBoxCargo.Name = "textBoxCargo";
+ textBoxCargo.Size = new Size(313, 27);
+ textBoxCargo.TabIndex = 1;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(305, 73);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(94, 29);
+ buttonCreate.TabIndex = 2;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += ButtonCreate_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(417, 73);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormCreateCargo
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(571, 118);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonCreate);
+ Controls.Add(textBoxCargo);
+ Controls.Add(label1);
+ Name = "FormCreateCargo";
+ Text = "Создание груза";
+ Load += FormCreateCargo_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label1;
+ private TextBox textBoxCargo;
+ private Button buttonCreate;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCreateCargo.cs b/TransportCompany/TransportCompany/FormCreateCargo.cs
new file mode 100644
index 0000000..bf8255a
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateCargo.cs
@@ -0,0 +1,104 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+using TransportCompanyContracts.SearchModels;
+
+namespace TransportCompany
+{
+ public partial class FormCreateCargo : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly ICargoLogic _logicCg;
+
+ private int? _id;
+
+ public int Id { set { _id = value; } }
+
+ public FormCreateCargo(ILogger logger, ICargoLogic logicCg)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logicCg = logicCg;
+ }
+
+ private void FormCreateCargo_Load(object sender, EventArgs e)
+ {
+ //проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение типа груза");
+
+ var view = _logicCg.ReadElement(new CargoSearchModel { Id = _id.Value });
+
+ if (view != null)
+ {
+ textBoxCargo.Text = view.TypeCargo;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения типа груза");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCargo.Text))
+ {
+ MessageBox.Show("Введите тип груза", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Добавление груза");
+
+ try
+ {
+ var model = new CargoBindingModel
+ {
+ Id = 0,
+ TypeCargo = textBoxCargo.Text
+ };
+
+ var operationResult = _id.HasValue ? _logicCg.Update(model) : _logicCg.Create(model);
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах.");
+ }
+
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения клиента");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormCreateCargo.resx b/TransportCompany/TransportCompany/FormCreateCargo.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateCargo.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCreateClient.Designer.cs b/TransportCompany/TransportCompany/FormCreateClient.Designer.cs
new file mode 100644
index 0000000..0d8df62
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateClient.Designer.cs
@@ -0,0 +1,184 @@
+namespace TransportCompany
+{
+ partial class FormCreateClient
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ 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();
+ }
+
+ #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;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCreateClient.cs b/TransportCompany/TransportCompany/FormCreateClient.cs
new file mode 100644
index 0000000..910daae
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateClient.cs
@@ -0,0 +1,137 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+using TransportCompanyContracts.SearchModels;
+
+namespace TransportCompany
+{
+ public partial class FormCreateClient : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IClientLogic _logicC;
+
+ private int? _id;
+
+ public int Id { set { _id = value; } }
+
+ public FormCreateClient(ILogger logger, IClientLogic logicC)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logicC = logicC;
+ }
+
+ //для загрузки данных при редактировании
+ private void FormCreateClient_Load(object sender, EventArgs e)
+ {
+ //проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение клиента");
+
+ var view = _logicC.ReadElement(new ClientSearchModel { Id = _id.Value });
+
+ if (view != null)
+ {
+ textBoxName.Text = view.Name;
+ textBoxSurname.Text = view.Surname;
+ textBoxPatronymic.Text = view.Patronymic;
+ textBoxTelephone.Text = view.Telephone;
+ textBoxEmail.Text = view.Email;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения компонента");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Введите своё имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(textBoxSurname.Text))
+ {
+ MessageBox.Show("Введите свою фамилию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(textBoxPatronymic.Text))
+ {
+ MessageBox.Show("Введите своё отчество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(textBoxTelephone.Text))
+ {
+ MessageBox.Show("Введите свой телефон", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(textBoxEmail.Text))
+ {
+ MessageBox.Show("Введите свою почту", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Добавление клиента");
+
+ try
+ {
+ var model = new ClientBindingModel
+ {
+ Id = 0,
+ Name = textBoxName.Text,
+ Surname = textBoxSurname.Text,
+ Patronymic = textBoxPatronymic.Text,
+ Telephone = textBoxTelephone.Text,
+ Email = textBoxEmail.Text
+ };
+
+ var operationResult = _id.HasValue ? _logicC.Update(model) : _logicC.Create(model);
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах.");
+ }
+
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения клиента");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormCreateClient.resx b/TransportCompany/TransportCompany/FormCreateClient.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateClient.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCreateTransport.Designer.cs b/TransportCompany/TransportCompany/FormCreateTransport.Designer.cs
new file mode 100644
index 0000000..94fc285
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateTransport.Designer.cs
@@ -0,0 +1,96 @@
+namespace TransportCompany
+{
+ partial class FormCreateTransport
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ 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();
+ }
+
+ #endregion
+
+ private Label label1;
+ private TextBox textBoxTransport;
+ private Button buttonCreate;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCreateTransport.cs b/TransportCompany/TransportCompany/FormCreateTransport.cs
new file mode 100644
index 0000000..f2c8f48
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateTransport.cs
@@ -0,0 +1,104 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+using TransportCompanyContracts.SearchModels;
+
+namespace TransportCompany
+{
+ public partial class FormCreateTransport : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly ITransportLogic _logicT;
+
+ private int? _id;
+
+ public int Id { set { _id = value; } }
+
+ public FormCreateTransport(ILogger logger, ITransportLogic logicT)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logicT = logicT;
+ }
+
+ private void FormCreateTransport_Load(object sender, EventArgs e)
+ {
+ //проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение транспорта");
+
+ var view = _logicT.ReadElement(new TransportSearchModel { Id = _id.Value });
+
+ if (view != null)
+ {
+ textBoxTransport.Text = view.Tranport;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения транспорта");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxTransport.Text))
+ {
+ MessageBox.Show("Введите тип транспорта", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Добавление транспорта");
+
+ try
+ {
+ var model = new TransportBindingModel
+ {
+ Id = 0,
+ Tranport = textBoxTransport.Text,
+ };
+
+ var operationResult = _id.HasValue ? _logicT.Update(model) : _logicT.Create(model);
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах.");
+ }
+
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения транспорта");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormCreateTransport.resx b/TransportCompany/TransportCompany/FormCreateTransport.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateTransport.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCreateTrucking.Designer.cs b/TransportCompany/TransportCompany/FormCreateTrucking.Designer.cs
new file mode 100644
index 0000000..b2cf148
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateTrucking.Designer.cs
@@ -0,0 +1,232 @@
+namespace TransportCompany
+{
+ partial class FormCreateTrucking
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ 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();
+ }
+
+ #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;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCreateTrucking.cs b/TransportCompany/TransportCompany/FormCreateTrucking.cs
new file mode 100644
index 0000000..a4ce2d5
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateTrucking.cs
@@ -0,0 +1,176 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+using TransportCompanyContracts.SearchModels;
+
+namespace TransportCompany
+{
+ public partial class FormCreateTrucking : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IClientLogic _logicCl;
+
+ private readonly ITransportLogic _logicTransport;
+
+ private readonly ITransportationLogic _logicTransportation;
+
+ private readonly ICargoLogic _logicCargo;
+
+ private readonly ITruckingLogic _logic;
+
+ private int? _id;
+
+ public int Id { set { _id = value; } }
+
+ public FormCreateTrucking(ILogger logger, ITruckingLogic logic, ICargoLogic logicCargo,
+ IClientLogic logicCl, ITransportLogic logicTransport, ITransportationLogic logicTransportation)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logic = logic;
+ _logicCargo = logicCargo;
+ _logicCl = logicCl;
+ _logicTransport = logicTransport;
+ _logicTransportation = logicTransportation;
+ }
+
+ private void FormCreateTrucking_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ _logger.LogInformation("Получение сводки по перевозке");
+
+ var viewClient = _logicCl.ReadList(null);
+ var viewCargo = _logicCargo.ReadList(null);
+ var viewTransport = _logicTransport.ReadList(null);
+ var viewTransportation = _logicTransportation.ReadList(null);
+
+ //var view = _logic.ReadElement(new TruckingSearchModel { Id = _id.Value });
+
+ if (viewClient != null)
+ {
+ comboBoxClients.DisplayMember = "Email";
+ comboBoxClients.ValueMember = "Id";
+ comboBoxClients.DataSource = viewClient;
+ comboBoxClients.SelectedItem = null;
+ }
+
+ if (viewCargo != null)
+ {
+ comboBoxCargos.DisplayMember = "TypeCargo";
+ comboBoxCargos.ValueMember = "Id";
+ comboBoxCargos.DataSource = viewCargo;
+ comboBoxCargos.SelectedItem = null;
+ }
+
+ if (viewTransport != null)
+ {
+ comboBoxTransports.DisplayMember = "Tranport";
+ comboBoxTransports.ValueMember = "Id";
+ comboBoxTransports.DataSource = viewTransport;
+ comboBoxTransports.SelectedItem = null;
+ }
+
+ if (viewTransportation != null)
+ {
+ comboBoxTypeTransportations.DisplayMember = "TransportationType";
+ comboBoxTypeTransportations.ValueMember = "Id";
+ comboBoxTypeTransportations.DataSource = viewTransportation;
+ comboBoxTypeTransportations.SelectedItem = null;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения сводки по перевозке");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ if (dateTimePickerStart.Value > dateTimePickerEnd.Value)
+ {
+ MessageBox.Show("Дата начала транспортировки не может быть позже её конца", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+
+ return;
+ }
+
+ if (comboBoxClients.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+
+ return;
+ }
+
+ if (comboBoxCargos.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите груз", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+
+ return;
+ }
+
+ if (comboBoxTransports.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите транспорт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+
+ return;
+ }
+
+ if (comboBoxTypeTransportations.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+
+ return;
+ }
+
+ _logger.LogInformation("Создание сводки по перевозке");
+
+ try
+ {
+ var operationResult = _logic.Create(new TruckingBindingModel
+ {
+ ClientId = Convert.ToInt32(comboBoxClients.SelectedValue),
+ CargoId = Convert.ToInt32(comboBoxCargos.SelectedValue),
+ TransportId = Convert.ToInt32(comboBoxTransports.SelectedValue),
+ TransportationId = Convert.ToInt32(comboBoxTypeTransportations.SelectedValue),
+ Price = Convert.ToInt32(textBoxPrice.Text),
+ DateStart = dateTimePickerStart.Value,
+ DateEnd = dateTimePickerEnd.Value
+ });
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при создании сводки по перевозке. Дополнительная информация в логах.");
+ }
+
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка создания сводки по перевозке");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormCreateTrucking.resx b/TransportCompany/TransportCompany/FormCreateTrucking.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateTrucking.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCreateTypeTransportation.Designer.cs b/TransportCompany/TransportCompany/FormCreateTypeTransportation.Designer.cs
new file mode 100644
index 0000000..3405713
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateTypeTransportation.Designer.cs
@@ -0,0 +1,96 @@
+namespace TransportCompany
+{
+ partial class FormCreateTypeTransportation
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ label1 = new Label();
+ textBoxTypeTransportation = new TextBox();
+ buttonCreate = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(24, 36);
+ label1.Name = "label1";
+ label1.Size = new Size(165, 20);
+ label1.TabIndex = 0;
+ label1.Text = "Тип транспортировки:";
+ //
+ // textBoxTypeTransportation
+ //
+ textBoxTypeTransportation.Location = new Point(232, 33);
+ textBoxTypeTransportation.Name = "textBoxTypeTransportation";
+ textBoxTypeTransportation.Size = new Size(330, 27);
+ textBoxTypeTransportation.TabIndex = 1;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(355, 83);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(94, 29);
+ buttonCreate.TabIndex = 2;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += ButtonCreate_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(468, 83);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormCreateTypeTransportation
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(617, 138);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonCreate);
+ Controls.Add(textBoxTypeTransportation);
+ Controls.Add(label1);
+ Name = "FormCreateTypeTransportation";
+ Text = "FormCreateTypeTransportation";
+ Load += FormCreateTypeTransportation_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label1;
+ private TextBox textBoxTypeTransportation;
+ private Button buttonCreate;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCreateTypeTransportation.cs b/TransportCompany/TransportCompany/FormCreateTypeTransportation.cs
new file mode 100644
index 0000000..43bffb0
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateTypeTransportation.cs
@@ -0,0 +1,104 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+using TransportCompanyContracts.SearchModels;
+
+namespace TransportCompany
+{
+ public partial class FormCreateTypeTransportation : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly ITransportationLogic _logic;
+
+ private int? _id;
+
+ public int Id { set { _id = value; } }
+
+ public FormCreateTypeTransportation(ILogger logger, ITransportationLogic logic)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormCreateTypeTransportation_Load(object sender, EventArgs e)
+ {
+ //проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение типа транспортировки");
+
+ var view = _logic.ReadElement(new TransportationSearchModel { Id = _id.Value });
+
+ if (view != null)
+ {
+ textBoxTypeTransportation.Text = view.TransportationType;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения типа транспортировки");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxTypeTransportation.Text))
+ {
+ MessageBox.Show("Введите тип транспортировки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Добавление типа транспортировки");
+
+ try
+ {
+ var model = new TransportationBindingModel
+ {
+ Id = 0,
+ TransportationType = textBoxTypeTransportation.Text
+ };
+
+ var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах.");
+ }
+
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения типа транспортировки");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormCreateTypeTransportation.resx b/TransportCompany/TransportCompany/FormCreateTypeTransportation.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCreateTypeTransportation.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormRandomCreateClient.Designer.cs b/TransportCompany/TransportCompany/FormRandomCreateClient.Designer.cs
new file mode 100644
index 0000000..38c5260
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormRandomCreateClient.Designer.cs
@@ -0,0 +1,95 @@
+namespace TransportCompany
+{
+ partial class FormRandomCreateClient
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelCount = new Label();
+ textBoxCount = new TextBox();
+ buttonStart = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(21, 25);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(93, 20);
+ labelCount.TabIndex = 0;
+ labelCount.Text = "Количество:";
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(158, 22);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(217, 27);
+ textBoxCount.TabIndex = 1;
+ //
+ // buttonStart
+ //
+ buttonStart.Location = new Point(147, 87);
+ buttonStart.Name = "buttonStart";
+ buttonStart.Size = new Size(110, 29);
+ buttonStart.TabIndex = 2;
+ buttonStart.Text = "Генерация";
+ buttonStart.UseVisualStyleBackColor = true;
+ buttonStart.Click += ButtonStart_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(281, 87);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormRandomCreateClient
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(429, 141);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonStart);
+ Controls.Add(textBoxCount);
+ Controls.Add(labelCount);
+ Name = "FormRandomCreateClient";
+ Text = "Случайная генерация клиентов";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelCount;
+ private TextBox textBoxCount;
+ private Button buttonStart;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormRandomCreateClient.cs b/TransportCompany/TransportCompany/FormRandomCreateClient.cs
new file mode 100644
index 0000000..fbb0a41
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormRandomCreateClient.cs
@@ -0,0 +1,77 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+
+namespace TransportCompany
+{
+ public partial class FormRandomCreateClient : Form
+ {
+ private readonly IClientLogic _logicC;
+
+ Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
+
+ private string[] _names = { "Иван", "Егор", "Роман", "Денис", "Игнат", "Ренат", "Никита", "Павел", "Данил", "Максим", "Николай", "Дмитрий", "Владислав", "Марк", "Булат", "Марсель", "Назар", "Багир", "Кирилл", "Всеволод", "Ярослав", "Юрий", "Виталий" };
+
+ private string[] _surnames = { "Иванов", "Елисеев", "Марков", "Негин", "Мусоев", "Сегреев", "Распаев", "Минаров", "Захарченко", "Пятаков", "Юдаков", "Карташев", "Селин", "Марков", "Захаров", "Никитин", "Распаев", "Алексанян", "Скалкин", "Строев", "Горшков", "Каримов", "Кочкадаев", "Ершов", "Алиакберов", "Закуанов", "Пахомов" };
+
+ private string[] _patronymics = { "Иванович", "Евгеньевич", "Егорович", "Николаевич", "Дмитриевич", "Владиславович", "Юрьевич", "Кириллович", "Артемиевич", "Павлович", "Максимович", "Назарович", "Багирович", "Булатович", "Всеволодович", "Витальевич", "Евгеньевич", "Романович", "Ярославович", "Данилович", "Зульфия", "Марсельевич", "Маркович", };
+
+ private string[] _telephones = { "89529876316", "88804293534", "84508874804", "82035754008", "80926246994", "83316923921", "88497436387", "82372606638", "81582656294", "83605675249", "87978864427", "81882538381", "83432311066", "80220603131", "82166498710", "80271945648", "83581821702", "84911615179", "89993116947", "80830482909", "89463846784", "84817550460", "81785373218", "80654035595", "81304432863", "85601863128" };
+
+ private string[] _emails = { "deffabuttiprei-5025@yopmail.com", "quiquoucrobrilla-7902@yopmail.com", "tucoffokexoi-9537@yopmail.com", "nebroijulleinne-7231@yopmail.com", "xedeujezoilli-1668@yopmail.com", "foikoussoidouhau-5112@yopmail.com", "pruddougoddeda-2757@yopmail.com", "keidevoillaga-5758@yopmail.com", "palemeinnacra-4165@yopmail.com", "capribukoippa-8523@yopmail.com", "truwauheineita-8708@yopmail.com", "mudebralanu-3594@yopmail.com", "nuxauttisoibri-7020@yopmail.com", "dufenosatte-4543@yopmail.com", "xullusaquilou-9479@yopmail.com", "broixifrommelle-3859@yopmail.com", "yimozofreixeu-4046@yopmail.com", "wetrouddemoro-9168@yopmail.com", "crepropretaji-6969@yopmail.com", "pahoufforutre-6805@yopmail.com", "gretreidineuba-8655@yopmail.com", "koullinnorulli-5851@yopmail.com", "bougreigewetto-3164@yopmail.com", "brocoffanauba-5102@yopmail.com", "kaddasumetre-7742@yopmail.com", "heussouprogromu-7061@yopmail.com", "teresitruffe-8881@yopmail.com", "kejicrouzazei-9377@yopmail.com", "zoicaquaugrili-2744@yopmail.com", "quepifrucragrou-8404@yopmail.com", "graditilladdi-7217@yopmail.com", "doboijifammeu-4816@yopmail.com", "tobrograusessoi-6295@yopmail.com", "xeifeuffiyoka-8243@yopmail.com", "greuquekucaju-9438@yopmail.com", "prisseproittunne-3785@yopmail.com", "vuppeiyatrare-8690@yopmail.com", "pennibexewa-9132@yopmail.com", "gayufeppaucu-4744@yopmail.com", "boicegreisussa-1695@yopmail.com" };
+
+ public FormRandomCreateClient(IClientLogic logicC)
+ {
+ InitializeComponent();
+
+ _logicC = logicC;
+ }
+
+ private void ButtonStart_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ for (int i = 0; i < Convert.ToInt32(textBoxCount.Text); i++)
+ {
+ var model = new ClientBindingModel
+ {
+ Id = 0,
+ Name = _names[rnd.Next(0, _names.Length)],
+ Surname = _surnames[rnd.Next(0, _surnames.Length)],
+ Patronymic = _patronymics[rnd.Next(0, _patronymics.Length)],
+ Telephone = _telephones[rnd.Next(0, _telephones.Length)] + Convert.ToString(rnd.Next(0, 800000)),
+ Email = Convert.ToString(rnd.Next(0, 800000)) + _emails[rnd.Next(0, _emails.Length)],
+ };
+
+ var operationResult = _logicC.Create(model);
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ Close();
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormRandomCreateClient.resx b/TransportCompany/TransportCompany/FormRandomCreateClient.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormRandomCreateClient.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormRandomCreateTrucking.Designer.cs b/TransportCompany/TransportCompany/FormRandomCreateTrucking.Designer.cs
new file mode 100644
index 0000000..6e9dfd3
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormRandomCreateTrucking.Designer.cs
@@ -0,0 +1,95 @@
+namespace TransportCompany
+{
+ partial class FormRandomCreateTrucking
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelClient = new Label();
+ textBoxCount = new TextBox();
+ buttonCreate = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelClient
+ //
+ labelClient.AutoSize = true;
+ labelClient.Location = new Point(32, 33);
+ labelClient.Name = "labelClient";
+ labelClient.Size = new Size(151, 20);
+ labelClient.TabIndex = 0;
+ labelClient.Text = "Введите количество:";
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(221, 30);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(280, 27);
+ textBoxCount.TabIndex = 1;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(237, 91);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(123, 29);
+ buttonCreate.TabIndex = 2;
+ buttonCreate.Text = "Генерация";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += ButtonCreate_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(382, 91);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(119, 29);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormRandomCreateTrucking
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(548, 147);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonCreate);
+ Controls.Add(textBoxCount);
+ Controls.Add(labelClient);
+ Name = "FormRandomCreateTrucking";
+ Text = "Генерация перевозок";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelClient;
+ private TextBox textBoxCount;
+ private Button buttonCreate;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormRandomCreateTrucking.cs b/TransportCompany/TransportCompany/FormRandomCreateTrucking.cs
new file mode 100644
index 0000000..dc74974
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormRandomCreateTrucking.cs
@@ -0,0 +1,95 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Xml.Linq;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+
+namespace TransportCompany
+{
+ public partial class FormRandomCreateTrucking : Form
+ {
+ Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
+
+ private readonly IClientLogic _logicCl;
+
+ private readonly ITransportLogic _logicTransport;
+
+ private readonly ITransportationLogic _logicTransportation;
+
+ private readonly ICargoLogic _logicCargo;
+
+ private readonly ITruckingLogic _logic;
+
+ private int? _id;
+
+ public int Id { set { _id = value; } }
+
+ public FormRandomCreateTrucking(ILogger logger, ITruckingLogic logic, ICargoLogic logicCargo,
+ IClientLogic logicCl, ITransportLogic logicTransport, ITransportationLogic logicTransportation)
+ {
+ InitializeComponent();
+
+ _logic = logic;
+ _logicCargo = logicCargo;
+ _logicCl = logicCl;
+ _logicTransport = logicTransport;
+ _logicTransportation = logicTransportation;
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ var viewClient = _logicCl.ReadList(null);
+ var viewCargo = _logicCargo.ReadList(null);
+ var viewTransport = _logicTransport.ReadList(null);
+ var viewTransportation = _logicTransportation.ReadList(null);
+
+ try
+ {
+ for (int i = 0; i < Convert.ToInt32(textBoxCount.Text); i++)
+ {
+ DateTime dateStart = new DateTime(rnd.Next(1991, 2023), rnd.Next(1, 12), rnd.Next(1, 28));
+ DateTime dateEnd = dateStart.AddDays(20);
+
+ var model = new TruckingBindingModel
+ {
+ Id = 0,
+ ClientId = viewClient[rnd.Next(0, viewClient.Count)].Id,
+ CargoId = viewCargo[rnd.Next(0, viewCargo.Count)].Id,
+ TransportId = viewTransport[rnd.Next(0, viewTransport.Count)].Id,
+ TransportationId = viewTransportation[rnd.Next(0, viewTransportation.Count)].Id,
+ DateStart = dateStart,
+ DateEnd = dateEnd,
+ Price = viewClient.Count * rnd.Next(100, 5000)
+ };
+
+ var operationResult = _logic.Create(model);
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ Close();
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormRandomCreateTrucking.resx b/TransportCompany/TransportCompany/FormRandomCreateTrucking.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormRandomCreateTrucking.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormTransport.Designer.cs b/TransportCompany/TransportCompany/FormTransport.Designer.cs
new file mode 100644
index 0000000..2c39d2b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormTransport.Designer.cs
@@ -0,0 +1,114 @@
+namespace TransportCompany
+{
+ partial class FormTransport
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ buttonCreate = new Button();
+ buttonUpdate = new Button();
+ buttonReload = new Button();
+ buttonDelete = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(455, 426);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(521, 39);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(138, 29);
+ buttonCreate.TabIndex = 1;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += ButtonCreate_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(521, 112);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(138, 29);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonReload
+ //
+ buttonReload.Location = new Point(521, 258);
+ buttonReload.Name = "buttonReload";
+ buttonReload.Size = new Size(138, 29);
+ buttonReload.TabIndex = 4;
+ buttonReload.Text = "Обновить";
+ buttonReload.UseVisualStyleBackColor = true;
+ buttonReload.Click += ButtonReload_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(521, 184);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(138, 29);
+ buttonDelete.TabIndex = 5;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // FormTransport
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(703, 450);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonReload);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreate);
+ Controls.Add(dataGridView);
+ Name = "FormTransport";
+ Text = "FormTransports";
+ Load += FormTransport_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonCreate;
+ private Button buttonUpdate;
+ private Button buttonReload;
+ private Button buttonDelete;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormTransport.cs b/TransportCompany/TransportCompany/FormTransport.cs
new file mode 100644
index 0000000..1bf398b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormTransport.cs
@@ -0,0 +1,131 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+
+namespace TransportCompany
+{
+ public partial class FormTransport : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly ITransportLogic _logic;
+
+ public FormTransport(ILogger logger, ITransportLogic logic)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormClients_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+
+ //растягиваем колонку Название на всю ширину, колонку Id скрываем
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+
+ _logger.LogInformation("Загрузка транспортных средств");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки транспортных средств");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void FormTransport_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateTransport));
+
+ if (service is FormCreateTransport form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateTransport));
+
+ if (service is FormCreateTransport form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ //проверяем наличие выделенной строки
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ _logger.LogInformation("Удаление транспорта");
+
+ try
+ {
+ if (!_logic.Delete(new TransportBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления транспорта");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonReload_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormTransport.resx b/TransportCompany/TransportCompany/FormTransport.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormTransport.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormTrucking.Designer.cs b/TransportCompany/TransportCompany/FormTrucking.Designer.cs
new file mode 100644
index 0000000..cab8ba1
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormTrucking.Designer.cs
@@ -0,0 +1,192 @@
+namespace TransportCompany
+{
+ partial class FormTrucking
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ 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();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ menuStrip.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(11, 36);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(937, 448);
+ 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;
+ //
+ // FormTrucking
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1297, 496);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreateTrucking);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip);
+ MainMenuStrip = menuStrip;
+ Name = "FormTrucking";
+ Text = "Перевозки";
+ Load += FormMain_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonCreateTrucking;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonRef;
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem toolStripMenuItem;
+ private ToolStripMenuItem transportToolStripMenuItem;
+ private ToolStripMenuItem workPieceToolStripMenuItem;
+ private ToolStripMenuItem typeTransportationToolStripMenuItem;
+ private ToolStripMenuItem cargoToolStripMenuItem;
+ private ToolStripMenuItem clientToolStripMenuItem;
+ private ToolStripMenuItem shopToolStripMenuItem;
+ private ToolStripMenuItem addManufactureToolStripMenuItem;
+ private Button buttonSellManufacture;
+ private ToolStripMenuItem reportToolStripMenuItem;
+ private ToolStripMenuItem groupedOrdersReportToolStripMenuItem;
+ private ToolStripMenuItem ordersReportToolStripMenuItem;
+ private ToolStripMenuItem manufactureWorkPiecesReportToolStripMenuItem;
+ private ToolStripMenuItem shopsReportToolStripMenuItem;
+ private ToolStripMenuItem rndGenerationToolStripMenuItem;
+ private ToolStripMenuItem generationClientsToolStripMenuItem;
+ private ToolStripMenuItem generationTruckingsToolStripMenuItem;
+ private Button buttonUpdate;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormTrucking.cs b/TransportCompany/TransportCompany/FormTrucking.cs
new file mode 100644
index 0000000..5bffa4f
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormTrucking.cs
@@ -0,0 +1,133 @@
+using Microsoft.Extensions.Logging;
+using TransportCompanyContracts.BusinessLogicsContracts;
+
+namespace TransportCompany
+{
+ public partial class FormTrucking : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly ITruckingLogic _truckingLogic;
+
+ public FormTrucking(ILogger logger, ITruckingLogic truckingLogic)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _truckingLogic = truckingLogic;
+ }
+
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ _logger.LogInformation(" ");
+
+ try
+ {
+ var list = _truckingLogic.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;
+ }
+
+ _logger.LogInformation(" ");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, " ");
+ MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCreateTrucking_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateTrucking));
+
+ if (service is FormCreateTrucking form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void TransportToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormTransport));
+
+ if (service is FormTransport form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void CargoToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCargo));
+
+ if (service is FormCargo form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormClients));
+
+ if (service is FormClients form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void TypeTransportationToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormTypeTransportation));
+
+ if (service is FormTypeTransportation form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void GenerationClientsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateClient));
+
+ if (service is FormRandomCreateClient form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void GenerationTruckingsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateTrucking));
+
+ if (service is FormRandomCreateTrucking form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormTrucking.resx b/TransportCompany/TransportCompany/FormTrucking.resx
new file mode 100644
index 0000000..81a9e3d
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormTrucking.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormTypeTransportation.Designer.cs b/TransportCompany/TransportCompany/FormTypeTransportation.Designer.cs
new file mode 100644
index 0000000..7241744
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormTypeTransportation.Designer.cs
@@ -0,0 +1,114 @@
+namespace TransportCompany
+{
+ partial class FormTypeTransportation
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ buttonCreate = new Button();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonReload = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(450, 426);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(512, 27);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(145, 29);
+ buttonCreate.TabIndex = 1;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += ButtonCreate_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(512, 93);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(145, 29);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Обновить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(512, 160);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(145, 29);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonReload
+ //
+ buttonReload.Location = new Point(512, 228);
+ buttonReload.Name = "buttonReload";
+ buttonReload.Size = new Size(145, 29);
+ buttonReload.TabIndex = 4;
+ buttonReload.Text = "Обновить";
+ buttonReload.UseVisualStyleBackColor = true;
+ buttonReload.Click += ButtonReload_Click;
+ //
+ // FormTypeTransportation
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(701, 450);
+ Controls.Add(buttonReload);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreate);
+ Controls.Add(dataGridView);
+ Name = "FormTypeTransportation";
+ Text = "Типы перевозок";
+ Load += FormTypeTransportation_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonCreate;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonReload;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormTypeTransportation.cs b/TransportCompany/TransportCompany/FormTypeTransportation.cs
new file mode 100644
index 0000000..3ce69ac
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormTypeTransportation.cs
@@ -0,0 +1,126 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BindingModels;
+using TransportCompanyContracts.BusinessLogicsContracts;
+
+namespace TransportCompany
+{
+ public partial class FormTypeTransportation : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly ITransportationLogic _logic;
+
+ public FormTypeTransportation(ILogger logger, ITransportationLogic logic)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormTypeTransportation_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+
+ //растягиваем колонку Название на всю ширину, колонку Id скрываем
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+
+ _logger.LogInformation("Загрузка типа перевозок");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки типа перевозок");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateTypeTransportation));
+
+ if (service is FormCreateTypeTransportation form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateTypeTransportation));
+
+ if (service is FormCreateTypeTransportation form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ //проверяем наличие выделенной строки
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ _logger.LogInformation("Удаление типа перевозки");
+
+ try
+ {
+ if (!_logic.Delete(new TransportationBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления типа перевозки");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonReload_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormTypeTransportation.resx b/TransportCompany/TransportCompany/FormTypeTransportation.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormTypeTransportation.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/Program.cs b/TransportCompany/TransportCompany/Program.cs
index 40c4648..5211704 100644
--- a/TransportCompany/TransportCompany/Program.cs
+++ b/TransportCompany/TransportCompany/Program.cs
@@ -1,17 +1,66 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using TransportCompanyBusinessLogic.BusinessLogic;
+using TransportCompanyContracts.BusinessLogicsContracts;
+using TransportCompanyContracts.StoragesContracts;
+using TransportCompanyDatabaseImplements.Implements;
+
namespace TransportCompany
{
internal static class Program
{
+ private static ServiceProvider? _serviceProvider;
+
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
- // To customize application configuration such as set high DPI settings or default font,
+ // To customize application configuration such as set high DPI settings or default font;
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddLogging(option =>
+ {
+ option.SetMinimumLevel(LogLevel.Information);
+ option.AddNLog("nlog.config");
+ });
+
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/TransportCompany.csproj b/TransportCompany/TransportCompany/TransportCompany.csproj
index a044fef..9d2c9db 100644
--- a/TransportCompany/TransportCompany/TransportCompany.csproj
+++ b/TransportCompany/TransportCompany/TransportCompany.csproj
@@ -17,6 +17,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Implements/TranportationStorage.cs b/TransportCompany/TransportCompanyDatabaseImplements/Implements/TransportationStorage.cs
similarity index 97%
rename from TransportCompany/TransportCompanyDatabaseImplements/Implements/TranportationStorage.cs
rename to TransportCompany/TransportCompanyDatabaseImplements/Implements/TransportationStorage.cs
index 1af94e7..7bd15c0 100644
--- a/TransportCompany/TransportCompanyDatabaseImplements/Implements/TranportationStorage.cs
+++ b/TransportCompany/TransportCompanyDatabaseImplements/Implements/TransportationStorage.cs
@@ -11,7 +11,7 @@ using TransportCompanyDatabaseImplements.Models;
namespace TransportCompanyDatabaseImplements.Implements
{
- public class TranportationStorage : ITransportationStorage
+ public class TransportationStorage : ITransportationStorage
{
public TransportationViewModel? Delete(TransportationBindingModel model)
{
diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs b/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs
index b6272af..17e288d 100644
--- a/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs
+++ b/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.EntityFrameworkCore;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -85,7 +86,13 @@ namespace TransportCompanyDatabaseImplements.Implements
context.Truckings.Add(newTrucking);
context.SaveChanges();
- return newTrucking.GetViewModel;
+ return context.Truckings
+ .Include(x => x.Transport)
+ .Include(x => x.Cargo)
+ .Include(x => x.TypeTransportation)
+ .Include (x => x.Client)
+ .Select(x => x.GetViewModel)
+ .FirstOrDefault(x => x.Id == model.Id);
}
public TruckingViewModel? Update(TruckingBindingModel model)
diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.Designer.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.Designer.cs
new file mode 100644
index 0000000..d435610
--- /dev/null
+++ b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.Designer.cs
@@ -0,0 +1,239 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using TransportCompanyDatabaseImplements;
+
+#nullable disable
+
+namespace TransportCompanyDatabaseImplements.Migrations
+{
+ [DbContext(typeof(ElegevContext))]
+ [Migration("20230413092204_ClearClients")]
+ partial class ClearClients
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.5")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.HasSequence("seq_cargo");
+
+ modelBuilder.HasSequence("seq_client");
+
+ modelBuilder.HasSequence("seq_trucking");
+
+ modelBuilder.HasSequence("seq_type_transport");
+
+ modelBuilder.HasSequence("seq_type_transportation");
+
+ modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Cargo", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("integer")
+ .HasColumnName("id");
+
+ b.Property("TypeCargo")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("type_cargo");
+
+ b.HasKey("Id")
+ .HasName("cargo_pkey");
+
+ b.ToTable("cargo", (string)null);
+ });
+
+ modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Client", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("integer")
+ .HasColumnName("id");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("email");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("name");
+
+ b.Property("Patronymic")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("patronymic");
+
+ b.Property("Surname")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("surname");
+
+ b.Property("Telephone")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("telephone");
+
+ b.HasKey("Id")
+ .HasName("client_pkey");
+
+ b.ToTable("client", (string)null);
+ });
+
+ modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Transport", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("integer")
+ .HasColumnName("id");
+
+ b.Property("TransportType")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("transport_type");
+
+ b.HasKey("Id")
+ .HasName("transport_pkey");
+
+ b.ToTable("transport", (string)null);
+ });
+
+ modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Trucking", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("integer")
+ .HasColumnName("id");
+
+ b.Property("CargoId")
+ .HasColumnType("integer")
+ .HasColumnName("cargo_id");
+
+ b.Property("ClientId")
+ .HasColumnType("integer")
+ .HasColumnName("client_id");
+
+ b.Property("DateEnd")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("date_end");
+
+ b.Property("DateStart")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("date_start");
+
+ b.Property("Price")
+ .HasColumnType("double precision")
+ .HasColumnName("price");
+
+ b.Property("TransportId")
+ .HasColumnType("integer")
+ .HasColumnName("transport_id");
+
+ b.Property("TransportationId")
+ .HasColumnType("integer")
+ .HasColumnName("transportation_id");
+
+ b.HasKey("Id")
+ .HasName("trucking_pkey");
+
+ b.HasIndex("CargoId");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("TransportId");
+
+ b.HasIndex("TransportationId");
+
+ b.ToTable("trucking", (string)null);
+ });
+
+ modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.TypeTransportation", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("integer")
+ .HasColumnName("id");
+
+ b.Property("TransportationType")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("transportation_type");
+
+ b.HasKey("Id")
+ .HasName("type_transportation_pkey");
+
+ b.ToTable("type_transportation", (string)null);
+ });
+
+ modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Trucking", b =>
+ {
+ b.HasOne("TransportCompanyDatabaseImplements.Models.Cargo", "Cargo")
+ .WithMany("Truckings")
+ .HasForeignKey("CargoId")
+ .IsRequired()
+ .HasConstraintName("cargo_id");
+
+ b.HasOne("TransportCompanyDatabaseImplements.Models.Client", "Client")
+ .WithMany("Truckings")
+ .HasForeignKey("ClientId")
+ .IsRequired()
+ .HasConstraintName("client_id");
+
+ b.HasOne("TransportCompanyDatabaseImplements.Models.Transport", "Transport")
+ .WithMany("Truckings")
+ .HasForeignKey("TransportId")
+ .IsRequired()
+ .HasConstraintName("transport_id");
+
+ b.HasOne("TransportCompanyDatabaseImplements.Models.TypeTransportation", "TypeTransportation")
+ .WithMany("Truckings")
+ .HasForeignKey("TransportationId")
+ .IsRequired()
+ .HasConstraintName("type_transportation_id");
+
+ b.Navigation("Cargo");
+
+ b.Navigation("Client");
+
+ b.Navigation("Transport");
+
+ b.Navigation("TypeTransportation");
+ });
+
+ modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Cargo", b =>
+ {
+ b.Navigation("Truckings");
+ });
+
+ modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Client", b =>
+ {
+ b.Navigation("Truckings");
+ });
+
+ modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Transport", b =>
+ {
+ b.Navigation("Truckings");
+ });
+
+ modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.TypeTransportation", b =>
+ {
+ b.Navigation("Truckings");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.cs
new file mode 100644
index 0000000..d5f1616
--- /dev/null
+++ b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.cs
@@ -0,0 +1,22 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace TransportCompanyDatabaseImplements.Migrations
+{
+ ///
+ public partial class ClearClients : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+
+ }
+ }
+}