String method = request.getParameter("method")==null?"":request.getParameter("method");
if("add".equals(method)){
String departName=request.getParameter("departName");
int parentDepartId=Integer.parseInt(request.getParameter("parentDepartId"));
String departMemo=request.getParameter("departMemo");
if(new TbDepartDAO().add(new TbDepart(departName,parentDepartId,departMemo,new UtilDAO().decodeDate()))){
request.getSession().setAttribute("result", "添加成功");
}else{
request.getSession().setAttribute("result", "添加失败");
}
request.getSession(true).setAttribute("tbDepartList",new TbDepartDAO().getTbDepartAll());
response.sendRedirect("DepartModule/TbDepartList.jsp");
}
if("del".equals(method)){
if(UtilDAO.delin("Tb_Depart", "DepartId", request.getParameter("delIds"))){
request.getSession().setAttribute("result", "删除成功");
}else{
request.getSession().setAttribute("result", "删除失败");
}
request.getSession(true).setAttribute("tbDepartList",new TbDepartDAO().getTbDepartAll());
response.sendRedirect("DepartModule/TbDepartList.jsp");
}
if("edit".equals(method)){
int departId=Integer.parseInt(request.getParameter("departId"));
String departName=request.getParameter("departName");
int parentDepartId=Integer.parseInt(request.getParameter("parentDepartId"));
String departMemo=request.getParameter("departMemo");
if(new TbDepartDAO().edit(new TbDepart(departId,departName,parentDepartId,departMemo,new UtilDAO().decodeDate()))){
request.getSession().setAttribute("result", "修改成功");
}else{
request.getSession().setAttribute("result", "修改失败");
}
request.getSession(true).setAttribute("tbDepartList",new TbDepartDAO().getTbDepartAll());