private void confirmButton_Click(object sender, EventArgs e) { List <int> chosenIds = new List <int>(); foreach (Label label in seatsPanel1.Labels) { if (label.BackColor == Color.Yellow) { Int32.TryParse(label.Name, out int id); chosenIds.Add(id); } } if (chosenIds.Count == 0) { MessageBox.Show("Nie wybrano żadnego miejsca", "Błąd", MessageBoxButtons.OK); } else { BookSeatsRequest request = new BookSeatsRequest { ShowingId = ShowingId }; request.SeatsIds = chosenIds.ToArray(); RequestBookShowing.Invoke(request); foreach (Label label in seatsPanel1.Labels) { seatsPanel1.Controls.Remove(label); } Visible = false; } }
private void InitializeMainForm(string username) { mainForm = new MainForm(); mainForm.RequestLogOut += () => RequestLogOut?.Invoke(); mainForm.RequestBookingsList += () => RequestBookingsList?.Invoke(); mainForm.RequestShowingsList += (DateTime date) => RequestShowingsList?.Invoke(date); mainForm.RequestSeatsList += (int showingId) => RequestSeatsList.Invoke(showingId); mainForm.RequestShowingsDates += () => RequestShowingsDates?.Invoke(); mainForm.RequestBookShowing += (BookSeatsRequest request) => RequestBookShowing?.Invoke(request); mainForm.FormClosing += (object sender, FormClosingEventArgs e) => activeForm = null; mainForm.SetLoggedUser(username); }
public MainForm() { bookingsListControl = new BookingsList(); chooseDateControl = new DateControl(); showingsListControl = new ShowingsListBox(); seatsViewControl = new SeatsView(); InitializeControl(bookingsListControl); InitializeControl(chooseDateControl); InitializeControl(showingsListControl); InitializeControl(seatsViewControl); InitializeComponent(); chooseDateControl.RequestShowingsDates += () => RequestShowingsDates?.Invoke(); chooseDateControl.RequestShowingsList += (DateTime date) => RequestShowingsList?.Invoke(date); showingsListControl.RequestSeatsList += (int id) => RequestSeatsList?.Invoke(id); seatsViewControl.RequestBookShowing += (BookSeatsRequest request) => RequestBookShowing?.Invoke(request); }