Package com.contractmodule.servlet

Source Code of com.contractmodule.servlet.TbContractServlet

package com.contractmodule.servlet;
import com.contractmodule.bean.TbContract;
import com.contractmodule.dao.*;

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

public class TbContractServlet 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 contractCode=request.getParameter("contractCode");
        String contractName=request.getParameter("contractName");
        String contractContent=request.getParameter("contractContent");
        String startDateSigned=request.getParameter("startDateSigned");
        String endDateSigned=request.getParameter("endDateSigned");
        String partyAName=request.getParameter("partyAName");
        String partyAAddress=request.getParameter("partyAAddress");
        String partyBName=request.getParameter("partyBName");
        String partybAddress=request.getParameter("partybAddress");

            if(new TbContractDAO().add(new TbContract(contractCode,contractName,contractContent,startDateSigned,endDateSigned,partyAName,partyAAddress,partyBName,partybAddress,new UtilDAO().decodeDate()))){
            request.getSession().setAttribute("result", "添加成功");
            }else{           
            request.getSession().setAttribute("result", "添加失败");
            }
             request.getSession(true).setAttribute("tbContractList",new TbContractDAO().getTbContractAll());
            response.sendRedirect("ContractModule/TbContractList.jsp");
        }
        if("del".equals(method)){
            if(UtilDAO.delinForStringPrimaryKey("Tb_Contract", "ContractCode", request.getParameter("delIds"))){           
            request.getSession().setAttribute("result", "删除成功");
            }else{           
            request.getSession().setAttribute("result", "删除失败");
            }
             request.getSession(true).setAttribute("tbContractList",new TbContractDAO().getTbContractAll());
            response.sendRedirect("ContractModule/TbContractList.jsp");
        }
        if("edit".equals(method)){
        String contractCode=request.getParameter("contractCode");
        String contractName=request.getParameter("contractName");
        String contractContent=request.getParameter("contractContent");
        String startDateSigned=request.getParameter("startDateSigned");
        String endDateSigned=request.getParameter("endDateSigned");
        String partyAName=request.getParameter("partyAName");
        String partyAAddress=request.getParameter("partyAAddress");
        String partyBName=request.getParameter("partyBName");
        String partybAddress=request.getParameter("partybAddress");

            if(new TbContractDAO().edit(new TbContract(contractCode,contractName,contractContent,startDateSigned,endDateSigned,partyAName,partyAAddress,partyBName,partybAddress,new UtilDAO().decodeDate()))){
            request.getSession().setAttribute("result", "修改成功");
            }else{           
            request.getSession().setAttribute("result", "修改失败");
            }
             request.getSession(true).setAttribute("tbContractList",new TbContractDAO().getTbContractAll());
            response.sendRedirect("ContractModule/TbContractList.jsp");
        }
        if ("list".equals(method)) {
             request.getSession(true).setAttribute("tbContractList",new TbContractDAO().getTbContractAll());
            response.sendRedirect("ContractModule/TbContractList.jsp");
          }
        if ("listById".equals(method)) {
            request.getSession(true).setAttribute("tbContract",new TbContractDAO().getTbContractByContractCode((request.getParameter("contractCode"))));
            response.sendRedirect("ContractModule/TbContractOperate.jsp");
      }
        if("showadd".equals(method)){
           
            request.getSession(true).removeAttribute("tbContract");
            response.sendRedirect("ContractModule/TbContractOperate.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.contractmodule.servlet.TbContractServlet

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.