Personnel management system --第四天

部门管理的其他功能:添加部门,编辑部门,删除部门。。

  
//添加部门
public
void toAdd(HttpServletRequest request, HttpServletResponse response) throws IOException { response.sendRedirect("../department_add.jsp"); } public void add(HttpServletRequest request, HttpServletResponse response) throws IOException { String name=request.getParameter("name"); String address=request.getParameter("address"); Department department=new Department(); department.setName(name); department.setAddress(address); departmentService.add(department); response.sendRedirect("list.do"); }
//删除部门
public void remove(HttpServletRequest request, HttpServletResponse response) throws IOException { String id=request.getParameter("id"); departmentService.remove(Integer.parseInt(id)); response.sendRedirect("list.do"); }
//修改部门信息
public void toEdit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String id=request.getParameter("id"); Department department=departmentService.get(Integer.parseInt(id)); request.setAttribute("dep",department); request.getRequestDispatcher("../department_edit.jsp").forward(request,response); } public void edit(HttpServletRequest request, HttpServletResponse response) throws IOException { String id=request.getParameter("id"); String name=request.getParameter("name"); String address=request.getParameter("address"); Department department=new Department(); department.setName(name); department.setAddress(address); departmentService.edit(department); response.sendRedirect("list.do"); }

猜你喜欢

转载自www.cnblogs.com/liu-chen/p/11652025.html