?? storehousemanageraction.java
字號:
int shmIdI = -1;
try{
managerIdI = Integer.parseInt(managerId);
compFlagI = Integer.parseInt(compFlag);
shmIdI = Integer.parseInt(shmId);
}catch(Exception e){
e.printStackTrace();
}
// System.out.println("managerIdI="+managerIdI);
// System.out.println("compFlagI="+compFlagI);
if(compFlagI==0&&managerIdI>0){//當為自有倉管時
target="gotoMUserStr";
request.setAttribute("gotoMUserStr",request.getContextPath()+"/compuser/compUserAction.do?flag=modify&compUserId="+managerIdI);
}else if(compFlagI==1&&managerIdI>0){//當為第三方倉管時
StorehouseManagerOutView outView= StorehouseManagerOutViewDAO.selectStorehouseManagerOutViewByshmId(managerIdI);
request.setAttribute("outView",outView);
target="modifySHManager";
}
}
//修改
else if(flag.equals("modify")){
try{
OutShManagerDAO.startTransation();
storehouseManager.setCompFlag(1);
//判斷倉管員類型.true表示自有倉管員;false表示第三方倉管員
boolean managerType = com.tool.StorehouseTool.getSHManagerType(storehouseManager.getShmId());
if(!managerType){
StorehouseManagerDAO.updateStorehouseManager(storehouseManager);
OutShManagerDAO.updateOutShManager(storehouseManager);
}
OutShManagerDAO.commit();
ActionError actionError = new ActionError(
"errors.addSuccese");
actionErrors.add("", actionError);
saveErrors(request, actionErrors);
}catch(Exception e){
e.printStackTrace();
ActionError actionError = new ActionError(
"errors.generally.failed",e.getMessage());
actionErrors.add("", actionError);
saveErrors(request, actionErrors);
}finally{
StorehouseManagerDAO.rollback();
//最后繼續跳轉到修改頁面
StorehouseManagerOutView outView= StorehouseManagerOutViewDAO.selectStorehouseManagerOutViewByshmId(storehouseManager.getOutShMagerId());
request.setAttribute("outView",outView);
target="modifySHManager";
System.out.println("in modify manqager");
System.out.println("storehouseManager.getShmId()="+storehouseManager.getShmId());
}
}
//查看詳細
//radioValue參數的組成:“自有倉管員ID(或第三方倉管員ID)||||倉管類型標識and倉庫ID”
//倉管類型標識的值為:1或0。1 表示自有倉庫,0表示第三方倉庫
else if (flag.equals("detail")) {
String radioValue = request.getParameter("radioValue");
String managerId = radioValue.substring(0, radioValue.indexOf("|"));
String compFlag = radioValue.substring(radioValue.lastIndexOf("|") +
1);
}
//跳轉到分配倉庫窗體
else if (flag.equals("giveSH")) {
// System.out.println("in asdfasdfasdasd2----");
String radioValue = request.getParameter("radioValue");
if(radioValue==null||radioValue.length()<5) return mapping.findForward("editSHManager");
String shmId = radioValue.substring(radioValue.lastIndexOf("d")+1,radioValue.length());//統一倉庫管理員Id
// System.out.println("shmId="+shmId);
// System.out.println("radioValue="+radioValue);
request.setAttribute("realName",StorehouseShmanagerViewDAO.selectStorehouseShmanagerViewByshmId(new Integer(shmId.trim()).intValue()).getRealName());
request.setAttribute("managerId",shmId);
StorehouseAction storehouseAction = new StorehouseAction();
storehouseAction.initPage(request);
target="listSHForManager";
}
//執行分配倉庫
else if(flag.equals("forManager")){
try{
String shIdStr = (String)request.getParameter("shId");
String managerIdStr = (String)request.getParameter("managerId");
int shId = new Integer(shIdStr.trim()).intValue();
int managerId = new Integer(managerIdStr.trim()).intValue();
StorehouseShmanagerDAO.startTransation();
int shmanagerId = StorehouseShmanagerDAO.getLastId();
StorehouseShmanager storehouseShmanager = new StorehouseShmanager();
storehouseShmanager.setDelFlag(0);
storehouseShmanager.setSelfId(shmanagerId+1);
storehouseShmanager.setShId(shId);
storehouseShmanager.setShmId(managerId);
//判斷當前倉管員能否添加到當前倉庫
boolean tmp = com.tool.StorehouseTool.isShMCanAddToSh(managerId,
shId);
request.setAttribute("realName",StorehouseShmanagerViewDAO.selectStorehouseShmanagerViewByshmId(managerId).getRealName());
request.setAttribute("managerId",managerIdStr);
if (!tmp) {
ActionError actionError = new ActionError(
"errors.generally.failed","倉管員類型與倉庫類型不匹配!");
actionErrors.add("", actionError);
saveErrors(request, actionErrors);
StorehouseAction storehouseAction = new StorehouseAction();
storehouseAction.initPage(request);
return mapping.findForward("listSHForManager");
}
StorehouseShmanagerDAO.insertStorehouseShmanager(
storehouseShmanager);
StorehouseShmanagerDAO.commit();
ActionError actionError = new ActionError(
"errors.addSuccese");
actionErrors.add("", actionError);
saveErrors(request, actionErrors);
}catch(Exception e){
e.printStackTrace();
}finally{
StorehouseShmanagerDAO.rollback();
StorehouseAction storehouseAction = new StorehouseAction();
storehouseAction.initPage(request);
target="listSHForManager";
}
}
else if(flag.equals("queryForImport")){
initPage(request);
target="importShM";
}
return mapping.findForward(target);
}
//初始化并獲得分頁
private Page initPage(HttpServletRequest request) {
String currentPageStr = request.getParameter("currentPage");
String queryStr = QueryStrCreator.create("Shmanager", request);
// System.out.println("#"+queryStr);
int currentPage = 1; //當前頁碼
int size = 20; //每頁的記錄數
try { //防止從地址欄直接輸入非法頁碼
if (currentPageStr != null) currentPage = new Integer(
currentPageStr).intValue();
} catch (Exception e) {
e.printStackTrace();
}
//處理分頁
//會話中是否已有分頁生成工具
PageTool pageTool = null;
HttpSession session = request.getSession();
pageTool = (PageTool) session.getAttribute("shManagerPageTool"); //有,則直接拿來用
if (pageTool == null) { //沒有,則新建,并放進會話中,以備下次用
pageTool = PageToolBuilder.builder(new StorehouseShmanagerViewDAO());
session.setAttribute("shManagerPageTool", pageTool);
}
//由分頁工具生成分頁
Page page = null;
try {
String flag = request.getParameter("flag");
if (flag.equals("query")||flag.equals("queryForImport")) //查詢時的分頁
page = pageTool.createPage(currentPage, size, queryStr);
else //其它非查詢的分頁
page = pageTool.createPage(currentPage, size);
} catch (SQLException ex) {
ex.printStackTrace();
}
//將分頁放進請求中,分發到下一個頁面顯示
request.setAttribute("allshManagerPage", page);
return page;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -