Ejemplo n.º 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); // 修改保存
    }
  }
Ejemplo n.º 2
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;
  }