コード例 #1
0
ファイル: AddEditForm.java プロジェクト: robpuff/2761Login
  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();
  }
コード例 #2
0
ファイル: FrameLogin.java プロジェクト: robpuff/2761Login
 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;
 }
コード例 #3
0
ファイル: FrameLogin.java プロジェクト: robpuff/2761Login
 public static boolean isIdFound(int id) {
   Connection con = getConnect();
   boolean isFound = false;
   try {
     String SQL =
         "SELECT PersonId, FirstName, LastName, SchoolId FROM 2761DB.Persons WHERE SchoolId = "
             + id;
     Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
     ResultSet rs = stmt.executeQuery(SQL);
     if (rs.first()) {
       isFound = true;
     } else {
       AddUserQuery addUser = new AddUserQuery();
       addUser.setVisible(true);
     }
   } catch (SQLException err) {
     System.out.println(err);
     MessageBox.infoBox(err.toString(), "Error");
   }
   closeConnect();
   return isFound;
 }