Пример #1
0
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    String ulr = req.getParameter("aUrl");
    req.setCharacterEncoding("utf-8"); // 设置编码
    resp.setContentType("text/html;charset=utf-8");
    // 获得session
    HttpSession session = req.getSession();
    // 获得session中保留的信息
    User user = (User) session.getAttribute("user");
    String name = user.getUserName();
    System.out.println(ulr);
    if ("query".equals(ulr)) {
      query(req, resp, name);
    } else if ("save".equals(ulr)) {
      Map<String, String> map = white_tool.setPhoto(req, resp, "jpg");
      save(req, resp, map, name);
    } else if ("delete".equals(ulr)) {
      delete(req, resp);
    } else if ("updata".equals(ulr)) {
      updata(req, resp, name); // 提交申请
      // } else if("edit".equals(ulr)){
      // edit(req,resp);
    } else if ("fileSave".equals(ulr)) {
      // 上传xls文件 并且写库
      Map<String, String> map = white_tool.setPhoto(req, resp, "xls");
      this.Insert_xls(req, resp, map);
    } else {
      Map<String, String> map = white_tool.setPhoto(req, resp, "jpg");
      editSave(req, resp, map); // 修改保存
    }
  }
Пример #2
0
  public List<User> getUserList() {

    List<User> userList = new ArrayList();
    SSRS ssrs = es.execSQL("SELECT ID, USERNAME, PASSWORD, MENUJSON FROM SYJK_CCS_USER ");
    if (ssrs.MaxRow > 0) {
      for (int i = 0; i < ssrs.MaxRow; i++) {
        User user = new User();
        user.setId(Integer.parseInt(ssrs.GetText(i + 1, 1)));
        user.setUserName(ssrs.GetText(i + 1, 2));
        user.setPassWord(ssrs.GetText(i + 1, 3));
        user.setMenujson(ssrs.GetText(i + 1, 4));
        userList.add(user);
      }
    }
    return userList;
  }
Пример #3
0
  // 验证登录用户是否存在
  public User ChkUser(String userName, String passWord) {

    PreparedStatement pstmt = null;
    ResultSet rs = null;
    Connection conn = null;
    try {
      conn = DBConnPool.getConnection();
    } catch (NoFreeConnectionException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    User user = null;
    String sql = "select t.*, t.rowid from syjk_ccs_user t where t.username=? and t.password=?";

    try {
      pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, userName);
      pstmt.setString(2, passWord);
      rs = pstmt.executeQuery();
      if (rs.next()) {
        user = new User();
        user.setUserName(rs.getString("userName"));
        user.setPassWord(rs.getString("passWord"));
        user.setMenujson(rs.getString("menujson"));
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        if (rs != null) {
          rs.close();
        }
        if (pstmt != null) {
          pstmt.close();
        }
        ConnectDBBean.closeConnection(
            ReadWriteDBPool.readPool, conn); //  因关闭方式有问题  需要原来的关闭方式进行连接的关闭  mili 2015-3-20 16:34:57
        //				if(conn != null){
        //					conn.close();
        //				}
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    return user;
  }
Пример #4
0
  /**
   * 保存(新增、更新)用户信息
   *
   * @param user
   * @return
   */
  public boolean saveUser(User user) {

    boolean saveFlag = false;
    String updSql = null;

    if (isExist(user.getUserName())) {
      // 更新用户信息
      updSql =
          "UPDATE SYJK_CCS_USER SET PASSWORD = '******', MENUJSON = '"
              + user.getMenujson()
              + "' WHERE USERNAME= '******'";
    } else {
      // 新增用户
      String userId =
          String.valueOf(Integer.parseInt(es.getOneValue("select max(id) from syjk_ccs_user")) + 1);
      updSql =
          "INSERT INTO SYJK_CCS_USER (ID,USERNAME, PASSWORD, MENUJSON) VALUES ('"
              + userId
              + "','"
              + user.getUserName()
              + "','"
              + user.getPassWord()
              + "','"
              + user.getMenujson()
              + "') ";
    }

    if (null != updSql) {
      saveFlag = es.execUpdateSQL(updSql);
    }

    return saveFlag;
  }