⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 examineedao.java

📁 该系统采用了B/S结构模式
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    if (organization_id == null || "".equals(organization_id)) {
      organization_id = "%";
    } else if (! ("%".equals(organization_id))) {
      conditionStr += ("&organization_id=" + organization_id);
    }

    if (post_index == null || "".equals(post_index)) {
      post_index = "%";
    } else if (! ("%".equals(post_index))) {
      conditionStr += ("&post_index=" + post_index);
    }

    if (state == null || "".equals(state)) {
      state = "%";
    } else if (! ("%".equals(state))) {
      conditionStr += ("&state=" + state);
    }

    if (operation == null || "".equals(operation)) {
      operation = "%";
    } else if (! ("%".equals(operation))) {
      conditionStr += ("&operation=" + operation);
    }


    try {
      if ("%".equals(post_index)) {
        pstmt = conn.prepareStatement(GET_SHARCH_RESULT,
                                      ResultSet.TYPE_SCROLL_SENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
        pstmt.setString(1, examinee_id);
        pstmt.setString(2, name);
        pstmt.setString(3, sex);
        pstmt.setString(4, organization_id);
        pstmt.setString(5, state);
        pstmt.setString(6, operation);
      } else {
        pstmt = conn.prepareStatement(GET_SHARCH_RESULT2,
                                      ResultSet.TYPE_SCROLL_SENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
        pstmt.setString(1, examinee_id);
        pstmt.setString(2, name);
        pstmt.setString(3, sex);
        pstmt.setString(4, organization_id);
        pstmt.setString(5, state);
        pstmt.setString(6, operation);
        pstmt.setString(7, post_index);
      }
      rs = pstmt.executeQuery();

      if (false == rs.last()) {
        rowCount = 0;
        pageCount = 0;
        ipage = 0;
        return list;
      }

      this.rowCount = rs.getRow();
      int offset = 1;
      int pagesize = getLength();
      if (getLength() < 1) {
        pagesize = rowCount;
        pageCount = 1;
      } else {
        pageCount = rowCount / getLength() +
            ( (rowCount % getLength()) > 0 ? 1 : 0);
        offset = (ipage - 1) * getLength() + 1;
        if (offset < 1) {
          offset = 1;
        }

        if (offset > rowCount) {
          offset = rowCount;
        }
      }
      rs.absolute(offset);

      for (int i = 0; i < pagesize && offset < rowCount + 1; i++, offset++) {
        examinee = new Examinee();
        examinee.setExaminee_id(rs.getString(1));
        examinee.setPassword(rs.getString("PASSWORD"));
        examinee.setName(rs.getString("NAME"));
        examinee.setSex(rs.getString("SEX"));
        examinee.setSexName(rs.getString("SEXNAME"));
        examinee.setAge(rs.getString("AGE"));
        examinee.setOrganization_id(rs.getString("ORGANIZATION_ID"));
        examinee.setOrganizationName(rs.getString("ORGANIZATIONNAME"));
        examinee.setPost_index(rs.getString("POST_INDEX"));
        examinee.setPostName(rs.getString("POSTNAME"));
        examinee.setState(rs.getString("STATE"));
        examinee.setStateName(rs.getString("STATENAME"));
        examinee.setOperation(rs.getString("OPERATION"));
        examinee.setOperationName(rs.getString("OPERATIONNAME"));
        examinee.setEducation_index(rs.getString("EDUCATION_INDEX"));
        examinee.setEducationName(rs.getString("EDUCATIONNAME"));
        examinee.setAddress(rs.getString("ADDRESS"));
        examinee.setPhone(rs.getString("PHONE"));
        examinee.setMobile(rs.getString("MOBILE"));
        examinee.setEmail(rs.getString("EMAIL"));
        examinee.setRemark(rs.getString("REMARK"));

        rs.next();
        list.add(examinee);
      }
    } catch (SQLException ex) {
      ex.printStackTrace();
    } finally {
      try {
        rs.close();
        rs = null;
        pstmt.close();
        pstmt = null;
        conn.close();
        conn = null;
      } catch (SQLException ex1) {
        ex1.printStackTrace();
      }
      
    }
    return list;
  }

  public Collection getSearchWithoutPage(RandomDistributeExamPaperForm randomDistributeExamPaperForm) throws
      SQLException {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    Examinee examinee = null;
    Collection list = null;
    list = new ArrayList();

    String examinee_id = randomDistributeExamPaperForm.getExaminee_id();
    String name = randomDistributeExamPaperForm.getName();
    String sex = randomDistributeExamPaperForm.getSex();
    String organization_id = randomDistributeExamPaperForm.getOrganization_id();
    String post_index = randomDistributeExamPaperForm.getPost_index();
    String state = randomDistributeExamPaperForm.getState();
    String operation = randomDistributeExamPaperForm.getOperation();

    if (examinee_id == null || "".equals(examinee_id)) {
      examinee_id = "%";
    } else if (! ("%".equals(examinee_id))) {
      conditionStr += ("&examinee_id=" + examinee_id);
    }

    if (name == null || "".equals(name)) {
      name = "%";
    } else if (! ("%".equals(name))) {
      conditionStr += ("&name=" + name);
    }

    if (sex == null || "".equals(sex)) {
      sex = "%";
    } else if (! ("%".equals(sex))) {
      conditionStr += ("&sex=" + sex);
    }

    if (organization_id == null || "".equals(organization_id)) {
      organization_id = "%";
    } else if (! ("%".equals(organization_id))) {
      conditionStr += ("&organization_id=" + organization_id);
    }

    if (post_index == null || "".equals(post_index)) {
      post_index = "%";
    } else if (! ("%".equals(post_index))) {
      conditionStr += ("&post_index=" + post_index);
    }

    if (state == null || "".equals(state)) {
      state = "%";
    } else if (! ("%".equals(state))) {
      conditionStr += ("&state=" + state);
    }

    if (operation == null || "".equals(operation)) {
      operation = "%";
    } else if (! ("%".equals(operation))) {
      conditionStr += ("&operation=" + operation);
    }


    try {
      if ("%".equals(post_index)) {
        pstmt = conn.prepareStatement(GET_SHARCH_RESULT_WITHOUT_PAGE,
                                      ResultSet.TYPE_SCROLL_SENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
        pstmt.setString(1, examinee_id);
        pstmt.setString(2, name);
        pstmt.setString(3, sex);
        pstmt.setString(4, organization_id);
        pstmt.setString(5, state);
        pstmt.setString(6, operation);
      } else {
        pstmt = conn.prepareStatement(GET_SHARCH_RESULT2_WITHOUT_PAGE,
                                      ResultSet.TYPE_SCROLL_SENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
        pstmt.setString(1, examinee_id);
        pstmt.setString(2, name);
        pstmt.setString(3, sex);
        pstmt.setString(4, organization_id);
        pstmt.setString(5, state);
        pstmt.setString(6, operation);
        pstmt.setString(7, post_index);
      }
      rs = pstmt.executeQuery();

      while(rs.next()){
        examinee = new Examinee();
        examinee.setExaminee_id(rs.getString(1));
        examinee.setPassword(rs.getString("PASSWORD"));
        examinee.setName(rs.getString("NAME"));
        examinee.setSex(rs.getString("SEX"));
        examinee.setSexName(rs.getString("SEXNAME"));
        examinee.setAge(rs.getString("AGE"));
        examinee.setOrganization_id(rs.getString("ORGANIZATION_ID"));
        examinee.setOrganizationName(rs.getString("ORGANIZATIONNAME"));
        examinee.setPost_index(rs.getString("POST_INDEX"));
        examinee.setPostName(rs.getString("POSTNAME"));
        examinee.setState(rs.getString("STATE"));
        examinee.setStateName(rs.getString("STATENAME"));
        examinee.setOperation(rs.getString("OPERATION"));
        examinee.setOperationName(rs.getString("OPERATIONNAME"));
        examinee.setEducation_index(rs.getString("EDUCATION_INDEX"));
        examinee.setEducationName(rs.getString("EDUCATIONNAME"));
        examinee.setAddress(rs.getString("ADDRESS"));
        examinee.setPhone(rs.getString("PHONE"));
        examinee.setMobile(rs.getString("MOBILE"));
        examinee.setEmail(rs.getString("EMAIL"));
        examinee.setRemark(rs.getString("REMARK"));

        list.add(examinee);

      }
    } catch (SQLException ex) {
      ex.printStackTrace();
    } finally {
      try {
        rs.close();
        rs = null;
        pstmt.close();
        pstmt = null;
        conn.close();
        conn = null;
      } catch (SQLException ex1) {
        ex1.printStackTrace();
      }
      
    }
    return list;
  }





  public boolean isUser(LogonForm logonForm) {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    boolean isUser = false;

    try {
      pstmt = conn.prepareStatement(IS_USER);
      pstmt.setString(1, logonForm.getUserName());
      rs = pstmt.executeQuery();
      if (rs.next()) {
        if (rs.getString(1).equals(logonForm.getPassword())) {
          isUser = true;
        }
      }
    } catch (SQLException ex) {
      ex.printStackTrace();
    } finally {
      try {
        rs.close();
        rs = null;
        pstmt.close();
        pstmt = null;
        conn.close();
        conn = null;
      } catch (SQLException ex1) {
        ex1.printStackTrace();
      }
    }
    return isUser;
  }

  public boolean isAdminUser(LogonForm logonForm) {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    boolean isAdminUser = false;

    try {
      pstmt = conn.prepareStatement(IS_ADMINUSER);
      pstmt.setString(1,logonForm.getUserName());
      pstmt.setString(2,logonForm.getPassword());
      rs = pstmt.executeQuery();
      while(rs.next()){
      	isAdminUser=true;
      	return isAdminUser;
      }
    } catch (SQLException ex) {
      ex.printStackTrace();
    } finally {
      try {
        rs.close();
        rs = null;
        pstmt.close();
        pstmt = null;
        conn.close();
        conn = null;
      } catch (SQLException ex1) {
        ex1.printStackTrace();
      }
    }
    return isAdminUser;
  }
  
  
  
  /**
   * hasUser
   *
   * @param examinee_id String
   * @return boolean
   */
  public boolean hasUser(String examinee_id) {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    boolean overlap = false;
    try {
      pstmt = conn.prepareStatement(HAS_USER);
      pstmt.setString(1, examinee_id);
      rs = pstmt.executeQuery();
      if (rs.next()) {
        overlap = true;
      }
    } catch (SQLException ex) {
      ex.printStackTrace();
    } finally {
      try {
        rs.close();
        rs = null;
        pstmt.close();
        pstmt = null;
        conn.close();
        conn = null;
      } catch (SQLException ex1) {
        ex1.printStackTrace();
      }

      
    }
    return overlap;
  }

  /**
   * re-initialize password as examinee_id
   * @param examinee_id String
   * @throws SQLException
   */
  public void reInitPwd(String examinee_id) throws SQLException {
    PreparedStatement pstmt = null;
    try {
      pstmt = conn.prepareStatement(RE_INIT_PWD);
      pstmt.setString(1, examinee_id);
      pstmt.executeUpdate();
    } catch (SQLException ex) {
      ex.getStackTrace();
      ex.printStackTrace();
    } finally {
      try {
        pstmt.close();
        pstmt = null;
        conn.close();
        conn = null;
      } catch (SQLException ex1) {
        ex1.printStackTrace();
      }
    }
  }

  /**
   * updatePwd password as examinee_set
   * @param examinee_id String
   * @throws SQLException
   */
  public void updatePwd(String examinee_id, String oldPwd, String newPwd) throws
      SQLException {
    PreparedStatement pstmt = null;
    try {
      pstmt = conn.prepareStatement(UPDATE_PWD);
      pstmt.setString(1, newPwd);
      pstmt.setString(2, examinee_id);
      pstmt.setString(3, oldPwd);
      pstmt.executeUpdate();
    } catch (SQLException ex) {
      ex.getStackTrace();
      throw new SQLException("SQLExction on : ExamineeDAO.updatePwd()");
    } finally {
      try {
        pstmt.close();
        pstmt = null;
        conn.close();
        conn = null;
      } catch (SQLException ex1) {
        ex1.printStackTrace();
      }
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -