Package com.projectmodule.servlet

Source Code of com.projectmodule.servlet.TbProjectServlet

package com.projectmodule.servlet;
import com.projectmodule.bean.TbProject;
import com.projectmodule.dao.*;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import util.*;

public class TbProjectServlet 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 projectCode=request.getParameter("projectCode");
        String projectName=request.getParameter("projectName");
        String projectStartTime=request.getParameter("projectStartTime");
        String projectEndTime=request.getParameter("projectEndTime");
        String projectAcceptanceTime=request.getParameter("projectAcceptanceTime");
        String contractCode=request.getParameter("contractCode");
        String projectManager=request.getParameter("projectManager");
        String tempProjectGroupCode=request.getParameter("tempProjectGroupCode");

            if(new TbProjectDAO().add(new TbProject(projectCode,projectName,projectStartTime,projectEndTime,projectAcceptanceTime,contractCode,projectManager,tempProjectGroupCode))){
            request.getSession().setAttribute("result", "添加成功");
            }else{           
            request.getSession().setAttribute("result", "添加失败");
            }
             request.getSession(true).setAttribute("tbProjectList",new TbProjectDAO().getTbProjectAll());
            response.sendRedirect("ProjectModule/TbProjectList.jsp");
        }
        if("del".equals(method)){
            if(UtilDAO.delin("Tb_Project", "ProjectId", request.getParameter("delIds"))){           
            request.getSession().setAttribute("result", "删除成功");
            }else{           
            request.getSession().setAttribute("result", "删除失败");
            }
             request.getSession(true).setAttribute("tbProjectList",new TbProjectDAO().getTbProjectAll());
            response.sendRedirect("ProjectModule/TbProjectList.jsp");
        }
        if("edit".equals(method)){
        int projectId=Integer.parseInt(request.getParameter("projectId"));
        String projectCode=request.getParameter("projectCode");
        String projectName=request.getParameter("projectName");
        String projectStartTime=request.getParameter("projectStartTime");
        String projectEndTime=request.getParameter("projectEndTime");
        String projectAcceptanceTime=request.getParameter("projectAcceptanceTime");
        String contractCode=request.getParameter("contractCode");
        String projectManager=request.getParameter("projectManager");
        String tempProjectGroupCode=request.getParameter("tempProjectGroupCode");

            if(new TbProjectDAO().edit(new TbProject(projectId,projectCode,projectName,projectStartTime,projectEndTime,projectAcceptanceTime,contractCode,projectManager,tempProjectGroupCode))){
            request.getSession().setAttribute("result", "修改成功");
            }else{           
            request.getSession().setAttribute("result", "修改失败");
            }
             request.getSession(true).setAttribute("tbProjectList",new TbProjectDAO().getTbProjectAll());
            response.sendRedirect("ProjectModule/TbProjectList.jsp");
        }
        if ("list".equals(method)) {
             request.getSession(true).setAttribute("tbProjectList",new TbProjectDAO().getTbProjectAll());
            response.sendRedirect("ProjectModule/TbProjectList.jsp");
          }
        if ("listById".equals(method)) {
             request.getSession(true).setAttribute("tbProject",new TbProjectDAO().getTbProjectByProjectId(Integer.parseInt(request.getParameter("projectId"))));
            response.sendRedirect("ProjectModule/TbProjectOperate.jsp");
      }
        if("showadd".equals(method)){
           
            request.getSession(true).removeAttribute("tbProject");
            response.sendRedirect("ProjectModule/TbProjectOperate.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
}
TOP

Related Classes of com.projectmodule.servlet.TbProjectServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.