/// <summary> /// On load event to load the flight numbers /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddPassenger_Load(object sender, EventArgs e) { ///Try executing if problem call HandleError to display the error Message; try { ///Initialize database object flightResDb = new FlightReservationDb(); ///sets the flights to a list flights = flightResDb.selectFlights(); ///clears the flights combo box cb_flight_number.Items.Clear(); ///sorts the flights list by by flight id flights.Sort(delegate(Flight x, Flight y) { ///returns the flights by flight id return(x.FlightID.CompareTo(y.FlightID)); }); ///iterates through the adding them to the flights combo box foreach (Flight fl in flights) { ///Adds each flight to the flight combobox cb_flight_number.Items.Add(fl.FlightNO); } } catch (Exception ex) { /// Call handleError Method to display the exception HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// Form1 constructor to initialize form, user control events, database object, set size for width and height, and initialize seat tag /// </summary> public Form1() { ///Try executing if problem call HandleError to display the error Message; try { ///Initialize form InitializeComponent(); ///set form width this.Width = 850; ///set from height; this.Height = 420; ///Bind Flight 1 object event to event in Form 1 FlightOneLayout.SeatClickEvent += Flight1SeatSelectEvent_Click; ///Bind Flight 2 object event to event in Form 1 FlightTwoLayout.SeatClickEvent += Flight1SeatSelectEvent_Click; ///Create database object flightResDb = new FlightReservationDb(); ///Initializes the seat tag seatTag = ""; } catch (Exception ex) { /// Call handleError Method to display the exception HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// Save values to add new passenger /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_save_Click(object sender, EventArgs e) { ///Try executing if problem call HandleError to display the error Message; try { ///Initialize database object flightResDb = new FlightReservationDb(); ///check to see if any text box is empty if (tb_first_name.Text != "" && tb_last_name.Text != "" && cb_flight_number.Text != "" && tb_seat_number.Text != "") { ///flight number result int flightNO = 0; ///seat number result int seatNo = 0; if (Int32.TryParse(cb_flight_number.Text, out flightNO) && Int32.TryParse(tb_seat_number.Text, out seatNo)) { ///Add User to database flightResDb.AddPassenger(tb_first_name.Text, tb_last_name.Text, flightNO, seatNo); ///close add user dialog this.Close(); } else { ///Message box to remind user to put in an integer MessageBox.Show("Enter Numbers for flight number and seat number."); } } else { ///Message box to fill in all information MessageBox.Show("Enter all infromation in form!"); } } catch (Exception ex) { /// Call handleError Method to display the exception HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }