コード例 #1
0
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
    String destination = dest.getText();
    if (destination.matches("[a-zA-Z]+")) {
    } else {
      super.dispose();
    }

    String via = vi.getText();
    if (via.matches("[a-zA-Z]+")) {

    } else {
      super.dispose();
    }
    Date date = new Date();
    String date1 = dat.getText();
    SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
      date = date2.parse(date1);
    } catch (ParseException ex) {
      Logger.getLogger(AddFlight.class.getName()).log(Level.SEVERE, null, ex);
    }

    String remarks = rem.getText();

    String airline = air.getSelectedItem().toString();
    String code = flight.getSelectedItem().toString();

    try {
      String sql = "DELETE FROM FLIGHTS WHERE CODE='" + code + "'";
      db.setPst(db.getCon().prepareStatement(sql));
      db.setRs(db.getPst().executeQuery());

      sql =
          "INSERT INTO FLIGHTS VALUES ('"
              + destination
              + "','"
              + code
              + "','"
              + via
              + "','"
              + remarks
              + "',"
              + date
              + ",'"
              + airline
              + "')";
      db.setPst(db.getCon().prepareStatement(sql));
      db.setRs(db.getPst().executeQuery());

    } catch (SQLException ex) {
      Logger.getLogger(AddFlight.class.getName()).log(Level.SEVERE, null, ex);
    }
    super.dispose();
  } // GEN-LAST:event_jButton1ActionPerformed
コード例 #2
0
 private void FillCombo2() {
   try {
     String sql = "SELECT * FROM FLIGHTS";
     db.setPst(db.getCon().prepareStatement(sql));
     db.setRs(db.getPst().executeQuery());
     while (db.getRs().next()) {
       String code = db.getRs().getString("CODE");
       flight.addItem(code);
     }
   } catch (SQLException ex) {
     Logger.getLogger(AddFlight.class.getName()).log(Level.SEVERE, null, ex);
   }
 }
コード例 #3
0
 private void FillCombo() {
   try {
     String sql = "SELECT * FROM AIRLINES";
     db.setPst(db.getCon().prepareStatement(sql));
     db.setRs(db.getPst().executeQuery());
     while (db.getRs().next()) {
       String name = db.getRs().getString("NAME");
       air.addItem(name);
     }
   } catch (SQLException ex) {
     Logger.getLogger(AddFlight.class.getName()).log(Level.SEVERE, null, ex);
   }
 }