diff --git a/ProjectAirline/Entities/Airport.cs b/ProjectAirline/Entities/Airport.cs
new file mode 100644
index 0000000..c9e5c2d
--- /dev/null
+++ b/ProjectAirline/Entities/Airport.cs
@@ -0,0 +1,19 @@
+namespace YourNamespace.Entities
+{
+ public class Airport
+ {
+ public int Id { get; private set; }
+ public string Name { get; private set; }
+ public string Location { get; private set; }
+
+ public static Airport CreateEntity(int id, string name, string location)
+ {
+ return new Airport
+ {
+ Id = id,
+ Name = name ?? string.Empty,
+ Location = location ?? string.Empty
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Entities/Employee.cs b/ProjectAirline/Entities/Employee.cs
new file mode 100644
index 0000000..e5fff89
--- /dev/null
+++ b/ProjectAirline/Entities/Employee.cs
@@ -0,0 +1,23 @@
+using YourNamespace.Entities.Enums;
+
+namespace YourNamespace.Entities
+{
+ public class Employee
+ {
+ public int Id { get; private set; }
+ public string FirstName { get; private set; }
+ public string LastName { get; private set; }
+ public EmployeePost EmployeePost { get; private set; }
+
+ public static Employee CreateEntity(int id, string firstName, string lastName, EmployeePost employeePost)
+ {
+ return new Employee
+ {
+ Id = id,
+ FirstName = firstName ?? string.Empty,
+ LastName = lastName ?? string.Empty,
+ EmployeePost = employeePost
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Entities/Enums/EmployeePost.cs b/ProjectAirline/Entities/Enums/EmployeePost.cs
new file mode 100644
index 0000000..8d600e5
--- /dev/null
+++ b/ProjectAirline/Entities/Enums/EmployeePost.cs
@@ -0,0 +1,10 @@
+namespace YourNamespace.Entities.Enums
+{
+ public enum EmployeePost
+ {
+ None = 0,
+ Pilot = 1,
+ Stewardess = 2,
+ GroundStaff = 3
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Entities/Flight.cs b/ProjectAirline/Entities/Flight.cs
new file mode 100644
index 0000000..a10ac84
--- /dev/null
+++ b/ProjectAirline/Entities/Flight.cs
@@ -0,0 +1,25 @@
+namespace YourNamespace.Entities
+{
+ public class Flight
+ {
+ public int Id { get; private set; }
+ public int FlightNumber { get; private set; }
+ public DateTime DepartureDateTime { get; private set; }
+ public DateTime ArrivalDateTime { get; private set; }
+ public int PlaneId { get; private set; }
+ public int AirportId { get; private set; }
+
+ public static Flight CreateEntity(int id, int flightNumber, DateTime departureDateTime, DateTime arrivalDateTime, int planeId, int airportId)
+ {
+ return new Flight
+ {
+ Id = id,
+ FlightNumber = flightNumber,
+ DepartureDateTime = departureDateTime,
+ ArrivalDateTime = arrivalDateTime,
+ PlaneId = planeId,
+ AirportId = airportId
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Entities/Passanger.cs b/ProjectAirline/Entities/Passanger.cs
new file mode 100644
index 0000000..3a4ad40
--- /dev/null
+++ b/ProjectAirline/Entities/Passanger.cs
@@ -0,0 +1,21 @@
+namespace YourNamespace.Entities
+{
+ public class Passenger
+ {
+ public int Id { get; private set; }
+ public string FirstName { get; private set; }
+ public string LastName { get; private set; }
+ public string PassportNumber { get; private set; }
+
+ public static Passenger CreateEntity(int id, string firstName, string lastName, string passportNumber)
+ {
+ return new Passenger
+ {
+ Id = id,
+ FirstName = firstName ?? string.Empty,
+ LastName = lastName ?? string.Empty,
+ PassportNumber = passportNumber ?? string.Empty
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Entities/Plane.cs b/ProjectAirline/Entities/Plane.cs
new file mode 100644
index 0000000..5c56be4
--- /dev/null
+++ b/ProjectAirline/Entities/Plane.cs
@@ -0,0 +1,19 @@
+namespace YourNamespace.Entities
+{
+ public class Plane
+ {
+ public int Id { get; private set; }
+ public string Model { get; private set; }
+ public int Capacity { get; private set; }
+
+ public static Plane CreateEntity(int id, string model, int capacity)
+ {
+ return new Plane
+ {
+ Id = id,
+ Model = model ?? string.Empty,
+ Capacity = capacity
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Entities/Ticket.cs b/ProjectAirline/Entities/Ticket.cs
new file mode 100644
index 0000000..a69e467
--- /dev/null
+++ b/ProjectAirline/Entities/Ticket.cs
@@ -0,0 +1,23 @@
+namespace YourNamespace.Entities
+{
+ public class Ticket
+ {
+ public int Id { get; private set; }
+ public int PassengerId { get; private set; }
+ public int FlightId { get; private set; }
+ public DateTime DateBuy { get; private set; }
+ public int TicketPrice { get; private set; }
+
+ public static Ticket CreateEntity(int id, int passengerId, int flightId, DateTime dateBuy, int ticketPrice)
+ {
+ return new Ticket
+ {
+ Id = id,
+ PassengerId = passengerId,
+ FlightId = flightId,
+ DateBuy = dateBuy,
+ TicketPrice = ticketPrice
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Form1.Designer.cs b/ProjectAirline/Form1.Designer.cs
deleted file mode 100644
index eca5924..0000000
--- a/ProjectAirline/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace ProjectAirline
-{
- 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
- }
-}
diff --git a/ProjectAirline/Form1.cs b/ProjectAirline/Form1.cs
deleted file mode 100644
index c73297f..0000000
--- a/ProjectAirline/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace ProjectAirline
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/ProjectAirline/Forms/FormAirport.Designer.cs b/ProjectAirline/Forms/FormAirport.Designer.cs
new file mode 100644
index 0000000..0a4bb68
--- /dev/null
+++ b/ProjectAirline/Forms/FormAirport.Designer.cs
@@ -0,0 +1,118 @@
+namespace YourNamespace.Forms
+{
+ partial class FormAirport
+ {
+ ///
+ /// 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.labelName = new System.Windows.Forms.Label();
+ this.labelLocation = new System.Windows.Forms.Label();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.textBoxLocation = new System.Windows.Forms.TextBox();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(12, 22);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(57, 13);
+ this.labelName.TabIndex = 0;
+ this.labelName.Text = "Название:";
+ //
+ // labelLocation
+ //
+ this.labelLocation.AutoSize = true;
+ this.labelLocation.Location = new System.Drawing.Point(12, 58);
+ this.labelLocation.Name = "labelLocation";
+ this.labelLocation.Size = new System.Drawing.Size(48, 13);
+ this.labelLocation.TabIndex = 1;
+ this.labelLocation.Text = "Место:";
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(111, 19);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(200, 20);
+ this.textBoxName.TabIndex = 2;
+ //
+ // textBoxLocation
+ //
+ this.textBoxLocation.Location = new System.Drawing.Point(111, 55);
+ this.textBoxLocation.Name = "textBoxLocation";
+ this.textBoxLocation.Size = new System.Drawing.Size(200, 20);
+ this.textBoxLocation.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(155, 91);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(236, 91);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // FormAirport
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(324, 126);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxLocation);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.labelLocation);
+ this.Controls.Add(this.labelName);
+ this.Name = "FormAirport";
+ this.Text = "Редактирование аэропорта";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label labelName;
+ private System.Windows.Forms.Label labelLocation;
+ private System.Windows.Forms.TextBox textBoxName;
+ private System.Windows.Forms.TextBox textBoxLocation;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormAirport.cs b/ProjectAirline/Forms/FormAirport.cs
new file mode 100644
index 0000000..455eb1c
--- /dev/null
+++ b/ProjectAirline/Forms/FormAirport.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Windows.Forms;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormAirport : Form
+ {
+ private readonly IAirportRepository _airportRepository;
+ private int? _airportId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var airport = _airportRepository.ReadAirportById(value);
+ if (airport == null)
+ {
+ throw new InvalidDataException(nameof(airport));
+ }
+ textBoxName.Text = airport.Name;
+ textBoxLocation.Text = airport.Location;
+ _airportId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormAirport(IAirportRepository airportRepository)
+ {
+ InitializeComponent();
+ _airportRepository = airportRepository ?? throw new ArgumentNullException(nameof(airportRepository));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxLocation.Text))
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_airportId.HasValue)
+ {
+ _airportRepository.UpdateAirport(CreateAirport(_airportId.Value));
+ }
+ else
+ {
+ _airportRepository.CreateAirport(CreateAirport(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Airport CreateAirport(int id) => Airport.CreateEntity(id, textBoxName.Text, textBoxLocation.Text);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Form1.resx b/ProjectAirline/Forms/FormAirport.resx
similarity index 100%
rename from ProjectAirline/Form1.resx
rename to ProjectAirline/Forms/FormAirport.resx
diff --git a/ProjectAirline/Forms/FormAirports.Designer.cs b/ProjectAirline/Forms/FormAirports.Designer.cs
new file mode 100644
index 0000000..ffd1ff8
--- /dev/null
+++ b/ProjectAirline/Forms/FormAirports.Designer.cs
@@ -0,0 +1,106 @@
+namespace YourNamespace.Forms
+{
+ partial class FormAirports
+ {
+ ///
+ /// 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.dataGridViewData = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).BeginInit();
+ this.SuspendLayout(); // Вызов SuspendLayout
+ //
+ // dataGridViewData
+ //
+ this.dataGridViewData.AllowUserToAddRows = false;
+ this.dataGridViewData.AllowUserToDeleteRows = false;
+ this.dataGridViewData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridViewData.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridViewData.Location = new System.Drawing.Point(0, 0);
+ this.dataGridViewData.MultiSelect = false;
+ this.dataGridViewData.Name = "dataGridViewData";
+ this.dataGridViewData.ReadOnly = true;
+ this.dataGridViewData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+ this.dataGridViewData.Size = new System.Drawing.Size(800, 450);
+ this.dataGridViewData.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(12, 12);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(75, 23);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(93, 12);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(75, 23);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(174, 12);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(75, 23);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // FormAirports
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridViewData);
+ this.Name = "FormAirports";
+ this.Text = "Аэропорты";
+ this.Load += new System.EventHandler(this.FormAirports_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).EndInit();
+ this.ResumeLayout(false); // Вызов ResumeLayout
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView dataGridViewData;
+ private System.Windows.Forms.Button buttonAdd;
+ private System.Windows.Forms.Button buttonUpd;
+ private System.Windows.Forms.Button buttonDel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormAirports.cs b/ProjectAirline/Forms/FormAirports.cs
new file mode 100644
index 0000000..9380497
--- /dev/null
+++ b/ProjectAirline/Forms/FormAirports.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Windows.Forms;
+using Unity;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormAirports : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IAirportRepository _airportRepository;
+
+ public FormAirports(IUnityContainer container, IAirportRepository airportRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _airportRepository = airportRepository ?? throw new ArgumentNullException(nameof(airportRepository));
+ }
+
+ private void FormAirports_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpd_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 ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
+ {
+ return;
+ }
+ try
+ {
+ _airportRepository.DeleteAirport(findId);
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewData.DataSource = _airportRepository.ReadAirports();
+
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormAirports.resx b/ProjectAirline/Forms/FormAirports.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormAirports.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/ProjectAirline/Forms/FormEmployee.Designer.cs b/ProjectAirline/Forms/FormEmployee.Designer.cs
new file mode 100644
index 0000000..eb0082c
--- /dev/null
+++ b/ProjectAirline/Forms/FormEmployee.Designer.cs
@@ -0,0 +1,141 @@
+namespace YourNamespace.Forms
+{
+ partial class FormEmployee
+ {
+ ///
+ /// 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.labelFirstName = new System.Windows.Forms.Label();
+ this.labelLastName = new System.Windows.Forms.Label();
+ this.labelPost = new System.Windows.Forms.Label();
+ this.textBoxFirstName = new System.Windows.Forms.TextBox();
+ this.textBoxLastName = new System.Windows.Forms.TextBox();
+ this.comboBoxPost = new System.Windows.Forms.ComboBox();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // labelFirstName
+ //
+ this.labelFirstName.AutoSize = true;
+ this.labelFirstName.Location = new System.Drawing.Point(12, 22);
+ this.labelFirstName.Name = "labelFirstName";
+ this.labelFirstName.Size = new System.Drawing.Size(32, 13);
+ this.labelFirstName.TabIndex = 0;
+ this.labelFirstName.Text = "Имя:";
+ //
+ // labelLastName
+ //
+ this.labelLastName.AutoSize = true;
+ this.labelLastName.Location = new System.Drawing.Point(12, 58);
+ this.labelLastName.Name = "labelLastName";
+ this.labelLastName.Size = new System.Drawing.Size(59, 13);
+ this.labelLastName.TabIndex = 1;
+ this.labelLastName.Text = "Фамилия:";
+ //
+ // labelPost
+ //
+ this.labelPost.AutoSize = true;
+ this.labelPost.Location = new System.Drawing.Point(12, 94);
+ this.labelPost.Name = "labelPost";
+ this.labelPost.Size = new System.Drawing.Size(65, 13);
+ this.labelPost.TabIndex = 2;
+ this.labelPost.Text = "Должность:";
+ //
+ // textBoxFirstName
+ //
+ this.textBoxFirstName.Location = new System.Drawing.Point(111, 19);
+ this.textBoxFirstName.Name = "textBoxFirstName";
+ this.textBoxFirstName.Size = new System.Drawing.Size(200, 20);
+ this.textBoxFirstName.TabIndex = 3;
+ //
+ // textBoxLastName
+ //
+ this.textBoxLastName.Location = new System.Drawing.Point(111, 55);
+ this.textBoxLastName.Name = "textBoxLastName";
+ this.textBoxLastName.Size = new System.Drawing.Size(200, 20);
+ this.textBoxLastName.TabIndex = 4;
+ //
+ // comboBoxPost
+ //
+ this.comboBoxPost.FormattingEnabled = true;
+ this.comboBoxPost.Location = new System.Drawing.Point(111, 91);
+ this.comboBoxPost.Name = "comboBoxPost";
+ this.comboBoxPost.Size = new System.Drawing.Size(200, 21);
+ this.comboBoxPost.TabIndex = 5;
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(155, 128);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 6;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(236, 128);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+ this.buttonCancel.TabIndex = 7;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // FormEmployee
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(324, 166);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.comboBoxPost);
+ this.Controls.Add(this.textBoxLastName);
+ this.Controls.Add(this.textBoxFirstName);
+ this.Controls.Add(this.labelPost);
+ this.Controls.Add(this.labelLastName);
+ this.Controls.Add(this.labelFirstName);
+ this.Name = "FormEmployee";
+ this.Text = "Редактирование сотрудника";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label labelFirstName;
+ private System.Windows.Forms.Label labelLastName;
+ private System.Windows.Forms.Label labelPost;
+ private System.Windows.Forms.TextBox textBoxFirstName;
+ private System.Windows.Forms.TextBox textBoxLastName;
+ private System.Windows.Forms.ComboBox comboBoxPost;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormEmployee.cs b/ProjectAirline/Forms/FormEmployee.cs
new file mode 100644
index 0000000..f267728
--- /dev/null
+++ b/ProjectAirline/Forms/FormEmployee.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Windows.Forms;
+using YourNamespace.Entities;
+using YourNamespace.Entities.Enums;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormEmployee : Form
+ {
+ private readonly IEmployeeRepository _employeeRepository;
+ private int? _employeeId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var employee = _employeeRepository.ReadEmployeeById(value);
+ if (employee == null)
+ {
+ throw new InvalidDataException(nameof(employee));
+ }
+ textBoxFirstName.Text = employee.FirstName;
+ textBoxLastName.Text = employee.LastName;
+ comboBoxPost.SelectedItem = employee.EmployeePost;
+ _employeeId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormEmployee(IEmployeeRepository employeeRepository)
+ {
+ InitializeComponent();
+ _employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
+
+ comboBoxPost.DataSource = Enum.GetValues(typeof(EmployeePost));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text) || comboBoxPost.SelectedIndex < 0)
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_employeeId.HasValue)
+ {
+ _employeeRepository.UpdateEmployee(CreateEmployee(_employeeId.Value));
+ }
+ else
+ {
+ _employeeRepository.CreateEmployee(CreateEmployee(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Employee CreateEmployee(int id) => Employee.CreateEntity(id, textBoxFirstName.Text, textBoxLastName.Text, (EmployeePost)comboBoxPost.SelectedItem);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormEmployee.resx b/ProjectAirline/Forms/FormEmployee.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormEmployee.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/ProjectAirline/Forms/FormEmployees.Designer.cs b/ProjectAirline/Forms/FormEmployees.Designer.cs
new file mode 100644
index 0000000..136c80e
--- /dev/null
+++ b/ProjectAirline/Forms/FormEmployees.Designer.cs
@@ -0,0 +1,106 @@
+namespace YourNamespace.Forms
+{
+ partial class FormEmployees
+ {
+ ///
+ /// 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.dataGridViewData = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).BeginInit();
+ this.SuspendLayout(); // Вызов SuspendLayout
+ //
+ // dataGridViewData
+ //
+ this.dataGridViewData.AllowUserToAddRows = false;
+ this.dataGridViewData.AllowUserToDeleteRows = false;
+ this.dataGridViewData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridViewData.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridViewData.Location = new System.Drawing.Point(0, 0);
+ this.dataGridViewData.MultiSelect = false;
+ this.dataGridViewData.Name = "dataGridViewData";
+ this.dataGridViewData.ReadOnly = true;
+ this.dataGridViewData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+ this.dataGridViewData.Size = new System.Drawing.Size(800, 450);
+ this.dataGridViewData.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(12, 12);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(75, 23);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(93, 12);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(75, 23);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(174, 12);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(75, 23);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // FormEmployees
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridViewData);
+ this.Name = "FormEmployees";
+ this.Text = "Сотрудники";
+ this.Load += new System.EventHandler(this.FormEmployees_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).EndInit();
+ this.ResumeLayout(false); // Вызов ResumeLayout
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView dataGridViewData;
+ private System.Windows.Forms.Button buttonAdd;
+ private System.Windows.Forms.Button buttonUpd;
+ private System.Windows.Forms.Button buttonDel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormEmployees.cs b/ProjectAirline/Forms/FormEmployees.cs
new file mode 100644
index 0000000..34e24b3
--- /dev/null
+++ b/ProjectAirline/Forms/FormEmployees.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Windows.Forms;
+using Unity;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormEmployees : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IEmployeeRepository _employeeRepository;
+
+ public FormEmployees(IUnityContainer container, IEmployeeRepository employeeRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
+ }
+
+ private void FormEmployees_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpd_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 ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
+ {
+ return;
+ }
+ try
+ {
+ _employeeRepository.DeleteEmployee(findId);
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewData.DataSource = _employeeRepository.ReadEmployees();
+
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormEmployees.resx b/ProjectAirline/Forms/FormEmployees.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormEmployees.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/ProjectAirline/Forms/FormFlight.Designer.cs b/ProjectAirline/Forms/FormFlight.Designer.cs
new file mode 100644
index 0000000..11266b9
--- /dev/null
+++ b/ProjectAirline/Forms/FormFlight.Designer.cs
@@ -0,0 +1,188 @@
+namespace YourNamespace.Forms
+{
+ partial class FormFlight
+ {
+ ///
+ /// 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.labelFlightNumber = new System.Windows.Forms.Label();
+ this.labelDepartureDateTime = new System.Windows.Forms.Label();
+ this.labelArrivalDateTime = new System.Windows.Forms.Label();
+ this.labelPlane = new System.Windows.Forms.Label();
+ this.labelAirport = new System.Windows.Forms.Label();
+ this.numericUpDownFlightNumber = new System.Windows.Forms.NumericUpDown();
+ this.dateTimePickerDeparture = new System.Windows.Forms.DateTimePicker();
+ this.dateTimePickerArrival = new System.Windows.Forms.DateTimePicker();
+ this.comboBoxPlane = new System.Windows.Forms.ComboBox();
+ this.comboBoxAirport = new System.Windows.Forms.ComboBox();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFlightNumber)).BeginInit();
+ this.SuspendLayout(); // Вызов SuspendLayout
+ //
+ // labelFlightNumber
+ //
+ this.labelFlightNumber.AutoSize = true;
+ this.labelFlightNumber.Location = new System.Drawing.Point(12, 22);
+ this.labelFlightNumber.Name = "labelFlightNumber";
+ this.labelFlightNumber.Size = new System.Drawing.Size(80, 13);
+ this.labelFlightNumber.TabIndex = 0;
+ this.labelFlightNumber.Text = "Номер рейса:";
+ //
+ // labelDepartureDateTime
+ //
+ this.labelDepartureDateTime.AutoSize = true;
+ this.labelDepartureDateTime.Location = new System.Drawing.Point(12, 58);
+ this.labelDepartureDateTime.Name = "labelDepartureDateTime";
+ this.labelDepartureDateTime.Size = new System.Drawing.Size(115, 13);
+ this.labelDepartureDateTime.TabIndex = 1;
+ this.labelDepartureDateTime.Text = "Дата и время вылета:";
+ //
+ // labelArrivalDateTime
+ //
+ this.labelArrivalDateTime.AutoSize = true;
+ this.labelArrivalDateTime.Location = new System.Drawing.Point(12, 94);
+ this.labelArrivalDateTime.Name = "labelArrivalDateTime";
+ this.labelArrivalDateTime.Size = new System.Drawing.Size(119, 13);
+ this.labelArrivalDateTime.TabIndex = 2;
+ this.labelArrivalDateTime.Text = "Дата и время прибытия:";
+ //
+ // labelPlane
+ //
+ this.labelPlane.AutoSize = true;
+ this.labelPlane.Location = new System.Drawing.Point(12, 130);
+ this.labelPlane.Name = "labelPlane";
+ this.labelPlane.Size = new System.Drawing.Size(54, 13);
+ this.labelPlane.TabIndex = 3;
+ this.labelPlane.Text = "Самолет:";
+ //
+ // labelAirport
+ //
+ this.labelAirport.AutoSize = true;
+ this.labelAirport.Location = new System.Drawing.Point(12, 166);
+ this.labelAirport.Name = "labelAirport";
+ this.labelAirport.Size = new System.Drawing.Size(59, 13);
+ this.labelAirport.TabIndex = 4;
+ this.labelAirport.Text = "Аэропорт:";
+ //
+ // numericUpDownFlightNumber
+ //
+ this.numericUpDownFlightNumber.Location = new System.Drawing.Point(133, 20);
+ this.numericUpDownFlightNumber.Name = "numericUpDownFlightNumber";
+ this.numericUpDownFlightNumber.Size = new System.Drawing.Size(150, 20);
+ this.numericUpDownFlightNumber.TabIndex = 5;
+ //
+ // dateTimePickerDeparture
+ //
+ this.dateTimePickerDeparture.Location = new System.Drawing.Point(133, 56);
+ this.dateTimePickerDeparture.Name = "dateTimePickerDeparture";
+ this.dateTimePickerDeparture.Size = new System.Drawing.Size(150, 20);
+ this.dateTimePickerDeparture.TabIndex = 6;
+ //
+ // dateTimePickerArrival
+ //
+ this.dateTimePickerArrival.Location = new System.Drawing.Point(133, 92);
+ this.dateTimePickerArrival.Name = "dateTimePickerArrival";
+ this.dateTimePickerArrival.Size = new System.Drawing.Size(150, 20);
+ this.dateTimePickerArrival.TabIndex = 7;
+ //
+ // comboBoxPlane
+ //
+ this.comboBoxPlane.FormattingEnabled = true;
+ this.comboBoxPlane.Location = new System.Drawing.Point(133, 128);
+ this.comboBoxPlane.Name = "comboBoxPlane";
+ this.comboBoxPlane.Size = new System.Drawing.Size(150, 21);
+ this.comboBoxPlane.TabIndex = 8;
+ //
+ // comboBoxAirport
+ //
+ this.comboBoxAirport.FormattingEnabled = true;
+ this.comboBoxAirport.Location = new System.Drawing.Point(133, 164);
+ this.comboBoxAirport.Name = "comboBoxAirport";
+ this.comboBoxAirport.Size = new System.Drawing.Size(150, 21);
+ this.comboBoxAirport.TabIndex = 9;
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(133, 200);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 10;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(208, 200);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+ this.buttonCancel.TabIndex = 11;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // FormFlight
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(304, 235);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.comboBoxAirport);
+ this.Controls.Add(this.comboBoxPlane);
+ this.Controls.Add(this.dateTimePickerArrival);
+ this.Controls.Add(this.dateTimePickerDeparture);
+ this.Controls.Add(this.numericUpDownFlightNumber);
+ this.Controls.Add(this.labelAirport);
+ this.Controls.Add(this.labelPlane);
+ this.Controls.Add(this.labelArrivalDateTime);
+ this.Controls.Add(this.labelDepartureDateTime);
+ this.Controls.Add(this.labelFlightNumber);
+ this.Name = "FormFlight";
+ this.Text = "Редактирование рейса";
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFlightNumber)).EndInit();
+ this.ResumeLayout(false); // Вызов ResumeLayout
+ this.PerformLayout(); // Вызов PerformLayout
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label labelFlightNumber;
+ private System.Windows.Forms.Label labelDepartureDateTime;
+ private System.Windows.Forms.Label labelArrivalDateTime;
+ private System.Windows.Forms.Label labelPlane;
+ private System.Windows.Forms.Label labelAirport;
+ private System.Windows.Forms.NumericUpDown numericUpDownFlightNumber;
+ private System.Windows.Forms.DateTimePicker dateTimePickerDeparture;
+ private System.Windows.Forms.DateTimePicker dateTimePickerArrival;
+ private System.Windows.Forms.ComboBox comboBoxPlane;
+ private System.Windows.Forms.ComboBox comboBoxAirport;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormFlight.cs b/ProjectAirline/Forms/FormFlight.cs
new file mode 100644
index 0000000..2d48f5f
--- /dev/null
+++ b/ProjectAirline/Forms/FormFlight.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Windows.Forms;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormFlight : Form
+ {
+ private readonly IFlightRepository _flightRepository;
+ private readonly IPlaneRepository _planeRepository;
+ private readonly IAirportRepository _airportRepository;
+ private int? _flightId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var flight = _flightRepository.ReadFlightById(value);
+ if (flight == null)
+ {
+ throw new InvalidDataException(nameof(flight));
+ }
+ numericUpDownFlightNumber.Value = flight.FlightNumber;
+ dateTimePickerDeparture.Value = flight.DepartureDateTime;
+ dateTimePickerArrival.Value = flight.ArrivalDateTime;
+ comboBoxPlane.SelectedValue = flight.PlaneId;
+ comboBoxAirport.SelectedValue = flight.AirportId;
+ _flightId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormFlight(IFlightRepository flightRepository, IPlaneRepository planeRepository, IAirportRepository airportRepository)
+ {
+ InitializeComponent();
+ _flightRepository = flightRepository ?? throw new ArgumentNullException(nameof(flightRepository));
+ _planeRepository = planeRepository ?? throw new ArgumentNullException(nameof(planeRepository));
+ _airportRepository = airportRepository ?? throw new ArgumentNullException(nameof(airportRepository));
+
+ comboBoxPlane.DataSource = _planeRepository.ReadPlanes();
+ comboBoxPlane.DisplayMember = "Model";
+ comboBoxPlane.ValueMember = "Id";
+
+ comboBoxAirport.DataSource = _airportRepository.ReadAirports();
+ comboBoxAirport.DisplayMember = "Name";
+ comboBoxAirport.ValueMember = "Id";
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (comboBoxPlane.SelectedIndex < 0 || comboBoxAirport.SelectedIndex < 0)
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_flightId.HasValue)
+ {
+ _flightRepository.UpdateFlight(CreateFlight(_flightId.Value));
+ }
+ else
+ {
+ _flightRepository.CreateFlight(CreateFlight(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Flight CreateFlight(int id) => Flight.CreateEntity(id, (int)numericUpDownFlightNumber.Value, dateTimePickerDeparture.Value, dateTimePickerArrival.Value, (int)comboBoxPlane.SelectedValue, (int)comboBoxAirport.SelectedValue);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormFlight.resx b/ProjectAirline/Forms/FormFlight.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormFlight.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/ProjectAirline/Forms/FormFlights.Designer.cs b/ProjectAirline/Forms/FormFlights.Designer.cs
new file mode 100644
index 0000000..d8c51b0
--- /dev/null
+++ b/ProjectAirline/Forms/FormFlights.Designer.cs
@@ -0,0 +1,106 @@
+namespace YourNamespace.Forms
+{
+ partial class FormFlights
+ {
+ ///
+ /// 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.dataGridViewData = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridViewData
+ //
+ this.dataGridViewData.AllowUserToAddRows = false;
+ this.dataGridViewData.AllowUserToDeleteRows = false;
+ this.dataGridViewData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridViewData.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridViewData.Location = new System.Drawing.Point(0, 0);
+ this.dataGridViewData.MultiSelect = false;
+ this.dataGridViewData.Name = "dataGridViewData";
+ this.dataGridViewData.ReadOnly = true;
+ this.dataGridViewData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+ this.dataGridViewData.Size = new System.Drawing.Size(800, 450);
+ this.dataGridViewData.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(12, 12);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(75, 23);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(93, 12);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(75, 23);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(174, 12);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(75, 23);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // FormFlights
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridViewData);
+ this.Name = "FormFlights";
+ this.Text = "Рейсы";
+ this.Load += new System.EventHandler(this.FormFlights_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView dataGridViewData;
+ private System.Windows.Forms.Button buttonAdd;
+ private System.Windows.Forms.Button buttonUpd;
+ private System.Windows.Forms.Button buttonDel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormFlights.cs b/ProjectAirline/Forms/FormFlights.cs
new file mode 100644
index 0000000..19fdfc9
--- /dev/null
+++ b/ProjectAirline/Forms/FormFlights.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Windows.Forms;
+using Unity;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormFlights : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IFlightRepository _flightRepository;
+
+ public FormFlights(IUnityContainer container, IFlightRepository flightRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _flightRepository = flightRepository ?? throw new ArgumentNullException(nameof(flightRepository));
+ }
+
+ private void FormFlights_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpd_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 ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
+ {
+ return;
+ }
+ try
+ {
+ _flightRepository.DeleteFlight(findId);
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewData.DataSource = _flightRepository.ReadFlights();
+
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormFlights.resx b/ProjectAirline/Forms/FormFlights.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormFlights.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/ProjectAirline/Forms/FormMain.Designer.cs b/ProjectAirline/Forms/FormMain.Designer.cs
new file mode 100644
index 0000000..ff8c32b
--- /dev/null
+++ b/ProjectAirline/Forms/FormMain.Designer.cs
@@ -0,0 +1,134 @@
+namespace YourNamespace.Forms
+{
+ partial class FormMain
+ {
+ ///
+ /// 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.menuStrip = new System.Windows.Forms.MenuStrip();
+ this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ticketsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.passengersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.flightsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.airportsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.planesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.employeesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.menuStrip.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // menuStrip
+ //
+ this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.справочникиToolStripMenuItem});
+ this.menuStrip.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip.Name = "menuStrip";
+ this.menuStrip.Size = new System.Drawing.Size(800, 24);
+ this.menuStrip.TabIndex = 0;
+ this.menuStrip.Text = "menuStrip1";
+ //
+ // справочникиToolStripMenuItem
+ //
+ this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.ticketsToolStripMenuItem,
+ this.passengersToolStripMenuItem,
+ this.flightsToolStripMenuItem,
+ this.airportsToolStripMenuItem,
+ this.planesToolStripMenuItem,
+ this.employeesToolStripMenuItem});
+ this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
+ this.справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // ticketsToolStripMenuItem
+ //
+ this.ticketsToolStripMenuItem.Name = "ticketsToolStripMenuItem";
+ this.ticketsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.ticketsToolStripMenuItem.Text = "Билеты";
+ this.ticketsToolStripMenuItem.Click += new System.EventHandler(this.TicketsToolStripMenuItem_Click);
+ //
+ // passengersToolStripMenuItem
+ //
+ this.passengersToolStripMenuItem.Name = "passengersToolStripMenuItem";
+ this.passengersToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.passengersToolStripMenuItem.Text = "Пассажиры";
+ this.passengersToolStripMenuItem.Click += new System.EventHandler(this.PassengersToolStripMenuItem_Click);
+ //
+ // flightsToolStripMenuItem
+ //
+ this.flightsToolStripMenuItem.Name = "flightsToolStripMenuItem";
+ this.flightsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.flightsToolStripMenuItem.Text = "Рейсы";
+ this.flightsToolStripMenuItem.Click += new System.EventHandler(this.FlightsToolStripMenuItem_Click);
+ //
+ // airportsToolStripMenuItem
+ //
+ this.airportsToolStripMenuItem.Name = "airportsToolStripMenuItem";
+ this.airportsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.airportsToolStripMenuItem.Text = "Аэропорты";
+ this.airportsToolStripMenuItem.Click += new System.EventHandler(this.AirportsToolStripMenuItem_Click);
+ //
+ // planesToolStripMenuItem
+ //
+ this.planesToolStripMenuItem.Name = "planesToolStripMenuItem";
+ this.planesToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.planesToolStripMenuItem.Text = "Самолеты";
+ this.planesToolStripMenuItem.Click += new System.EventHandler(this.PlanesToolStripMenuItem_Click);
+ //
+ // employeesToolStripMenuItem
+ //
+ this.employeesToolStripMenuItem.Name = "employeesToolStripMenuItem";
+ this.employeesToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.employeesToolStripMenuItem.Text = "Сотрудники";
+ this.employeesToolStripMenuItem.Click += new System.EventHandler(this.EmployeesToolStripMenuItem_Click);
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.menuStrip);
+ this.MainMenuStrip = this.menuStrip;
+ this.Name = "FormMain";
+ this.Text = "Главная форма";
+ this.menuStrip.ResumeLayout(false);
+ this.menuStrip.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuStrip menuStrip;
+ private System.Windows.Forms.ToolStripMenuItem справочникиToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem ticketsToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem passengersToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem flightsToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem airportsToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem planesToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem employeesToolStripMenuItem;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormMain.cs b/ProjectAirline/Forms/FormMain.cs
new file mode 100644
index 0000000..d4a4cba
--- /dev/null
+++ b/ProjectAirline/Forms/FormMain.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Windows.Forms;
+using Unity;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormMain : Form
+ {
+ private readonly IUnityContainer _container;
+
+ public FormMain(IUnityContainer container)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ }
+
+ private void PassengersToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void EmployeesToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void FlightsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void PlanesToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void TicketsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void AirportsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormMain.resx b/ProjectAirline/Forms/FormMain.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormMain.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/ProjectAirline/Forms/FormPassenger.Designer.cs b/ProjectAirline/Forms/FormPassenger.Designer.cs
new file mode 100644
index 0000000..2fa486b
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassenger.Designer.cs
@@ -0,0 +1,140 @@
+namespace YourNamespace.Forms
+{
+ partial class FormPassenger
+ {
+ ///
+ /// 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.labelFirstName = new System.Windows.Forms.Label();
+ this.labelLastName = new System.Windows.Forms.Label();
+ this.labelPassportNumber = new System.Windows.Forms.Label();
+ this.textBoxFirstName = new System.Windows.Forms.TextBox();
+ this.textBoxLastName = new System.Windows.Forms.TextBox();
+ this.textBoxPassportNumber = new System.Windows.Forms.TextBox();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // labelFirstName
+ //
+ this.labelFirstName.AutoSize = true;
+ this.labelFirstName.Location = new System.Drawing.Point(12, 22);
+ this.labelFirstName.Name = "labelFirstName";
+ this.labelFirstName.Size = new System.Drawing.Size(32, 13);
+ this.labelFirstName.TabIndex = 0;
+ this.labelFirstName.Text = "Имя:";
+ //
+ // labelLastName
+ //
+ this.labelLastName.AutoSize = true;
+ this.labelLastName.Location = new System.Drawing.Point(12, 58);
+ this.labelLastName.Name = "labelLastName";
+ this.labelLastName.Size = new System.Drawing.Size(59, 13);
+ this.labelLastName.TabIndex = 1;
+ this.labelLastName.Text = "Фамилия:";
+ //
+ // labelPassportNumber
+ //
+ this.labelPassportNumber.AutoSize = true;
+ this.labelPassportNumber.Location = new System.Drawing.Point(12, 94);
+ this.labelPassportNumber.Name = "labelPassportNumber";
+ this.labelPassportNumber.Size = new System.Drawing.Size(93, 13);
+ this.labelPassportNumber.TabIndex = 2;
+ this.labelPassportNumber.Text = "Номер паспорта:";
+ //
+ // textBoxFirstName
+ //
+ this.textBoxFirstName.Location = new System.Drawing.Point(111, 19);
+ this.textBoxFirstName.Name = "textBoxFirstName";
+ this.textBoxFirstName.Size = new System.Drawing.Size(200, 20);
+ this.textBoxFirstName.TabIndex = 3;
+ //
+ // textBoxLastName
+ //
+ this.textBoxLastName.Location = new System.Drawing.Point(111, 55);
+ this.textBoxLastName.Name = "textBoxLastName";
+ this.textBoxLastName.Size = new System.Drawing.Size(200, 20);
+ this.textBoxLastName.TabIndex = 4;
+ //
+ // textBoxPassportNumber
+ //
+ this.textBoxPassportNumber.Location = new System.Drawing.Point(111, 91);
+ this.textBoxPassportNumber.Name = "textBoxPassportNumber";
+ this.textBoxPassportNumber.Size = new System.Drawing.Size(200, 20);
+ this.textBoxPassportNumber.TabIndex = 5;
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(155, 128);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 6;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(236, 128);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+ this.buttonCancel.TabIndex = 7;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // FormPassenger
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(324, 166);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxPassportNumber);
+ this.Controls.Add(this.textBoxLastName);
+ this.Controls.Add(this.textBoxFirstName);
+ this.Controls.Add(this.labelPassportNumber);
+ this.Controls.Add(this.labelLastName);
+ this.Controls.Add(this.labelFirstName);
+ this.Name = "FormPassenger";
+ this.Text = "Редактирование пассажира";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label labelFirstName;
+ private System.Windows.Forms.Label labelLastName;
+ private System.Windows.Forms.Label labelPassportNumber;
+ private System.Windows.Forms.TextBox textBoxFirstName;
+ private System.Windows.Forms.TextBox textBoxLastName;
+ private System.Windows.Forms.TextBox textBoxPassportNumber;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPassenger.cs b/ProjectAirline/Forms/FormPassenger.cs
new file mode 100644
index 0000000..d628f5c
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassenger.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Windows.Forms;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormPassenger : Form
+ {
+ private readonly IPassengerRepository _passengerRepository;
+ private int? _passengerId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var passenger = _passengerRepository.ReadPassengerById(value);
+ if (passenger == null)
+ {
+ throw new InvalidDataException(nameof(passenger));
+ }
+ textBoxFirstName.Text = passenger.FirstName;
+ textBoxLastName.Text = passenger.LastName;
+ textBoxPassportNumber.Text = passenger.PassportNumber;
+ _passengerId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormPassenger(IPassengerRepository passengerRepository)
+ {
+ InitializeComponent();
+ _passengerRepository = passengerRepository ?? throw new ArgumentNullException(nameof(passengerRepository));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text) || string.IsNullOrWhiteSpace(textBoxPassportNumber.Text))
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_passengerId.HasValue)
+ {
+ _passengerRepository.UpdatePassenger(CreatePassenger(_passengerId.Value));
+ }
+ else
+ {
+ _passengerRepository.CreatePassenger(CreatePassenger(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Passenger CreatePassenger(int id) => Passenger.CreateEntity(id, textBoxFirstName.Text, textBoxLastName.Text, textBoxPassportNumber.Text);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPassenger.resx b/ProjectAirline/Forms/FormPassenger.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassenger.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/ProjectAirline/Forms/FormPassengers.Designer.cs b/ProjectAirline/Forms/FormPassengers.Designer.cs
new file mode 100644
index 0000000..db78842
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassengers.Designer.cs
@@ -0,0 +1,106 @@
+namespace YourNamespace.Forms
+{
+ partial class FormPassengers
+ {
+ ///
+ /// 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.dataGridViewData = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridViewData
+ //
+ this.dataGridViewData.AllowUserToAddRows = false;
+ this.dataGridViewData.AllowUserToDeleteRows = false;
+ this.dataGridViewData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridViewData.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridViewData.Location = new System.Drawing.Point(0, 0);
+ this.dataGridViewData.MultiSelect = false;
+ this.dataGridViewData.Name = "dataGridViewData";
+ this.dataGridViewData.ReadOnly = true;
+ this.dataGridViewData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+ this.dataGridViewData.Size = new System.Drawing.Size(800, 450);
+ this.dataGridViewData.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(12, 12);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(75, 23);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(93, 12);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(75, 23);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(174, 12);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(75, 23);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // FormPassengers
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridViewData);
+ this.Name = "FormPassengers";
+ this.Text = "Пассажиры";
+ this.Load += new System.EventHandler(this.FormPassengers_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView dataGridViewData;
+ private System.Windows.Forms.Button buttonAdd;
+ private System.Windows.Forms.Button buttonUpd;
+ private System.Windows.Forms.Button buttonDel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPassengers.cs b/ProjectAirline/Forms/FormPassengers.cs
new file mode 100644
index 0000000..af67542
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassengers.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Windows.Forms;
+using Unity;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormPassengers : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IPassengerRepository _passengerRepository;
+
+ public FormPassengers(IUnityContainer container, IPassengerRepository passengerRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _passengerRepository = passengerRepository ?? throw new ArgumentNullException(nameof(passengerRepository));
+ }
+
+ private void FormPassengers_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpd_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 ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
+ {
+ return;
+ }
+ try
+ {
+ _passengerRepository.DeletePassenger(findId);
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewData.DataSource = _passengerRepository.ReadPassengers();
+
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPassengers.resx b/ProjectAirline/Forms/FormPassengers.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassengers.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/ProjectAirline/Forms/FormPlane.Designer.cs b/ProjectAirline/Forms/FormPlane.Designer.cs
new file mode 100644
index 0000000..3c00cc3
--- /dev/null
+++ b/ProjectAirline/Forms/FormPlane.Designer.cs
@@ -0,0 +1,120 @@
+namespace YourNamespace.Forms
+{
+ partial class FormPlane
+ {
+ ///
+ /// 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.labelModel = new System.Windows.Forms.Label();
+ this.labelCapacity = new System.Windows.Forms.Label();
+ this.textBoxModel = new System.Windows.Forms.TextBox();
+ this.numericUpDownCapacity = new System.Windows.Forms.NumericUpDown();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCapacity)).BeginInit();
+ this.SuspendLayout();
+ //
+ // labelModel
+ //
+ this.labelModel.AutoSize = true;
+ this.labelModel.Location = new System.Drawing.Point(12, 22);
+ this.labelModel.Name = "labelModel";
+ this.labelModel.Size = new System.Drawing.Size(54, 13);
+ this.labelModel.TabIndex = 0;
+ this.labelModel.Text = "Модель:";
+ //
+ // labelCapacity
+ //
+ this.labelCapacity.AutoSize = true;
+ this.labelCapacity.Location = new System.Drawing.Point(12, 58);
+ this.labelCapacity.Name = "labelCapacity";
+ this.labelCapacity.Size = new System.Drawing.Size(72, 13);
+ this.labelCapacity.TabIndex = 1;
+ this.labelCapacity.Text = "Вместимость:";
+ //
+ // textBoxModel
+ //
+ this.textBoxModel.Location = new System.Drawing.Point(111, 19);
+ this.textBoxModel.Name = "textBoxModel";
+ this.textBoxModel.Size = new System.Drawing.Size(200, 20);
+ this.textBoxModel.TabIndex = 2;
+ //
+ // numericUpDownCapacity
+ //
+ this.numericUpDownCapacity.Location = new System.Drawing.Point(111, 56);
+ this.numericUpDownCapacity.Name = "numericUpDownCapacity";
+ this.numericUpDownCapacity.Size = new System.Drawing.Size(200, 20);
+ this.numericUpDownCapacity.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(155, 91);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(236, 91);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // FormPlane
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(324, 126);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.numericUpDownCapacity);
+ this.Controls.Add(this.textBoxModel);
+ this.Controls.Add(this.labelCapacity);
+ this.Controls.Add(this.labelModel);
+ this.Name = "FormPlane";
+ this.Text = "Редактирование самолета";
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCapacity)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label labelModel;
+ private System.Windows.Forms.Label labelCapacity;
+ private System.Windows.Forms.TextBox textBoxModel;
+ private System.Windows.Forms.NumericUpDown numericUpDownCapacity;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPlane.cs b/ProjectAirline/Forms/FormPlane.cs
new file mode 100644
index 0000000..a640cc1
--- /dev/null
+++ b/ProjectAirline/Forms/FormPlane.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Windows.Forms;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormPlane : Form
+ {
+ private readonly IPlaneRepository _planeRepository;
+ private int? _planeId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var plane = _planeRepository.ReadPlaneById(value);
+ if (plane == null)
+ {
+ throw new InvalidDataException(nameof(plane));
+ }
+ textBoxModel.Text = plane.Model;
+ numericUpDownCapacity.Value = plane.Capacity;
+ _planeId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormPlane(IPlaneRepository planeRepository)
+ {
+ InitializeComponent();
+ _planeRepository = planeRepository ?? throw new ArgumentNullException(nameof(planeRepository));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxModel.Text))
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_planeId.HasValue)
+ {
+ _planeRepository.UpdatePlane(CreatePlane(_planeId.Value));
+ }
+ else
+ {
+ _planeRepository.CreatePlane(CreatePlane(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Plane CreatePlane(int id) => Plane.CreateEntity(id, textBoxModel.Text, (int)numericUpDownCapacity.Value);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPlane.resx b/ProjectAirline/Forms/FormPlane.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormPlane.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/ProjectAirline/Forms/FormPlanes.Designer.cs b/ProjectAirline/Forms/FormPlanes.Designer.cs
new file mode 100644
index 0000000..7887b42
--- /dev/null
+++ b/ProjectAirline/Forms/FormPlanes.Designer.cs
@@ -0,0 +1,106 @@
+namespace YourNamespace.Forms
+{
+ partial class FormPlanes
+ {
+ ///
+ /// 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.dataGridViewData = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridViewData
+ //
+ this.dataGridViewData.AllowUserToAddRows = false;
+ this.dataGridViewData.AllowUserToDeleteRows = false;
+ this.dataGridViewData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridViewData.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridViewData.Location = new System.Drawing.Point(0, 0);
+ this.dataGridViewData.MultiSelect = false;
+ this.dataGridViewData.Name = "dataGridViewData";
+ this.dataGridViewData.ReadOnly = true;
+ this.dataGridViewData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+ this.dataGridViewData.Size = new System.Drawing.Size(800, 450);
+ this.dataGridViewData.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(12, 12);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(75, 23);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(93, 12);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(75, 23);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(174, 12);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(75, 23);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // FormPlanes
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridViewData);
+ this.Name = "FormPlanes";
+ this.Text = "Самолеты";
+ this.Load += new System.EventHandler(this.FormPlanes_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView dataGridViewData;
+ private System.Windows.Forms.Button buttonAdd;
+ private System.Windows.Forms.Button buttonUpd;
+ private System.Windows.Forms.Button buttonDel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPlanes.cs b/ProjectAirline/Forms/FormPlanes.cs
new file mode 100644
index 0000000..250eb21
--- /dev/null
+++ b/ProjectAirline/Forms/FormPlanes.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Windows.Forms;
+using Unity;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormPlanes : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly IPlaneRepository _planeRepository;
+
+ public FormPlanes(IUnityContainer container, IPlaneRepository planeRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _planeRepository = planeRepository ?? throw new ArgumentNullException(nameof(planeRepository));
+ }
+
+ private void FormPlanes_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpd_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 ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
+ {
+ return;
+ }
+ try
+ {
+ _planeRepository.DeletePlane(findId);
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewData.DataSource = _planeRepository.ReadPlanes();
+
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPlanes.resx b/ProjectAirline/Forms/FormPlanes.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormPlanes.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/ProjectAirline/Forms/FormTicket.Designer.cs b/ProjectAirline/Forms/FormTicket.Designer.cs
new file mode 100644
index 0000000..65ef35c
--- /dev/null
+++ b/ProjectAirline/Forms/FormTicket.Designer.cs
@@ -0,0 +1,166 @@
+namespace YourNamespace.Forms
+{
+ partial class FormTicket
+ {
+ ///
+ /// 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.labelPassenger = new System.Windows.Forms.Label();
+ this.labelFlight = new System.Windows.Forms.Label();
+ this.labelDateBuy = new System.Windows.Forms.Label();
+ this.labelTicketPrice = new System.Windows.Forms.Label();
+ this.comboBoxPassenger = new System.Windows.Forms.ComboBox();
+ this.comboBoxFlight = new System.Windows.Forms.ComboBox();
+ this.dateTimePickerDateBuy = new System.Windows.Forms.DateTimePicker();
+ this.numericUpDownTicketPrice = new System.Windows.Forms.NumericUpDown();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTicketPrice)).BeginInit();
+ this.SuspendLayout();
+ //
+ // labelPassenger
+ //
+ this.labelPassenger.AutoSize = true;
+ this.labelPassenger.Location = new System.Drawing.Point(12, 22);
+ this.labelPassenger.Name = "labelPassenger";
+ this.labelPassenger.Size = new System.Drawing.Size(63, 13);
+ this.labelPassenger.TabIndex = 0;
+ this.labelPassenger.Text = "Пассажир:";
+ //
+ // labelFlight
+ //
+ this.labelFlight.AutoSize = true;
+ this.labelFlight.Location = new System.Drawing.Point(12, 58);
+ this.labelFlight.Name = "labelFlight";
+ this.labelFlight.Size = new System.Drawing.Size(37, 13);
+ this.labelFlight.TabIndex = 1;
+ this.labelFlight.Text = "Рейс:";
+ //
+ // labelDateBuy
+ //
+ this.labelDateBuy.AutoSize = true;
+ this.labelDateBuy.Location = new System.Drawing.Point(12, 94);
+ this.labelDateBuy.Name = "labelDateBuy";
+ this.labelDateBuy.Size = new System.Drawing.Size(80, 13);
+ this.labelDateBuy.TabIndex = 2;
+ this.labelDateBuy.Text = "Дата покупки:";
+ //
+ // labelTicketPrice
+ //
+ this.labelTicketPrice.AutoSize = true;
+ this.labelTicketPrice.Location = new System.Drawing.Point(12, 130);
+ this.labelTicketPrice.Name = "labelTicketPrice";
+ this.labelTicketPrice.Size = new System.Drawing.Size(74, 13);
+ this.labelTicketPrice.TabIndex = 3;
+ this.labelTicketPrice.Text = "Цена билета:";
+ //
+ // comboBoxPassenger
+ //
+ this.comboBoxPassenger.FormattingEnabled = true;
+ this.comboBoxPassenger.Location = new System.Drawing.Point(111, 19);
+ this.comboBoxPassenger.Name = "comboBoxPassenger";
+ this.comboBoxPassenger.Size = new System.Drawing.Size(200, 21);
+ this.comboBoxPassenger.TabIndex = 4;
+ //
+ // comboBoxFlight
+ //
+ this.comboBoxFlight.FormattingEnabled = true;
+ this.comboBoxFlight.Location = new System.Drawing.Point(111, 55);
+ this.comboBoxFlight.Name = "comboBoxFlight";
+ this.comboBoxFlight.Size = new System.Drawing.Size(200, 21);
+ this.comboBoxFlight.TabIndex = 5;
+ //
+ // dateTimePickerDateBuy
+ //
+ this.dateTimePickerDateBuy.Location = new System.Drawing.Point(111, 91);
+ this.dateTimePickerDateBuy.Name = "dateTimePickerDateBuy";
+ this.dateTimePickerDateBuy.Size = new System.Drawing.Size(200, 20);
+ this.dateTimePickerDateBuy.TabIndex = 6;
+ //
+ // numericUpDownTicketPrice
+ //
+ this.numericUpDownTicketPrice.Location = new System.Drawing.Point(111, 128);
+ this.numericUpDownTicketPrice.Name = "numericUpDownTicketPrice";
+ this.numericUpDownTicketPrice.Size = new System.Drawing.Size(200, 20);
+ this.numericUpDownTicketPrice.TabIndex = 7;
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(155, 164);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 8;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(236, 164);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+ this.buttonCancel.TabIndex = 9;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // FormTicket
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(324, 201);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.numericUpDownTicketPrice);
+ this.Controls.Add(this.dateTimePickerDateBuy);
+ this.Controls.Add(this.comboBoxFlight);
+ this.Controls.Add(this.comboBoxPassenger);
+ this.Controls.Add(this.labelTicketPrice);
+ this.Controls.Add(this.labelDateBuy);
+ this.Controls.Add(this.labelFlight);
+ this.Controls.Add(this.labelPassenger);
+ this.Name = "FormTicket";
+ this.Text = "Редактирование билета";
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTicketPrice)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label labelPassenger;
+ private System.Windows.Forms.Label labelFlight;
+ private System.Windows.Forms.Label labelDateBuy;
+ private System.Windows.Forms.Label labelTicketPrice;
+ private System.Windows.Forms.ComboBox comboBoxPassenger;
+ private System.Windows.Forms.ComboBox comboBoxFlight;
+ private System.Windows.Forms.DateTimePicker dateTimePickerDateBuy;
+ private System.Windows.Forms.NumericUpDown numericUpDownTicketPrice;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormTicket.cs b/ProjectAirline/Forms/FormTicket.cs
new file mode 100644
index 0000000..e08a0ba
--- /dev/null
+++ b/ProjectAirline/Forms/FormTicket.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Windows.Forms;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormTicket : Form
+ {
+ private readonly ITicketRepository _ticketRepository;
+ private readonly IPassengerRepository _passengerRepository;
+ private readonly IFlightRepository _flightRepository;
+ private int? _ticketId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var ticket = _ticketRepository.ReadTicketById(value);
+ if (ticket == null)
+ {
+ throw new InvalidDataException(nameof(ticket));
+ }
+ comboBoxPassenger.SelectedValue = ticket.PassengerId;
+ comboBoxFlight.SelectedValue = ticket.FlightId;
+ dateTimePickerDateBuy.Value = ticket.DateBuy;
+ numericUpDownTicketPrice.Value = ticket.TicketPrice;
+ _ticketId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormTicket(ITicketRepository ticketRepository, IPassengerRepository passengerRepository, IFlightRepository flightRepository)
+ {
+ InitializeComponent();
+ _ticketRepository = ticketRepository ?? throw new ArgumentNullException(nameof(ticketRepository));
+ _passengerRepository = passengerRepository ?? throw new ArgumentNullException(nameof(passengerRepository));
+ _flightRepository = flightRepository ?? throw new ArgumentNullException(nameof(flightRepository));
+
+ comboBoxPassenger.DataSource = _passengerRepository.ReadPassengers();
+ comboBoxPassenger.DisplayMember = "Name";
+ comboBoxPassenger.ValueMember = "Id";
+
+ comboBoxFlight.DataSource = _flightRepository.ReadFlights();
+ comboBoxFlight.DisplayMember = "FlightNumber";
+ comboBoxFlight.ValueMember = "Id";
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (comboBoxPassenger.SelectedIndex < 0 || comboBoxFlight.SelectedIndex < 0)
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+ if (_ticketId.HasValue)
+ {
+ _ticketRepository.UpdateTicket(CreateTicket(_ticketId.Value));
+ }
+ else
+ {
+ _ticketRepository.CreateTicket(CreateTicket(0));
+ }
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Ticket CreateTicket(int id) => Ticket.CreateEntity(id, (int)comboBoxPassenger.SelectedValue, (int)comboBoxFlight.SelectedValue, dateTimePickerDateBuy.Value, (int)numericUpDownTicketPrice.Value);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormTicket.resx b/ProjectAirline/Forms/FormTicket.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormTicket.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/ProjectAirline/Forms/FormTickets.Designer.cs b/ProjectAirline/Forms/FormTickets.Designer.cs
new file mode 100644
index 0000000..db4bc18
--- /dev/null
+++ b/ProjectAirline/Forms/FormTickets.Designer.cs
@@ -0,0 +1,106 @@
+namespace YourNamespace.Forms
+{
+ partial class FormTickets
+ {
+ ///
+ /// 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.dataGridViewData = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridViewData
+ //
+ this.dataGridViewData.AllowUserToAddRows = false;
+ this.dataGridViewData.AllowUserToDeleteRows = false;
+ this.dataGridViewData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridViewData.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridViewData.Location = new System.Drawing.Point(0, 0);
+ this.dataGridViewData.MultiSelect = false;
+ this.dataGridViewData.Name = "dataGridViewData";
+ this.dataGridViewData.ReadOnly = true;
+ this.dataGridViewData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+ this.dataGridViewData.Size = new System.Drawing.Size(800, 450);
+ this.dataGridViewData.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(12, 12);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(75, 23);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(93, 12);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(75, 23);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(174, 12);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(75, 23);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // FormTickets
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridViewData);
+ this.Name = "FormTickets";
+ this.Text = "Билеты";
+ this.Load += new System.EventHandler(this.FormTickets_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView dataGridViewData;
+ private System.Windows.Forms.Button buttonAdd;
+ private System.Windows.Forms.Button buttonUpd;
+ private System.Windows.Forms.Button buttonDel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormTickets.cs b/ProjectAirline/Forms/FormTickets.cs
new file mode 100644
index 0000000..1dd6279
--- /dev/null
+++ b/ProjectAirline/Forms/FormTickets.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Windows.Forms;
+using Unity;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Forms
+{
+ public partial class FormTickets : Form
+ {
+ private readonly IUnityContainer _container;
+ private readonly ITicketRepository _ticketRepository;
+
+ public FormTickets(IUnityContainer container, ITicketRepository ticketRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _ticketRepository = ticketRepository ?? throw new ArgumentNullException(nameof(ticketRepository));
+ }
+
+ private void FormTickets_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ _container.Resolve().ShowDialog();
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonUpd_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 ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (!TryGetIdentifierFromSelectedRow(out var findId))
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
+ {
+ return;
+ }
+ try
+ {
+ _ticketRepository.DeleteTicket(findId);
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewData.DataSource = _ticketRepository.ReadTickets();
+
+ private bool TryGetIdentifierFromSelectedRow(out int id)
+ {
+ id = 0;
+ if (dataGridViewData.SelectedRows.Count < 1)
+ {
+ MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormTickets.resx b/ProjectAirline/Forms/FormTickets.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ProjectAirline/Forms/FormTickets.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/ProjectAirline/Program.cs b/ProjectAirline/Program.cs
index 4cd196a..d64344d 100644
--- a/ProjectAirline/Program.cs
+++ b/ProjectAirline/Program.cs
@@ -1,17 +1,50 @@
-namespace ProjectAirline
+using System;
+using System.Windows.Forms;
+using Unity;
+using Unity.Lifetime;
+using YourNamespace.Repositories;
+using YourNamespace.Repositories.Implementations;
+using YourNamespace.Forms;
+
+namespace YourNamespace
{
- internal static class Program
+ static class Program
{
///
- /// The main entry point for the application.
+ /// The main entry point for the application.
///
[STAThread]
static void Main()
{
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
- ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+
+ var container = CreateContainer();
+ Application.Run(container.Resolve());
+ }
+
+ private static IUnityContainer CreateContainer()
+ {
+ var container = new UnityContainer();
+
+ //
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+
+ //
+ container.RegisterType(new ContainerControlledLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+ container.RegisterType(new TransientLifetimeManager());
+
+ return container;
}
}
}
\ No newline at end of file
diff --git a/ProjectAirline/ProjectAirline.csproj b/ProjectAirline/ProjectAirline.csproj
index 663fdb8..894afcd 100644
--- a/ProjectAirline/ProjectAirline.csproj
+++ b/ProjectAirline/ProjectAirline.csproj
@@ -8,4 +8,8 @@
enable
+
+
+
+
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/IAirportRepository.cs b/ProjectAirline/Repositories/IAirportRepository.cs
new file mode 100644
index 0000000..c756088
--- /dev/null
+++ b/ProjectAirline/Repositories/IAirportRepository.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using YourNamespace.Entities;
+
+namespace YourNamespace.Repositories
+{
+ public interface IAirportRepository
+ {
+ IEnumerable ReadAirports();
+ Airport ReadAirportById(int id);
+ void CreateAirport(Airport airport);
+ void UpdateAirport(Airport airport);
+ void DeleteAirport(int id);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/IEmployeeRepository.cs b/ProjectAirline/Repositories/IEmployeeRepository.cs
new file mode 100644
index 0000000..e69e6ff
--- /dev/null
+++ b/ProjectAirline/Repositories/IEmployeeRepository.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using YourNamespace.Entities;
+
+namespace YourNamespace.Repositories
+{
+ public interface IEmployeeRepository
+ {
+ IEnumerable ReadEmployees();
+ Employee ReadEmployeeById(int id);
+ void CreateEmployee(Employee employee);
+ void UpdateEmployee(Employee employee);
+ void DeleteEmployee(int id);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/IFlightRepository.cs b/ProjectAirline/Repositories/IFlightRepository.cs
new file mode 100644
index 0000000..eadb303
--- /dev/null
+++ b/ProjectAirline/Repositories/IFlightRepository.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using YourNamespace.Entities;
+
+namespace YourNamespace.Repositories
+{
+ public interface IFlightRepository
+ {
+ IEnumerable ReadFlights();
+ Flight ReadFlightById(int id);
+ void CreateFlight(Flight flight);
+ void UpdateFlight(Flight flight);
+ void DeleteFlight(int id);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/IPassengerRepository.cs b/ProjectAirline/Repositories/IPassengerRepository.cs
new file mode 100644
index 0000000..9c3b1fc
--- /dev/null
+++ b/ProjectAirline/Repositories/IPassengerRepository.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using YourNamespace.Entities;
+
+namespace YourNamespace.Repositories
+{
+ public interface IPassengerRepository
+ {
+ IEnumerable ReadPassengers();
+ Passenger ReadPassengerById(int id);
+ void CreatePassenger(Passenger passenger);
+ void UpdatePassenger(Passenger passenger);
+ void DeletePassenger(int id);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/IPlaneRepository.cs b/ProjectAirline/Repositories/IPlaneRepository.cs
new file mode 100644
index 0000000..6665c28
--- /dev/null
+++ b/ProjectAirline/Repositories/IPlaneRepository.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using YourNamespace.Entities;
+
+namespace YourNamespace.Repositories
+{
+ public interface IPlaneRepository
+ {
+ IEnumerable ReadPlanes();
+ Plane ReadPlaneById(int id);
+ void CreatePlane(Plane plane);
+ void UpdatePlane(Plane plane);
+ void DeletePlane(int id);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/ITicketRepository.cs b/ProjectAirline/Repositories/ITicketRepository.cs
new file mode 100644
index 0000000..a028c35
--- /dev/null
+++ b/ProjectAirline/Repositories/ITicketRepository.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using YourNamespace.Entities;
+
+namespace YourNamespace.Repositories
+{
+ public interface ITicketRepository
+ {
+ IEnumerable ReadTickets();
+ Ticket ReadTicketById(int id);
+ void CreateTicket(Ticket ticket);
+ void UpdateTicket(Ticket ticket);
+ void DeleteTicket(int id);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/Implementations/AirportRepository.cs b/ProjectAirline/Repositories/Implementations/AirportRepository.cs
new file mode 100644
index 0000000..519bc12
--- /dev/null
+++ b/ProjectAirline/Repositories/Implementations/AirportRepository.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using System.Linq;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Repositories.Implementations
+{
+ public class AirportRepository : IAirportRepository
+ {
+ private readonly List _airports = new List();
+ private int _nextId = 1;
+
+ public IEnumerable ReadAirports()
+ {
+ return _airports;
+ }
+
+ public Airport ReadAirportById(int id)
+ {
+ return _airports.FirstOrDefault(a => a.Id == id);
+ }
+
+ public void CreateAirport(Airport airport)
+ {
+ var newAirport = Airport.CreateEntity(_nextId++, airport.Name, airport.Location);
+ _airports.Add(newAirport);
+ }
+
+ public void UpdateAirport(Airport airport)
+ {
+ var existingAirport = _airports.FirstOrDefault(a => a.Id == airport.Id);
+ if (existingAirport != null)
+ {
+ var updatedAirport = Airport.CreateEntity(existingAirport.Id, airport.Name, airport.Location);
+ _airports.Remove(existingAirport);
+ _airports.Add(updatedAirport);
+ }
+ }
+
+ public void DeleteAirport(int id)
+ {
+ var airportToRemove = _airports.FirstOrDefault(a => a.Id == id);
+ if (airportToRemove != null)
+ {
+ _airports.Remove(airportToRemove);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/Implementations/EmployeeRepository.cs b/ProjectAirline/Repositories/Implementations/EmployeeRepository.cs
new file mode 100644
index 0000000..779dc94
--- /dev/null
+++ b/ProjectAirline/Repositories/Implementations/EmployeeRepository.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using System.Linq;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Repositories.Implementations
+{
+ public class EmployeeRepository : IEmployeeRepository
+ {
+ private readonly List _employees = new List();
+ private int _nextId = 1;
+
+ public IEnumerable ReadEmployees()
+ {
+ return _employees;
+ }
+
+ public Employee ReadEmployeeById(int id)
+ {
+ return _employees.FirstOrDefault(e => e.Id == id);
+ }
+
+ public void CreateEmployee(Employee employee)
+ {
+ var newEmployee = Employee.CreateEntity(_nextId++, employee.FirstName, employee.LastName, employee.EmployeePost);
+ _employees.Add(newEmployee);
+ }
+
+ public void UpdateEmployee(Employee employee)
+ {
+ var existingEmployee = _employees.FirstOrDefault(e => e.Id == employee.Id);
+ if (existingEmployee != null)
+ {
+ var updatedEmployee = Employee.CreateEntity(existingEmployee.Id, employee.FirstName, employee.LastName, employee.EmployeePost);
+ _employees.Remove(existingEmployee);
+ _employees.Add(updatedEmployee);
+ }
+ }
+
+ public void DeleteEmployee(int id)
+ {
+ var employeeToRemove = _employees.FirstOrDefault(e => e.Id == id);
+ if (employeeToRemove != null)
+ {
+ _employees.Remove(employeeToRemove);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/Implementations/FlightRepository.cs b/ProjectAirline/Repositories/Implementations/FlightRepository.cs
new file mode 100644
index 0000000..3f15b9a
--- /dev/null
+++ b/ProjectAirline/Repositories/Implementations/FlightRepository.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using System.Linq;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Repositories.Implementations
+{
+ public class FlightRepository : IFlightRepository
+ {
+ private readonly List _flights = new List();
+ private int _nextId = 1;
+
+ public IEnumerable ReadFlights()
+ {
+ return _flights;
+ }
+
+ public Flight ReadFlightById(int id)
+ {
+ return _flights.FirstOrDefault(f => f.Id == id);
+ }
+
+ public void CreateFlight(Flight flight)
+ {
+ var newFlight = Flight.CreateEntity(_nextId++, flight.FlightNumber, flight.DepartureDateTime, flight.ArrivalDateTime, flight.PlaneId, flight.AirportId);
+ _flights.Add(newFlight);
+ }
+
+ public void UpdateFlight(Flight flight)
+ {
+ var existingFlight = _flights.FirstOrDefault(f => f.Id == flight.Id);
+ if (existingFlight != null)
+ {
+ var updatedFlight = Flight.CreateEntity(existingFlight.Id, flight.FlightNumber, flight.DepartureDateTime, flight.ArrivalDateTime, flight.PlaneId, flight.AirportId);
+ _flights.Remove(existingFlight);
+ _flights.Add(updatedFlight);
+ }
+ }
+
+ public void DeleteFlight(int id)
+ {
+ var flightToRemove = _flights.FirstOrDefault(f => f.Id == id);
+ if (flightToRemove != null)
+ {
+ _flights.Remove(flightToRemove);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/Implementations/PassengerRepository.cs b/ProjectAirline/Repositories/Implementations/PassengerRepository.cs
new file mode 100644
index 0000000..aed6b6f
--- /dev/null
+++ b/ProjectAirline/Repositories/Implementations/PassengerRepository.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using System.Linq;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Repositories.Implementations
+{
+ public class PassengerRepository : IPassengerRepository
+ {
+ private readonly List _passengers = new List();
+ private int _nextId = 1;
+
+ public IEnumerable ReadPassengers()
+ {
+ return _passengers;
+ }
+
+ public Passenger ReadPassengerById(int id)
+ {
+ return _passengers.FirstOrDefault(p => p.Id == id);
+ }
+
+ public void CreatePassenger(Passenger passenger)
+ {
+ var newPassenger = Passenger.CreateEntity(_nextId++, passenger.FirstName, passenger.LastName, passenger.PassportNumber);
+ _passengers.Add(newPassenger);
+ }
+
+ public void UpdatePassenger(Passenger passenger)
+ {
+ var existingPassenger = _passengers.FirstOrDefault(p => p.Id == passenger.Id);
+ if (existingPassenger != null)
+ {
+ var updatedPassenger = Passenger.CreateEntity(existingPassenger.Id, passenger.FirstName, passenger.LastName, passenger.PassportNumber);
+ _passengers.Remove(existingPassenger);
+ _passengers.Add(updatedPassenger);
+ }
+ }
+
+ public void DeletePassenger(int id)
+ {
+ var passengerToRemove = _passengers.FirstOrDefault(p => p.Id == id);
+ if (passengerToRemove != null)
+ {
+ _passengers.Remove(passengerToRemove);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/Implementations/PlaneRepository.cs b/ProjectAirline/Repositories/Implementations/PlaneRepository.cs
new file mode 100644
index 0000000..9eecd18
--- /dev/null
+++ b/ProjectAirline/Repositories/Implementations/PlaneRepository.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using System.Linq;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Repositories.Implementations
+{
+ public class PlaneRepository : IPlaneRepository
+ {
+ private readonly List _planes = new List();
+ private int _nextId = 1;
+
+ public IEnumerable ReadPlanes()
+ {
+ return _planes;
+ }
+
+ public Plane ReadPlaneById(int id)
+ {
+ return _planes.FirstOrDefault(p => p.Id == id);
+ }
+
+ public void CreatePlane(Plane plane)
+ {
+ var newPlane = Plane.CreateEntity(_nextId++, plane.Model, plane.Capacity);
+ _planes.Add(newPlane);
+ }
+
+ public void UpdatePlane(Plane plane)
+ {
+ var existingPlane = _planes.FirstOrDefault(p => p.Id == plane.Id);
+ if (existingPlane != null)
+ {
+ var updatedPlane = Plane.CreateEntity(existingPlane.Id, plane.Model, plane.Capacity);
+ _planes.Remove(existingPlane);
+ _planes.Add(updatedPlane);
+ }
+ }
+
+ public void DeletePlane(int id)
+ {
+ var planeToRemove = _planes.FirstOrDefault(p => p.Id == id);
+ if (planeToRemove != null)
+ {
+ _planes.Remove(planeToRemove);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/Implementations/TicketRepository.cs b/ProjectAirline/Repositories/Implementations/TicketRepository.cs
new file mode 100644
index 0000000..5bd5603
--- /dev/null
+++ b/ProjectAirline/Repositories/Implementations/TicketRepository.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using System.Linq;
+using YourNamespace.Entities;
+using YourNamespace.Repositories;
+
+namespace YourNamespace.Repositories.Implementations
+{
+ public class TicketRepository : ITicketRepository
+ {
+ private readonly List _tickets = new List();
+ private int _nextId = 1;
+
+ public IEnumerable ReadTickets()
+ {
+ return _tickets;
+ }
+
+ public Ticket ReadTicketById(int id)
+ {
+ return _tickets.FirstOrDefault(t => t.Id == id);
+ }
+
+ public void CreateTicket(Ticket ticket)
+ {
+ var newTicket = Ticket.CreateEntity(_nextId++, ticket.PassengerId, ticket.FlightId, ticket.DateBuy, ticket.TicketPrice);
+ _tickets.Add(newTicket);
+ }
+
+ public void UpdateTicket(Ticket ticket)
+ {
+ var existingTicket = _tickets.FirstOrDefault(t => t.Id == ticket.Id);
+ if (existingTicket != null)
+ {
+ var updatedTicket = Ticket.CreateEntity(existingTicket.Id, ticket.PassengerId, ticket.FlightId, ticket.DateBuy, ticket.TicketPrice);
+ _tickets.Remove(existingTicket);
+ _tickets.Add(updatedTicket);
+ }
+ }
+
+ public void DeleteTicket(int id)
+ {
+ var ticketToRemove = _tickets.FirstOrDefault(t => t.Id == id);
+ if (ticketToRemove != null)
+ {
+ _tickets.Remove(ticketToRemove);
+ }
+ }
+ }
+}
\ No newline at end of file