полнейшее пипяу
This commit is contained in:
parent
e6defea462
commit
735cb575f9
26
ProjectAirline/Entities/PraparatoryWorkPlane.cs
Normal file
26
ProjectAirline/Entities/PraparatoryWorkPlane.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirline.Entities;
|
||||||
|
|
||||||
|
public class PreparatoryWorkPlane
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public int PreparatoryWorkId { get; private set; }
|
||||||
|
public int PlaneId { get; private set; }
|
||||||
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
public static PreparatoryWorkPlane CreateElement(int id, int preparatoryWorkId, int planeId, int count)
|
||||||
|
{
|
||||||
|
return new PreparatoryWorkPlane
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
PreparatoryWorkId = preparatoryWorkId,
|
||||||
|
PlaneId = planeId,
|
||||||
|
Count = count
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using ProjectAirline.Entities.Enums;
|
using ProjectAirline.Entities.Enums;
|
||||||
|
using ProjectAirline.Forms;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -10,27 +11,22 @@ namespace ProjectAirline.Entities;
|
|||||||
public class PreparatoryWork
|
public class PreparatoryWork
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public int FlightId { get; private set; }
|
public int FlightId { get; private set; }
|
||||||
|
|
||||||
public int PlaneId { get; private set; }
|
|
||||||
|
|
||||||
public DateTime StartDate { get; private set; }
|
public DateTime StartDate { get; private set; }
|
||||||
|
|
||||||
public DateTime EndDate { get; private set; }
|
public DateTime EndDate { get; private set; }
|
||||||
|
|
||||||
public PreparatoryWorkStatus Status { get; private set; }
|
public PreparatoryWorkStatus Status { get; private set; }
|
||||||
|
public IEnumerable<PreparatoryWorkPlane> PreparatoryWorkPlanes { get; private set; } = Enumerable.Empty<PreparatoryWorkPlane>();
|
||||||
|
|
||||||
public static PreparatoryWork CreatePrerapatoryWork(int id, int FlightId, int PlaneId, DateTime StartDate, DateTime EndDate, PreparatoryWorkStatus Status)
|
public static PreparatoryWork CreatePreparatoryWork(int id, int flightId, DateTime startDate, DateTime endDate, PreparatoryWorkStatus status, IEnumerable<PreparatoryWorkPlane> preparatoryWorkPlanes)
|
||||||
{
|
{
|
||||||
return new PreparatoryWork
|
return new PreparatoryWork
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
FlightId = FlightId,
|
FlightId = flightId,
|
||||||
PlaneId = PlaneId,
|
StartDate = startDate,
|
||||||
StartDate = StartDate,
|
EndDate = endDate,
|
||||||
EndDate = EndDate,
|
Status = status,
|
||||||
Status = Status
|
PreparatoryWorkPlanes = preparatoryWorkPlanes
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
69
ProjectAirline/FormAirline.Designer.cs
generated
69
ProjectAirline/FormAirline.Designer.cs
generated
@ -30,13 +30,13 @@
|
|||||||
{
|
{
|
||||||
menuStrip = new MenuStrip();
|
menuStrip = new MenuStrip();
|
||||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
полетToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
пассажирыToolStripMenuItem = new ToolStripMenuItem();
|
пассажирыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
самолетыToolStripMenuItem = new ToolStripMenuItem();
|
самолетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
билетыToolStripMenuItem = new ToolStripMenuItem();
|
билетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||||
подготовительныеРаботыToolStripMenuItem = new ToolStripMenuItem();
|
подготовительныеРаботыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
полетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -51,53 +51,58 @@
|
|||||||
//
|
//
|
||||||
// справочникиToolStripMenuItem
|
// справочникиToolStripMenuItem
|
||||||
//
|
//
|
||||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { полетToolStripMenuItem, пассажирыToolStripMenuItem, самолетыToolStripMenuItem, билетыToolStripMenuItem });
|
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { пассажирыToolStripMenuItem, самолетыToolStripMenuItem, билетыToolStripMenuItem });
|
||||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||||
справочникиToolStripMenuItem.Text = "Справочники";
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
//
|
//
|
||||||
// полетToolStripMenuItem
|
// пассажирыToolStripMenuItem
|
||||||
//
|
//
|
||||||
полетToolStripMenuItem.Name = "полетToolStripMenuItem";
|
пассажирыToolStripMenuItem.Name = "пассажирыToolStripMenuItem";
|
||||||
полетToolStripMenuItem.Size = new Size(180, 22);
|
пассажирыToolStripMenuItem.Size = new Size(180, 22);
|
||||||
полетToolStripMenuItem.Text = "Полеты";
|
пассажирыToolStripMenuItem.Text = "Пассажиры";
|
||||||
|
пассажирыToolStripMenuItem.Click += PassangersToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// самолетыToolStripMenuItem
|
||||||
|
//
|
||||||
|
самолетыToolStripMenuItem.Name = "самолетыToolStripMenuItem";
|
||||||
|
самолетыToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
самолетыToolStripMenuItem.Text = "Самолеты";
|
||||||
|
самолетыToolStripMenuItem.Click += PlanesToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// билетыToolStripMenuItem
|
||||||
|
//
|
||||||
|
билетыToolStripMenuItem.Name = "билетыToolStripMenuItem";
|
||||||
|
билетыToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
билетыToolStripMenuItem.Text = "Билеты";
|
||||||
|
билетыToolStripMenuItem.Click += TicketsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// операцииToolStripMenuItem
|
// операцииToolStripMenuItem
|
||||||
//
|
//
|
||||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { подготовительныеРаботыToolStripMenuItem });
|
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { подготовительныеРаботыToolStripMenuItem, полетыToolStripMenuItem });
|
||||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||||
операцииToolStripMenuItem.Size = new Size(75, 20);
|
операцииToolStripMenuItem.Size = new Size(75, 20);
|
||||||
операцииToolStripMenuItem.Text = "Операции";
|
операцииToolStripMenuItem.Text = "Операции";
|
||||||
//
|
//
|
||||||
|
// подготовительныеРаботыToolStripMenuItem
|
||||||
|
//
|
||||||
|
подготовительныеРаботыToolStripMenuItem.Name = "подготовительныеРаботыToolStripMenuItem";
|
||||||
|
подготовительныеРаботыToolStripMenuItem.Size = new Size(223, 22);
|
||||||
|
подготовительныеРаботыToolStripMenuItem.Text = "Подготовительные работы";
|
||||||
|
подготовительныеРаботыToolStripMenuItem.Click += PreparatoryWorksToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
//
|
//
|
||||||
// пассажирыToolStripMenuItem
|
// полетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
пассажирыToolStripMenuItem.Name = "пассажирыToolStripMenuItem";
|
полетыToolStripMenuItem.Name = "полетыToolStripMenuItem";
|
||||||
пассажирыToolStripMenuItem.Size = new Size(180, 22);
|
полетыToolStripMenuItem.Size = new Size(223, 22);
|
||||||
пассажирыToolStripMenuItem.Text = "Пассажиры";
|
полетыToolStripMenuItem.Text = "Полеты";
|
||||||
//
|
полетыToolStripMenuItem.Click += FlightsToolStripMenuItem_Click;
|
||||||
// самолетыToolStripMenuItem
|
|
||||||
//
|
|
||||||
самолетыToolStripMenuItem.Name = "самолетыToolStripMenuItem";
|
|
||||||
самолетыToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
самолетыToolStripMenuItem.Text = "Самолеты";
|
|
||||||
//
|
|
||||||
// билетыToolStripMenuItem
|
|
||||||
//
|
|
||||||
билетыToolStripMenuItem.Name = "билетыToolStripMenuItem";
|
|
||||||
билетыToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
билетыToolStripMenuItem.Text = "Билеты";
|
|
||||||
//
|
|
||||||
// подготовительныеРаботыToolStripMenuItem
|
|
||||||
//
|
|
||||||
подготовительныеРаботыToolStripMenuItem.Name = "подготовительныеРаботыToolStripMenuItem";
|
|
||||||
подготовительныеРаботыToolStripMenuItem.Size = new Size(223, 22);
|
|
||||||
подготовительныеРаботыToolStripMenuItem.Text = "Подготовительные работы";
|
|
||||||
//
|
//
|
||||||
// FormAirline
|
// FormAirline
|
||||||
//
|
//
|
||||||
@ -121,12 +126,12 @@
|
|||||||
|
|
||||||
private MenuStrip menuStrip;
|
private MenuStrip menuStrip;
|
||||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||||
private ToolStripMenuItem полетToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
private ToolStripMenuItem пассажирыToolStripMenuItem;
|
private ToolStripMenuItem пассажирыToolStripMenuItem;
|
||||||
private ToolStripMenuItem самолетыToolStripMenuItem;
|
private ToolStripMenuItem самолетыToolStripMenuItem;
|
||||||
private ToolStripMenuItem билетыToolStripMenuItem;
|
private ToolStripMenuItem билетыToolStripMenuItem;
|
||||||
private ToolStripMenuItem подготовительныеРаботыToolStripMenuItem;
|
private ToolStripMenuItem подготовительныеРаботыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem полетыToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,75 @@
|
|||||||
namespace ProjectAirline
|
using ProjectAirline.Forms;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectAirline;
|
||||||
|
|
||||||
|
public partial class FormAirline : Form
|
||||||
{
|
{
|
||||||
public partial class FormAirline : Form
|
private readonly IUnityContainer _container;
|
||||||
{
|
|
||||||
public FormAirline()
|
public FormAirline(IUnityContainer container)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FlightsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormFlights>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PassangersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormPassangers>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TicketsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormTickets>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlanesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormPlanes>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PreparatoryWorksToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormPreparatoryWorks>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
ProjectAirline/Forms/FormPassanger.Designer.cs
generated
2
ProjectAirline/Forms/FormPassanger.Designer.cs
generated
@ -100,7 +100,7 @@
|
|||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Name = "FormPassanger";
|
Name = "FormPassanger";
|
||||||
Text = "FormPassanger";
|
Text = "Пассажир";
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,15 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using ProjectAirline.Repositories.Implementations;
|
||||||
|
|
||||||
namespace ProjectAirline.Forms;
|
namespace ProjectAirline.Forms;
|
||||||
|
|
||||||
public partial class FormPreparatoryWork : Form
|
public partial class FormPreparatoryWork : Form
|
||||||
{
|
{
|
||||||
private readonly IPreparatoryWorkRepository _preparatoryWorkRepository;
|
private readonly IPreparatoryWorkRepository _preparatoryWorkRepository;
|
||||||
|
private readonly IFlightRepository _flightRepository;
|
||||||
|
private readonly IPlaneRepository _planeRepository;
|
||||||
private int? _preparatoryWorkId;
|
private int? _preparatoryWorkId;
|
||||||
|
|
||||||
public int Id
|
public int Id
|
||||||
@ -30,7 +33,6 @@ public partial class FormPreparatoryWork : Form
|
|||||||
throw new InvalidDataException(nameof(preparatoryWork));
|
throw new InvalidDataException(nameof(preparatoryWork));
|
||||||
}
|
}
|
||||||
comboBoxFlightId.SelectedItem = preparatoryWork.FlightId;
|
comboBoxFlightId.SelectedItem = preparatoryWork.FlightId;
|
||||||
comboBoxPlaneId.SelectedItem = preparatoryWork.PlaneId;
|
|
||||||
comboBoxStatus.SelectedItem = preparatoryWork.Status;
|
comboBoxStatus.SelectedItem = preparatoryWork.Status;
|
||||||
_preparatoryWorkId = value;
|
_preparatoryWorkId = value;
|
||||||
}
|
}
|
||||||
@ -42,16 +44,15 @@ public partial class FormPreparatoryWork : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FormPreparatoryWork(IPreparatoryWorkRepository preparatoryWorkRepository)
|
public FormPreparatoryWork(IPreparatoryWorkRepository preparatoryWorkRepository, IFlightRepository flightRepository, IPlaneRepository planeRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_preparatoryWorkRepository = preparatoryWorkRepository ?? throw new ArgumentNullException(nameof(preparatoryWorkRepository));
|
_preparatoryWorkRepository = preparatoryWorkRepository ?? throw new ArgumentNullException(nameof(preparatoryWorkRepository));
|
||||||
|
_flightRepository = flightRepository ?? throw new ArgumentNullException(nameof(_flightRepository));
|
||||||
|
_planeRepository = planeRepository ?? throw new ArgumentNullException(nameof(_planeRepository));
|
||||||
|
comboBoxFlightId.DataSource = _flightRepository.ReadFlights();
|
||||||
|
comboBoxPlaneId.DataSource = _planeRepository.ReadPlanes();
|
||||||
|
|
||||||
// Заполнение comboBoxFlightId и comboBoxPlaneId данными из репозитория
|
|
||||||
comboBoxFlightId.DataSource = _preparatoryWorkRepository.GetFlightIds();
|
|
||||||
comboBoxPlaneId.DataSource = _preparatoryWorkRepository.GetPlaneIds();
|
|
||||||
|
|
||||||
// Заполнение comboBoxStatus данными из перечисления PreparatoryWorkStatus
|
|
||||||
comboBoxStatus.DataSource = Enum.GetValues(typeof(PreparatoryWorkStatus));
|
comboBoxStatus.DataSource = Enum.GetValues(typeof(PreparatoryWorkStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,10 +89,10 @@ public partial class FormPreparatoryWork : Form
|
|||||||
return PreparatoryWork.CreatePreparatoryWork(
|
return PreparatoryWork.CreatePreparatoryWork(
|
||||||
id,
|
id,
|
||||||
(int)comboBoxFlightId.SelectedItem,
|
(int)comboBoxFlightId.SelectedItem,
|
||||||
(int)comboBoxPlaneId.SelectedItem,
|
|
||||||
DateTime.Now,
|
DateTime.Now,
|
||||||
DateTime.Now.AddHours(1),
|
DateTime.Now.AddHours(1),
|
||||||
(PreparatoryWorkStatus)comboBoxStatus.SelectedItem
|
(PreparatoryWorkStatus)comboBoxStatus.SelectedItem
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,38 +48,38 @@
|
|||||||
panel.Size = new Size(200, 450);
|
panel.Size = new Size(200, 450);
|
||||||
panel.TabIndex = 0;
|
panel.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// buttonUpd
|
//// buttonUpd
|
||||||
//
|
////
|
||||||
buttonUpd.BackgroundImage = Properties.Resources.Antu_qtdesigner_svg;
|
//buttonUpd.BackgroundImage = Properties.Resources.Antu_qtdesigner_svg;
|
||||||
buttonUpd.BackgroundImageLayout = ImageLayout.Zoom;
|
//buttonUpd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
buttonUpd.Location = new Point(51, 148);
|
//buttonUpd.Location = new Point(51, 148);
|
||||||
buttonUpd.Name = "buttonUpd";
|
//buttonUpd.Name = "buttonUpd";
|
||||||
buttonUpd.Size = new Size(79, 65);
|
//buttonUpd.Size = new Size(79, 65);
|
||||||
buttonUpd.TabIndex = 2;
|
//buttonUpd.TabIndex = 2;
|
||||||
buttonUpd.UseVisualStyleBackColor = true;
|
//buttonUpd.UseVisualStyleBackColor = true;
|
||||||
buttonUpd.Click += ButtonUpd_Click;
|
//buttonUpd.Click += ButtonUpd_Click;
|
||||||
//
|
////
|
||||||
// buttonDel
|
//// buttonDel
|
||||||
//
|
////
|
||||||
buttonDel.BackgroundImage = Properties.Resources.kisspng_computer_icons_download_5b218289889485_4804831415289227615594;
|
//buttonDel.BackgroundImage = Properties.Resources.kisspng_computer_icons_download_5b218289889485_4804831415289227615594;
|
||||||
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
//buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
buttonDel.Location = new Point(51, 248);
|
//buttonDel.Location = new Point(51, 248);
|
||||||
buttonDel.Name = "buttonDel";
|
//buttonDel.Name = "buttonDel";
|
||||||
buttonDel.Size = new Size(79, 65);
|
//buttonDel.Size = new Size(79, 65);
|
||||||
buttonDel.TabIndex = 1;
|
//buttonDel.TabIndex = 1;
|
||||||
buttonDel.UseVisualStyleBackColor = true;
|
//buttonDel.UseVisualStyleBackColor = true;
|
||||||
buttonDel.Click += ButtonDel_Click;
|
//buttonDel.Click += ButtonDel_Click;
|
||||||
//
|
////
|
||||||
// buttonAdd
|
//// buttonAdd
|
||||||
//
|
////
|
||||||
buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
|
//buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
|
||||||
buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
|
//buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
buttonAdd.Location = new Point(51, 44);
|
//buttonAdd.Location = new Point(51, 44);
|
||||||
buttonAdd.Name = "buttonAdd";
|
//buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(79, 65);
|
//buttonAdd.Size = new Size(79, 65);
|
||||||
buttonAdd.TabIndex = 0;
|
//buttonAdd.TabIndex = 0;
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
//buttonAdd.UseVisualStyleBackColor = true;
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
//buttonAdd.Click += ButtonAdd_Click;
|
||||||
//
|
//
|
||||||
// dataGridViewData
|
// dataGridViewData
|
||||||
//
|
//
|
||||||
@ -107,6 +107,7 @@
|
|||||||
Controls.Add(dataGridViewData);
|
Controls.Add(dataGridViewData);
|
||||||
Controls.Add(panel);
|
Controls.Add(panel);
|
||||||
Name = "FormPreparatoryWorks";
|
Name = "FormPreparatoryWorks";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Подготовительные работы";
|
Text = "Подготовительные работы";
|
||||||
Load += FormPreparatoryWorks_Load;
|
Load += FormPreparatoryWorks_Load;
|
||||||
panel.ResumeLayout(false);
|
panel.ResumeLayout(false);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using ProjectAirline.Repositories;
|
using ProjectAirline.Entities.Enums;
|
||||||
|
using ProjectAirline.Entities;
|
||||||
|
using ProjectAirline.Repositories;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -12,94 +14,173 @@ using Unity;
|
|||||||
|
|
||||||
namespace ProjectAirline.Forms;
|
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<FormPreparatoryWork>().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<FormPreparatoryWork>();
|
||||||
|
// 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;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
public partial class FormPreparatoryWorks : Form
|
public partial class FormPreparatoryWorks : Form
|
||||||
{
|
{
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly IPreparatoryWorkRepository _preparatoryWorkRepository;
|
private readonly IPreparatoryWorkRepository _preparatoryWorkRepository;
|
||||||
|
private readonly IPlaneRepository _planeRepository;
|
||||||
|
|
||||||
public FormPreparatoryWorks(IUnityContainer container, IPreparatoryWorkRepository preparatoryWorkRepository)
|
public FormPreparatoryWorks(IPreparatoryWorkRepository preparatoryWorkRepository, IPlaneRepository planeRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_preparatoryWorkRepository = preparatoryWorkRepository ?? throw new ArgumentNullException(nameof(preparatoryWorkRepository));
|
_preparatoryWorkRepository = preparatoryWorkRepository ?? throw new ArgumentNullException(nameof(preparatoryWorkRepository));
|
||||||
|
_planeRepository = planeRepository ?? throw new ArgumentNullException(nameof(planeRepository));
|
||||||
|
|
||||||
|
// Настройка DataGridView
|
||||||
|
dataGridViewData.AutoGenerateColumns = false;
|
||||||
|
dataGridViewData.Columns.Add(new DataGridViewComboBoxColumn
|
||||||
|
{
|
||||||
|
Name = "ColumnPlane",
|
||||||
|
HeaderText = "Самолет",
|
||||||
|
DataSource = _planeRepository.ReadPlanes(),
|
||||||
|
DisplayMember = "Name",
|
||||||
|
ValueMember = "Id",
|
||||||
|
DataPropertyName = "PlaneId"
|
||||||
|
});
|
||||||
|
dataGridViewData.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
Name = "ColumnCount",
|
||||||
|
HeaderText = "Количество",
|
||||||
|
DataPropertyName = "Count"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormPreparatoryWorks_Load(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoadList();
|
if (dataGridViewData.RowCount < 1)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
|
||||||
|
var preparatoryWorkPlanes = CreateListPreparatoryWorkPlanesFromDataGrid();
|
||||||
|
|
||||||
|
var preparatoryWork = PreparatoryWork.CreatePreparatoryWork(
|
||||||
|
0, // ID будет присвоен при сохранении
|
||||||
|
-1, // FlightId (если нужно, добавьте поле для ввода)
|
||||||
|
DateTime.Now, // StartDate (если нужно, добавьте поле для ввода)
|
||||||
|
DateTime.Now, // EndDate (если нужно, добавьте поле для ввода)
|
||||||
|
PreparatoryWorkStatus.None, // Status (если нужно, добавьте поле для ввода)
|
||||||
|
preparatoryWorkPlanes
|
||||||
|
);
|
||||||
|
|
||||||
|
_preparatoryWorkRepository.CreatePreparatoryWork(preparatoryWork);
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private List<PreparatoryWorkPlane> CreateListPreparatoryWorkPlanesFromDataGrid()
|
||||||
{
|
{
|
||||||
try
|
var list = new List<PreparatoryWorkPlane>();
|
||||||
|
foreach (DataGridViewRow row in dataGridViewData.Rows)
|
||||||
{
|
{
|
||||||
_container.Resolve<FormPreparatoryWork>().ShowDialog();
|
if (row.Cells["ColumnPlane"].Value == null || row.Cells["ColumnCount"].Value == null)
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
var planeId = Convert.ToInt32(row.Cells["ColumnPlane"].Value);
|
||||||
{
|
var count = Convert.ToInt32(row.Cells["ColumnCount"].Value);
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormPreparatoryWork>();
|
|
||||||
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)
|
list.Add(PreparatoryWorkPlane.CreateElement(0, -1, planeId, count));
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
return list;
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
ProjectAirline/Forms/FormTicket.Designer.cs
generated
4
ProjectAirline/Forms/FormTicket.Designer.cs
generated
@ -60,7 +60,7 @@
|
|||||||
buttonSave.TabIndex = 3;
|
buttonSave.TabIndex = 3;
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
buttonSave.Click += buttonSave_Click;
|
buttonSave.Click += ButtonSave_Click;
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
@ -70,7 +70,7 @@
|
|||||||
buttonCancel.TabIndex = 4;
|
buttonCancel.TabIndex = 4;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += buttonCancel_Click;
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
// FormTicket
|
// FormTicket
|
||||||
//
|
//
|
||||||
|
@ -10,20 +10,55 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Microsoft.VisualBasic.FileIO;
|
||||||
|
|
||||||
namespace ProjectAirline.Forms;
|
namespace ProjectAirline.Forms;
|
||||||
|
|
||||||
public partial class FormTicket : Form
|
public partial class FormTicket : Form
|
||||||
{
|
{
|
||||||
private readonly ITicketRepository _ticketRepository;
|
private readonly ITicketRepository _ticketRepository;
|
||||||
|
private int? _ticketId;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ticket = _ticketRepository.ReadTicketById(value);
|
||||||
|
if (ticket == null)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException(nameof(ticket));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (TicketStatus elem in Enum.GetValues(typeof(TicketStatus)))
|
||||||
|
{
|
||||||
|
if ((elem & ticket.Status) != 0)
|
||||||
|
{
|
||||||
|
checkedListBoxStatus.SetItemChecked(checkedListBoxStatus.Items.IndexOf(elem), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_ticketId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public FormTicket(ITicketRepository ticketRepository)
|
public FormTicket(ITicketRepository ticketRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_ticketRepository = ticketRepository ?? throw new ArgumentNullException(nameof(ticketRepository));
|
_ticketRepository = ticketRepository ?? throw new ArgumentNullException(nameof(ticketRepository));
|
||||||
|
|
||||||
//Тут нада чета делать но я пьяный уже пол 2 ночи пора спать
|
foreach (var elem in Enum.GetValues(typeof(TicketStatus)))
|
||||||
//checkedListBoxStatus.Items.AddRange(Enum.GetValues(typeof(TicketStatus)).Cast<TicketStatus>().ToArray());
|
{
|
||||||
|
checkedListBoxStatus.Items.Add(elem);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
@ -36,7 +71,15 @@ public partial class FormTicket : Form
|
|||||||
throw new Exception("Необходимо выбрать хотя бы один статус");
|
throw new Exception("Необходимо выбрать хотя бы один статус");
|
||||||
}
|
}
|
||||||
|
|
||||||
_ticketRepository.CreateTicket(Ticket.CreateTicket(0, status));
|
if (_ticketId.HasValue)
|
||||||
|
{
|
||||||
|
_ticketRepository.UpdateTicket(CreateTicket(_ticketId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ticketRepository.CreateTicket(CreateTicket(0));
|
||||||
|
}
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -47,6 +90,12 @@ public partial class FormTicket : Form
|
|||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private Ticket CreateTicket(int id)
|
||||||
|
{
|
||||||
|
var status = GetTicketStatusFromCheckedListBox();
|
||||||
|
return Ticket.CreateTicket(id, status);
|
||||||
|
}
|
||||||
|
|
||||||
private TicketStatus GetTicketStatusFromCheckedListBox()
|
private TicketStatus GetTicketStatusFromCheckedListBox()
|
||||||
{
|
{
|
||||||
TicketStatus status = TicketStatus.None;
|
TicketStatus status = TicketStatus.None;
|
||||||
|
125
ProjectAirline/Forms/FormTickets.Designer.cs
generated
Normal file
125
ProjectAirline/Forms/FormTickets.Designer.cs
generated
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
namespace ProjectAirline.Forms
|
||||||
|
{
|
||||||
|
partial class FormTickets
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
panel = new Panel();
|
||||||
|
dataGridViewData = new DataGridView();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonUpd = new Button();
|
||||||
|
buttonDel = new Button();
|
||||||
|
panel.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel
|
||||||
|
//
|
||||||
|
panel.Controls.Add(buttonDel);
|
||||||
|
panel.Controls.Add(buttonUpd);
|
||||||
|
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;
|
||||||
|
//
|
||||||
|
// 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;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonAdd.Location = new Point(35, 70);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(69, 65);
|
||||||
|
buttonAdd.TabIndex = 0;
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.BackgroundImage = Properties.Resources.Antu_qtdesigner_svg;
|
||||||
|
buttonUpd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonUpd.Location = new Point(35, 166);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(69, 65);
|
||||||
|
buttonUpd.TabIndex = 1;
|
||||||
|
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(35, 264);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(69, 65);
|
||||||
|
buttonDel.TabIndex = 2;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// FormTickets
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(dataGridViewData);
|
||||||
|
Controls.Add(panel);
|
||||||
|
Name = "FormTickets";
|
||||||
|
Text = "Билеты";
|
||||||
|
Load += FormTickets_Load;
|
||||||
|
panel.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridViewData;
|
||||||
|
}
|
||||||
|
}
|
105
ProjectAirline/Forms/FormTickets.cs
Normal file
105
ProjectAirline/Forms/FormTickets.cs
Normal file
@ -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 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<FormTicket>().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<FormTicket>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
120
ProjectAirline/Forms/FormTickets.resx
Normal file
120
ProjectAirline/Forms/FormTickets.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -15,6 +15,7 @@ public interface IPreparatoryWorkRepository
|
|||||||
void CreatePreparatoryWork(PreparatoryWork preparatoryWork);
|
void CreatePreparatoryWork(PreparatoryWork preparatoryWork);
|
||||||
|
|
||||||
void UpdatePreparatoryWork(PreparatoryWork preparatoryWork);
|
void UpdatePreparatoryWork(PreparatoryWork preparatoryWork);
|
||||||
|
|
||||||
void DeletePreparatoryWork(int id);
|
void DeletePreparatoryWork(int id);
|
||||||
|
|
||||||
PreparatoryWork ReadPreparatoryWorkById(int id);
|
PreparatoryWork ReadPreparatoryWorkById(int id);
|
||||||
|
@ -21,13 +21,20 @@ public class PreparatoryWorkRepository : IPreparatoryWorkRepository
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PreparatoryWork ReadPreparatoryWorkById(int id)
|
public PreparatoryWork ReadPreparatoryWorkById(int id)
|
||||||
{
|
{
|
||||||
return PreparatoryWork.CreatePrerapatoryWork(0, 0, 0, DateTime.Now, DateTime.Now, 0);
|
return PreparatoryWork.CreatePreparatoryWork(0, 0, DateTime.Now, DateTime.Now, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<PreparatoryWork> ReadPreparatoryWork(DateTime? dateFrom = null, int? planeId = null, int? flightId = null, DateTime? dateTo = null, int? preparatoryWorkId = null, PreparatoryWork? preparatoryWorkStatus = null)
|
public IEnumerable<PreparatoryWork> ReadPreparatoryWork(DateTime? dateFrom = null, int? planeId = null, int? flightId = null, DateTime? dateTo = null, int? preparatoryWorkId = null, PreparatoryWork? preparatoryWorkStatus = null)
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<PreparatoryWork> ReadPreparatoryWorks()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user