📄 calloutinventory.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.model;
import java.math.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.compiere.util.*;
/**
* Physical Inventory Callouts
*
* @author Jorg Janke
* @version $Id: CalloutInventory.java,v 1.7 2005/11/06 01:17:27 jjanke Exp $
*/
public class CalloutInventory extends CalloutEngine
{
/**
* Product/Locator/ASI modified.
* Set Attribute Set Instance
*
* @param ctx Context
* @param WindowNo current Window No
* @param mTab Model Tab
* @param mField Model Field
* @param value The new value
* @return Error message or ""
*/
public String product (Properties ctx, int WindowNo, MTab mTab, MField mField, Object value)
{
if (isCalloutActive())
return "";
Integer InventoryLine = (Integer)mTab.getValue("M_InventoryLine_ID");
if (InventoryLine != null && InventoryLine.intValue() != 0)
return "";
// New Line - Get Book Value
int M_Product_ID = 0;
Integer Product = (Integer)mTab.getValue("M_Product_ID");
if (Product != null)
M_Product_ID = Product.intValue();
if (M_Product_ID == 0)
return "";
int M_Locator_ID = 0;
Integer Locator = (Integer)mTab.getValue("M_Locator_ID");
if (Locator != null)
M_Locator_ID = Locator.intValue();
if (M_Locator_ID == 0)
return "";
setCalloutActive(true);
// Set Attribute
int M_AttributeSetInstance_ID = 0;
Integer ASI = (Integer)mTab.getValue("M_AttributeSetInstance_ID");
if (ASI != null)
M_AttributeSetInstance_ID = ASI.intValue();
// Product Selection
if (Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_Product_ID") == M_Product_ID)
{
M_AttributeSetInstance_ID = Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID");
if (M_AttributeSetInstance_ID != 0)
mTab.setValue("M_AttributeSetInstance_ID", new Integer(M_AttributeSetInstance_ID));
else
mTab.setValue("M_AttributeSetInstance_ID", null);
}
// Set QtyBook from first storage location
BigDecimal bd = null;
String sql = "SELECT QtyOnHand FROM M_Storage "
+ "WHERE M_Product_ID=?" // 1
+ " AND M_Locator_ID=?" // 2
+ " AND M_AttributeSetInstance_ID=?";
if (M_AttributeSetInstance_ID == 0)
sql = "SELECT SUM(QtyOnHand) FROM M_Storage "
+ "WHERE M_Product_ID=?" // 1
+ " AND M_Locator_ID=?"; // 2
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, M_Product_ID);
pstmt.setInt(2, M_Locator_ID);
if (M_AttributeSetInstance_ID != 0)
pstmt.setInt(3, M_AttributeSetInstance_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
bd = rs.getBigDecimal(1);
if (bd != null)
mTab.setValue("QtyBook", bd);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
//
log.info("M_Product_ID=" + M_Product_ID
+ ", M_Locator_ID=" + M_Locator_ID
+ ", M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID
+ " - QtyBook=" + bd);
setCalloutActive(false);
return "";
} // product
} // CalloutInventory
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -