diff --git a/ProjectAirline/Entities/Ticket.cs b/ProjectAirline/Entities/Ticket.cs
index dec91ee..519d91f 100644
--- a/ProjectAirline/Entities/Ticket.cs
+++ b/ProjectAirline/Entities/Ticket.cs
@@ -1,4 +1,5 @@
-using System;
+using ProjectAirline.Entities.Enums;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -12,11 +13,14 @@ public class Ticket
public DateTime DateBuy { get; private set; }
- public static Ticket CreateTicket(int id)
+ public TicketStatus Status { get; private set; }
+
+ public static Ticket CreateTicket(int id, TicketStatus status)
{
return new Ticket
{
Id = id,
+ Status = status,
DateBuy = DateTime.Now,
};
}
diff --git a/ProjectAirline/Forms/FormTicket.Designer.cs b/ProjectAirline/Forms/FormTicket.Designer.cs
new file mode 100644
index 0000000..40f52fe
--- /dev/null
+++ b/ProjectAirline/Forms/FormTicket.Designer.cs
@@ -0,0 +1,99 @@
+namespace ProjectAirline.Forms
+{
+ partial class FormTicket
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelStatus = new Label();
+ checkedListBoxStatus = new CheckedListBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelStatus
+ //
+ labelStatus.AutoSize = true;
+ labelStatus.Location = new Point(34, 46);
+ labelStatus.Name = "labelStatus";
+ labelStatus.Size = new Size(43, 15);
+ labelStatus.TabIndex = 1;
+ labelStatus.Text = "Статус";
+ //
+ // checkedListBoxStatus
+ //
+ checkedListBoxStatus.FormattingEnabled = true;
+ checkedListBoxStatus.Items.AddRange(new object[] { "Оплачен", "Отменен", "Возврат Средств" });
+ checkedListBoxStatus.Location = new Point(103, 29);
+ checkedListBoxStatus.Name = "checkedListBoxStatus";
+ checkedListBoxStatus.Size = new Size(120, 58);
+ checkedListBoxStatus.TabIndex = 2;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(34, 180);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 3;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(148, 180);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 4;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormTicket
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(266, 270);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(checkedListBoxStatus);
+ Controls.Add(labelStatus);
+ Name = "FormTicket";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Билет";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label labelStatus;
+ private CheckedListBox checkedListBoxStatus;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirline/Forms/FormTicket.cs b/ProjectAirline/Forms/FormTicket.cs
new file mode 100644
index 0000000..e17f5c7
--- /dev/null
+++ b/ProjectAirline/Forms/FormTicket.cs
@@ -0,0 +1,59 @@
+using ProjectAirline.Entities.Enums;
+using ProjectAirline.Entities;
+using ProjectAirline.Repositories;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ProjectAirline.Forms;
+
+public partial class FormTicket : Form
+{
+ private readonly ITicketRepository _ticketRepository;
+
+ public FormTicket(ITicketRepository ticketRepository)
+ {
+ InitializeComponent();
+ _ticketRepository = ticketRepository ?? throw new ArgumentNullException(nameof(ticketRepository));
+
+ //Тут нада чета делать но я пьяный уже пол 2 ночи пора спать
+ //checkedListBoxStatus.Items.AddRange(Enum.GetValues(typeof(TicketStatus)).Cast().ToArray());
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ var status = GetTicketStatusFromCheckedListBox();
+ if (status == TicketStatus.None)
+ {
+ throw new Exception("Необходимо выбрать хотя бы один статус");
+ }
+
+ _ticketRepository.CreateTicket(Ticket.CreateTicket(0, status));
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e) => Close();
+
+ private TicketStatus GetTicketStatusFromCheckedListBox()
+ {
+ TicketStatus status = TicketStatus.None;
+ foreach (TicketStatus item in checkedListBoxStatus.CheckedItems)
+ {
+ status |= item;
+ }
+ return status;
+ }
+}
diff --git a/ProjectAirline/Forms/FormTicket.resx b/ProjectAirline/Forms/FormTicket.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectAirline/Forms/FormTicket.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ProjectAirline/Repositories/Implementations/TicketRepository.cs b/ProjectAirline/Repositories/Implementations/TicketRepository.cs
index 9e89239..3f5eff7 100644
--- a/ProjectAirline/Repositories/Implementations/TicketRepository.cs
+++ b/ProjectAirline/Repositories/Implementations/TicketRepository.cs
@@ -19,7 +19,7 @@ public class TicketRepository : ITicketRepository
public Ticket ReadTicketById(int id)
{
- return Ticket.CreateTicket(0);
+ return Ticket.CreateTicket(0, 0);
}
public IEnumerable ReadTickets()