?? outstockformevent.java.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;
}
//將產品序列號設置為“已被占用”
if(detail.getStatus() != null && detail.getStatus().intValue() == 1)
{
contentFormForm.setRetMsg("產品" + detail.getName() + "已經出庫");
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 + -