groovy:get進貨單明細拉採購單明細品號與數量
Callout
====================================
import java.sql.Timestamp
import java.math.BigDecimal
import java.sql.PreparedStatement
import java.sql.ResultSet
import org.compiere.util.DB
import org.compiere.model.MUser
//@script:groovy:getQuotationForOrder
if (A_Value != null )
{
int id = ((Integer) A_Value).intValue();
String sql ="SELECT \"品號_id\", \"品名\",\"規格\",\"採購數量\",\"單位_id\",\"採購單價\",\"庫別_id\",\"幣別_id\" FROM \"採購單明細\" WHERE \"採購單明細_id\"=? ";
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, id);
ResultSet rs = pstmt.executeQuery();
// 只作 1筆 while (rs.next()) {
if (rs.next()) {
if (rs.getInt("品號_id") > 0) A_Tab.setValue("品號_ID",new Integer(rs.getInt("品號_id")));
if (rs.getInt("單位_id") > 0) A_Tab.setValue("單位_ID",new Integer(rs.getInt("單位_id")));
if (rs.getInt("庫別_id") > 0) A_Tab.setValue("庫別_ID",new Integer(rs.getInt("庫別_id")));
if (rs.getInt("幣別_id") > 0) A_Tab.setValue("幣別_ID",new Integer(rs.getInt("幣別_id")));
if (rs.getString("品名") != null) A_Tab.setValue("品名",rs. getString ("品名"));
if (rs. getString ("規格") != null) A_Tab.setValue("規格",rs. getString ("規格"));
if (rs.getBigDecimal ("採購數量") != null) A_Tab.setValue("進貨數量",rs.getBigDecimal ("採購數量"));
if (rs.getBigDecimal ("採購單價") != null) A_Tab.setValue("單位進價",rs.getBigDecimal ("採購單價"));
}
rs.close();
pstmt.close();
}
result=""
沒有留言:
張貼留言