shoppingaction.java

来自「本文论述了一个前台笔记本销售系统的开发过程」· Java 代码 · 共 96 行

JAVA
96
字号
package com.set.system.struts.action;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.set.appframe.exception.SystemException;
import com.set.appframe.web.MyBaseAction;
import com.set.system.business.ShoppingMgr;
import com.set.system.model.ShoppingVO;

public class ShoppingAction extends MyBaseAction {

	private static final int INT_PAGESIZE = 10;

	public ActionForward search(ActionMapping mapping, ActionForm form,
			javax.servlet.http.HttpServletRequest request,
			javax.servlet.http.HttpServletResponse response)
			throws SystemException {
        String key="";
        if(request.getParameter("key")!=null){
            key=request.getParameter("key");
        }
		String userid = (String) request.getSession().getAttribute("ID");
		List resultList = null;
		ShoppingMgr mgr = (ShoppingMgr) getBean("ShoppingMgr");
		resultList = mgr.search(userid);
		request.setAttribute("shopping", resultList);
		if(key.equals("search")||key.equals("")){
			return mapping.findForward("search");
		}else{
			return mapping.findForward("balance");
		}		
	}
	
	//未写完
	public ActionForward modify(ActionMapping mapping, ActionForm form,
			javax.servlet.http.HttpServletRequest request,
			javax.servlet.http.HttpServletResponse response)
			throws SystemException {
		String[] id = request.getParameterValues("ID");
		String[] number = request.getParameterValues("NUMBER");
		ShoppingMgr mgr = (ShoppingMgr) getBean("ShoppingMgr");
		mgr.update(id , number);
		return this.search(mapping, form, request, response);
	}
	
	public ActionForward removeAll(ActionMapping mapping, ActionForm form,
			javax.servlet.http.HttpServletRequest request,
			javax.servlet.http.HttpServletResponse response)
			throws SystemException {
		
		String userid = (String) request.getSession().getAttribute("ID");
		ShoppingMgr mgr = (ShoppingMgr) getBean("ShoppingMgr");
        mgr.deleteAll(userid);
		return this.search(mapping, form, request, response);
	}
	
	public ActionForward remove(ActionMapping mapping, ActionForm form,
			javax.servlet.http.HttpServletRequest request,
			javax.servlet.http.HttpServletResponse response)
			throws SystemException {
		
		String userid = (String) request.getSession().getAttribute("ID");
		String id=request.getParameter("id");
		ShoppingMgr mgr = (ShoppingMgr) getBean("ShoppingMgr");
        mgr.delete(userid, id);
		return this.search(mapping, form, request, response);
	}
	
	public ActionForward create(ActionMapping mapping, ActionForm form,
			javax.servlet.http.HttpServletRequest request,
			javax.servlet.http.HttpServletResponse response)
			throws SystemException {
		String productId=request.getParameter("productId");
		String userid = (String) request.getSession().getAttribute("ID");
		ShoppingVO vo=new ShoppingVO();
		vo.setProductId(productId);
		vo.setUserid(userid);
		ShoppingMgr mgr = (ShoppingMgr) getBean("ShoppingMgr");
        mgr.create(vo);  
		return this.search(mapping, form, request, response);
	}
	
	public ActionForward next(ActionMapping mapping, ActionForm form,
			javax.servlet.http.HttpServletRequest request,
			javax.servlet.http.HttpServletResponse response){
		String totalprice=request.getParameter("totalprice");
		request.setAttribute("totalprice", totalprice);
		return mapping.findForward("deliveryway");
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?