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 )
{
Timestamp dt = (Timestamp ) A_Value;
String sql ="SELECT max(\"報價單號\") as 報價單號 FROM \"報價單\" WHERE \"單據日期\"=? ";
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setTimestamp (1, dt);
ResultSet rs = pstmt.executeQuery();
// 只作 1筆 while (rs.next()){
if (rs.next())
{
if (rs.getString("報價單號") != null)
{
String no1=rs.getString("報價單號")
int no2=Integer.parseInt(no1,10)
int no3 = no2+1
String no4 = ""+no3
A_Tab.setValue("報價單號",no4)
}else{
Timestamp now = new Timestamp(System.currentTimeMillis());
def dt = ""+now
def dt1 = dt.substring(0,4)
def dt2 = dt.substring(5,7)
def dt3 = dt.substring(8,10)
dt = dt1+dt2+dt3
String no4 = dt+"01"
A_Tab.setValue("報價單號",no4)
}
}
rs.close();
pstmt.close();
}
result=""
沒有留言:
張貼留言