日期:2014-05-20 浏览次数:20807 次
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType("text/html;charset=gb2312"); PrintWriter out = response.getWriter(); System.out.println("测试==============="); InventoryManager mgr = (InventoryManager) getBean("inventoryManager"); InventoryForm InventoryForm = (InventoryForm) form; String[] cinvCodes = request.getParameterValues("cinvCode"); String[] cInvPersonCodes = request.getParameterValues("cInvPersonCode"); String[] iAdvanceDates = request.getParameterValues("iAdvanceDate"); String[] fMinSupplys = request.getParameterValues("fMinSupply"); String[] fSupplyMultis = request.getParameterValues("fSupplyMulti"); String[] bPurchases =request.getParameterValues("bPurchase"); String[] bSelfs = request.getParameterValues("bSelf"); String[] cPurPersonCodes = request.getParameterValues("cPurPersonCode"); String[] cInvStds = request.getParameterValues("cInvStd"); String[] cInvAddCodes = request.getParameterValues("cInvAddCode"); ActionMessages act = new ActionMessages(); ActionMessages errors = new ActionMessages(); Inventory in = new Inventory(); int a = 0; int b = 0; boolean bPurchase = false; boolean bSelf = false; for(int i = 0;i<cinvCodes.length;i++){ if(Integer.parseInt(bPurchases[i])==1){ bPurchase = true; } if(Integer.parseInt(bSelfs[i])==1){ bSelf = true; } System.out.println("------"+cinvCodes[i]); // mgr.updateInventory(cInvPersonCodes[i], iAdvanceDate, fMinSupply, fSupplyMulti, bPurchase, bSelf, cPurPersonCode, cInvStd, cInvAddCode, cinvCode) Inventory inv = mgr.getInventory(cinvCodes[i]); if(inv==null){ System.out.println("第" + i + "条数据插入失败"); act.add("error1", new ActionMessage("'第''"+i+"''条数据更新失败,原因:编码不存在'")); //out.println("'第''"+i+"''条数据更新失败,原因:编码不存在'"); a++; }else{ mgr.updateInventory(cInvPersonCodes[i], Integer.parseInt(iAdvanceDates[i]), Integer.parseInt(fMinSupplys[i]),Integer.parseInt(fSupplyMultis[i]), bPurchase, bSelf, cPurPersonCodes[i], cInvStds[i], cInvAddCodes[i], cinvCodes[i]); b++; } } act.add("success1", new ActionMessage("失败条数:'"+a+"'",false)); act.add("success2", new ActionMessage("成功条数:'"+b+"'",false)); System.out.println("失败条数==="+a); System.out.println("成功条数==="+b); request.setAttribute("msg", act); return mapping.findForward("update"); }