import org.compiere.model.MTable
import org.compiere.util.DB
import org.compiere.util.Msg
import java.math.BigDecimal
import java.sql.PreparedStatement
import java.sql.ResultSet
// A_WindowNo A_Tab A_Field A_Value A_OldValue A_Ctx BOMQty
if (A_Value!=null) // A_OldValue!=A_Value)
{
Integer ID= (Integer)A_Value;
// Integer ID= (Integer)A_Tab.getValue("SK_BOM_ID");
String sql = "SELECT 採購品號, 採購品名, 採購規格 FROM 採購品 WHERE 採購品_ID=?";
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, ID.intValue());
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
String code1= rs.getString("採購品號");
String name1= rs.getString("採購品名");
String spec1= rs.getString("採購規格");
if (code1== null) code1="";
if (name1== null) name1="";
if (spec1== null) spec1="";
A_Tab.setValue("採購品號", code1 );
A_Tab.setValue("採購品名", name1 );
A_Tab.setValue("採購規格", spec1 );
}
Integer VID=(Integer)A_Tab.getValue("廠商_ID");
if (VID != null && ID != null)
{
sql = "SELECT 單價 FROM 採購單 WHERE 廠商_ID=? AND 採購品_ID=? ORDER BY 採購日期 DESC ";
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, VID.intValue());
pstmt.setInt(2, ID.intValue());
rs = pstmt.executeQuery();
if(rs.next()) {
BigDecimal price = rs.getBigDecimal("單價");
if (price == null) price = new BigDecimal(0);
A_Tab.setValue("單價", price);
}
}
}
result=""
沒有留言:
張貼留言