Beispiel #1
0
    @Override
    public void actionPerformed(ActionEvent e) {
      // TODO Auto-generated method stub
      try {
        String sql = "SELECT * From STUDENT WHERE ID = '" + getstudent + "'";
        System.out.println(sql);
        Statement stmtment;
        ResultSet resultset = null;
        try {
          stmtment = connection().createStatement();
          resultset = stmtment.executeQuery(sql);
        } catch (SQLException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
        // System.out.println(result);
        while (resultset.next()) {
          System.out.println(resultset.getString(4) + resultset.getString(8));
          student.setUName(resultset.getString(4));
          student.setUBirthday(resultset.getString(8));
          student.setUCard(resultset.getString(1));
          student.setUClass(resultset.getString(6));
          student.setUHometown(resultset.getString(7));
          student.setUID(resultset.getString(2));
          student.setURole(resultset.getString(3));
          student.setUSex(resultset.getString(6));
        }

      } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      SchoolRollStudents stu = new SchoolRollStudents(student, true);
      stu.setVisible(true);
      stu.setPanel();
      dispose();
    }
  public void judge() throws ClassNotFoundException, IOException, SQLException {

    if (user.getURole().equalsIgnoreCase("student")) {
      String sql = "SELECT * From STUDENT WHERE ID = '" + user.getUID() + "'";
      System.out.println(sql);
      Statement stmt;
      ResultSet result = null;
      try {
        stmt = connection().createStatement();
        result = stmt.executeQuery(sql);
      } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      // System.out.println(result);

      try {
        while (result.next()) {
          System.out.println(result.getString(4) + result.getString(2));
          student.setUName(result.getString(4));
          student.setUBirthday(result.getString(8));
          student.setUCard(result.getString(1));
          student.setUClass(result.getString(6));
          student.setUHometown(result.getString(7));
          student.setUID(result.getString(2));
          student.setURole(result.getString(3));
          student.setUSex(result.getString(6));
        }
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      SchoolRollStudents SRS = new SchoolRollStudents(student, false);
      System.out.println(student.getUName());
      SRS.setPanel();
      SRS.setVisible(true);
    } else if (user.getURole().equalsIgnoreCase("teacher")
        || user.getURole().equalsIgnoreCase("admin")) {
      String sql = "SELECT * From TEACHER where ID = '" + user.getUID() + "'";
      System.out.println(sql);
      Statement stmt;
      ResultSet result = null;
      try {
        stmt = connection().createStatement();
        result = stmt.executeQuery(sql);
      } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      System.out.println(result);
      try {
        while (result.next()) {
          teacher.setUName(result.getString("Name"));
          // teacher.setUBirthday(result.getString(1));
          teacher.setUCard(result.getString("ID"));
          teacher.setUClass(result.getString("class"));
          // teacher.setUHometown(result.getString(4));
          teacher.setUID(result.getString("Num"));
          teacher.setURole(result.getString("role"));
          teacher.setUSex(result.getString("sex"));
        }

      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      SchoolRollTeachers SCT = new SchoolRollTeachers(teacher, true);
      SCT.setVisible(true);
      SCT.setPanel();
    }
  }