package com.tempprojectgroupmodule.servlet;
import com.tempprojectgroupmodule.bean.TbTempProjectGroup;
import com.tempprojectgroupmodule.dao.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import util.*;
public class TbTempProjectGroupServlet extends HttpServlet{
public void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
String method = request.getParameter("method")==null?"":request.getParameter("method");
if("add".equals(method)){
String tempProjectGroupCode=request.getParameter("tempProjectGroupCode");
String tempProjectGroupName=request.getParameter("tempProjectGroupName");
String tempProjectGroupMaster=request.getParameter("tempProjectGroupMaster");
String tempProjectGroupMembers=request.getParameter("tempProjectGroupMembers");
String tempProjectGroupCreateTime=request.getParameter("tempProjectGroupCreateTime");
if(new TbTempProjectGroupDAO().add(new TbTempProjectGroup(tempProjectGroupCode,tempProjectGroupName,tempProjectGroupMaster,tempProjectGroupMembers,tempProjectGroupCreateTime))){
request.getSession().setAttribute("result", "添加成功");
}else{
request.getSession().setAttribute("result", "添加失败");
}
request.getSession(true).setAttribute("tbTempProjectGroupList",new TbTempProjectGroupDAO().getTbTempProjectGroupAll());
response.sendRedirect("TempProjectGroupModule/TbTempProjectGroupList.jsp");
}
if("del".equals(method)){
if(UtilDAO.delin("Tb_TempProjectGroup", "TempProjectGroupId", request.getParameter("delIds"))){
request.getSession().setAttribute("result", "删除成功");
}else{
request.getSession().setAttribute("result", "删除失败");
}
request.getSession(true).setAttribute("tbTempProjectGroupList",new TbTempProjectGroupDAO().getTbTempProjectGroupAll());
response.sendRedirect("TempProjectGroupModule/TbTempProjectGroupList.jsp");
}
if("edit".equals(method)){
int tempProjectGroupId=Integer.parseInt(request.getParameter("tempProjectGroupId"));
String tempProjectGroupCode=request.getParameter("tempProjectGroupCode");
String tempProjectGroupName=request.getParameter("tempProjectGroupName");
String tempProjectGroupMaster=request.getParameter("tempProjectGroupMaster");
String tempProjectGroupMembers=request.getParameter("tempProjectGroupMembers");
String tempProjectGroupCreateTime=request.getParameter("tempProjectGroupCreateTime");
if(new TbTempProjectGroupDAO().edit(new TbTempProjectGroup(tempProjectGroupId,tempProjectGroupCode,tempProjectGroupName,tempProjectGroupMaster,tempProjectGroupMembers,tempProjectGroupCreateTime))){
request.getSession().setAttribute("result", "修改成功");
}else{
request.getSession().setAttribute("result", "修改失败");
}
request.getSession(true).setAttribute("tbTempProjectGroupList",new TbTempProjectGroupDAO().getTbTempProjectGroupAll());
response.sendRedirect("TempProjectGroupModule/TbTempProjectGroupList.jsp");
}
if ("list".equals(method)) {
request.getSession(true).setAttribute("tbTempProjectGroupList",new TbTempProjectGroupDAO().getTbTempProjectGroupAll());
response.sendRedirect("TempProjectGroupModule/TbTempProjectGroupList.jsp");
}
if ("listById".equals(method)) {
request.getSession(true).setAttribute("tbTempProjectGroup",new TbTempProjectGroupDAO().getTbTempProjectGroupByTempProjectGroupId(Integer.parseInt(request.getParameter("tempProjectGroupId"))));
response.sendRedirect("TempProjectGroupModule/TbTempProjectGroupOperate.jsp");
}
if("showadd".equals(method)){
request.getSession(true).removeAttribute("tbTempProjectGroup");
response.sendRedirect("TempProjectGroupModule/TbTempProjectGroupOperate.jsp");
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.processRequest(request, response);
}// end method doGet
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.processRequest(request, response);
}// end method doPost
}