在客户端脚本,只能查询,sql写法如下:
var imp = JavaImporter();
imp.importPackage(Packages.com.kingdee.eas.util.app);
imp.importPackage(Packages.java.sql);
imp.importPackage(Packages.com.kingdee.eas.util.client);
imp.importPackage(Packages.com.kingdee.bos.dao.query);
with(imp){
var ctx = pluginCtx.getUIContext();
var editData = pluginCtx.getDataObject();
if(pluginCtx.getOprtState().equals("EDIT"))
{
var billId=editData.getId();
var sql = "select count(*) as fjs from T_BAS_BoAttchAsso where FBOID= '"+billId+"'";
var se=new SQLExecutor(sql);
var rows = se.executeSQL();
while ( rows. next ( ) )
{ var fujian= rows.getInt("fjs"); }
if(fujian==0)
{
com.kingdee.eas.util.client.MsgBox.showInfo("附件数不能为0");
com.kingdee.eas.util.SysUtil.abort();
}
}
}
服务端扩展脚本,可以执行查询、修改的sql语句
修改语句写法如下:
var imp = JavaImporter();
imp.importPackage(Packages.com.kingdee.eas.util.app);
with(imp){
var ctx = pluginCtx.getContext();
var billId = methodCtx.getParamValue(0).getId();
var status = "13923772024";
var sql = "update CT_CUS_Cunhuodan SET cflink = " + status + " WHERE FID = '"+billId+"'";
DbUtil.execute(ctx, sql);
}
查询的写法如下:
var imp = JavaImporter();
imp.importPackage(Packages.com.kingdee.eas.util.app);
with(imp){
var ctx = pluginCtx.getContext();
var billId = methodCtx.getParamValue(0).getId();
var status = "13923772024";
var sql = "select cflink as link from CT_CUS_Cunhuodan WHERE FID = '"+billId+"'";
var row=DbUtil.executeQuery(ctx,sql);
while ( row . next ( ) )
{ var link= row . getString ( "link" ) ; }
}
推荐阅读