diff --git a/ProjectGarage/Entities/Driver.cs b/ProjectGarage/Entities/Driver.cs
index 686e79a..02ecffc 100644
--- a/ProjectGarage/Entities/Driver.cs
+++ b/ProjectGarage/Entities/Driver.cs
@@ -17,9 +17,9 @@ public class Driver
public string Phone_Number { get;private set; } = string.Empty;
- public int TruckID { get; set; }
+ public int TruckId { get;private set; }
- public static Driver CreateDriver(int id, string fname, string lname ,string phone_num, int truck_id)
+ public static Driver CreateDriver(int id, string fname, string lname ,string phone_num, int tryckid)
{
return new Driver
{
@@ -27,7 +27,7 @@ public class Driver
First_name = fname,
Last_name = lname,
Phone_Number = phone_num ?? string.Empty,
- TruckID = truck_id
+ TruckId = tryckid
};
}
}
diff --git a/ProjectGarage/Entities/Enums/TruckType.cs b/ProjectGarage/Entities/Enums/TruckType.cs
new file mode 100644
index 0000000..9523151
--- /dev/null
+++ b/ProjectGarage/Entities/Enums/TruckType.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectGarage.Entities.Enums
+{
+ public enum TruckType
+ {
+ None = 0,
+ Mercedes = 1,
+ SCANIA = 2,
+ KAMAZ = 3,
+ MAN = 4,
+ Volvo = 5
+ }
+}
diff --git a/ProjectGarage/Entities/Transportation.cs b/ProjectGarage/Entities/Transportation.cs
index ea09e65..0aa3408 100644
--- a/ProjectGarage/Entities/Transportation.cs
+++ b/ProjectGarage/Entities/Transportation.cs
@@ -20,7 +20,7 @@ public class Transportation
public DateTime TransportationDate { get; set; }
- public Transportation CreateTransportation(int id, int fuel_id, int route_id, int driver_id, int amount)
+ public static Transportation CreateTransportation(int id, int fuel_id, int route_id, int driver_id, int amount)
{
return new Transportation
{
diff --git a/ProjectGarage/Entities/Truck.cs b/ProjectGarage/Entities/Truck.cs
index f627ac5..c416718 100644
--- a/ProjectGarage/Entities/Truck.cs
+++ b/ProjectGarage/Entities/Truck.cs
@@ -13,24 +13,18 @@ public class Truck
public string Numbers { get; private set; } = string.Empty;
- public string Brand { get; private set; } = string.Empty;
-
- public string Model { get; private set; } = string.Empty;
+ public TruckType Type { get; set; }
public int MaxFuel { get; private set; }
- public bool HasDriver { get; private set; }
-
- public static Truck CreateTruck(int id,string numbers, string brand, string model, int maxFuel)
+ public static Truck CreateTruck(int id,string numbers, TruckType type, int maxFuel)
{
return new Truck()
{
Id = id,
Numbers = numbers,
- Brand = brand,
- Model = model,
- MaxFuel = maxFuel,
- HasDriver = false
+ Type = type,
+ MaxFuel = maxFuel
};
}
}
diff --git a/ProjectGarage/Forms/FormDriver.Designer.cs b/ProjectGarage/Forms/FormDriver.Designer.cs
index c8169b1..b63e004 100644
--- a/ProjectGarage/Forms/FormDriver.Designer.cs
+++ b/ProjectGarage/Forms/FormDriver.Designer.cs
@@ -124,7 +124,7 @@
comboBoxTruckID.FormattingEnabled = true;
comboBoxTruckID.Location = new Point(120, 156);
comboBoxTruckID.Name = "comboBoxTruckID";
- comboBoxTruckID.Size = new Size(151, 28);
+ comboBoxTruckID.Size = new Size(183, 28);
comboBoxTruckID.TabIndex = 10;
//
// FormDriver
diff --git a/ProjectGarage/Forms/FormDriver.cs b/ProjectGarage/Forms/FormDriver.cs
index a630642..ea1a7f6 100644
--- a/ProjectGarage/Forms/FormDriver.cs
+++ b/ProjectGarage/Forms/FormDriver.cs
@@ -33,7 +33,7 @@ namespace ProjectGarage.Forms
}
textBoxFirstName.Text = driver.First_name;
textBoxLastName.Text = driver.Last_name;
- comboBoxTruckID.SelectedItem = driver.Id;//TODO НЕ ЗАБУДЬ
+ //comboBoxTruckID.SelectedItem = driver.TruckId;
_driverId = value;
}
catch (Exception ex)
@@ -44,12 +44,13 @@ namespace ProjectGarage.Forms
}
}
- public FormDriver(IDriverRepository driverRepository)
+ public FormDriver(IDriverRepository driverRepository, ITruckRepository truckRepository)
{
InitializeComponent();
_driverRepository = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
- comboBoxTruckID.DataSource = Enum.GetValues(typeof(FuelType));//TODO НЕ ЗАБУДЬ
-
+ comboBoxTruckID.DataSource = truckRepository.ReadTrucks();//
+ comboBoxTruckID.DisplayMember = "Numbers";
+ comboBoxTruckID.ValueMember = "Id";
}
private void ButtonSaveDriver_Click(object sender, EventArgs e)
@@ -57,7 +58,7 @@ namespace ProjectGarage.Forms
try
{
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text)
- || comboBoxTruckID.SelectedIndex < 1)//TODO НЕ ЗАБУДЬ
+ || comboBoxTruckID.SelectedIndex < 0)//
{
throw new Exception("Имеются незаполненные поля");
}
@@ -78,14 +79,9 @@ namespace ProjectGarage.Forms
}
}
-
- private void ButtonCancelDriver_Click(object sender, EventArgs e)
- {
-
- }
+ private void ButtonCancelDriver_Click(object sender, EventArgs e) => Close();
private Driver CreateDriver(int id) => Driver.CreateDriver(id, textBoxFirstName.Text,
- textBoxLastName.Text, textBoxPhoneNum.Text, (int)(FuelType)comboBoxTruckID.SelectedItem!);//TODO НЕ ЗАБУДЬ
+ textBoxLastName.Text, textBoxPhoneNum.Text, (int)comboBoxTruckID.SelectedIndex!);//
}
-
}
diff --git a/ProjectGarage/Forms/FormDrivers.Designer.cs b/ProjectGarage/Forms/FormDrivers.Designer.cs
new file mode 100644
index 0000000..918e93c
--- /dev/null
+++ b/ProjectGarage/Forms/FormDrivers.Designer.cs
@@ -0,0 +1,125 @@
+namespace ProjectGarage.Forms
+{
+ partial class FormDrivers
+ {
+ ///
+ /// 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()
+ {
+ dataGridViewDrivers = new DataGridView();
+ panelFormDriversButtons = new Panel();
+ buttonUpdateDriver = new Button();
+ buttonDeleteDriver = new Button();
+ buttonAddDriver = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewDrivers).BeginInit();
+ panelFormDriversButtons.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridViewDrivers
+ //
+ dataGridViewDrivers.AllowUserToAddRows = false;
+ dataGridViewDrivers.AllowUserToDeleteRows = false;
+ dataGridViewDrivers.AllowUserToResizeColumns = false;
+ dataGridViewDrivers.AllowUserToResizeRows = false;
+ dataGridViewDrivers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewDrivers.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewDrivers.Dock = DockStyle.Fill;
+ dataGridViewDrivers.Location = new Point(0, 0);
+ dataGridViewDrivers.Name = "dataGridViewDrivers";
+ dataGridViewDrivers.ReadOnly = true;
+ dataGridViewDrivers.RowHeadersVisible = false;
+ dataGridViewDrivers.RowHeadersWidth = 51;
+ dataGridViewDrivers.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewDrivers.Size = new Size(639, 367);
+ dataGridViewDrivers.TabIndex = 3;
+ //
+ // panelFormDriversButtons
+ //
+ panelFormDriversButtons.Controls.Add(buttonUpdateDriver);
+ panelFormDriversButtons.Controls.Add(buttonDeleteDriver);
+ panelFormDriversButtons.Controls.Add(buttonAddDriver);
+ panelFormDriversButtons.Dock = DockStyle.Right;
+ panelFormDriversButtons.Location = new Point(639, 0);
+ panelFormDriversButtons.Name = "panelFormDriversButtons";
+ panelFormDriversButtons.Size = new Size(161, 367);
+ panelFormDriversButtons.TabIndex = 2;
+ //
+ // buttonUpdateDriver
+ //
+ buttonUpdateDriver.BackgroundImage = Properties.Resources.каранд;
+ buttonUpdateDriver.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdateDriver.Location = new Point(35, 140);
+ buttonUpdateDriver.Name = "buttonUpdateDriver";
+ buttonUpdateDriver.Size = new Size(94, 75);
+ buttonUpdateDriver.TabIndex = 2;
+ buttonUpdateDriver.UseVisualStyleBackColor = true;
+ buttonUpdateDriver.Click += ButtonUpdateDriver_Click;
+ //
+ // buttonDeleteDriver
+ //
+ buttonDeleteDriver.BackgroundImage = Properties.Resources.минусик;
+ buttonDeleteDriver.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDeleteDriver.Location = new Point(35, 249);
+ buttonDeleteDriver.Name = "buttonDeleteDriver";
+ buttonDeleteDriver.Size = new Size(94, 78);
+ buttonDeleteDriver.TabIndex = 1;
+ buttonDeleteDriver.UseVisualStyleBackColor = true;
+ buttonDeleteDriver.Click += ButtonDeleteDriver_Click;
+ //
+ // buttonAddDriver
+ //
+ buttonAddDriver.BackgroundImage = Properties.Resources.плюсик;
+ buttonAddDriver.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAddDriver.Location = new Point(35, 23);
+ buttonAddDriver.Name = "buttonAddDriver";
+ buttonAddDriver.Size = new Size(94, 75);
+ buttonAddDriver.TabIndex = 0;
+ buttonAddDriver.UseVisualStyleBackColor = true;
+ buttonAddDriver.Click += ButtonAddDriver_Click;
+ //
+ // FormDrivers
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 367);
+ Controls.Add(dataGridViewDrivers);
+ Controls.Add(panelFormDriversButtons);
+ Name = "FormDrivers";
+ Text = "FormDrivers";
+ Click += FormDrivers_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridViewDrivers).EndInit();
+ panelFormDriversButtons.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridViewDrivers;
+ private Panel panelFormDriversButtons;
+ private Button buttonUpdateDriver;
+ private Button buttonDeleteDriver;
+ private Button buttonAddDriver;
+ }
+}
\ No newline at end of file
diff --git a/ProjectGarage/Forms/FormDrivers.cs b/ProjectGarage/Forms/FormDrivers.cs
new file mode 100644
index 0000000..b5444ad
--- /dev/null
+++ b/ProjectGarage/Forms/FormDrivers.cs
@@ -0,0 +1,114 @@
+using ProjectGarage.Repositories;
+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 Unity;
+
+namespace ProjectGarage.Forms
+{
+ public partial class FormDrivers : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IDriverRepository _driverRepository;
+
+ public FormDrivers(IUnityContainer container, IDriverRepository driverRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _driverRepository = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
+ }
+ private void FormDrivers_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+
+ private void ButtonAddDriver_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpdateDriver_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ try
+ {
+ var form = _container.Resolve();
+ form.Id = findId;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonDeleteDriver_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить запись?", "Удаление",
+ MessageBoxButtons.YesNo) != DialogResult.Yes)
+ {
+ return;
+ }
+ try
+ {
+ _driverRepository.DeleteDriver(findId);
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ }
+
+ private void LoadList() => dataGridViewDrivers.DataSource = _driverRepository.ReadDrivers();
+
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewDrivers.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id =
+ Convert.ToInt32(dataGridViewDrivers.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectGarage/Forms/FormDrivers.resx b/ProjectGarage/Forms/FormDrivers.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectGarage/Forms/FormDrivers.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/ProjectGarage/Forms/FormFuel.Designer.cs b/ProjectGarage/Forms/FormFuel.Designer.cs
new file mode 100644
index 0000000..db9db84
--- /dev/null
+++ b/ProjectGarage/Forms/FormFuel.Designer.cs
@@ -0,0 +1,144 @@
+namespace ProjectGarage.Forms
+{
+ partial class FormFuel
+ {
+ ///
+ /// 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()
+ {
+ checkedListBoxFuel = new CheckedListBox();
+ labelFuelType = new Label();
+ labelFuelName = new Label();
+ textBoxFuelName = new TextBox();
+ numericUpDownFuelPrice = new NumericUpDown();
+ labelFuelPrice = new Label();
+ buttonFuelSave = new Button();
+ buttonFuelCancel = new Button();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownFuelPrice).BeginInit();
+ SuspendLayout();
+ //
+ // checkedListBoxFuel
+ //
+ checkedListBoxFuel.FormattingEnabled = true;
+ checkedListBoxFuel.Location = new Point(121, 12);
+ checkedListBoxFuel.Name = "checkedListBoxFuel";
+ checkedListBoxFuel.Size = new Size(150, 114);
+ checkedListBoxFuel.TabIndex = 0;
+ //
+ // labelFuelType
+ //
+ labelFuelType.AutoSize = true;
+ labelFuelType.Location = new Point(12, 12);
+ labelFuelType.Name = "labelFuelType";
+ labelFuelType.Size = new Size(96, 20);
+ labelFuelType.TabIndex = 1;
+ labelFuelType.Text = "Тип топлива";
+ //
+ // labelFuelName
+ //
+ labelFuelName.AutoSize = true;
+ labelFuelName.Location = new Point(21, 138);
+ labelFuelName.Name = "labelFuelName";
+ labelFuelName.Size = new Size(77, 20);
+ labelFuelName.TabIndex = 2;
+ labelFuelName.Text = "Название";
+ //
+ // textBoxFuelName
+ //
+ textBoxFuelName.Location = new Point(121, 138);
+ textBoxFuelName.Name = "textBoxFuelName";
+ textBoxFuelName.Size = new Size(150, 27);
+ textBoxFuelName.TabIndex = 3;
+ //
+ // numericUpDownFuelPrice
+ //
+ numericUpDownFuelPrice.Location = new Point(121, 180);
+ numericUpDownFuelPrice.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
+ numericUpDownFuelPrice.Name = "numericUpDownFuelPrice";
+ numericUpDownFuelPrice.Size = new Size(150, 27);
+ numericUpDownFuelPrice.TabIndex = 4;
+ numericUpDownFuelPrice.Value = new decimal(new int[] { 1, 0, 0, 0 });
+ //
+ // labelFuelPrice
+ //
+ labelFuelPrice.AutoSize = true;
+ labelFuelPrice.Location = new Point(8, 182);
+ labelFuelPrice.Name = "labelFuelPrice";
+ labelFuelPrice.Size = new Size(100, 20);
+ labelFuelPrice.TabIndex = 5;
+ labelFuelPrice.Text = "Цена за литр";
+ //
+ // buttonFuelSave
+ //
+ buttonFuelSave.Location = new Point(8, 219);
+ buttonFuelSave.Name = "buttonFuelSave";
+ buttonFuelSave.Size = new Size(121, 29);
+ buttonFuelSave.TabIndex = 6;
+ buttonFuelSave.Text = "Сохранить";
+ buttonFuelSave.UseVisualStyleBackColor = true;
+ buttonFuelSave.Click += ButtonFuelSave_Click;
+ //
+ // buttonFuelCancel
+ //
+ buttonFuelCancel.Location = new Point(152, 219);
+ buttonFuelCancel.Name = "buttonFuelCancel";
+ buttonFuelCancel.Size = new Size(119, 29);
+ buttonFuelCancel.TabIndex = 7;
+ buttonFuelCancel.Text = "Отмена";
+ buttonFuelCancel.UseVisualStyleBackColor = true;
+ buttonFuelCancel.Click += ButtonFuelCancel_Click;
+ //
+ // FormFuel
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(292, 260);
+ Controls.Add(buttonFuelCancel);
+ Controls.Add(buttonFuelSave);
+ Controls.Add(labelFuelPrice);
+ Controls.Add(numericUpDownFuelPrice);
+ Controls.Add(textBoxFuelName);
+ Controls.Add(labelFuelName);
+ Controls.Add(labelFuelType);
+ Controls.Add(checkedListBoxFuel);
+ Name = "FormFuel";
+ Text = "FormFuel";
+ ((System.ComponentModel.ISupportInitialize)numericUpDownFuelPrice).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private CheckedListBox checkedListBoxFuel;
+ private Label labelFuelType;
+ private Label labelFuelName;
+ private TextBox textBoxFuelName;
+ private NumericUpDown numericUpDownFuelPrice;
+ private Label labelFuelPrice;
+ private Button buttonFuelSave;
+ private Button buttonFuelCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectGarage/Forms/FormFuel.cs b/ProjectGarage/Forms/FormFuel.cs
new file mode 100644
index 0000000..9fe7b08
--- /dev/null
+++ b/ProjectGarage/Forms/FormFuel.cs
@@ -0,0 +1,104 @@
+using Microsoft.VisualBasic.FileIO;
+using ProjectGarage.Entities;
+using ProjectGarage.Entities.Enums;
+using ProjectGarage.Repositories;
+using ProjectGarage.Repositories.Implementations;
+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;
+
+namespace ProjectGarage.Forms
+{
+ public partial class FormFuel : Form
+ {
+ private readonly IFuelRepository _fuelRepository;
+ private int? _fuelId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var fuel = _fuelRepository.ReadFuelByID(value);
+ if (fuel == null)
+ {
+ throw new InvalidDataException(nameof(fuel));
+ }
+ foreach (FuelType elem in Enum.GetValues(typeof(FuelType)))
+ {
+ if ((elem & fuel.Type) != 0)
+ {
+ checkedListBoxFuel.SetItemChecked(checkedListBoxFuel.Items.IndexOf(elem), true);
+ }
+ }
+ textBoxFuelName.Text = fuel.Name;
+ _fuelId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ }
+ }
+
+ public FormFuel(IFuelRepository fuelRepository)
+ {
+ InitializeComponent();
+ _fuelRepository = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
+ foreach (var elem in Enum.GetValues(typeof(FuelType)))
+ {
+ checkedListBoxFuel.Items.Add(elem);
+ }
+
+ }
+
+ private void ButtonFuelSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxFuelName.Text) ||
+ checkedListBoxFuel.CheckedItems.Count == 0)
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_fuelId.HasValue)
+ {
+ _fuelRepository.UpdateFuel(CreateFuel(_fuelId.Value));
+ }
+ else
+ {
+ _fuelRepository.CreateFuel(CreateFuel(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ }
+
+ private void ButtonFuelCancel_Click(object sender, EventArgs e) => Close();
+
+ private Fuel CreateFuel(int id)
+ {
+ FuelType fuelType = FuelType.None;
+ foreach (var elem in checkedListBoxFuel.CheckedItems)
+ {
+ fuelType |= (FuelType)elem;
+ }
+ return Fuel.CreateFuel(id, textBoxFuelName.Text, fuelType, Convert.ToInt32(numericUpDownFuelPrice.Value));
+ }
+
+ }
+}
diff --git a/ProjectGarage/Forms/FormFuel.resx b/ProjectGarage/Forms/FormFuel.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectGarage/Forms/FormFuel.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/ProjectGarage/Forms/FormFuels.Designer.cs b/ProjectGarage/Forms/FormFuels.Designer.cs
new file mode 100644
index 0000000..064fe4c
--- /dev/null
+++ b/ProjectGarage/Forms/FormFuels.Designer.cs
@@ -0,0 +1,125 @@
+namespace ProjectGarage.Forms
+{
+ partial class FormFuels
+ {
+ ///
+ /// 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()
+ {
+ dataGridViewFuels = new DataGridView();
+ panelFormFuelsButtons = new Panel();
+ buttonUpdateFuel = new Button();
+ buttonDeleteFuel = new Button();
+ buttonAddFuel = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewFuels).BeginInit();
+ panelFormFuelsButtons.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridViewFuels
+ //
+ dataGridViewFuels.AllowUserToAddRows = false;
+ dataGridViewFuels.AllowUserToDeleteRows = false;
+ dataGridViewFuels.AllowUserToResizeColumns = false;
+ dataGridViewFuels.AllowUserToResizeRows = false;
+ dataGridViewFuels.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewFuels.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewFuels.Dock = DockStyle.Fill;
+ dataGridViewFuels.Location = new Point(0, 0);
+ dataGridViewFuels.Name = "dataGridViewFuels";
+ dataGridViewFuels.ReadOnly = true;
+ dataGridViewFuels.RowHeadersVisible = false;
+ dataGridViewFuels.RowHeadersWidth = 51;
+ dataGridViewFuels.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewFuels.Size = new Size(648, 367);
+ dataGridViewFuels.TabIndex = 5;
+ //
+ // panelFormFuelsButtons
+ //
+ panelFormFuelsButtons.Controls.Add(buttonUpdateFuel);
+ panelFormFuelsButtons.Controls.Add(buttonDeleteFuel);
+ panelFormFuelsButtons.Controls.Add(buttonAddFuel);
+ panelFormFuelsButtons.Dock = DockStyle.Right;
+ panelFormFuelsButtons.Location = new Point(648, 0);
+ panelFormFuelsButtons.Name = "panelFormFuelsButtons";
+ panelFormFuelsButtons.Size = new Size(161, 367);
+ panelFormFuelsButtons.TabIndex = 4;
+ //
+ // buttonUpdateFuel
+ //
+ buttonUpdateFuel.BackgroundImage = Properties.Resources.каранд;
+ buttonUpdateFuel.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdateFuel.Location = new Point(35, 140);
+ buttonUpdateFuel.Name = "buttonUpdateFuel";
+ buttonUpdateFuel.Size = new Size(94, 75);
+ buttonUpdateFuel.TabIndex = 2;
+ buttonUpdateFuel.UseVisualStyleBackColor = true;
+ buttonUpdateFuel.Click += ButtonUpdateFuel_Click;
+ //
+ // buttonDeleteFuel
+ //
+ buttonDeleteFuel.BackgroundImage = Properties.Resources.минусик;
+ buttonDeleteFuel.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDeleteFuel.Location = new Point(35, 249);
+ buttonDeleteFuel.Name = "buttonDeleteFuel";
+ buttonDeleteFuel.Size = new Size(94, 78);
+ buttonDeleteFuel.TabIndex = 1;
+ buttonDeleteFuel.UseVisualStyleBackColor = true;
+ buttonDeleteFuel.Click += ButtonDeleteFuel_Click;
+ //
+ // buttonAddFuel
+ //
+ buttonAddFuel.BackgroundImage = Properties.Resources.плюсик;
+ buttonAddFuel.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAddFuel.Location = new Point(35, 23);
+ buttonAddFuel.Name = "buttonAddFuel";
+ buttonAddFuel.Size = new Size(94, 75);
+ buttonAddFuel.TabIndex = 0;
+ buttonAddFuel.UseVisualStyleBackColor = true;
+ buttonAddFuel.Click += ButtonAddFuel_Click;
+ //
+ // FormFuels
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(809, 367);
+ Controls.Add(dataGridViewFuels);
+ Controls.Add(panelFormFuelsButtons);
+ Name = "FormFuels";
+ Text = "FormFuels";
+ Load += FormFeeds_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridViewFuels).EndInit();
+ panelFormFuelsButtons.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridViewFuels;
+ private Panel panelFormFuelsButtons;
+ private Button buttonUpdateFuel;
+ private Button buttonDeleteFuel;
+ private Button buttonAddFuel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectGarage/Forms/FormFuels.cs b/ProjectGarage/Forms/FormFuels.cs
new file mode 100644
index 0000000..893dc14
--- /dev/null
+++ b/ProjectGarage/Forms/FormFuels.cs
@@ -0,0 +1,114 @@
+using ProjectGarage.Repositories;
+using ProjectGarage.Repositories.Implementations;
+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 Unity;
+
+namespace ProjectGarage.Forms
+{
+ public partial class FormFuels : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IFuelRepository _fuelRepository;
+
+ public FormFuels(IUnityContainer container, IFuelRepository fuelRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _fuelRepository = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
+ }
+
+ private void FormFeeds_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAddFuel_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpdateFuel_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ try
+ {
+ var form = _container.Resolve();
+ form.Id = findId;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ }
+
+ private void ButtonDeleteFuel_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить запись?", "Удаление",
+ MessageBoxButtons.YesNo) != DialogResult.Yes)
+ {
+ return;
+ }
+ try
+ {
+ _fuelRepository.DeleteFuel(findId);
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewFuels.DataSource = _fuelRepository.ReadFuels();
+
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewFuels.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewFuels.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectGarage/Forms/FormFuels.resx b/ProjectGarage/Forms/FormFuels.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectGarage/Forms/FormFuels.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/ProjectGarage/Forms/FormRoute.Designer.cs b/ProjectGarage/Forms/FormRoute.Designer.cs
new file mode 100644
index 0000000..36649fa
--- /dev/null
+++ b/ProjectGarage/Forms/FormRoute.Designer.cs
@@ -0,0 +1,143 @@
+namespace ProjectGarage.Forms
+{
+ partial class FormRoute
+ {
+ ///
+ /// 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()
+ {
+ labelRouteStart = new Label();
+ labelRouteFinal = new Label();
+ numericUpDownRouteLen = new NumericUpDown();
+ labelRouteLen = new Label();
+ buttonRouteSave = new Button();
+ buttonRouteFinal = new Button();
+ textBoxRouteStart = new TextBox();
+ textBoxRouteFinal = new TextBox();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownRouteLen).BeginInit();
+ SuspendLayout();
+ //
+ // labelRouteStart
+ //
+ labelRouteStart.AutoSize = true;
+ labelRouteStart.Location = new Point(12, 20);
+ labelRouteStart.Name = "labelRouteStart";
+ labelRouteStart.Size = new Size(135, 20);
+ labelRouteStart.TabIndex = 0;
+ labelRouteStart.Text = "Начало маршрута";
+ //
+ // labelRouteFinal
+ //
+ labelRouteFinal.AutoSize = true;
+ labelRouteFinal.Location = new Point(12, 62);
+ labelRouteFinal.Name = "labelRouteFinal";
+ labelRouteFinal.Size = new Size(127, 20);
+ labelRouteFinal.TabIndex = 1;
+ labelRouteFinal.Text = "Конец маршрута";
+ //
+ // numericUpDownRouteLen
+ //
+ numericUpDownRouteLen.Location = new Point(160, 103);
+ numericUpDownRouteLen.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
+ numericUpDownRouteLen.Name = "numericUpDownRouteLen";
+ numericUpDownRouteLen.Size = new Size(150, 27);
+ numericUpDownRouteLen.TabIndex = 2;
+ numericUpDownRouteLen.Value = new decimal(new int[] { 1, 0, 0, 0 });
+ //
+ // labelRouteLen
+ //
+ labelRouteLen.AutoSize = true;
+ labelRouteLen.Location = new Point(12, 103);
+ labelRouteLen.Name = "labelRouteLen";
+ labelRouteLen.Size = new Size(127, 20);
+ labelRouteLen.TabIndex = 3;
+ labelRouteLen.Text = "Длина маршрута";
+ //
+ // buttonRouteSave
+ //
+ buttonRouteSave.Location = new Point(12, 149);
+ buttonRouteSave.Name = "buttonRouteSave";
+ buttonRouteSave.Size = new Size(135, 29);
+ buttonRouteSave.TabIndex = 4;
+ buttonRouteSave.Text = "Сохранить";
+ buttonRouteSave.UseVisualStyleBackColor = true;
+ buttonRouteSave.Click += ButtonRouteSave_Click;
+ //
+ // buttonRouteFinal
+ //
+ buttonRouteFinal.Location = new Point(160, 149);
+ buttonRouteFinal.Name = "buttonRouteFinal";
+ buttonRouteFinal.Size = new Size(150, 29);
+ buttonRouteFinal.TabIndex = 5;
+ buttonRouteFinal.Text = "Отмена";
+ buttonRouteFinal.UseVisualStyleBackColor = true;
+ buttonRouteFinal.Click += ButtonRouteFinal_Click;
+ //
+ // textBoxRouteStart
+ //
+ textBoxRouteStart.Location = new Point(160, 20);
+ textBoxRouteStart.Name = "textBoxRouteStart";
+ textBoxRouteStart.Size = new Size(150, 27);
+ textBoxRouteStart.TabIndex = 6;
+ //
+ // textBoxRouteFinal
+ //
+ textBoxRouteFinal.Location = new Point(160, 62);
+ textBoxRouteFinal.Name = "textBoxRouteFinal";
+ textBoxRouteFinal.Size = new Size(150, 27);
+ textBoxRouteFinal.TabIndex = 7;
+ //
+ // FormRoute
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(332, 199);
+ Controls.Add(textBoxRouteFinal);
+ Controls.Add(textBoxRouteStart);
+ Controls.Add(buttonRouteFinal);
+ Controls.Add(buttonRouteSave);
+ Controls.Add(labelRouteLen);
+ Controls.Add(numericUpDownRouteLen);
+ Controls.Add(labelRouteFinal);
+ Controls.Add(labelRouteStart);
+ Name = "FormRoute";
+ Text = "FormRoute";
+ ((System.ComponentModel.ISupportInitialize)numericUpDownRouteLen).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelRouteStart;
+ private Label labelRouteFinal;
+ private NumericUpDown numericUpDownRouteLen;
+ private Label labelRouteLen;
+ private Button buttonRouteSave;
+ private Button buttonRouteFinal;
+ private TextBox textBoxRouteStart;
+ private TextBox textBoxRouteFinal;
+ }
+}
\ No newline at end of file
diff --git a/ProjectGarage/Forms/FormRoute.cs b/ProjectGarage/Forms/FormRoute.cs
new file mode 100644
index 0000000..d49b465
--- /dev/null
+++ b/ProjectGarage/Forms/FormRoute.cs
@@ -0,0 +1,85 @@
+using ProjectGarage.Entities;
+using ProjectGarage.Entities.Enums;
+using ProjectGarage.Repositories;
+using ProjectGarage.Repositories.Implementations;
+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;
+
+namespace ProjectGarage.Forms
+{
+ public partial class FormRoute : Form
+ {
+ private readonly IRouteRepository _routeRepository;
+ private int? _routeId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var route = _routeRepository.ReadRouteByID(value);
+ if (route == null)
+ {
+ throw new InvalidDataException(nameof(route));
+ }
+
+ textBoxRouteStart.Text = route.StartPoint;
+ textBoxRouteFinal.Text = route.FinalPoint;
+ numericUpDownRouteLen.Value = route.Length;
+ _routeId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ }
+ }
+
+ public FormRoute(IRouteRepository routeRepository)
+ {
+ InitializeComponent();
+ _routeRepository = routeRepository ??
+ throw new ArgumentNullException(nameof(routeRepository));
+ }
+
+ private void ButtonRouteSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxRouteStart.Text)
+ || string.IsNullOrWhiteSpace(textBoxRouteFinal.Text))
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_routeId.HasValue)
+ {
+ _routeRepository.UpdateRoute(CreateRoute(_routeId.Value));
+ }
+ else
+ {
+ _routeRepository.CreateRoute(CreateRoute(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonRouteFinal_Click(object sender, EventArgs e) => Close();
+
+ private Route CreateRoute(int id) => Route.CreateRoute(id, textBoxRouteStart.Text,
+ textBoxRouteFinal.Text, Convert.ToInt32(numericUpDownRouteLen.Value));
+ }
+}
diff --git a/ProjectGarage/Forms/FormRoute.resx b/ProjectGarage/Forms/FormRoute.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectGarage/Forms/FormRoute.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/ProjectGarage/Forms/FormRoutes.Designer.cs b/ProjectGarage/Forms/FormRoutes.Designer.cs
new file mode 100644
index 0000000..dd68c26
--- /dev/null
+++ b/ProjectGarage/Forms/FormRoutes.Designer.cs
@@ -0,0 +1,124 @@
+namespace ProjectGarage.Forms
+{
+ partial class FormRoutes
+ {
+ ///
+ /// 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()
+ {
+ dataGridViewRoutes = new DataGridView();
+ panelFormRoutesButtons = new Panel();
+ buttonUpdateRoute = new Button();
+ buttonDeleteRoute = new Button();
+ buttonAddRoute = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit();
+ panelFormRoutesButtons.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridViewRoutes
+ //
+ dataGridViewRoutes.AllowUserToAddRows = false;
+ dataGridViewRoutes.AllowUserToDeleteRows = false;
+ dataGridViewRoutes.AllowUserToResizeColumns = false;
+ dataGridViewRoutes.AllowUserToResizeRows = false;
+ dataGridViewRoutes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewRoutes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewRoutes.Dock = DockStyle.Fill;
+ dataGridViewRoutes.Location = new Point(0, 0);
+ dataGridViewRoutes.Name = "dataGridViewRoutes";
+ dataGridViewRoutes.ReadOnly = true;
+ dataGridViewRoutes.RowHeadersVisible = false;
+ dataGridViewRoutes.RowHeadersWidth = 51;
+ dataGridViewRoutes.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewRoutes.Size = new Size(584, 355);
+ dataGridViewRoutes.TabIndex = 5;
+ //
+ // panelFormRoutesButtons
+ //
+ panelFormRoutesButtons.Controls.Add(buttonUpdateRoute);
+ panelFormRoutesButtons.Controls.Add(buttonDeleteRoute);
+ panelFormRoutesButtons.Controls.Add(buttonAddRoute);
+ panelFormRoutesButtons.Dock = DockStyle.Right;
+ panelFormRoutesButtons.Location = new Point(584, 0);
+ panelFormRoutesButtons.Name = "panelFormRoutesButtons";
+ panelFormRoutesButtons.Size = new Size(161, 355);
+ panelFormRoutesButtons.TabIndex = 4;
+ //
+ // buttonUpdateRoute
+ //
+ buttonUpdateRoute.BackgroundImage = Properties.Resources.каранд;
+ buttonUpdateRoute.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpdateRoute.Location = new Point(35, 140);
+ buttonUpdateRoute.Name = "buttonUpdateRoute";
+ buttonUpdateRoute.Size = new Size(94, 75);
+ buttonUpdateRoute.TabIndex = 2;
+ buttonUpdateRoute.UseVisualStyleBackColor = true;
+ buttonUpdateRoute.Click += ButtonUpdateRoute_Click;
+ //
+ // buttonDeleteRoute
+ //
+ buttonDeleteRoute.BackgroundImage = Properties.Resources.минусик;
+ buttonDeleteRoute.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDeleteRoute.Location = new Point(35, 249);
+ buttonDeleteRoute.Name = "buttonDeleteRoute";
+ buttonDeleteRoute.Size = new Size(94, 78);
+ buttonDeleteRoute.TabIndex = 1;
+ buttonDeleteRoute.UseVisualStyleBackColor = true;
+ buttonDeleteRoute.Click += ButtonDeleteRoute_Click;
+ //
+ // buttonAddRoute
+ //
+ buttonAddRoute.BackgroundImage = Properties.Resources.плюсик;
+ buttonAddRoute.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAddRoute.Location = new Point(35, 23);
+ buttonAddRoute.Name = "buttonAddRoute";
+ buttonAddRoute.Size = new Size(94, 75);
+ buttonAddRoute.TabIndex = 0;
+ buttonAddRoute.UseVisualStyleBackColor = true;
+ buttonAddRoute.Click += ButtonAddRoute_Click;
+ //
+ // FormRoutes
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(745, 355);
+ Controls.Add(dataGridViewRoutes);
+ Controls.Add(panelFormRoutesButtons);
+ Name = "FormRoutes";
+ Text = "FormRoutes";
+ ((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit();
+ panelFormRoutesButtons.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridViewRoutes;
+ private Panel panelFormRoutesButtons;
+ private Button buttonUpdateRoute;
+ private Button buttonDeleteRoute;
+ private Button buttonAddRoute;
+ }
+}
\ No newline at end of file
diff --git a/ProjectGarage/Forms/FormRoutes.cs b/ProjectGarage/Forms/FormRoutes.cs
new file mode 100644
index 0000000..26e8885
--- /dev/null
+++ b/ProjectGarage/Forms/FormRoutes.cs
@@ -0,0 +1,91 @@
+using ProjectGarage.Repositories;
+using ProjectGarage.Repositories.Implementations;
+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 Unity;
+
+namespace ProjectGarage.Forms
+{
+ public partial class FormRoutes : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IRouteRepository _routeRepository;
+
+ public FormRoutes(IUnityContainer container, IRouteRepository routeRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository));
+ }
+ private void ButtonAddRoute_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpdateRoute_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonDeleteRoute_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ try
+ {
+ var form = _container.Resolve();
+ form.Id = findId;
+ form.ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при изменении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewRoutes.DataSource = _routeRepository.ReadRoute();
+
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewRoutes.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id =
+ Convert.ToInt32(dataGridViewRoutes.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
diff --git a/ProjectGarage/Forms/FormRoutes.resx b/ProjectGarage/Forms/FormRoutes.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectGarage/Forms/FormRoutes.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/ProjectGarage/Forms/FormTransportation.Designer.cs b/ProjectGarage/Forms/FormTransportation.Designer.cs
new file mode 100644
index 0000000..db32cdf
--- /dev/null
+++ b/ProjectGarage/Forms/FormTransportation.Designer.cs
@@ -0,0 +1,171 @@
+namespace ProjectGarage.Forms
+{
+ partial class FormTransportation
+ {
+ ///
+ /// 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()
+ {
+ labelFuel = new Label();
+ labelDriver = new Label();
+ labelRoute = new Label();
+ label1 = new Label();
+ numericUpDownAmountFuel = new NumericUpDown();
+ comboBoxFuel = new ComboBox();
+ comboBoxRoute = new ComboBox();
+ comboBoxDriver = new ComboBox();
+ buttonTransportationSave = new Button();
+ buttonTransportationCancel = new Button();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownAmountFuel).BeginInit();
+ SuspendLayout();
+ //
+ // labelFuel
+ //
+ labelFuel.AutoSize = true;
+ labelFuel.Location = new Point(32, 26);
+ labelFuel.Name = "labelFuel";
+ labelFuel.Size = new Size(69, 20);
+ labelFuel.TabIndex = 0;
+ labelFuel.Text = "Топливо";
+ //
+ // labelDriver
+ //
+ labelDriver.AutoSize = true;
+ labelDriver.Location = new Point(32, 70);
+ labelDriver.Name = "labelDriver";
+ labelDriver.Size = new Size(74, 20);
+ labelDriver.TabIndex = 1;
+ labelDriver.Text = "Водитель";
+ //
+ // labelRoute
+ //
+ labelRoute.AutoSize = true;
+ labelRoute.Location = new Point(32, 116);
+ labelRoute.Name = "labelRoute";
+ labelRoute.Size = new Size(73, 20);
+ labelRoute.TabIndex = 2;
+ labelRoute.Text = "Маршрут";
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(12, 157);
+ label1.Name = "label1";
+ label1.Size = new Size(118, 20);
+ label1.TabIndex = 3;
+ label1.Text = "Объем топлива";
+ //
+ // numericUpDownAmountFuel
+ //
+ numericUpDownAmountFuel.Location = new Point(152, 155);
+ numericUpDownAmountFuel.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
+ numericUpDownAmountFuel.Name = "numericUpDownAmountFuel";
+ numericUpDownAmountFuel.Size = new Size(150, 27);
+ numericUpDownAmountFuel.TabIndex = 4;
+ numericUpDownAmountFuel.Value = new decimal(new int[] { 1, 0, 0, 0 });
+ //
+ // comboBoxFuel
+ //
+ comboBoxFuel.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxFuel.FormattingEnabled = true;
+ comboBoxFuel.Location = new Point(151, 23);
+ comboBoxFuel.Name = "comboBoxFuel";
+ comboBoxFuel.Size = new Size(151, 28);
+ comboBoxFuel.TabIndex = 5;
+ //
+ // comboBoxRoute
+ //
+ comboBoxRoute.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxRoute.FormattingEnabled = true;
+ comboBoxRoute.Location = new Point(151, 113);
+ comboBoxRoute.Name = "comboBoxRoute";
+ comboBoxRoute.Size = new Size(151, 28);
+ comboBoxRoute.TabIndex = 6;
+ //
+ // comboBoxDriver
+ //
+ comboBoxDriver.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxDriver.FormattingEnabled = true;
+ comboBoxDriver.Location = new Point(152, 67);
+ comboBoxDriver.Name = "comboBoxDriver";
+ comboBoxDriver.Size = new Size(151, 28);
+ comboBoxDriver.TabIndex = 7;
+ //
+ // buttonTransportationSave
+ //
+ buttonTransportationSave.Location = new Point(12, 194);
+ buttonTransportationSave.Name = "buttonTransportationSave";
+ buttonTransportationSave.Size = new Size(135, 29);
+ buttonTransportationSave.TabIndex = 8;
+ buttonTransportationSave.Text = "Сохранить";
+ buttonTransportationSave.UseVisualStyleBackColor = true;
+ buttonTransportationSave.Click += ButtonTransportationSave_Click;
+ //
+ // buttonTransportationCancel
+ //
+ buttonTransportationCancel.Location = new Point(163, 194);
+ buttonTransportationCancel.Name = "buttonTransportationCancel";
+ buttonTransportationCancel.Size = new Size(140, 29);
+ buttonTransportationCancel.TabIndex = 9;
+ buttonTransportationCancel.Text = "Отмена";
+ buttonTransportationCancel.UseVisualStyleBackColor = true;
+ buttonTransportationCancel.Click += ButtonTransportationCancel_Click;
+ //
+ // FormTransportation
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(324, 244);
+ Controls.Add(buttonTransportationCancel);
+ Controls.Add(buttonTransportationSave);
+ Controls.Add(comboBoxDriver);
+ Controls.Add(comboBoxRoute);
+ Controls.Add(comboBoxFuel);
+ Controls.Add(numericUpDownAmountFuel);
+ Controls.Add(label1);
+ Controls.Add(labelRoute);
+ Controls.Add(labelDriver);
+ Controls.Add(labelFuel);
+ Name = "FormTransportation";
+ Text = "FormTransportation";
+ ((System.ComponentModel.ISupportInitialize)numericUpDownAmountFuel).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelFuel;
+ private Label labelDriver;
+ private Label labelRoute;
+ private Label label1;
+ private NumericUpDown numericUpDownAmountFuel;
+ private ComboBox comboBoxFuel;
+ private ComboBox comboBoxRoute;
+ private ComboBox comboBoxDriver;
+ private Button buttonTransportationSave;
+ private Button buttonTransportationCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectGarage/Forms/FormTransportation.cs b/ProjectGarage/Forms/FormTransportation.cs
new file mode 100644
index 0000000..a1b2448
--- /dev/null
+++ b/ProjectGarage/Forms/FormTransportation.cs
@@ -0,0 +1,63 @@
+using ProjectGarage.Entities;
+using ProjectGarage.Repositories;
+using ProjectGarage.Repositories.Implementations;
+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;
+
+namespace ProjectGarage.Forms
+{
+ public partial class FormTransportation : Form
+ {
+ private readonly ITransportationRepository _transportationRepository;
+
+ public FormTransportation(ITransportationRepository transportationRepository,
+ IFuelRepository fuelRepository, IDriverRepository driverRepository, IRouteRepository routeRepository)
+ {
+ InitializeComponent();
+ _transportationRepository = transportationRepository ??
+ throw new ArgumentNullException(nameof(transportationRepository));
+
+ comboBoxDriver.DataSource = driverRepository.ReadDrivers();
+ comboBoxDriver.DisplayMember = "First_name";
+ comboBoxDriver.ValueMember = "Id";
+
+ comboBoxFuel.DataSource = fuelRepository.ReadFuels();
+ comboBoxFuel.DisplayMember = "Name";
+ comboBoxFuel.ValueMember = "Id";
+
+ comboBoxRoute.DataSource = routeRepository.ReadRoute();
+ comboBoxRoute.DisplayMember = "Name";
+ comboBoxRoute.ValueMember = "Id";
+ }
+
+ private void ButtonTransportationSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (comboBoxFuel.SelectedIndex < 0 || comboBoxDriver.SelectedIndex < 0 ||
+ comboBoxRoute.SelectedIndex < 0)
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ _transportationRepository.CreateTransportation(Transportation.CreateTransportation(0,
+ (int)comboBoxFuel.SelectedValue!, (int)comboBoxRoute.SelectedValue!,
+ (int)comboBoxDriver.SelectedValue!, Convert.ToInt32(numericUpDownAmountFuel.Value)));
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonTransportationCancel_Click(object sender, EventArgs e) => Close();
+ }
+}
diff --git a/ProjectGarage/Forms/FormTransportation.resx b/ProjectGarage/Forms/FormTransportation.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectGarage/Forms/FormTransportation.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/ProjectGarage/Forms/FormTransportations.Designer.cs b/ProjectGarage/Forms/FormTransportations.Designer.cs
new file mode 100644
index 0000000..985838c
--- /dev/null
+++ b/ProjectGarage/Forms/FormTransportations.Designer.cs
@@ -0,0 +1,96 @@
+namespace ProjectGarage.Forms
+{
+ partial class FormTransportations
+ {
+ ///
+ /// 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()
+ {
+ buttonAddTransportation = new Button();
+ dataGridViewTransportations = new DataGridView();
+ panelFormTransportationsButtons = new Panel();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewTransportations).BeginInit();
+ panelFormTransportationsButtons.SuspendLayout();
+ SuspendLayout();
+ //
+ // buttonAddTransportation
+ //
+ buttonAddTransportation.BackgroundImage = Properties.Resources.плюсик;
+ buttonAddTransportation.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAddTransportation.Location = new Point(35, 23);
+ buttonAddTransportation.Name = "buttonAddTransportation";
+ buttonAddTransportation.Size = new Size(94, 75);
+ buttonAddTransportation.TabIndex = 0;
+ buttonAddTransportation.UseVisualStyleBackColor = true;
+ buttonAddTransportation.Click += ButtonAddTransportation_Click;
+ //
+ // dataGridViewTransportations
+ //
+ dataGridViewTransportations.AllowUserToAddRows = false;
+ dataGridViewTransportations.AllowUserToDeleteRows = false;
+ dataGridViewTransportations.AllowUserToResizeColumns = false;
+ dataGridViewTransportations.AllowUserToResizeRows = false;
+ dataGridViewTransportations.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewTransportations.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewTransportations.Dock = DockStyle.Fill;
+ dataGridViewTransportations.Location = new Point(0, 0);
+ dataGridViewTransportations.Name = "dataGridViewTransportations";
+ dataGridViewTransportations.ReadOnly = true;
+ dataGridViewTransportations.RowHeadersVisible = false;
+ dataGridViewTransportations.RowHeadersWidth = 51;
+ dataGridViewTransportations.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewTransportations.Size = new Size(639, 450);
+ dataGridViewTransportations.TabIndex = 7;
+ //
+ // panelFormTransportationsButtons
+ //
+ panelFormTransportationsButtons.Controls.Add(buttonAddTransportation);
+ panelFormTransportationsButtons.Dock = DockStyle.Right;
+ panelFormTransportationsButtons.Location = new Point(639, 0);
+ panelFormTransportationsButtons.Name = "panelFormTransportationsButtons";
+ panelFormTransportationsButtons.Size = new Size(161, 450);
+ panelFormTransportationsButtons.TabIndex = 6;
+ //
+ // FormTransportations
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridViewTransportations);
+ Controls.Add(panelFormTransportationsButtons);
+ Name = "FormTransportations";
+ Text = "FormTransportations";
+ ((System.ComponentModel.ISupportInitialize)dataGridViewTransportations).EndInit();
+ panelFormTransportationsButtons.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonAddTransportation;
+ private DataGridView dataGridViewTransportations;
+ private Panel panelFormTransportationsButtons;
+ }
+}
\ No newline at end of file
diff --git a/ProjectGarage/Forms/FormTransportations.cs b/ProjectGarage/Forms/FormTransportations.cs
new file mode 100644
index 0000000..4ab11d4
--- /dev/null
+++ b/ProjectGarage/Forms/FormTransportations.cs
@@ -0,0 +1,57 @@
+using ProjectGarage.Repositories;
+using ProjectGarage.Repositories.Implementations;
+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 Unity;
+
+namespace ProjectGarage.Forms
+{
+ public partial class FormTransportations : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly ITransportationRepository _transportationRepository;
+
+ public FormTransportations(IUnityContainer container, ITransportationRepository transportationRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _transportationRepository = transportationRepository ??
+ throw new
+ ArgumentNullException(nameof(transportationRepository));
+ }
+ private void FormTransportations_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAddTransportation_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewTransportations.DataSource = _transportationRepository.ReadTransportation();
+ }
+}
diff --git a/ProjectGarage/Forms/FormTransportations.resx b/ProjectGarage/Forms/FormTransportations.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectGarage/Forms/FormTransportations.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/ProjectGarage/Forms/FormTruck.Designer.cs b/ProjectGarage/Forms/FormTruck.Designer.cs
index c9c2210..a1a9af7 100644
--- a/ProjectGarage/Forms/FormTruck.Designer.cs
+++ b/ProjectGarage/Forms/FormTruck.Designer.cs
@@ -28,9 +28,6 @@
///
private void InitializeComponent()
{
- textBoxTruckModel = new TextBox();
- labelTruckModel = new Label();
- textBoxTruckBrand = new TextBox();
labelTruckBrand = new Label();
textBoxTruckNumbers = new TextBox();
labelTruckNumbers = new Label();
@@ -38,32 +35,10 @@
numericUpDownMaxFuel = new NumericUpDown();
buttonTruckSave = new Button();
buttonTruckCancel = new Button();
+ comboBoxTruckType = new ComboBox();
((System.ComponentModel.ISupportInitialize)numericUpDownMaxFuel).BeginInit();
SuspendLayout();
//
- // textBoxTruckModel
- //
- textBoxTruckModel.Location = new Point(158, 114);
- textBoxTruckModel.Name = "textBoxTruckModel";
- textBoxTruckModel.Size = new Size(183, 27);
- textBoxTruckModel.TabIndex = 13;
- //
- // labelTruckModel
- //
- labelTruckModel.AutoSize = true;
- labelTruckModel.Location = new Point(43, 121);
- labelTruckModel.Name = "labelTruckModel";
- labelTruckModel.Size = new Size(63, 20);
- labelTruckModel.TabIndex = 12;
- labelTruckModel.Text = "Модель";
- //
- // textBoxTruckBrand
- //
- textBoxTruckBrand.Location = new Point(158, 73);
- textBoxTruckBrand.Name = "textBoxTruckBrand";
- textBoxTruckBrand.Size = new Size(183, 27);
- textBoxTruckBrand.TabIndex = 11;
- //
// labelTruckBrand
//
labelTruckBrand.AutoSize = true;
@@ -92,7 +67,7 @@
// labelMaxFuel
//
labelMaxFuel.AutoSize = true;
- labelMaxFuel.Location = new Point(12, 163);
+ labelMaxFuel.Location = new Point(12, 122);
labelMaxFuel.Name = "labelMaxFuel";
labelMaxFuel.Size = new Size(129, 20);
labelMaxFuel.TabIndex = 14;
@@ -100,16 +75,16 @@
//
// numericUpDownMaxFuel
//
- numericUpDownMaxFuel.Location = new Point(158, 156);
+ numericUpDownMaxFuel.Location = new Point(158, 115);
numericUpDownMaxFuel.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numericUpDownMaxFuel.Name = "numericUpDownMaxFuel";
- numericUpDownMaxFuel.Size = new Size(117, 27);
+ numericUpDownMaxFuel.Size = new Size(183, 27);
numericUpDownMaxFuel.TabIndex = 15;
numericUpDownMaxFuel.Value = new decimal(new int[] { 1, 0, 0, 0 });
//
// buttonTruckSave
//
- buttonTruckSave.Location = new Point(12, 211);
+ buttonTruckSave.Location = new Point(12, 170);
buttonTruckSave.Name = "buttonTruckSave";
buttonTruckSave.Size = new Size(156, 37);
buttonTruckSave.TabIndex = 16;
@@ -119,7 +94,7 @@
//
// buttonTruckCancel
//
- buttonTruckCancel.Location = new Point(196, 211);
+ buttonTruckCancel.Location = new Point(196, 170);
buttonTruckCancel.Name = "buttonTruckCancel";
buttonTruckCancel.Size = new Size(156, 37);
buttonTruckCancel.TabIndex = 17;
@@ -127,18 +102,25 @@
buttonTruckCancel.UseVisualStyleBackColor = true;
buttonTruckCancel.Click += ButtonTruckCancel_Click;
//
+ // comboBoxTruckType
+ //
+ comboBoxTruckType.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxTruckType.FormattingEnabled = true;
+ comboBoxTruckType.Location = new Point(158, 68);
+ comboBoxTruckType.Name = "comboBoxTruckType";
+ comboBoxTruckType.Size = new Size(183, 28);
+ comboBoxTruckType.TabIndex = 18;
+ //
// FormTruck
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(364, 260);
+ ClientSize = new Size(364, 222);
+ Controls.Add(comboBoxTruckType);
Controls.Add(buttonTruckCancel);
Controls.Add(buttonTruckSave);
Controls.Add(numericUpDownMaxFuel);
Controls.Add(labelMaxFuel);
- Controls.Add(textBoxTruckModel);
- Controls.Add(labelTruckModel);
- Controls.Add(textBoxTruckBrand);
Controls.Add(labelTruckBrand);
Controls.Add(textBoxTruckNumbers);
Controls.Add(labelTruckNumbers);
@@ -151,10 +133,6 @@
}
#endregion
-
- private TextBox textBoxTruckModel;
- private Label labelTruckModel;
- private TextBox textBoxTruckBrand;
private Label labelTruckBrand;
private TextBox textBoxTruckNumbers;
private Label labelTruckNumbers;
@@ -162,5 +140,6 @@
private NumericUpDown numericUpDownMaxFuel;
private Button buttonTruckSave;
private Button buttonTruckCancel;
+ private ComboBox comboBoxTruckType;
}
}
\ No newline at end of file
diff --git a/ProjectGarage/Forms/FormTruck.cs b/ProjectGarage/Forms/FormTruck.cs
index 50c16d2..b1878a1 100644
--- a/ProjectGarage/Forms/FormTruck.cs
+++ b/ProjectGarage/Forms/FormTruck.cs
@@ -1,4 +1,5 @@
using ProjectGarage.Entities;
+using ProjectGarage.Entities.Enums;
using ProjectGarage.Repositories;
namespace ProjectGarage.Forms
@@ -21,8 +22,7 @@ namespace ProjectGarage.Forms
}
textBoxTruckNumbers.Text = truck.Numbers;
- textBoxTruckBrand.Text = truck.Brand;
- textBoxTruckModel.Text = truck.Model;
+ comboBoxTruckType.SelectedItem = truck.Type;
numericUpDownMaxFuel.Value = truck.MaxFuel;
}
catch (Exception ex)
@@ -38,6 +38,7 @@ namespace ProjectGarage.Forms
InitializeComponent();
_truckRepository = truckRepository ??
throw new ArgumentNullException(nameof(truckRepository));
+ comboBoxTruckType.DataSource = Enum.GetValues(typeof(TruckType));
}
private void ButtonTruckSave_Click(object sender, EventArgs e)
@@ -45,8 +46,7 @@ namespace ProjectGarage.Forms
try
{
if (string.IsNullOrWhiteSpace(textBoxTruckNumbers.Text)
- || string.IsNullOrWhiteSpace(textBoxTruckBrand.Text)
- || string.IsNullOrWhiteSpace(textBoxTruckModel.Text))
+ || comboBoxTruckType.SelectedIndex < 1)
{
throw new Exception("Имеются незаполненные поля");
}
@@ -69,7 +69,6 @@ namespace ProjectGarage.Forms
private void ButtonTruckCancel_Click(object sender, EventArgs e) => Close();
private Truck CreateTruck(int id) => Truck.CreateTruck(id, textBoxTruckNumbers.Text,
- textBoxTruckBrand.Text, textBoxTruckModel.Text, Convert.ToInt32(numericUpDownMaxFuel.Value));
+ (TruckType)comboBoxTruckType.SelectedItem!, Convert.ToInt32(numericUpDownMaxFuel.Value));
}
-
}
diff --git a/ProjectGarage/Forms/FormTrucks.Designer.cs b/ProjectGarage/Forms/FormTrucks.Designer.cs
index 8652fc6..8946ee5 100644
--- a/ProjectGarage/Forms/FormTrucks.Designer.cs
+++ b/ProjectGarage/Forms/FormTrucks.Designer.cs
@@ -43,7 +43,7 @@
panelFormTrucksButtons.Controls.Add(buttonDeleteTruck);
panelFormTrucksButtons.Controls.Add(buttonAddTruck);
panelFormTrucksButtons.Dock = DockStyle.Right;
- panelFormTrucksButtons.Location = new Point(441, 0);
+ panelFormTrucksButtons.Location = new Point(565, 0);
panelFormTrucksButtons.Name = "panelFormTrucksButtons";
panelFormTrucksButtons.Size = new Size(161, 360);
panelFormTrucksButtons.TabIndex = 0;
@@ -96,14 +96,14 @@
dataGridViewTrucks.RowHeadersVisible = false;
dataGridViewTrucks.RowHeadersWidth = 51;
dataGridViewTrucks.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
- dataGridViewTrucks.Size = new Size(441, 360);
+ dataGridViewTrucks.Size = new Size(565, 360);
dataGridViewTrucks.TabIndex = 1;
//
// FormTrucks
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(602, 360);
+ ClientSize = new Size(726, 360);
Controls.Add(dataGridViewTrucks);
Controls.Add(panelFormTrucksButtons);
Name = "FormTrucks";
diff --git a/ProjectGarage/Forms/FormTrucks.cs b/ProjectGarage/Forms/FormTrucks.cs
index e676c39..c135a16 100644
--- a/ProjectGarage/Forms/FormTrucks.cs
+++ b/ProjectGarage/Forms/FormTrucks.cs
@@ -99,7 +99,7 @@ namespace ProjectGarage.Forms
id = 0;
if (dataGridViewTrucks.SelectedRows.Count < 1)
{
- MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK,MessageBoxIcon.Error);
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
diff --git a/ProjectGarage/Repositories/IRouteRepository.cs b/ProjectGarage/Repositories/IRouteRepository.cs
index 5ee1863..c1dec9e 100644
--- a/ProjectGarage/Repositories/IRouteRepository.cs
+++ b/ProjectGarage/Repositories/IRouteRepository.cs
@@ -11,7 +11,7 @@ public interface IRouteRepository
{
IEnumerable ReadRoute(string? startPoint = null,string? finalPoint = null);
- void ReadRouteByID(int id);
+ Route ReadRouteByID(int id);
void CreateRoute(Route route);
diff --git a/ProjectGarage/Repositories/Implementations/DriverRepository.cs b/ProjectGarage/Repositories/Implementations/DriverRepository.cs
index 0fba152..1401138 100644
--- a/ProjectGarage/Repositories/Implementations/DriverRepository.cs
+++ b/ProjectGarage/Repositories/Implementations/DriverRepository.cs
@@ -17,7 +17,7 @@ public class DriverRepository : IDriverRepository
{
}
- public Driver ReadDriverByID(int id) => Driver.CreateDriver(0, string.Empty, string.Empty, string.Empty, 0);
+ public Driver ReadDriverByID(int id) => Driver.CreateDriver(0, string.Empty, string.Empty, string.Empty);
public IEnumerable ReadDrivers() => [];
diff --git a/ProjectGarage/Repositories/Implementations/RouteRepository.cs b/ProjectGarage/Repositories/Implementations/RouteRepository.cs
index a27ba2e..3a745ec 100644
--- a/ProjectGarage/Repositories/Implementations/RouteRepository.cs
+++ b/ProjectGarage/Repositories/Implementations/RouteRepository.cs
@@ -21,7 +21,7 @@ public class RouteRepository : IRouteRepository
{
}
- public void ReadRouteByID(int id) => Route.CreateRoute(0, string.Empty, string.Empty, 0);
+ public Route ReadRouteByID(int id) => Route.CreateRoute(0, string.Empty, string.Empty, 0);
public IEnumerable ReadRoute(string? startPoint = null, string? finalPoint = null)
{
diff --git a/ProjectGarage/Repositories/Implementations/TransportationRepository.cs b/ProjectGarage/Repositories/Implementations/TransportationRepository.cs
index 34255c9..4cd902a 100644
--- a/ProjectGarage/Repositories/Implementations/TransportationRepository.cs
+++ b/ProjectGarage/Repositories/Implementations/TransportationRepository.cs
@@ -13,6 +13,11 @@ public class TransportationRepository : ITransportationRepository
{
}
+ public void DeleteTransportation(int id)
+ {
+ throw new NotImplementedException();
+ }
+
public IEnumerable ReadTransportation(DateTime? dateForm = null, DateTime? dateTo = null, int? fuelId = null, int? driverId = null, int? routeId = null)
{
return [];
diff --git a/ProjectGarage/Repositories/Implementations/TruckRepository.cs b/ProjectGarage/Repositories/Implementations/TruckRepository.cs
index d02f23f..ac2dbd3 100644
--- a/ProjectGarage/Repositories/Implementations/TruckRepository.cs
+++ b/ProjectGarage/Repositories/Implementations/TruckRepository.cs
@@ -1,4 +1,5 @@
using ProjectGarage.Entities;
+using ProjectGarage.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -17,7 +18,7 @@ public class TruckRepository : ITruckRepository
{
}
- public Truck ReadTruckByID(int id) => Truck.CreateTruck(0, string.Empty, string.Empty, string.Empty, 0);
+ public Truck ReadTruckByID(int id) => Truck.CreateTruck(0, string.Empty, TruckType.None, 0);
public IEnumerable ReadTrucks() => [];