Гуд лак некст тайм

This commit is contained in:
RavilGismatullin 2024-12-11 10:49:39 +04:00
parent 735cb575f9
commit 8ec32cd38e
21 changed files with 71 additions and 81 deletions

View File

@ -18,7 +18,7 @@ public class Flight
public int TicketPrice { get; private set; } public int TicketPrice { get; private set; }
public static Flight CreateFlight(int id, DateTime dateTimeDeparture, DateTime dateTimeArrival, string arrivalLocation, int ticketPrice) public static Flight CreateOperation(int id, DateTime dateTimeDeparture, DateTime dateTimeArrival, string arrivalLocation, int ticketPrice)
{ {
return new Flight return new Flight
{ {

View File

@ -14,7 +14,7 @@ public class Passanger
public string LastName { get; private set; } = string.Empty; public string LastName { get; private set; } = string.Empty;
public static Passanger CreatePassanger(int id, string fname, string lname) public static Passanger CreateEntity(int id, string fname, string lname)
{ {
return new Passanger return new Passanger
{ {

View File

@ -14,7 +14,7 @@ public class Plane
public int Capacity { get; private set; } public int Capacity { get; private set; }
public static Plane CreatePlane(int id, string name, int capacity) public static Plane CreateEntity(int id, string name, int capacity)
{ {
return new Plane return new Plane
{ {

View File

@ -15,9 +15,9 @@ public class PreparatoryWork
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 IEnumerable<PreparatoryWorkPlane> PreparatoryWorkPlanes { get; private set; } = [];
public static PreparatoryWork CreatePreparatoryWork(int id, int flightId, DateTime startDate, DateTime endDate, PreparatoryWorkStatus status, IEnumerable<PreparatoryWorkPlane> preparatoryWorkPlanes) public static PreparatoryWork CreateOperation(int id, int flightId, DateTime startDate, DateTime endDate, PreparatoryWorkStatus status, IEnumerable<PreparatoryWorkPlane> preparatoryWorkPlanes)
{ {
return new PreparatoryWork return new PreparatoryWork
{ {

View File

@ -13,7 +13,7 @@ public class PreparatoryWorkPlane
public int PlaneId { get; private set; } public int PlaneId { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
public static PreparatoryWorkPlane CreateElement(int id, int preparatoryWorkId, int planeId, int count) public static PreparatoryWorkPlane CreateOperation(int id, int preparatoryWorkId, int planeId, int count)
{ {
return new PreparatoryWorkPlane return new PreparatoryWorkPlane
{ {

View File

@ -15,7 +15,7 @@ public class Ticket
public TicketStatus Status { get; private set; } public TicketStatus Status { get; private set; }
public static Ticket CreateTicket(int id, TicketStatus status) public static Ticket CreateEntity(int id, TicketStatus status)
{ {
return new Ticket return new Ticket
{ {

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
@ -117,7 +117,12 @@
<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="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>17, 17</value> <value>17, 17</value>
</metadata> </data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="scale_1200" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\scale_1200.jpg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root> </root>

View File

@ -75,5 +75,5 @@ public partial class FormFlight : Form
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); 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)); private Flight CreateFlight(int id) => Flight.CreateOperation(id, DateTime.Now, DateTime.Now.AddHours(2), textBoxArrivalLocation.Text, Convert.ToInt32(numericUpDownTicketPrice.Value));
} }

View File

@ -74,5 +74,5 @@ public partial class FormPassanger : Form
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Passanger CreatePassanger(int id) => Passanger.CreatePassanger(id, textBoxFirstName.Text, textBoxFirstName.Text); private Passanger CreatePassanger(int id) => Passanger.CreateEntity(id, textBoxFirstName.Text, textBoxFirstName.Text);
} }

View File

@ -74,5 +74,5 @@ public partial class FormPlane : Form
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Plane CreatePlane(int id) => Plane.CreatePlane(id, textBoxName.Text, Convert.ToInt32(numericUpDownCapacity.Value)); private Plane CreatePlane(int id) => Plane.CreateEntity(id, textBoxName.Text, Convert.ToInt32(numericUpDownCapacity.Value));
} }

View File

@ -64,15 +64,10 @@ public partial class FormPreparatoryWork : Form
{ {
throw new Exception("Имеются незаполненные поля"); throw new Exception("Имеются незаполненные поля");
} }
//else
if (_preparatoryWorkId.HasValue) //{
{ // _preparatoryWorkRepository.CreatePreparatoryWork();
_preparatoryWorkRepository.UpdatePreparatoryWork(CreatePreparatoryWork(_preparatoryWorkId.Value)); //}
}
else
{
_preparatoryWorkRepository.CreatePreparatoryWork(CreatePreparatoryWork(0));
}
Close(); Close();
} }
@ -84,15 +79,15 @@ public partial class FormPreparatoryWork : Form
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private PreparatoryWork CreatePreparatoryWork(int id) //private PreparatoryWork CreatePreparatoryWork(int id)
{ //{
return PreparatoryWork.CreatePreparatoryWork( // return PreparatoryWork.CreateOperation(
id, // id,
(int)comboBoxFlightId.SelectedItem, // (int)comboBoxFlightId.SelectedItem,
DateTime.Now, // DateTime.Now,
DateTime.Now.AddHours(1), // DateTime.Now.AddHours(1),
(PreparatoryWorkStatus)comboBoxStatus.SelectedItem // (PreparatoryWorkStatus)comboBoxStatus.SelectedItem
); // );
} //}
} }

View File

@ -109,7 +109,6 @@
Name = "FormPreparatoryWorks"; Name = "FormPreparatoryWorks";
StartPosition = FormStartPosition.CenterParent; StartPosition = FormStartPosition.CenterParent;
Text = "Подготовительные работы"; Text = "Подготовительные работы";
Load += FormPreparatoryWorks_Load;
panel.ResumeLayout(false); panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false); ResumeLayout(false);

View File

@ -116,7 +116,7 @@ public partial class FormPreparatoryWorks : Form
_preparatoryWorkRepository = preparatoryWorkRepository ?? throw new ArgumentNullException(nameof(preparatoryWorkRepository)); _preparatoryWorkRepository = preparatoryWorkRepository ?? throw new ArgumentNullException(nameof(preparatoryWorkRepository));
_planeRepository = planeRepository ?? throw new ArgumentNullException(nameof(planeRepository)); _planeRepository = planeRepository ?? throw new ArgumentNullException(nameof(planeRepository));
// Настройка DataGridView
dataGridViewData.AutoGenerateColumns = false; dataGridViewData.AutoGenerateColumns = false;
dataGridViewData.Columns.Add(new DataGridViewComboBoxColumn dataGridViewData.Columns.Add(new DataGridViewComboBoxColumn
{ {
@ -146,12 +146,12 @@ public partial class FormPreparatoryWorks : Form
var preparatoryWorkPlanes = CreateListPreparatoryWorkPlanesFromDataGrid(); var preparatoryWorkPlanes = CreateListPreparatoryWorkPlanesFromDataGrid();
var preparatoryWork = PreparatoryWork.CreatePreparatoryWork( var preparatoryWork = PreparatoryWork.CreateOperation(
0, // ID будет присвоен при сохранении 0,
-1, // FlightId (если нужно, добавьте поле для ввода) -1,
DateTime.Now, // StartDate (если нужно, добавьте поле для ввода) DateTime.Now,
DateTime.Now, // EndDate (если нужно, добавьте поле для ввода) DateTime.Now,
PreparatoryWorkStatus.None, // Status (если нужно, добавьте поле для ввода) PreparatoryWorkStatus.None,
preparatoryWorkPlanes preparatoryWorkPlanes
); );
@ -179,7 +179,7 @@ public partial class FormPreparatoryWorks : Form
var planeId = Convert.ToInt32(row.Cells["ColumnPlane"].Value); var planeId = Convert.ToInt32(row.Cells["ColumnPlane"].Value);
var count = Convert.ToInt32(row.Cells["ColumnCount"].Value); var count = Convert.ToInt32(row.Cells["ColumnCount"].Value);
list.Add(PreparatoryWorkPlane.CreateElement(0, -1, planeId, count)); list.Add(PreparatoryWorkPlane.CreateOperation(0, -1, planeId, count));
} }
return list; return list;
} }

View File

@ -93,7 +93,7 @@ public partial class FormTicket : Form
private Ticket CreateTicket(int id) private Ticket CreateTicket(int id)
{ {
var status = GetTicketStatusFromCheckedListBox(); var status = GetTicketStatusFromCheckedListBox();
return Ticket.CreateTicket(id, status); return Ticket.CreateEntity(id, status);
} }
private TicketStatus GetTicketStatusFromCheckedListBox() private TicketStatus GetTicketStatusFromCheckedListBox()

View File

@ -17,10 +17,6 @@ public interface IFlightRepository
//IEnumerable<Flight> ReadFlights(); //IEnumerable<Flight> ReadFlights();
//void CreateFlight(Flight flight);
void UpdateFlight(Flight flight); void UpdateFlight(Flight flight);
void DeleteFlight(int id); void DeleteFlight(int id);

View File

@ -14,8 +14,6 @@ public interface IPreparatoryWorkRepository
void CreatePreparatoryWork(PreparatoryWork preparatoryWork); void CreatePreparatoryWork(PreparatoryWork preparatoryWork);
void UpdatePreparatoryWork(PreparatoryWork preparatoryWork);
void DeletePreparatoryWork(int id); void DeletePreparatoryWork(int id);
PreparatoryWork ReadPreparatoryWorkById(int id); PreparatoryWork ReadPreparatoryWorkById(int id);

View File

@ -25,7 +25,7 @@ public class FlightRepository : IFlightRepository
public Flight ReadFlightById(int id) public Flight ReadFlightById(int id)
{ {
return Flight.CreateFlight(0, DateTime.Now, DateTime.Now, string.Empty, 0); return Flight.CreateOperation(0, DateTime.Now, DateTime.Now, string.Empty, 0);
} }
//public IEnumerable<Flight> ReadFlights() //public IEnumerable<Flight> ReadFlights()

View File

@ -19,7 +19,7 @@ public class PassangerRepository : IPassangerRepository
public Passanger ReadPassangerById(int id) public Passanger ReadPassangerById(int id)
{ {
return Passanger.CreatePassanger(0, string.Empty, string.Empty); return Passanger.CreateEntity(0, string.Empty, string.Empty);
} }
public IEnumerable<Passanger> ReadPassangers() public IEnumerable<Passanger> ReadPassangers()

View File

@ -18,7 +18,7 @@ public class PlaneRepository : IPlaneRepository
public Plane ReadPlaneById(int id) public Plane ReadPlaneById(int id)
{ {
return Plane.CreatePlane(0, string.Empty, 0); return Plane.CreateEntity(0, string.Empty, 0);
} }
public IEnumerable<Plane> ReadPlanes() public IEnumerable<Plane> ReadPlanes()

View File

@ -20,12 +20,9 @@ public class PreparatoryWorkRepository : IPreparatoryWorkRepository
public void UpdatePreparatoryWork(PreparatoryWork preparatoryWork) public void UpdatePreparatoryWork(PreparatoryWork preparatoryWork)
{ {
} }
public PreparatoryWork ReadPreparatoryWorkById(int id) public PreparatoryWork ReadPreparatoryWorkById(int id)
{ {
return PreparatoryWork.CreatePreparatoryWork(0, 0, DateTime.Now, DateTime.Now, 0); return PreparatoryWork.CreateOperation(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)

View File

@ -19,7 +19,7 @@ public class TicketRepository : ITicketRepository
public Ticket ReadTicketById(int id) public Ticket ReadTicketById(int id)
{ {
return Ticket.CreateTicket(0, 0); return Ticket.CreateEntity(0, 0);
} }
public IEnumerable<Ticket> ReadTickets() public IEnumerable<Ticket> ReadTickets()