?? manageaction.java
字號:
GenericVO gvo = new GoodsMgr().getGoodsDetail(goodsId);
//得到相關商品
request.setAttribute("bean", gvo);
return mapping.findForward("toGoodsDetail");
}
public ActionForward toOOGoodsAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
//設置查詢條件
GenericVO gvo = new GenericVO();
ListVO lvo = new ListVO();
gvo = AppUtil.convertParameters(request, gvo); //將request 中的參數設置到cvo\uFFFD?
lvo.setItemsPerPage(30);
lvo = AppUtil.processListVO(lvo, request); //設置ListVO
gvo.setListVO(lvo);
//查詢數據
lvo = new GoodsMgr().searchGoods(gvo);
gvo.setListVO(lvo);
//設置頁面數據
request.setAttribute("bean", gvo);
return mapping.findForward("toOOGoodsAdd");
}
public ActionForward doOOGoodsAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
String[] goodIds = request.getParameterValues("good_id");
GoodsMgr gm = new GoodsMgr();
GenericVO gvo = new GenericVO();
for (int i = 0; i < goodIds.length; i++) {
gvo.add("GOODS_ID", request.getParameter("goods_id"));
gvo.add("RELATEGOODS_ID", goodIds[i]);
gm.addOOGoods(gvo);
}
return mapping.findForward("doOOGoodsAdd");
}
public ActionForward doOOGoodsDelete(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
new GoodsMgr().deleteOOGoods(BaseUtil.toInt(request.getParameter("id")));
return mapping.findForward("doOOGoodsAdd");
}
public ActionForward toGoodsModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
return mapping.findForward("toGoodsModify");
}
public ActionForward doGoodsModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
try {
//上傳圖片
// 新建??個SmartUpload對象
SmartUpload su = new SmartUpload();
// 上傳初始??
su.initialize(request.getSession().getServletContext(),
(HttpServletRequest) request,
(HttpServletResponse) response);
// 設定上傳限制
// 1.限制每個上傳文件的最大長度???
su.setMaxFileSize(10000000);
// 2.限制總上傳數據的長度??
// su.setTotalMaxFileSize(20000);
// 3.設定允許上傳的文件(通過擴展名限制),僅允許doc,txt文件??
su.setAllowedFilesList("jpg,gif,JPG,GIF");
// 4.設定禁止上傳的文件(通過擴展名限制),禁止上傳帶有exe,bat,jsp, htm, html擴展名的文件和沒有擴展名的文?? ??
// su.setDeniedFilesList("exe,bat,jsp,htm,html,,");
// 上傳文件
su.upload();
// 將上傳文件全部保存到指定目錄
su.save("/images/goodsphotoes");
// 逐一提取上傳文件信息,同時可保存文件??
for (int i = 0; i < su.getFiles().getCount(); i++) {
SmartFile file = su.getFiles().getFile(i);
SmartRequest sr = su.getRequest();
String goodsId = sr.getParameter("goods_id");
String name = sr.getParameter("name");
String brandId = sr.getParameter("brand_id");
String goodsTypeId = sr.getParameter("goodstype_id");
String goodsTypeId2 = sr.getParameter("goodstype_id2");
String price1 = sr.getParameter("price1");
String price2 = sr.getParameter("price2");
String dot = sr.getParameter("dot");
String weight = sr.getParameter("weight");
String kucun = sr.getParameter("kucun");
String description = sr.getParameter("description");
GenericVO gvo = new GenericVO();
// 若文件不存在則繼??
if (!file.isMissing()) {
//得到文件??
String fileName = su.getFileNames()[i];
//生成縮小圖片
ImgUtil iutil = new ImgUtil();
String tfileName = fileName.substring(0,
fileName.indexOf(".")) +
"_s." + file.getFileExt();
iutil.reduce(getServlet().getServletContext().getRealPath(
"/") +
fileName,
getServlet().getServletContext().getRealPath(
"/") +
tfileName, 125, 125);
gvo.add("PHOTO", fileName);
gvo.add("SPHOTO", tfileName);
}
gvo.add("GOODS_ID", goodsId);
gvo.add("NAME", name);
gvo.add("BRAND_ID", brandId);
gvo.add("GOODSTYPE_ID", goodsTypeId);
gvo.add("GOODSTYPE_ID2", goodsTypeId2);
gvo.add("PRICE1", price1);
gvo.add("PRICE2", price2);
gvo.add("DOT", dot);
gvo.add("WEIGHT", weight);
gvo.add("KUCUN", kucun);
gvo.add("DESCRIPTION", description);
new GoodsMgr().modifyGoods(gvo);
request.setAttribute("GOODS_ID", "" + goodsId);
}
} catch (Exception ex) {
ex.printStackTrace();
throw new AppException(ex);
}
return mapping.findForward("doGoodsModify");
}
//商品分類
public ActionForward toCategoryManage(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
Vector result = new GoodsMgr().getTopGoodsType();
request.setAttribute("RESULT", result);
return mapping.findForward("toCategoryManage");
}
public ActionForward toCategoryAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
Vector pid = new GoodsMgr().getTopGoodsType();
request.setAttribute("RESULT", pid);
return mapping.findForward("toCategoryAdd");
}
public ActionForward doCategoryAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO gvo = new GenericVO();
gvo = AppUtil.convertParameters(request, gvo); //將request 中的參數設置到cvo
new GoodsMgr().addGoodsType(gvo);
//重新生成首頁商品分類列表
this.genIndexCate();
return mapping.findForward("doCategoryAdd");
}
public ActionForward toCategoryModify(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO tvo = new GoodsMgr().getGoodsTypeDetail(BaseUtil.toInt(
request.getParameter("goodstype_id")));
request.setAttribute("bean", tvo);
return mapping.findForward("toCategoryModify");
}
public ActionForward doCategoryModify(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO gvo = new GenericVO();
gvo = AppUtil.convertParameters(request, gvo); //將request 中的參數設置到cvo
new GoodsMgr().modifyGoodsType(gvo);
//重新生成首頁商品分類列表
this.genIndexCate();
return mapping.findForward("doCategoryModify");
}
public ActionForward doCategoryDelete(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
int r = new GoodsMgr().deleteGoodsType(BaseUtil.toInt(request.
getParameter("goodstype_id")));
request.setAttribute("RESULT", r + "");
//重新生成首頁商品分類列表
this.genIndexCate();
return mapping.findForward("doCategoryDelete");
}
//品牌
public ActionForward toBrand(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
Vector r = new GoodsMgr().getBrand();
request.setAttribute("RESULT", r);
return mapping.findForward("toBrand");
}
public ActionForward toBrandAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
return mapping.findForward("toBrandAdd");
}
public ActionForward doBrandAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO gvo = new GenericVO();
gvo = AppUtil.convertParameters(request, gvo); //將request 中的參數設置到cvo
new GoodsMgr().addBrand(gvo);
return mapping.findForward("doBrandAdd");
}
public ActionForward toBrandModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO bvo = new GoodsMgr().getBrandDetail(BaseUtil.toInt(request.
getParameter("brand_id")));
request.setAttribute("bean", bvo);
return mapping.findForward("toBrandModify");
}
public ActionForward doBrandDelete(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
new GoodsMgr().deleteBrand(BaseUtil.toInt(request.getParameter(
"brand_id")));
request.setAttribute("BRAND_ID", request.getParameter("brand_id"));
return mapping.findForward("doBrandDelete");
}
public ActionForward doBrandModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO gvo = new GenericVO();
gvo = AppUtil.convertParameters(request, gvo); //將request 中的參數設置到cvo
new GoodsMgr().modifyBrand(gvo);
return mapping.findForward("doBrandModify");
}
public ActionForward toLogo1Modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO bvo = new GoodsMgr().getBrandDetail(BaseUtil.toInt(request.
getParameter("brand_id")));
request.setAttribute("bean", bvo);
return mapping.findForward("toLogo1Modify");
}
public ActionForward doLogo1Modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -