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); } }
private void btn_cancel_Click(object sender, EventArgs e) { _bookingListForm.Show(); Close(); }