예제 #1
0
        private void AddPassengerButton_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(outboundTickets.Firstname))
            {
                errors.AppendLine("Enter the firstname!");
            }
            if (string.IsNullOrWhiteSpace(outboundTickets.Firstname))
            {
                errors.AppendLine("Enter the lastname!");
            }
            if (string.IsNullOrWhiteSpace(outboundTickets.Phone))
            {
                errors.AppendLine("Enter the phone!");
            }
            if (CountryComboBox.SelectedItem == null)
            {
                errors.AppendLine("Enter the country!");
            }
            if (PhoneText.Text.Length > 14)
            {
                errors.AppendLine("Invalid phone number!");
            }

            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString(), "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }



            outboundTickets.BookingReference = BookRefGen();

            outboundTickets.PassportCountryID = ((Countries)CountryComboBox.SelectedItem).ID;

            Tickets tickets = new Tickets();

            tickets = (Tickets)outboundTickets.Clone();

            if (returnTickets.Schedules != null)
            {
                var returnTickets = (Tickets)outboundTickets.Clone();
                returnTickets.Schedules    = this.returnTickets.Schedules;
                returnTickets.Schedules.ID = this.returnTickets.Schedules.ID;
                ticketsList.Add(returnTickets);
            }

            ticketsList.Add(tickets);
            TicketsData.Items.Add(tickets);
        }