示例#1
0
文件: BookingForm.cs 项目: liamdp/Fly
        private void btn_search_Click(object sender, EventArgs e)
        {
            //can clean this up, or make a method to get just the city.
            var origin      = OriginDropDown.Text.Split(',')[0].Replace(" ", "");
            var destination = DestinationDropDown.Text.Split(',')[0].Replace(" ", "");
            var date        = flightDate.Value.Date;

            if (!origin.Equals(destination))
            {
                var matchingFlights = DBConnection.GetMatchingFlights(origin, destination, date);

                if (matchingFlights.Count != 0)
                {
                    string[] userChoices = { origin, destination, date.ToString("dd-MM-yyyy") };
                    var      listFlights = new BookingListForm(matchingFlights, this, userChoices);
                    listFlights.Show();
                    Hide();
                }
                else
                {
                    //matchingFlights list has no values
                    MessageBox.Show($@"No flights found from {origin} to {destination} on {date:dd MMMM yyyy}.", @"No Flights", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                //origin == destination
                MessageBox.Show(@"The origin and destination cannot be the same.", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
 public SearchTicketForm(BookingListForm bookingListForm, Flight selectedFlight)
 {
     InitializeComponent();
     _bookingListForm = bookingListForm;
     _selectedFlight  = selectedFlight;
 }