Чиназес?
This commit is contained in:
parent
0b66daff08
commit
85b8a7c41f
132
ProjectAirline/Forms/FormPreparatoryWork.Designer.cs
generated
132
ProjectAirline/Forms/FormPreparatoryWork.Designer.cs
generated
@ -29,13 +29,15 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
labelFlightID = new Label();
|
labelFlightID = new Label();
|
||||||
labelPlaneID = new Label();
|
comboBoxFlight = new ComboBox();
|
||||||
labelPreparatoryWorkStatus = new Label();
|
|
||||||
comboBoxStatus = new ComboBox();
|
|
||||||
comboBoxFlightId = new ComboBox();
|
|
||||||
comboBoxPlaneId = new ComboBox();
|
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
ColumnPlane = new DataGridViewComboBoxColumn();
|
||||||
|
ColumnCount = new DataGridViewTextBoxColumn();
|
||||||
|
comboBoxStatus = new ComboBox();
|
||||||
|
labelStatus = new Label();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelFlightID
|
// labelFlightID
|
||||||
@ -47,64 +49,27 @@
|
|||||||
labelFlightID.TabIndex = 0;
|
labelFlightID.TabIndex = 0;
|
||||||
labelFlightID.Text = "Рейс";
|
labelFlightID.Text = "Рейс";
|
||||||
//
|
//
|
||||||
// labelPlaneID
|
// comboBoxFlight
|
||||||
//
|
//
|
||||||
labelPlaneID.AutoSize = true;
|
comboBoxFlight.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
labelPlaneID.Location = new Point(40, 80);
|
comboBoxFlight.FormattingEnabled = true;
|
||||||
labelPlaneID.Name = "labelPlaneID";
|
comboBoxFlight.Location = new Point(142, 32);
|
||||||
labelPlaneID.Size = new Size(55, 15);
|
comboBoxFlight.Name = "comboBoxFlight";
|
||||||
labelPlaneID.TabIndex = 1;
|
comboBoxFlight.Size = new Size(121, 23);
|
||||||
labelPlaneID.Text = "Самолет";
|
comboBoxFlight.TabIndex = 4;
|
||||||
//
|
|
||||||
// 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
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(40, 210);
|
buttonSave.Location = new Point(40, 311);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
buttonSave.TabIndex = 6;
|
buttonSave.TabIndex = 6;
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(188, 210);
|
buttonCancel.Location = new Point(188, 311);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
buttonCancel.TabIndex = 7;
|
buttonCancel.TabIndex = 7;
|
||||||
@ -112,21 +77,63 @@
|
|||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnPlane, ColumnCount });
|
||||||
|
dataGridView.Location = new Point(40, 130);
|
||||||
|
dataGridView.MultiSelect = false;
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.Size = new Size(223, 150);
|
||||||
|
dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ColumnPlane
|
||||||
|
//
|
||||||
|
ColumnPlane.HeaderText = "Самолет";
|
||||||
|
ColumnPlane.Name = "ColumnPlane";
|
||||||
|
//
|
||||||
|
// ColumnCount
|
||||||
|
//
|
||||||
|
ColumnCount.HeaderText = "Количество";
|
||||||
|
ColumnCount.Name = "ColumnCount";
|
||||||
|
//
|
||||||
|
// comboBoxStatus
|
||||||
|
//
|
||||||
|
comboBoxStatus.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxStatus.FormattingEnabled = true;
|
||||||
|
comboBoxStatus.Location = new Point(142, 74);
|
||||||
|
comboBoxStatus.Name = "comboBoxStatus";
|
||||||
|
comboBoxStatus.Size = new Size(121, 23);
|
||||||
|
comboBoxStatus.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// labelStatus
|
||||||
|
//
|
||||||
|
labelStatus.AutoSize = true;
|
||||||
|
labelStatus.Location = new Point(40, 74);
|
||||||
|
labelStatus.Name = "labelStatus";
|
||||||
|
labelStatus.Size = new Size(43, 15);
|
||||||
|
labelStatus.TabIndex = 10;
|
||||||
|
labelStatus.Text = "Статус";
|
||||||
|
//
|
||||||
// FormPreparatoryWork
|
// FormPreparatoryWork
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(330, 314);
|
ClientSize = new Size(290, 364);
|
||||||
|
Controls.Add(labelStatus);
|
||||||
|
Controls.Add(comboBoxStatus);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(comboBoxPlaneId);
|
Controls.Add(comboBoxFlight);
|
||||||
Controls.Add(comboBoxFlightId);
|
|
||||||
Controls.Add(comboBoxStatus);
|
|
||||||
Controls.Add(labelPreparatoryWorkStatus);
|
|
||||||
Controls.Add(labelPlaneID);
|
|
||||||
Controls.Add(labelFlightID);
|
Controls.Add(labelFlightID);
|
||||||
Name = "FormPreparatoryWork";
|
Name = "FormPreparatoryWork";
|
||||||
Text = "Подготовительные работы";
|
Text = "Подготовительные работы";
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -134,12 +141,13 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Label labelFlightID;
|
private Label labelFlightID;
|
||||||
private Label labelPlaneID;
|
private ComboBox comboBoxFlight;
|
||||||
private Label labelPreparatoryWorkStatus;
|
|
||||||
private ComboBox comboBoxStatus;
|
|
||||||
private ComboBox comboBoxFlightId;
|
|
||||||
private ComboBox comboBoxPlaneId;
|
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private ComboBox comboBoxStatus;
|
||||||
|
private Label labelStatus;
|
||||||
|
private DataGridViewComboBoxColumn ColumnPlane;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,74 +1,46 @@
|
|||||||
using ProjectAirline.Entities.Enums;
|
using System;
|
||||||
using ProjectAirline.Entities;
|
|
||||||
using ProjectAirline.Repositories;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using ProjectAirline.Repositories.Implementations;
|
using ProjectAirline.Entities;
|
||||||
|
using ProjectAirline.Entities.Enums;
|
||||||
namespace ProjectAirline.Forms;
|
using ProjectAirline.Repositories;
|
||||||
|
|
||||||
|
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;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var preparatoryWork = _preparatoryWorkRepository.ReadPreparatoryWorkById(value);
|
|
||||||
if (preparatoryWork == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(preparatoryWork));
|
|
||||||
}
|
|
||||||
comboBoxFlightId.SelectedItem = preparatoryWork.FlightId;
|
|
||||||
comboBoxStatus.SelectedItem = preparatoryWork.Status;
|
|
||||||
_preparatoryWorkId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormPreparatoryWork(IPreparatoryWorkRepository preparatoryWorkRepository, IFlightRepository flightRepository, IPlaneRepository planeRepository)
|
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));
|
ColumnPlane.DataSource = planeRepository.ReadPlanes();
|
||||||
_planeRepository = planeRepository ?? throw new ArgumentNullException(nameof(_planeRepository));
|
ColumnPlane.DisplayMember = "Name";
|
||||||
comboBoxFlightId.DataSource = _flightRepository.ReadFlights();
|
ColumnPlane.ValueMember = "Id";
|
||||||
comboBoxPlaneId.DataSource = _planeRepository.ReadPlanes();
|
|
||||||
|
|
||||||
comboBoxStatus.DataSource = Enum.GetValues(typeof(PreparatoryWorkStatus));
|
comboBoxStatus.DataSource = preparatoryWorkRepository.ReadPreparatoryWorks();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (comboBoxFlight.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Имеются незаполненные поля.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (comboBoxFlightId.SelectedIndex < 0 || comboBoxPlaneId.SelectedIndex < 0 || comboBoxStatus.SelectedIndex < 0)
|
_preparatoryWorkRepository.CreatePreparatoryWork(PreparatoryWork.CreateOperation(
|
||||||
{
|
0,
|
||||||
throw new Exception("Имеются незаполненные поля");
|
(int)comboBoxFlight.SelectedValue,
|
||||||
}
|
DateTime.Now,
|
||||||
//else
|
DateTime.Now,
|
||||||
//{
|
(PreparatoryWorkStatus)comboBoxStatus.SelectedItem,
|
||||||
// _preparatoryWorkRepository.CreatePreparatoryWork();
|
CreateListFromDataGrid()
|
||||||
//}
|
));
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -77,17 +49,23 @@ public partial class FormPreparatoryWork : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
//private PreparatoryWork CreatePreparatoryWork(int id)
|
Close();
|
||||||
//{
|
}
|
||||||
// return PreparatoryWork.CreateOperation(
|
|
||||||
// id,
|
private List<PreparatoryWorkPlane> CreateListFromDataGrid()
|
||||||
// (int)comboBoxFlightId.SelectedItem,
|
{
|
||||||
// DateTime.Now,
|
var list = new List<PreparatoryWorkPlane>();
|
||||||
// DateTime.Now.AddHours(1),
|
foreach (DataGridViewRow row in dataGridView.Rows)
|
||||||
// (PreparatoryWorkStatus)comboBoxStatus.SelectedItem
|
{
|
||||||
|
if (row.Cells["ColumnPlane"].Value == null || row.Cells["ColumnCount"].Value == null)
|
||||||
// );
|
{
|
||||||
//}
|
continue;
|
||||||
|
}
|
||||||
|
list.Add(PreparatoryWorkPlane.CreateOperation(0, 0, Convert.ToInt32(row.Cells["ColumnPlane"].Value), Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -117,4 +117,10 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="ColumnPlane.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
104
ProjectAirline/Forms/FormPreparatoryWorks.Designer.cs
generated
104
ProjectAirline/Forms/FormPreparatoryWorks.Designer.cs
generated
@ -28,59 +28,14 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
panel = new Panel();
|
|
||||||
buttonUpd = new Button();
|
|
||||||
buttonDel = new Button();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
dataGridViewData = new DataGridView();
|
dataGridViewData = new DataGridView();
|
||||||
panel.SuspendLayout();
|
buttonAdd = new Button();
|
||||||
|
buttonDel = new Button();
|
||||||
|
panel = new Panel();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
||||||
|
panel.SuspendLayout();
|
||||||
SuspendLayout();
|
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
|
||||||
//
|
//
|
||||||
dataGridViewData.AllowUserToAddRows = false;
|
dataGridViewData.AllowUserToAddRows = false;
|
||||||
@ -89,37 +44,66 @@
|
|||||||
dataGridViewData.AllowUserToResizeRows = false;
|
dataGridViewData.AllowUserToResizeRows = false;
|
||||||
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridViewData.ColumnHeadersVisible = false;
|
dataGridViewData.Dock = DockStyle.Left;
|
||||||
dataGridViewData.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewData.Location = new Point(0, 0);
|
dataGridViewData.Location = new Point(0, 0);
|
||||||
dataGridViewData.MultiSelect = false;
|
dataGridViewData.MultiSelect = false;
|
||||||
dataGridViewData.Name = "dataGridViewData";
|
dataGridViewData.Name = "dataGridViewData";
|
||||||
dataGridViewData.ReadOnly = true;
|
dataGridViewData.ReadOnly = true;
|
||||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridViewData.Size = new Size(600, 450);
|
dataGridViewData.Size = new Size(616, 450);
|
||||||
dataGridViewData.TabIndex = 1;
|
dataGridViewData.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonAdd.Location = new Point(25, 15);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 65);
|
||||||
|
buttonAdd.TabIndex = 1;
|
||||||
|
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(25, 115);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(75, 65);
|
||||||
|
buttonDel.TabIndex = 3;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonRemove_Click;
|
||||||
|
//
|
||||||
|
// panel
|
||||||
|
//
|
||||||
|
panel.Controls.Add(buttonAdd);
|
||||||
|
panel.Controls.Add(buttonDel);
|
||||||
|
panel.Dock = DockStyle.Right;
|
||||||
|
panel.Location = new Point(613, 0);
|
||||||
|
panel.Name = "panel";
|
||||||
|
panel.Size = new Size(187, 450);
|
||||||
|
panel.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// FormPreparatoryWorks
|
// FormPreparatoryWorks
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel);
|
Controls.Add(panel);
|
||||||
|
Controls.Add(dataGridViewData);
|
||||||
Name = "FormPreparatoryWorks";
|
Name = "FormPreparatoryWorks";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Подготовительные работы";
|
Text = "Подготовительные работы";
|
||||||
panel.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
|
panel.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Panel panel;
|
|
||||||
private Button buttonUpd;
|
|
||||||
private Button buttonDel;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridViewData;
|
private DataGridView dataGridViewData;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Panel panel;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
using ProjectAirline.Entities.Enums;
|
using ProjectAirline.Repositories;
|
||||||
using ProjectAirline.Entities;
|
using ProjectAirline.Repositories.Implementations;
|
||||||
using ProjectAirline.Repositories;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,177 +9,82 @@ 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 System.Xml.Linq;
|
||||||
using Unity;
|
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(IPreparatoryWorkRepository preparatoryWorkRepository, IPlaneRepository planeRepository)
|
public FormPreparatoryWorks(IUnityContainer container, IPreparatoryWorkRepository preparatoryWorkRepository)
|
||||||
{
|
{
|
||||||
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));
|
|
||||||
|
|
||||||
|
|
||||||
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 ButtonSave_Click(object sender, EventArgs e)
|
private void FormPreparatoryWorks_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (dataGridViewData.RowCount < 1)
|
LoadList();
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
|
|
||||||
var preparatoryWorkPlanes = CreateListPreparatoryWorkPlanesFromDataGrid();
|
|
||||||
|
|
||||||
var preparatoryWork = PreparatoryWork.CreateOperation(
|
|
||||||
0,
|
|
||||||
-1,
|
|
||||||
DateTime.Now,
|
|
||||||
DateTime.Now,
|
|
||||||
PreparatoryWorkStatus.None,
|
|
||||||
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 ButtonCancel_Click(object sender, EventArgs e) => Close();
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
|
||||||
private List<PreparatoryWorkPlane> CreateListPreparatoryWorkPlanesFromDataGrid()
|
|
||||||
{
|
{
|
||||||
var list = new List<PreparatoryWorkPlane>();
|
try
|
||||||
foreach (DataGridViewRow row in dataGridViewData.Rows)
|
|
||||||
{
|
{
|
||||||
if (row.Cells["ColumnPlane"].Value == null || row.Cells["ColumnCount"].Value == null)
|
_container.Resolve<FormPreparatoryWork>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
continue;
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var planeId = Convert.ToInt32(row.Cells["ColumnPlane"].Value);
|
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||||
var count = Convert.ToInt32(row.Cells["ColumnCount"].Value);
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
list.Add(PreparatoryWorkPlane.CreateOperation(0, -1, planeId, count));
|
try
|
||||||
|
{
|
||||||
|
_preparatoryWorkRepository.DeletePreparatoryWork(findId);
|
||||||
|
LoadList();
|
||||||
}
|
}
|
||||||
return list;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user