📄 .#outstockformevent.java.1.1.svn-base
字号:
package com.casin.erp.event;
import com.waveline.webbuilder.event.DefaultContentFormEventImpl;
import com.waveline.webbuilder.struts.ContentFormForm;
import javax.servlet.http.HttpServletRequest;
import com.waveline.webbuilder.exception.ProgramException;
import com.waveline.webbuilder.exception.DataBaseException;
import com.casin.erp.OutStock;
import com.waveline.webbuilder.util.FunctionUtil;
import com.casin.erp.Stock;
import com.casin.erp.InStockDetail;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class OutStockFormEvent
extends DefaultContentFormEventImpl
{
public boolean beforInsertForm(HttpServletRequest request,
ContentFormForm contentFormForm,
Object session)
throws DataBaseException, ProgramException
{
if(contentFormForm.getContentObject() instanceof OutStock)
{
OutStock outStock = (OutStock)contentFormForm.getContentObject();
Stock stock = (Stock)FunctionUtil.loadContentObject(Stock.class.getName(),outStock.getStock().getId());
InStockDetail detail = (InStockDetail)FunctionUtil.loadContentObject(InStockDetail.class.getName(),outStock.getDetail().getId());
if(outStock.getAmount().intValue() < 1)
{
contentFormForm.setRetMsg("出库数量必须是大于0的正整数。");
return false;
}
if(outStock.getAmount().intValue() > stock.getAmount().intValue())
{
contentFormForm.setRetMsg("库存产品数量不足。");
return false;
}
try
{
stock.setAmount(new Integer(stock.
getAmount().intValue() - outStock.getAmount().intValue()));
FunctionUtil.update(stock, false, session);
}
catch(Exception ex)
{
contentFormForm.setRetMsg("核减库存产品数量出现异常");
return false;
}
//将产品序列号设置为“已被占用”
detail.setStatus(new Integer(1));
FunctionUtil.update(detail, false, session);
}
return true;
}
public boolean beforDeleteForm(HttpServletRequest request,
ContentFormForm contentFormForm,
Object session)
throws DataBaseException, ProgramException
{
if(contentFormForm.getContentObject() instanceof OutStock)
{
OutStock outStock = (OutStock)contentFormForm.getContentObject();
Stock stock = (Stock)FunctionUtil.loadContentObject(Stock.class.getName(),outStock.getStock().getId());
InStockDetail detail = (InStockDetail)FunctionUtil.loadContentObject(InStockDetail.class.getName(),outStock.getDetail().getId());
try
{
stock.setAmount(new Integer(stock.
getAmount().intValue() + outStock.getAmount().intValue()));
FunctionUtil.update(stock, false, session);
}
catch(Exception ex)
{
contentFormForm.setRetMsg("取消核减库存产品数量出现异常");
return false;
}
//将产品序列号恢复为“未占用”
detail.setStatus(new Integer(0));
FunctionUtil.update(detail, false, session);
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -