📄 orderaction.java
字号:
package com.set.system.struts.action;
import java.util.ArrayList;
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.data.GenericValueObject;
import com.set.appframe.data.SearchResult;
import com.set.appframe.exception.SystemException;
import com.set.appframe.web.MyBaseAction;
import com.set.system.business.OrderMgr;
import com.set.system.business.ShoppingMgr;
import com.set.system.model.OrderVO;
import com.set.system.model.OrderdetailVO;
import com.set.utils.StringUtils;
import com.set.utils.WebUtils;
public class OrderAction 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) {
int totalPage = 0;
int intPageNo = 1;
OrderVO values = new OrderVO(WebUtils.convertEnumeration(request, true));
String userId=(String)request.getSession().getAttribute("ID");
values.setUserid(userId);
int tmpPageNo = 0;
String searchStr = request.getParameter("SearchFormValues");
totalPage = StringUtils.toInteger(values.getItemString("ctlTotalPage"),
0);
if (tmpPageNo > totalPage) {
tmpPageNo = totalPage;
}
String ActionID = values.getItemString("ACTIONID");
if (tmpPageNo > 0) {
intPageNo = tmpPageNo;
} else {
intPageNo = WebUtils.getpageNo(request, ActionID, totalPage);
}
SearchResult result = null;
try {
OrderMgr manager = (OrderMgr) getBean("OrderMgr");
result = manager.search(values, intPageNo, INT_PAGESIZE);
} catch (SystemException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("GVOLIST", this.formatDate2(
result.getResultList(), new String[] { "CREATEDDATE" }));
int total = result.getCount();
if (total % INT_PAGESIZE == 0) {
totalPage = total / INT_PAGESIZE;
} else {
totalPage = total / INT_PAGESIZE + 1;
// 保存总的记录数
}
request.setAttribute("TotalRecords", new Integer(total));
// 保存总页数
request.setAttribute("TotalPage", new Integer(totalPage));
// 当前页数
request.setAttribute("PageNo", new Integer(intPageNo));
// 分页字符串
request.setAttribute("PagerString", WebUtils.getPagerString(totalPage,
intPageNo));
// 设定formValues,用来初始化前台的查询条件
request.setAttribute("FormValues", values);
return mapping.findForward("search");
}
public ActionForward remove(ActionMapping mapping, ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws SystemException {
String id=request.getParameter("id");
OrderMgr mgr= (OrderMgr)getBean("OrderMgr");
mgr.delete(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 {
OrderVO values = new OrderVO(WebUtils.convertEnumeration(request, true));
String userid=(String)request.getSession().getAttribute("ID");
List list=null;
values.setUserid(userid);
OrderMgr mgr= (OrderMgr)getBean("OrderMgr");
ShoppingMgr manger= (ShoppingMgr)getBean("ShoppingMgr");
list=manger.search(userid);
if(list.size()>0){
values=mgr.create(values,list);
manger.deleteAll(userid);
request.setAttribute("order", values);
return mapping.findForward("success");
}else{
request.setAttribute("false","0");
return mapping.findForward("false");
}
}
public ActionForward view(ActionMapping mapping, ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws SystemException {
String id=request.getParameter("id");
int totalPage = 0;
int intPageNo = 1;
OrderdetailVO values = new OrderdetailVO(WebUtils.convertEnumeration(request, true));
values.setOrderId(id);
int tmpPageNo = 0;
String searchStr = request.getParameter("SearchFormValues");
totalPage = StringUtils.toInteger(values.getItemString("ctlTotalPage"),
0);
if (tmpPageNo > totalPage) {
tmpPageNo = totalPage;
}
String ActionID = values.getItemString("ACTIONID");
if (tmpPageNo > 0) {
intPageNo = tmpPageNo;
} else {
intPageNo = WebUtils.getpageNo(request, ActionID, totalPage);
}
SearchResult result = null;
try {
OrderMgr manager = (OrderMgr) getBean("OrderMgr");
result = manager.orderdetailSearch(values, intPageNo, INT_PAGESIZE);
} catch (SystemException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("GVOLIST", this.formatDate2(
result.getResultList(), new String[] { "CREATEDDATE" }));
int total = result.getCount();
if (total % INT_PAGESIZE == 0) {
totalPage = total / INT_PAGESIZE;
} else {
totalPage = total / INT_PAGESIZE + 1;
// 保存总的记录数
}
request.setAttribute("TotalRecords", new Integer(total));
// 保存总页数
request.setAttribute("TotalPage", new Integer(totalPage));
// 当前页数
request.setAttribute("PageNo", new Integer(intPageNo));
// 分页字符串
request.setAttribute("PagerString", WebUtils.getPagerString(totalPage,
intPageNo));
// 设定formValues,用来初始化前台的查询条件
request.setAttribute("FormValues", values);
return mapping.findForward("view");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -