Esempio n. 1
0
  private void isEdit(Boolean isEdit) {
    if (isEdit) {
      try {
        Connection con = FrameLogin.getConnect();
        String sql = "SELECT * FROM Persons WHERE personId = " + Id;
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        if (rs.first()) {
          String firstname = rs.getString("FirstName");
          String lastname = rs.getString("LastName");
          String cellphone = rs.getString("CellPhoneNo");
          String homephone = rs.getString("HomePhoneNo");
          String gradyear = rs.getString("Graduation Year");
          String Gender = rs.getString("Gender");

          firstName.setText(firstname);
          lastName.setText(lastname);
          cellPhone.setText(cellphone);
          homePhone.setText(homephone);
          gradYear.setText(gradyear);
          gender.setSelectedItem(Gender);
          jLabel7.setVisible(false);
          studentId.setVisible(false);

        } else {
          MessageBox.infoBox("Error: ID not found", "Error");
        }
      } catch (Exception e) {
        MessageBox.infoBox(e.toString(), "Error in isEdit");
      }
    }
    FrameLogin.closeConnect();
  }
Esempio n. 2
0
 private void formWindowClosing(
     java.awt.event.WindowEvent evt) { // GEN-FIRST:event_formWindowClosing
   // TODO add your handling code here:
   Connection con = getConnect();
   try {
     // con.close();
   } catch (Exception err) {
     MessageBox.infoBox(err.toString(), "Error closing connection in formWindowClosed");
   }
 } // GEN-LAST:event_formWindowClosing
Esempio n. 3
0
 private boolean isLoggedIn(int id) {
   boolean isLoggedIn = false;
   Connection con = getConnect();
   int personId = getPersonId(id);
   try {
     String SQL = "SELECT * FROM LogInOut WHERE personId = " + personId + " AND TimeOut IS NULL";
     Statement stmt = con.createStatement();
     ResultSet rs = stmt.executeQuery(SQL);
     if (rs != null && rs.next()) {
       rs.last();
       isLoggedIn = true;
     }
   } catch (Exception err) {
     MessageBox.infoBox(err.toString(), "Error from isLoggedIn");
     System.out.println(err);
   }
   closeConnect();
   return isLoggedIn;
   // SELECT * FROM LogInOut WHERE personId = 1 AND TimeOut IS NULL
 }
Esempio n. 4
0
 public static int getPersonId(int id) {
   Connection con = getConnect();
   ResultSet rs = null;
   int personId = 0;
   try {
     String SQL = "SELECT PersonId FROM 2761DB.Persons WHERE SchoolId = " + id;
     Statement stmt = con.createStatement();
     rs = stmt.executeQuery(SQL);
     if (rs.next()) {
       rs.first();
       personId = rs.getInt("PersonId");
     } else {
       AddUserQuery addUserQuery = new AddUserQuery();
       addUserQuery.setVisible(true);
     }
   } catch (Exception err) {
     MessageBox.infoBox(err.toString(), "Error in getPersonId");
   }
   closeConnect();
   return personId;
 }
  @Override
  public void run() {
    while (true) {
      try {
        MILLISECONDS.sleep(100);

        // set speed
        int speed = 0;
        if (isUpPressed) speed = speedConfig;
        else if (isDownPressed) speed = -1 * speedConfig;

        // set direction
        int direction = 0;
        if (isLeftPressed) direction = -turnspeedConfig;
        else if (isRightPressed) direction = turnspeedConfig;

        if (speed != 0 || direction != 0) droneController.pcmd(speed, direction);
      } catch (Exception e1) {
        e1.printStackTrace();
      }
    }
  }