// 修改成员信息 public String UpdateMember() throws Exception { UserDAO uDAO = null; String retMess = "UpdateMemberFailed"; try { uDAO = DAOFactory.getUserDAOInstance(); User user = new User(); // 获得uId setUserId(Integer.parseInt(ServletActionContext.getRequest().getParameter("uId"))); user.setuId(getUserId()); user.setuMgr(getUserMgr()); user.setuEducation(getUserEducation()); if (uDAO.doUpdateMember(user)) { ArrayList<User> uList = (ArrayList<User>) uDAO.doSelectById(getUserId()); HttpServletRequest request = ServletActionContext.getRequest(); request.setAttribute("uList", uList); ArrayList<String> mgrList = (ArrayList<String>) uDAO.doSelectAllMgr(getUserId()); request.setAttribute("mgrList", mgrList); retMess = "UpdateMember"; } } catch (Exception e) { e.printStackTrace(); } return retMess; }
// 显示员工列表 public String ShowMemberList() throws Exception { UserDAO uDAO = null; String retMess = "ShowMemberListFailed"; try { uDAO = DAOFactory.getUserDAOInstance(); ArrayList<User> uList = (ArrayList<User>) uDAO.doSelectById(0); // 注册Session HttpSession session = ServletActionContext.getRequest().getSession(); session.setAttribute("uList", uList); return "ShowMemberList"; } catch (Exception e) { e.printStackTrace(); } return retMess; }
// 删除成员 public String DeleteMember() throws Exception { UserDAO uDAO = null; String retMess = "DeleteFailed"; try { uDAO = DAOFactory.getUserDAOInstance(); setUserId(Integer.parseInt(ServletActionContext.getRequest().getParameter("uId"))); if (uDAO.doDeleteMember(getUserId())) { return "DeleteMember"; } } catch (Exception e) { e.printStackTrace(); } return retMess; }
// 显示新建成员 public String ShowNewMember() throws Exception { UserDAO uDAO = null; String retMess = "ShowMemberFailed"; try { uDAO = DAOFactory.getUserDAOInstance(); ArrayList<String> mgrList = (ArrayList<String>) uDAO.doSelectAllMgr(0); HttpServletRequest request = ServletActionContext.getRequest(); request.setAttribute("mgrList", mgrList); retMess = "ShowMember"; } catch (Exception e) { e.printStackTrace(); } return retMess; }
// 新增成员 public String InsertMember() throws Exception { UserDAO uDAO = null; String retMess = "NewFailed"; try { uDAO = DAOFactory.getUserDAOInstance(); User user = new User(); user.setuName(getUserName()); if (getUserPwd1().equals(getUserPwd2())) { user.setuPwd(getUserPwd1()); } else { setError("201"); return retMess; } user.setuGender(getUserGender()); user.setuRole(getUserRole()); user.setuPosition(getUserPosition()); user.setuExprience(getUserExprience()); user.setuProfessional(getUserProfessional()); String mgr = getUserMgr(); if ("主管".equals(mgr)) { user.setuMgr(getUserName()); } else { user.setuMgr(getUserMgr()); } user.setuEducation(getUserEducation()); if (uDAO.doInsertMember(user)) { return "NewSuccess"; } } catch (Exception e) { e.printStackTrace(); } return retMess; }