Beispiel #1
0
        /// <summary>
        /// Starts the booking of selected seats
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bookButton_Click(object sender, EventArgs e)
        {
            if (seatsToAdd.Count == 0 && seatsToRemove.Count == 0)
            {
                MessageBox.Show("No changes has been made.");
                return;
            }

            if (seatsToRemove.Count > 0)
            {
                bool success = handler.RemoveTickets(shows[startTimeComboBox.SelectedIndex], seatsToRemove);
                if (success)
                {
                    MessageBox.Show($"Removed the booking of {seatsToRemove.Count} tickets.");
                    seatsToRemove.Clear();
                }
                else
                {
                    MessageBox.Show($"Attempted to remove {seatsToRemove.Count} tickets, but failed somehow.");
                }
            }
            if (seatsToAdd.Count > 0)
            {
                bool success = handler.BookTickets(Customer, shows[startTimeComboBox.SelectedIndex], seatsToAdd);
                if (success)
                {
                    MessageBox.Show($"You booked {seatsToAdd.Count} new tickets!");
                    seatsToAdd.Clear();
                }
                else
                {
                    MessageBox.Show($"Attempted to book {seatsToRemove.Count} tickets, but failed somehow.");
                }
            }
        }