1 14 package org.compiere.model; 15 16 import java.util.*; 17 import java.math.*; 18 import java.sql.*; 19 20 import org.compiere.util.*; 21 22 28 public class CalloutInventory extends CalloutEngine 29 { 30 41 public String product (Properties ctx, int WindowNo, MTab mTab, MField mField, Object value) 42 { 43 Integer M_Product_ID = (Integer )value; 44 if (M_Product_ID == null || M_Product_ID.intValue() == 0) 45 return ""; 46 if (Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_Product_ID") == M_Product_ID.intValue() 48 && Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID") != 0) 49 mTab.setValue("M_AttributeSetInstance_ID", new Integer (Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID"))); 50 else 51 mTab.setValue("M_AttributeSetInstance_ID", null); 52 53 54 Integer ID = (Integer )mTab.getValue("M_InventoryLine_ID"); 55 if (ID != null && ID.intValue() == 0) 57 { 58 int M_Locator_ID = Env.getContextAsInt(ctx, WindowNo, "M_Locator_ID"); 60 String sql = "SELECT QtyOnHand FROM M_Storage " 61 + "WHERE M_Product_ID=?" + " AND M_Locator_ID=?"; try 64 { 65 PreparedStatement pstmt = DB.prepareStatement(sql); 66 pstmt.setInt(1, M_Product_ID.intValue()); 67 pstmt.setInt(2, M_Locator_ID); 68 ResultSet rs = pstmt.executeQuery(); 69 if (rs.next()) 70 { 71 BigDecimal bd = rs.getBigDecimal(1); 72 if (!rs.wasNull()) 73 mTab.setValue("QtyBook", bd); 74 } 75 rs.close(); 76 pstmt.close(); 77 } 78 catch (SQLException e) 79 { 80 log.error("product", e); 81 return e.getLocalizedMessage(); 82 } 83 } 84 85 return ""; 86 } 88 }
| Popular Tags
|