private void btnFAdd_Click(object sender, EventArgs e) { if (IsInt(txtFlightId) == false) { MessageBox.Show("Id is not an integer"); txtFlightId.Focus(); return; } if (IsEmpty(txt_dep_time)) { MessageBox.Show("Text is empty"); txt_dep_time.Focus(); return; } if (IsEmpty(txt_arr_time)) { MessageBox.Show("Text is empty"); txt_arr_time.Focus(); return; } if (IsEmpty(txt_dep_date)) { MessageBox.Show("Text is empty"); txt_dep_date.Focus(); return; } if (IsEmpty(txt_arr_date)) { MessageBox.Show("Text is empty"); txt_arr_date.Focus(); return; } if (IsFloat(txtPrice) == false) { MessageBox.Show("price is not an float"); txtPrice.Focus(); return; } if (IsInt(txtNoSeat) == false) { MessageBox.Show("No Seat is not an integer"); txtNoSeat.Focus(); return; } if (IsEmpty(txtNameFlight)) { MessageBox.Show("Text is empty"); txtNameFlight.Focus(); return; } if (IsEmpty(txt_airway_station)) { MessageBox.Show("Text is empty"); txtNameFlight.Focus(); return; } int id = Int32.Parse(txtFlightId.Text); if (isExistedFlight(id) == false) { Flight flight = new Flight(); flight.Id = id; flight.Depart_time = txt_dep_time.Text; flight.Arrival_time = txt_arr_time.Text; flight.Depart_date = txt_dep_date.Text; flight.Arrival_date = txt_arr_date.Text; flight.Depart_country = comboDCountry.SelectedItem.ToString(); flight.Arrival_country = comboACountry.SelectedItem.ToString(); flight.Direction = comboDirection.SelectedItem.ToString(); flight.Type = comboType.SelectedItem.ToString(); flight.Price = float.Parse(txtPrice.Text); flight.No_seat = Int32.Parse(txtNoSeat.Text); flight.Name = txtNameFlight.Text; flight.Airway_station = txt_airway_station.Text; flightDAO.insertFlight(flight); KeyValuePair <int, String> selectedPair_airplane = (KeyValuePair <int, String>)comboAirplane.SelectedItem; int airplane_id = selectedPair_airplane.Key; flightDAO.insertOwnerFlight(id, airplane_id); MessageBox.Show("Add successfully"); clearDataFlight(); updateDatagridFlight(); } else { MessageBox.Show("duplicated id"); } }