Exemple #1
0
        private void BookBtn_Click(object sender, EventArgs e)
        {
            LOGGER.Info("handle add booking");
            try
            {
                string client     = clientTextBox.Text;
                string phone      = phoneTextBox.Text;
                string numTickets = numTicketsTextBox.Text;
                if (tripDataGridView.SelectedRows.Count == 0)
                {
                    MessageBox.Show("A trip must be selected");
                    return;
                }
                if (tripDataGridView.SelectedRows[0].Cells[0].Value == null)
                {
                    MessageBox.Show("A trip must be selected");
                    return;
                }
                Trip trip = (Trip)tripDataGridView.SelectedRows[0].DataBoundItem;
                if (client.Equals(""))
                {
                    MessageBox.Show("Client name must be entered");
                    return;
                }
                if (phone.Equals(""))
                {
                    MessageBox.Show("Phone number must be entered");
                    return;
                }

                if (numTickets.Equals(""))
                {
                    MessageBox.Show("Number of tickets must be entered");
                    return;
                }
                int noTickets = Int32.Parse(numTickets);
                MainController.AddBooking(client, phone, noTickets, trip);
                ClearTextBoxes();
                MessageBox.Show("Booking saved");
            }
            catch (FormatException)
            {
                LOGGER.Info("handle add booking failed invalid data");
                MessageBox.Show("Invalid data");
            }
            catch (ServiceException se)
            {
                MessageBox.Show(se.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }