2014年1月27日 星期一

groovy:銷退單明細拉銷貨單明細

groovy:銷退單明細拉銷貨單明細
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\",\"品名\",\"規格\",\"單位_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.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.getString("客戶單號") != null) A_Tab.setValue("客戶單號",rs. getString ("客戶單號"));
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 ("單價"));

 }
rs.close();
pstmt.close();
}
result=""

沒有留言:

張貼留言