Package com.pricemodule.servlet

Source Code of com.pricemodule.servlet.TbPriceServlet

package com.pricemodule.servlet;
import com.pricemodule.bean.TbPrice;
import com.pricemodule.dao.*;

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

public class TbPriceServlet 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 priceYear=request.getParameter("priceYear");
        String priceValue=request.getParameter("priceValue");
        String priceMemo=request.getParameter("priceMemo");

            if(new TbPriceDAO().add(new TbPrice(priceYear,priceValue,priceMemo,new UtilDAO().decodeDate()))){
            request.getSession().setAttribute("result", "添加成功");
            }else{           
            request.getSession().setAttribute("result", "添加失败");
            }
             request.getSession(true).setAttribute("tbPriceList",new TbPriceDAO().getTbPriceAll());
            response.sendRedirect("PriceModule/TbPriceList.jsp");
        }
        if("del".equals(method)){
            if(UtilDAO.delin("Tb_Price", "PriceId", request.getParameter("delIds"))){           
            request.getSession().setAttribute("result", "删除成功");
            }else{           
            request.getSession().setAttribute("result", "删除失败");
            }
             request.getSession(true).setAttribute("tbPriceList",new TbPriceDAO().getTbPriceAll());
            response.sendRedirect("PriceModule/TbPriceList.jsp");
        }
        if("edit".equals(method)){
        int priceId=Integer.parseInt(request.getParameter("priceId"));
        String priceYear=request.getParameter("priceYear");
        String priceValue=request.getParameter("priceValue");
        String priceMemo=request.getParameter("priceMemo");

            if(new TbPriceDAO().edit(new TbPrice(priceId,priceYear,priceValue,priceMemo,new UtilDAO().decodeDate()))){
            request.getSession().setAttribute("result", "修改成功");
            }else{           
            request.getSession().setAttribute("result", "修改失败");
            }
             request.getSession(true).setAttribute("tbPriceList",new TbPriceDAO().getTbPriceAll());
            response.sendRedirect("PriceModule/TbPriceList.jsp");
        }
        if ("list".equals(method)) {
             request.getSession(true).setAttribute("tbPriceList",new TbPriceDAO().getTbPriceAll());
            response.sendRedirect("PriceModule/TbPriceList.jsp");
          }
        if ("listById".equals(method)) {
             request.getSession(true).setAttribute("tbPrice",new TbPriceDAO().getTbPriceByPriceId(Integer.parseInt(request.getParameter("priceId"))));
            response.sendRedirect("PriceModule/TbPriceOperate.jsp");
      }
        if("showadd".equals(method)){
           
            request.getSession(true).removeAttribute("tbPrice");
            response.sendRedirect("PriceModule/TbPriceOperate.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.pricemodule.servlet.TbPriceServlet

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.