diff --git a/ProjectAirline/Entities/Passanger.cs b/ProjectAirline/Entities/Passanger.cs
index 8eee72d..5751a63 100644
--- a/ProjectAirline/Entities/Passanger.cs
+++ b/ProjectAirline/Entities/Passanger.cs
@@ -10,14 +10,17 @@ public class Passanger
{
public int Id { get; private set; }
- public string Name { get; private set; } = string.Empty;
+ public string FirstName { get; private set; } = string.Empty;
- public static Passanger CreatePassanger(int id, string name)
+ public string LastName { get; private set; } = string.Empty;
+
+ public static Passanger CreatePassanger(int id, string fname, string lname)
{
return new Passanger
{
Id = id,
- Name = name,
+ FirstName = fname,
+ LastName = lname
};
}
}
diff --git a/ProjectAirline/Entities/PreparatoryWork.cs b/ProjectAirline/Entities/PreparatoryWork.cs
index c9dae7b..add5718 100644
--- a/ProjectAirline/Entities/PreparatoryWork.cs
+++ b/ProjectAirline/Entities/PreparatoryWork.cs
@@ -11,17 +11,23 @@ public class PreparatoryWork
{
public int Id { get; private set; }
+ public int FlightId { get; private set; }
+
+ public int PlaneId { get; private set; }
+
public DateTime StartDate { get; private set; }
public DateTime EndDate { get; private set; }
public PreparatoryWorkStatus Status { get; private set; }
- public static PreparatoryWork CreatePrerapatoryWork(int id, DateTime StartDate, DateTime EndDate, PreparatoryWorkStatus Status)
+ public static PreparatoryWork CreatePrerapatoryWork(int id, int FlightId, int PlaneId, DateTime StartDate, DateTime EndDate, PreparatoryWorkStatus Status)
{
return new PreparatoryWork
{
Id = id,
+ FlightId = FlightId,
+ PlaneId = PlaneId,
StartDate = StartDate,
EndDate = EndDate,
Status = Status
diff --git a/ProjectAirline/Forms/FormFlight.Designer.cs b/ProjectAirline/Forms/FormFlight.Designer.cs
index bfefc71..cab4115 100644
--- a/ProjectAirline/Forms/FormFlight.Designer.cs
+++ b/ProjectAirline/Forms/FormFlight.Designer.cs
@@ -28,115 +28,92 @@
///
private void InitializeComponent()
{
- label1 = new Label();
- label2 = new Label();
- label3 = new Label();
- textBox1 = new TextBox();
- label4 = new Label();
- numericUpDown1 = new NumericUpDown();
- buttonFlightSave = new Button();
- buttonFlightCancel = new Button();
- ((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit();
+ labelArrivalLocation = new Label();
+ textBoxArrivalLocation = new TextBox();
+ labelTicketPrice = new Label();
+ numericUpDownTicketPrice = new NumericUpDown();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownTicketPrice).BeginInit();
SuspendLayout();
//
- // label1
+ // labelArrivalLocation
//
- label1.AutoSize = true;
- label1.Location = new Point(32, 35);
- label1.Name = "label1";
- label1.Size = new Size(74, 15);
- label1.TabIndex = 0;
- label1.Text = "Дата вылета";
+ labelArrivalLocation.AutoSize = true;
+ labelArrivalLocation.Location = new Point(30, 53);
+ labelArrivalLocation.Name = "labelArrivalLocation";
+ labelArrivalLocation.Size = new Size(100, 15);
+ labelArrivalLocation.TabIndex = 2;
+ labelArrivalLocation.Text = "Место прибытия";
//
- // label2
+ // textBoxArrivalLocation
//
- label2.AutoSize = true;
- label2.Location = new Point(32, 71);
- label2.Name = "label2";
- label2.Size = new Size(90, 15);
- label2.TabIndex = 1;
- label2.Text = "Дата прибытия";
+ textBoxArrivalLocation.Location = new Point(145, 53);
+ textBoxArrivalLocation.Name = "textBoxArrivalLocation";
+ textBoxArrivalLocation.Size = new Size(100, 23);
+ textBoxArrivalLocation.TabIndex = 3;
//
- // label3
+ // labelTicketPrice
//
- label3.AutoSize = true;
- label3.Location = new Point(32, 109);
- label3.Name = "label3";
- label3.Size = new Size(100, 15);
- label3.TabIndex = 2;
- label3.Text = "Место прибытия";
+ labelTicketPrice.AutoSize = true;
+ labelTicketPrice.Location = new Point(30, 117);
+ labelTicketPrice.Name = "labelTicketPrice";
+ labelTicketPrice.Size = new Size(76, 15);
+ labelTicketPrice.TabIndex = 4;
+ labelTicketPrice.Text = "Цена билета";
//
- // textBox1
+ // numericUpDownTicketPrice
//
- textBox1.Location = new Point(145, 106);
- textBox1.Name = "textBox1";
- textBox1.Size = new Size(100, 23);
- textBox1.TabIndex = 3;
+ numericUpDownTicketPrice.Location = new Point(145, 115);
+ numericUpDownTicketPrice.Name = "numericUpDownTicketPrice";
+ numericUpDownTicketPrice.Size = new Size(100, 23);
+ numericUpDownTicketPrice.TabIndex = 5;
//
- // label4
+ // buttonSave
//
- label4.AutoSize = true;
- label4.Location = new Point(32, 148);
- label4.Name = "label4";
- label4.Size = new Size(76, 15);
- label4.TabIndex = 4;
- label4.Text = "Цена билета";
+ buttonSave.Location = new Point(30, 223);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
//
- // numericUpDown1
+ // buttonCancel
//
- numericUpDown1.Location = new Point(145, 146);
- numericUpDown1.Name = "numericUpDown1";
- numericUpDown1.Size = new Size(100, 23);
- numericUpDown1.TabIndex = 5;
- //
- // buttonFlightSave
- //
- buttonFlightSave.Location = new Point(30, 223);
- buttonFlightSave.Name = "buttonFlightSave";
- buttonFlightSave.Size = new Size(75, 23);
- buttonFlightSave.TabIndex = 6;
- buttonFlightSave.Text = "Сохранить";
- buttonFlightSave.UseVisualStyleBackColor = true;
- //
- // buttonFlightCancel
- //
- buttonFlightCancel.Location = new Point(152, 223);
- buttonFlightCancel.Name = "buttonFlightCancel";
- buttonFlightCancel.Size = new Size(75, 23);
- buttonFlightCancel.TabIndex = 7;
- buttonFlightCancel.Text = "Отмена";
- buttonFlightCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Location = new Point(152, 223);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 7;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
//
// FormFlight
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(273, 282);
- Controls.Add(buttonFlightCancel);
- Controls.Add(buttonFlightSave);
- Controls.Add(numericUpDown1);
- Controls.Add(label4);
- Controls.Add(textBox1);
- Controls.Add(label3);
- Controls.Add(label2);
- Controls.Add(label1);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(numericUpDownTicketPrice);
+ Controls.Add(labelTicketPrice);
+ Controls.Add(textBoxArrivalLocation);
+ Controls.Add(labelArrivalLocation);
Name = "FormFlight";
StartPosition = FormStartPosition.CenterParent;
- Text = "Полет";
- ((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit();
+ Text = "Рейс";
+ ((System.ComponentModel.ISupportInitialize)numericUpDownTicketPrice).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
-
- private Label label1;
- private Label label2;
- private Label label3;
- private TextBox textBox1;
- private Label label4;
- private NumericUpDown numericUpDown1;
- private Button buttonFlightSave;
- private Button buttonFlightCancel;
+ private Label labelArrivalLocation;
+ private TextBox textBoxArrivalLocation;
+ private Label labelTicketPrice;
+ private NumericUpDown numericUpDownTicketPrice;
+ private Button buttonSave;
+ private Button buttonCancel;
}
}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormFlight.cs b/ProjectAirline/Forms/FormFlight.cs
index d201249..faa2539 100644
--- a/ProjectAirline/Forms/FormFlight.cs
+++ b/ProjectAirline/Forms/FormFlight.cs
@@ -1,4 +1,6 @@
-using System;
+using ProjectAirline.Entities;
+using ProjectAirline.Repositories;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -8,13 +10,70 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
-namespace ProjectAirline.Forms
+namespace ProjectAirline.Forms;
+
+
+public partial class FormFlight : Form
{
- public partial class FormFlight : Form
+ private readonly IFlightRepository _flightRepository;
+ private int? _flightId;
+
+ public int Id
{
- public FormFlight()
+ set
{
- InitializeComponent();
+ try
+ {
+ var flight = _flightRepository.ReadFlightById(value);
+ if (flight == null)
+ {
+ throw new InvalidDataException(nameof(flight));
+ }
+ textBoxArrivalLocation.Text = flight.ArrivalLocation;
+ numericUpDownTicketPrice.Value = flight.TicketPrice;
+ _flightId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
}
}
+
+ public FormFlight(IFlightRepository flightRepository)
+ {
+ InitializeComponent();
+ _flightRepository = flightRepository ?? throw new ArgumentNullException(nameof(flightRepository));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxArrivalLocation.Text))
+ {
+ 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.CreateFlight(id, DateTime.Now, DateTime.Now.AddHours(2), textBoxArrivalLocation.Text, Convert.ToInt32(numericUpDownTicketPrice.Value));
}
diff --git a/ProjectAirline/Forms/FormFlights.Designer.cs b/ProjectAirline/Forms/FormFlights.Designer.cs
new file mode 100644
index 0000000..977adc2
--- /dev/null
+++ b/ProjectAirline/Forms/FormFlights.Designer.cs
@@ -0,0 +1,123 @@
+namespace ProjectAirline.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()
+ {
+ panel = new Panel();
+ buttonAdd = new Button();
+ buttonDel = new Button();
+ buttonUpd = new Button();
+ dataGridViewData = new DataGridView();
+ panel.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
+ SuspendLayout();
+ //
+ // panel
+ //
+ panel.Controls.Add(buttonAdd);
+ panel.Controls.Add(buttonDel);
+ panel.Controls.Add(buttonUpd);
+ panel.Dock = DockStyle.Right;
+ panel.Location = new Point(652, 0);
+ panel.Name = "panel";
+ panel.Size = new Size(148, 450);
+ panel.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
+ buttonAdd.Location = new Point(43, 44);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(70, 59);
+ buttonAdd.TabIndex = 2;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.BackgroundImage = Properties.Resources.kisspng_computer_icons_download_5b218289889485_4804831415289227615594;
+ buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDel.Location = new Point(43, 244);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(70, 59);
+ buttonDel.TabIndex = 1;
+ buttonDel.UseVisualStyleBackColor = true;
+ //
+ // buttonUpd
+ //
+ buttonUpd.BackgroundImage = Properties.Resources.Antu_qtdesigner_svg;
+ buttonUpd.BackgroundImageLayout = ImageLayout.Zoom;
+ buttonUpd.Location = new Point(43, 137);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(70, 59);
+ buttonUpd.TabIndex = 0;
+ buttonUpd.UseVisualStyleBackColor = true;
+ //
+ // dataGridViewData
+ //
+ dataGridViewData.AllowUserToAddRows = false;
+ dataGridViewData.AllowUserToDeleteRows = false;
+ dataGridViewData.AllowUserToResizeColumns = false;
+ dataGridViewData.AllowUserToResizeRows = false;
+ dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewData.Dock = DockStyle.Fill;
+ dataGridViewData.Location = new Point(0, 0);
+ dataGridViewData.MultiSelect = false;
+ dataGridViewData.Name = "dataGridViewData";
+ dataGridViewData.ReadOnly = true;
+ dataGridViewData.RowHeadersVisible = false;
+ dataGridViewData.Size = new Size(652, 450);
+ dataGridViewData.TabIndex = 1;
+ //
+ // FormFlights
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridViewData);
+ Controls.Add(panel);
+ Name = "FormFlights";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Полеты";
+ Load += FormFlights_Load;
+ panel.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel panel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ private Button buttonDel;
+ private DataGridView dataGridViewData;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormFlights.cs b/ProjectAirline/Forms/FormFlights.cs
new file mode 100644
index 0000000..53fb9b4
--- /dev/null
+++ b/ProjectAirline/Forms/FormFlights.cs
@@ -0,0 +1,107 @@
+using ProjectAirline.Repositories;
+using ProjectAirline.Repositories.Implementations;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Xml.Linq;
+using Unity;
+
+namespace ProjectAirline.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..af32865
--- /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/FormPassanger.Designer.cs b/ProjectAirline/Forms/FormPassanger.Designer.cs
new file mode 100644
index 0000000..4f98a7c
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassanger.Designer.cs
@@ -0,0 +1,117 @@
+namespace ProjectAirline.Forms
+{
+ partial class FormPassanger
+ {
+ ///
+ /// 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()
+ {
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ labelFirstName = new Label();
+ textBoxFirstName = new TextBox();
+ labelLastName = new Label();
+ textBoxLastName = new TextBox();
+ SuspendLayout();
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(30, 216);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 0;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(164, 216);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 1;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // labelFirstName
+ //
+ labelFirstName.AutoSize = true;
+ labelFirstName.Location = new Point(50, 60);
+ labelFirstName.Name = "labelFirstName";
+ labelFirstName.Size = new Size(31, 15);
+ labelFirstName.TabIndex = 2;
+ labelFirstName.Text = "Имя";
+ //
+ // textBoxFirstName
+ //
+ textBoxFirstName.Location = new Point(129, 57);
+ textBoxFirstName.Name = "textBoxFirstName";
+ textBoxFirstName.Size = new Size(100, 23);
+ textBoxFirstName.TabIndex = 3;
+ //
+ // labelLastName
+ //
+ labelLastName.AutoSize = true;
+ labelLastName.Location = new Point(50, 118);
+ labelLastName.Name = "labelLastName";
+ labelLastName.Size = new Size(58, 15);
+ labelLastName.TabIndex = 4;
+ labelLastName.Text = "Фамилия";
+ //
+ // textBoxLastName
+ //
+ textBoxLastName.Location = new Point(129, 115);
+ textBoxLastName.Name = "textBoxLastName";
+ textBoxLastName.Size = new Size(100, 23);
+ textBoxLastName.TabIndex = 5;
+ //
+ // FormPassanger
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(281, 290);
+ Controls.Add(textBoxLastName);
+ Controls.Add(labelLastName);
+ Controls.Add(textBoxFirstName);
+ Controls.Add(labelFirstName);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Name = "FormPassanger";
+ Text = "FormPassanger";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label labelFirstName;
+ private TextBox textBoxFirstName;
+ private Label labelLastName;
+ private TextBox textBoxLastName;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPassanger.cs b/ProjectAirline/Forms/FormPassanger.cs
new file mode 100644
index 0000000..365d80a
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassanger.cs
@@ -0,0 +1,78 @@
+using ProjectAirline.Entities;
+using ProjectAirline.Repositories;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ProjectAirline.Forms;
+
+public partial class FormPassanger : Form
+{
+ private readonly IPassangerRepository _passangerRepository;
+ private int? _passangerId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var passenger = _passangerRepository.ReadPassangerById(value);
+ if (passenger == null)
+ {
+ throw new InvalidDataException(nameof(passenger));
+ }
+ textBoxFirstName.Text = passenger.FirstName;
+ textBoxFirstName.Text = passenger.LastName;
+ _passangerId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormPassanger(IPassangerRepository passengerRepository)
+ {
+ InitializeComponent();
+ _passangerRepository = passengerRepository ?? throw new ArgumentNullException(nameof(passengerRepository));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxFirstName.Text))
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+
+ if (_passangerId.HasValue)
+ {
+ _passangerRepository.UpdatePassanger(CreatePassanger(_passangerId.Value));
+ }
+ else
+ {
+ _passangerRepository.CreatePassanger(CreatePassanger(0));
+ }
+
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private Passanger CreatePassanger(int id) => Passanger.CreatePassanger(id, textBoxFirstName.Text, textBoxFirstName.Text);
+}
diff --git a/ProjectAirline/Forms/FormPassanger.resx b/ProjectAirline/Forms/FormPassanger.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassanger.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/FormPassangers.Designer.cs b/ProjectAirline/Forms/FormPassangers.Designer.cs
new file mode 100644
index 0000000..a72822a
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassangers.Designer.cs
@@ -0,0 +1,126 @@
+namespace ProjectAirline.Forms
+{
+ partial class FormPassangers
+ {
+ ///
+ /// 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()
+ {
+ panel = new Panel();
+ buttonUpd = new Button();
+ buttonDel = new Button();
+ buttonAdd = new Button();
+ dataGridViewData = new DataGridView();
+ panel.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
+ SuspendLayout();
+ //
+ // panel
+ //
+ panel.Controls.Add(buttonUpd);
+ panel.Controls.Add(buttonDel);
+ panel.Controls.Add(buttonAdd);
+ panel.Dock = DockStyle.Right;
+ panel.Location = new Point(630, 0);
+ panel.Name = "panel";
+ panel.Size = new Size(170, 450);
+ panel.TabIndex = 0;
+ //
+ // buttonUpd
+ //
+ buttonUpd.BackgroundImage = Properties.Resources.Antu_qtdesigner_svg;
+ buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUpd.Location = new Point(48, 131);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(73, 68);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += ButtonUpd_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.BackgroundImage = Properties.Resources.kisspng_computer_icons_download_5b218289889485_4804831415289227615594;
+ buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDel.Location = new Point(48, 227);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(73, 68);
+ buttonDel.TabIndex = 1;
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += ButtonDel_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonAdd.Location = new Point(48, 29);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(73, 68);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridViewData
+ //
+ dataGridViewData.AllowUserToAddRows = false;
+ dataGridViewData.AllowUserToDeleteRows = false;
+ dataGridViewData.AllowUserToResizeColumns = false;
+ dataGridViewData.AllowUserToResizeRows = false;
+ dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewData.Dock = DockStyle.Fill;
+ dataGridViewData.Location = new Point(0, 0);
+ dataGridViewData.MultiSelect = false;
+ dataGridViewData.Name = "dataGridViewData";
+ dataGridViewData.ReadOnly = true;
+ dataGridViewData.RowHeadersVisible = false;
+ dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewData.Size = new Size(630, 450);
+ dataGridViewData.TabIndex = 1;
+ //
+ // FormPassangers
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridViewData);
+ Controls.Add(panel);
+ Name = "FormPassangers";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Пассажиры";
+ Load += FormPassangers_Load;
+ panel.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel panel;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonAdd;
+ private DataGridView dataGridViewData;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPassangers.cs b/ProjectAirline/Forms/FormPassangers.cs
new file mode 100644
index 0000000..6abab9c
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassangers.cs
@@ -0,0 +1,105 @@
+using ProjectAirline.Repositories;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Unity;
+
+namespace ProjectAirline.Forms;
+
+public partial class FormPassangers : Form
+{
+ private readonly IUnityContainer _container;
+ private readonly IPassangerRepository _passangerRepository;
+
+ public FormPassangers(IUnityContainer container, IPassangerRepository passangerRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _passangerRepository = passangerRepository ?? throw new ArgumentNullException(nameof(passangerRepository));
+ }
+
+ private void FormPassangers_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
+ {
+ _passangerRepository.DeletePassanger(findId);
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewData.DataSource = _passangerRepository.ReadPassangers();
+
+ 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;
+ }
+}
diff --git a/ProjectAirline/Forms/FormPassangers.resx b/ProjectAirline/Forms/FormPassangers.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectAirline/Forms/FormPassangers.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..430e224
--- /dev/null
+++ b/ProjectAirline/Forms/FormPlane.Designer.cs
@@ -0,0 +1,120 @@
+namespace ProjectAirline.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()
+ {
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ labelName = new Label();
+ labelCapacity = new Label();
+ textBoxName = new TextBox();
+ numericUpDownCapacity = new NumericUpDown();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).BeginInit();
+ SuspendLayout();
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(49, 233);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 0;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(174, 233);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 1;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(49, 75);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(59, 15);
+ labelName.TabIndex = 2;
+ labelName.Text = "Название";
+ //
+ // labelCapacity
+ //
+ labelCapacity.AutoSize = true;
+ labelCapacity.Location = new Point(49, 132);
+ labelCapacity.Name = "labelCapacity";
+ labelCapacity.Size = new Size(80, 15);
+ labelCapacity.TabIndex = 3;
+ labelCapacity.Text = "Вместимость";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(174, 75);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(105, 23);
+ textBoxName.TabIndex = 4;
+ //
+ // numericUpDownCapacity
+ //
+ numericUpDownCapacity.Location = new Point(174, 130);
+ numericUpDownCapacity.Name = "numericUpDownCapacity";
+ numericUpDownCapacity.Size = new Size(120, 23);
+ numericUpDownCapacity.TabIndex = 5;
+ //
+ // FormPlane
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(325, 321);
+ Controls.Add(numericUpDownCapacity);
+ Controls.Add(textBoxName);
+ Controls.Add(labelCapacity);
+ Controls.Add(labelName);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Name = "FormPlane";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Самолет";
+ ((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label labelName;
+ private Label labelCapacity;
+ private TextBox textBoxName;
+ private NumericUpDown numericUpDownCapacity;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPlane.cs b/ProjectAirline/Forms/FormPlane.cs
new file mode 100644
index 0000000..f8bc98e
--- /dev/null
+++ b/ProjectAirline/Forms/FormPlane.cs
@@ -0,0 +1,78 @@
+using ProjectAirline.Repositories;
+using ProjectAirline.Entities;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ProjectAirline.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));
+ }
+ textBoxName.Text = plane.Name;
+ 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(textBoxName.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.CreatePlane(id, textBoxName.Text, Convert.ToInt32(numericUpDownCapacity.Value));
+}
diff --git a/ProjectAirline/Forms/FormPlane.resx b/ProjectAirline/Forms/FormPlane.resx
new file mode 100644
index 0000000..af32865
--- /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..ceaa3f7
--- /dev/null
+++ b/ProjectAirline/Forms/FormPlanes.Designer.cs
@@ -0,0 +1,126 @@
+namespace ProjectAirline.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()
+ {
+ dataGridViewData = new DataGridView();
+ panel = new Panel();
+ buttonUpd = new Button();
+ buttonDel = new Button();
+ buttonAdd = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
+ panel.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridViewData
+ //
+ dataGridViewData.AllowUserToAddRows = false;
+ dataGridViewData.AllowUserToDeleteRows = false;
+ dataGridViewData.AllowUserToResizeColumns = false;
+ dataGridViewData.AllowUserToResizeRows = false;
+ dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewData.ColumnHeadersVisible = false;
+ dataGridViewData.Dock = DockStyle.Fill;
+ dataGridViewData.Location = new Point(0, 0);
+ dataGridViewData.MultiSelect = false;
+ dataGridViewData.Name = "dataGridViewData";
+ dataGridViewData.ReadOnly = true;
+ dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewData.Size = new Size(800, 450);
+ dataGridViewData.TabIndex = 0;
+ //
+ // panel
+ //
+ panel.Controls.Add(buttonUpd);
+ panel.Controls.Add(buttonDel);
+ panel.Controls.Add(buttonAdd);
+ panel.Dock = DockStyle.Right;
+ panel.Location = new Point(600, 0);
+ panel.Name = "panel";
+ panel.Size = new Size(200, 450);
+ panel.TabIndex = 1;
+ //
+ // buttonUpd
+ //
+ buttonUpd.BackgroundImage = Properties.Resources.Antu_qtdesigner_svg;
+ buttonUpd.BackgroundImageLayout = ImageLayout.Zoom;
+ buttonUpd.Location = new Point(54, 133);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(75, 68);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += ButtonUpd_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.BackgroundImage = Properties.Resources.kisspng_computer_icons_download_5b218289889485_4804831415289227615594;
+ buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDel.Location = new Point(54, 225);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(75, 68);
+ buttonDel.TabIndex = 1;
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += ButtonDel_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
+ buttonAdd.Location = new Point(54, 42);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(75, 68);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // FormPlanes
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(panel);
+ Controls.Add(dataGridViewData);
+ Name = "FormPlanes";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Самолеты";
+ Load += FormPlanes_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
+ panel.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridViewData;
+ private Panel panel;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonAdd;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPlanes.cs b/ProjectAirline/Forms/FormPlanes.cs
new file mode 100644
index 0000000..dd68eea
--- /dev/null
+++ b/ProjectAirline/Forms/FormPlanes.cs
@@ -0,0 +1,105 @@
+using ProjectAirline.Repositories;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Unity;
+
+namespace ProjectAirline.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;
+ }
+}
diff --git a/ProjectAirline/Forms/FormPlanes.resx b/ProjectAirline/Forms/FormPlanes.resx
new file mode 100644
index 0000000..af32865
--- /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/FormPreparatoryWork.Designer.cs b/ProjectAirline/Forms/FormPreparatoryWork.Designer.cs
new file mode 100644
index 0000000..c0ad7e9
--- /dev/null
+++ b/ProjectAirline/Forms/FormPreparatoryWork.Designer.cs
@@ -0,0 +1,145 @@
+namespace ProjectAirline.Forms
+{
+ partial class FormPreparatoryWork
+ {
+ ///
+ /// 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()
+ {
+ labelFlightID = new Label();
+ labelPlaneID = new Label();
+ labelPreparatoryWorkStatus = new Label();
+ comboBoxStatus = new ComboBox();
+ comboBoxFlightId = new ComboBox();
+ comboBoxPlaneId = new ComboBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelFlightID
+ //
+ labelFlightID.AutoSize = true;
+ labelFlightID.Location = new Point(40, 32);
+ labelFlightID.Name = "labelFlightID";
+ labelFlightID.Size = new Size(33, 15);
+ labelFlightID.TabIndex = 0;
+ labelFlightID.Text = "Рейс";
+ //
+ // labelPlaneID
+ //
+ labelPlaneID.AutoSize = true;
+ labelPlaneID.Location = new Point(40, 80);
+ labelPlaneID.Name = "labelPlaneID";
+ labelPlaneID.Size = new Size(55, 15);
+ labelPlaneID.TabIndex = 1;
+ labelPlaneID.Text = "Самолет";
+ //
+ // labelPreparatoryWorkStatus
+ //
+ labelPreparatoryWorkStatus.AutoSize = true;
+ labelPreparatoryWorkStatus.Location = new Point(40, 130);
+ labelPreparatoryWorkStatus.Name = "labelPreparatoryWorkStatus";
+ labelPreparatoryWorkStatus.Size = new Size(43, 15);
+ labelPreparatoryWorkStatus.TabIndex = 2;
+ labelPreparatoryWorkStatus.Text = "Статус";
+ //
+ // comboBoxStatus
+ //
+ comboBoxStatus.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxStatus.FormattingEnabled = true;
+ comboBoxStatus.Location = new Point(142, 130);
+ comboBoxStatus.Name = "comboBoxStatus";
+ comboBoxStatus.Size = new Size(121, 23);
+ comboBoxStatus.TabIndex = 3;
+ //
+ // comboBoxFlightId
+ //
+ comboBoxFlightId.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxFlightId.FormattingEnabled = true;
+ comboBoxFlightId.Location = new Point(142, 32);
+ comboBoxFlightId.Name = "comboBoxFlightId";
+ comboBoxFlightId.Size = new Size(121, 23);
+ comboBoxFlightId.TabIndex = 4;
+ //
+ // comboBoxPlaneId
+ //
+ comboBoxPlaneId.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxPlaneId.FormattingEnabled = true;
+ comboBoxPlaneId.Location = new Point(142, 80);
+ comboBoxPlaneId.Name = "comboBoxPlaneId";
+ comboBoxPlaneId.Size = new Size(121, 23);
+ comboBoxPlaneId.TabIndex = 5;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(40, 210);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(188, 210);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 7;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormPreparatoryWork
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(330, 314);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(comboBoxPlaneId);
+ Controls.Add(comboBoxFlightId);
+ Controls.Add(comboBoxStatus);
+ Controls.Add(labelPreparatoryWorkStatus);
+ Controls.Add(labelPlaneID);
+ Controls.Add(labelFlightID);
+ Name = "FormPreparatoryWork";
+ Text = "Подготовительные работы";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelFlightID;
+ private Label labelPlaneID;
+ private Label labelPreparatoryWorkStatus;
+ private ComboBox comboBoxStatus;
+ private ComboBox comboBoxFlightId;
+ private ComboBox comboBoxPlaneId;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPreparatoryWork.cs b/ProjectAirline/Forms/FormPreparatoryWork.cs
new file mode 100644
index 0000000..73d6f48
--- /dev/null
+++ b/ProjectAirline/Forms/FormPreparatoryWork.cs
@@ -0,0 +1,97 @@
+using ProjectAirline.Entities.Enums;
+using ProjectAirline.Entities;
+using ProjectAirline.Repositories;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ProjectAirline.Forms;
+
+public partial class FormPreparatoryWork : Form
+{
+ private readonly IPreparatoryWorkRepository _preparatoryWorkRepository;
+ private int? _preparatoryWorkId;
+
+ public int Id
+ {
+ set
+ {
+ try
+ {
+ var preparatoryWork = _preparatoryWorkRepository.ReadPreparatoryWorkById(value);
+ if (preparatoryWork == null)
+ {
+ throw new InvalidDataException(nameof(preparatoryWork));
+ }
+ comboBoxFlightId.SelectedItem = preparatoryWork.FlightId;
+ comboBoxPlaneId.SelectedItem = preparatoryWork.PlaneId;
+ comboBoxStatus.SelectedItem = preparatoryWork.Status;
+ _preparatoryWorkId = value;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ }
+
+ public FormPreparatoryWork(IPreparatoryWorkRepository preparatoryWorkRepository)
+ {
+ InitializeComponent();
+ _preparatoryWorkRepository = preparatoryWorkRepository ?? throw new ArgumentNullException(nameof(preparatoryWorkRepository));
+
+ // Заполнение comboBoxFlightId и comboBoxPlaneId данными из репозитория
+ comboBoxFlightId.DataSource = _preparatoryWorkRepository.GetFlightIds();
+ comboBoxPlaneId.DataSource = _preparatoryWorkRepository.GetPlaneIds();
+
+ // Заполнение comboBoxStatus данными из перечисления PreparatoryWorkStatus
+ comboBoxStatus.DataSource = Enum.GetValues(typeof(PreparatoryWorkStatus));
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (comboBoxFlightId.SelectedIndex < 0 || comboBoxPlaneId.SelectedIndex < 0 || comboBoxStatus.SelectedIndex < 0)
+ {
+ throw new Exception("Имеются незаполненные поля");
+ }
+
+ if (_preparatoryWorkId.HasValue)
+ {
+ _preparatoryWorkRepository.UpdatePreparatoryWork(CreatePreparatoryWork(_preparatoryWorkId.Value));
+ }
+ else
+ {
+ _preparatoryWorkRepository.CreatePreparatoryWork(CreatePreparatoryWork(0));
+ }
+
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private PreparatoryWork CreatePreparatoryWork(int id)
+ {
+ return PreparatoryWork.CreatePreparatoryWork(
+ id,
+ (int)comboBoxFlightId.SelectedItem,
+ (int)comboBoxPlaneId.SelectedItem,
+ DateTime.Now,
+ DateTime.Now.AddHours(1),
+ (PreparatoryWorkStatus)comboBoxStatus.SelectedItem
+ );
+ }
+}
diff --git a/ProjectAirline/Forms/FormPreparatoryWork.resx b/ProjectAirline/Forms/FormPreparatoryWork.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectAirline/Forms/FormPreparatoryWork.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/FormPreparatoryWorks.Designer.cs b/ProjectAirline/Forms/FormPreparatoryWorks.Designer.cs
new file mode 100644
index 0000000..0a809fa
--- /dev/null
+++ b/ProjectAirline/Forms/FormPreparatoryWorks.Designer.cs
@@ -0,0 +1,125 @@
+namespace ProjectAirline.Forms
+{
+ partial class FormPreparatoryWorks
+ {
+ ///
+ /// 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()
+ {
+ panel = new Panel();
+ buttonUpd = new Button();
+ buttonDel = new Button();
+ buttonAdd = new Button();
+ dataGridViewData = new DataGridView();
+ panel.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
+ SuspendLayout();
+ //
+ // panel
+ //
+ panel.Controls.Add(buttonUpd);
+ panel.Controls.Add(buttonDel);
+ panel.Controls.Add(buttonAdd);
+ panel.Dock = DockStyle.Right;
+ panel.Location = new Point(600, 0);
+ panel.Name = "panel";
+ panel.Size = new Size(200, 450);
+ panel.TabIndex = 0;
+ //
+ // buttonUpd
+ //
+ buttonUpd.BackgroundImage = Properties.Resources.Antu_qtdesigner_svg;
+ buttonUpd.BackgroundImageLayout = ImageLayout.Zoom;
+ buttonUpd.Location = new Point(51, 148);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(79, 65);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += ButtonUpd_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.BackgroundImage = Properties.Resources.kisspng_computer_icons_download_5b218289889485_4804831415289227615594;
+ buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDel.Location = new Point(51, 248);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(79, 65);
+ buttonDel.TabIndex = 1;
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += ButtonDel_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
+ buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
+ buttonAdd.Location = new Point(51, 44);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(79, 65);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridViewData
+ //
+ dataGridViewData.AllowUserToAddRows = false;
+ dataGridViewData.AllowUserToDeleteRows = false;
+ dataGridViewData.AllowUserToResizeColumns = false;
+ dataGridViewData.AllowUserToResizeRows = false;
+ dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewData.ColumnHeadersVisible = false;
+ dataGridViewData.Dock = DockStyle.Fill;
+ dataGridViewData.Location = new Point(0, 0);
+ dataGridViewData.MultiSelect = false;
+ dataGridViewData.Name = "dataGridViewData";
+ dataGridViewData.ReadOnly = true;
+ dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewData.Size = new Size(600, 450);
+ dataGridViewData.TabIndex = 1;
+ //
+ // FormPreparatoryWorks
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridViewData);
+ Controls.Add(panel);
+ Name = "FormPreparatoryWorks";
+ Text = "Подготовительные работы";
+ Load += FormPreparatoryWorks_Load;
+ panel.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel panel;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonAdd;
+ private DataGridView dataGridViewData;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormPreparatoryWorks.cs b/ProjectAirline/Forms/FormPreparatoryWorks.cs
new file mode 100644
index 0000000..4df3dd8
--- /dev/null
+++ b/ProjectAirline/Forms/FormPreparatoryWorks.cs
@@ -0,0 +1,105 @@
+using ProjectAirline.Repositories;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Unity;
+
+namespace ProjectAirline.Forms;
+
+public partial class FormPreparatoryWorks : Form
+{
+ private readonly IUnityContainer _container;
+ private readonly IPreparatoryWorkRepository _preparatoryWorkRepository;
+
+ public FormPreparatoryWorks(IUnityContainer container, IPreparatoryWorkRepository preparatoryWorkRepository)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ _preparatoryWorkRepository = preparatoryWorkRepository ?? throw new ArgumentNullException(nameof(preparatoryWorkRepository));
+ }
+
+ private void FormPreparatoryWorks_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
+ {
+ _preparatoryWorkRepository.DeletePreparatoryWork(findId);
+ LoadList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void LoadList() => dataGridViewData.DataSource = _preparatoryWorkRepository.ReadPreparatoryWorks();
+
+ 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;
+ }
+}
diff --git a/ProjectAirline/Forms/FormPreparatoryWorks.resx b/ProjectAirline/Forms/FormPreparatoryWorks.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectAirline/Forms/FormPreparatoryWorks.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/Properties/Resources.Designer.cs b/ProjectAirline/Properties/Resources.Designer.cs
index e6fce52..933a756 100644
--- a/ProjectAirline/Properties/Resources.Designer.cs
+++ b/ProjectAirline/Properties/Resources.Designer.cs
@@ -60,6 +60,36 @@ namespace ProjectAirline.Properties {
}
}
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Antu_qtdesigner_svg {
+ get {
+ object obj = ResourceManager.GetObject("Antu_qtdesigner.svg", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Fairytale_button_add_svg {
+ get {
+ object obj = ResourceManager.GetObject("Fairytale_button_add.svg", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap kisspng_computer_icons_download_5b218289889485_4804831415289227615594 {
+ get {
+ object obj = ResourceManager.GetObject("kisspng-computer-icons-download-5b218289889485.4804831415289227615594", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
///
diff --git a/ProjectAirline/Properties/Resources.resx b/ProjectAirline/Properties/Resources.resx
index 190f64f..51a8f38 100644
--- a/ProjectAirline/Properties/Resources.resx
+++ b/ProjectAirline/Properties/Resources.resx
@@ -121,4 +121,13 @@
..\Resources\scale_1200.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\Antu_qtdesigner.svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\Fairytale_button_add.svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\kisspng-computer-icons-download-5b218289889485.4804831415289227615594.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/IFlightRepository.cs b/ProjectAirline/Repositories/IFlightRepository.cs
index 88490e6..71edc84 100644
--- a/ProjectAirline/Repositories/IFlightRepository.cs
+++ b/ProjectAirline/Repositories/IFlightRepository.cs
@@ -9,17 +9,19 @@ namespace ProjectAirline.Repositories;
public interface IFlightRepository
{
+ Flight ReadFlightById(int id);
+
IEnumerable ReadFlights(DateTime? dateFrom = null, DateTime? dateTo = null, int? flightId = null);
void CreateFlight(Flight flight);
//IEnumerable ReadFlights();
- //Flight ReadFlightById(int id);
+
//void CreateFlight(Flight flight);
- //void UpdateFlight(Flight flight);
+ void UpdateFlight(Flight flight);
- //void DeleteFlight(int id);
+ void DeleteFlight(int id);
}
diff --git a/ProjectAirline/Repositories/IPreparatoryWorkRepository.cs b/ProjectAirline/Repositories/IPreparatoryWorkRepository.cs
index 4f6fa00..f8d619e 100644
--- a/ProjectAirline/Repositories/IPreparatoryWorkRepository.cs
+++ b/ProjectAirline/Repositories/IPreparatoryWorkRepository.cs
@@ -9,10 +9,15 @@ namespace ProjectAirline.Repositories;
public interface IPreparatoryWorkRepository
{
- IEnumerable ReadPreparatoryWork(DateTime? dateFrom = null, DateTime? dateTo = null, int? preparatoryWorkId = null,
+ IEnumerable ReadPreparatoryWork(DateTime? dateFrom = null, int? planeId = null, int? flightId = null, DateTime? dateTo = null, int? preparatoryWorkId = null,
PreparatoryWork? preparatoryWorkStatus = null);
void CreatePreparatoryWork(PreparatoryWork preparatoryWork);
+ void UpdatePreparatoryWork(PreparatoryWork preparatoryWork);
void DeletePreparatoryWork(int id);
+
+ PreparatoryWork ReadPreparatoryWorkById(int id);
+
+ IEnumerable ReadPreparatoryWorks();
}
diff --git a/ProjectAirline/Repositories/Implementations/FlightRepository.cs b/ProjectAirline/Repositories/Implementations/FlightRepository.cs
index 0660a0b..c82dcab 100644
--- a/ProjectAirline/Repositories/Implementations/FlightRepository.cs
+++ b/ProjectAirline/Repositories/Implementations/FlightRepository.cs
@@ -19,21 +19,21 @@ public class FlightRepository : IFlightRepository
}
- //public void DeleteFlight(int id)
- //{
- //}
+ public void DeleteFlight(int id)
+ {
+ }
- //public Flight ReadFlightById(int id)
- //{
- // return Flight.CreateFlight(0, DateTime.Now, DateTime.Now, string.Empty, 0);
- //}
+ public Flight ReadFlightById(int id)
+ {
+ return Flight.CreateFlight(0, DateTime.Now, DateTime.Now, string.Empty, 0);
+ }
//public IEnumerable ReadFlights()
//{
// return [];
//}
- //public void UpdateFlight(Flight flight)
- //{
- //}
+ public void UpdateFlight(Flight flight)
+ {
+ }
}
diff --git a/ProjectAirline/Repositories/Implementations/PassangerRepository.cs b/ProjectAirline/Repositories/Implementations/PassangerRepository.cs
index 5a3cd05..cb810da 100644
--- a/ProjectAirline/Repositories/Implementations/PassangerRepository.cs
+++ b/ProjectAirline/Repositories/Implementations/PassangerRepository.cs
@@ -19,7 +19,7 @@ public class PassangerRepository : IPassangerRepository
public Passanger ReadPassangerById(int id)
{
- return Passanger.CreatePassanger(0, string.Empty);
+ return Passanger.CreatePassanger(0, string.Empty, string.Empty);
}
public IEnumerable ReadPassangers()
diff --git a/ProjectAirline/Repositories/Implementations/PreparatoryWorkRepository.cs b/ProjectAirline/Repositories/Implementations/PreparatoryWorkRepository.cs
index 6914af7..7b19aed 100644
--- a/ProjectAirline/Repositories/Implementations/PreparatoryWorkRepository.cs
+++ b/ProjectAirline/Repositories/Implementations/PreparatoryWorkRepository.cs
@@ -16,8 +16,17 @@ public class PreparatoryWorkRepository : IPreparatoryWorkRepository
public void DeletePreparatoryWork(int id)
{
}
+
+ public void UpdatePreparatoryWork(PreparatoryWork preparatoryWork)
+ {
+ }
- public IEnumerable ReadPreparatoryWork(DateTime? dateFrom = null, DateTime? dateTo = null, int? preparatoryWorkId = null, PreparatoryWork? preparatoryWorkStatus = null)
+ public PreparatoryWork ReadPreparatoryWorkById(int id)
+ {
+ return PreparatoryWork.CreatePrerapatoryWork(0, 0, 0, DateTime.Now, DateTime.Now, 0);
+ }
+
+ public IEnumerable ReadPreparatoryWork(DateTime? dateFrom = null, int? planeId = null, int? flightId = null, DateTime? dateTo = null, int? preparatoryWorkId = null, PreparatoryWork? preparatoryWorkStatus = null)
{
return [];
}
diff --git a/ProjectAirline/Resources/Antu_qtdesigner.svg.png b/ProjectAirline/Resources/Antu_qtdesigner.svg.png
new file mode 100644
index 0000000..7d0dfd9
Binary files /dev/null and b/ProjectAirline/Resources/Antu_qtdesigner.svg.png differ
diff --git a/ProjectAirline/Resources/Fairytale_button_add.svg.png b/ProjectAirline/Resources/Fairytale_button_add.svg.png
new file mode 100644
index 0000000..e4d9850
Binary files /dev/null and b/ProjectAirline/Resources/Fairytale_button_add.svg.png differ
diff --git a/ProjectAirline/Resources/kisspng-computer-icons-download-5b218289889485.4804831415289227615594.jpg b/ProjectAirline/Resources/kisspng-computer-icons-download-5b218289889485.4804831415289227615594.jpg
new file mode 100644
index 0000000..158be96
Binary files /dev/null and b/ProjectAirline/Resources/kisspng-computer-icons-download-5b218289889485.4804831415289227615594.jpg differ