varACTNAME=T_ALL_DA.GetStrSQL("ACTNAME","SELECT ACTNAME FROM WorkLog WHERE (ACTNAME='放单通知' or ACTNAME='取消放单通知' or ACTNAME='驳回放单通知') AND BSNO='" +item.GID+"' order by OPDATE desc ");
varACTNAME=T_ALL_DA.GetStrSQL("ACTNAME","SELECT ACTNAME FROM WorkLog WHERE (ACTNAME='放单通知' or ACTNAME='取消可放单' or ACTNAME='驳回可放单') AND BSNO='" +item.GID+"' order by OPDATE desc ");
varcmdupdate=db.GetSqlStringCommand("update op_blissue set BLSTATUS=(case when (select count(1) from worklog where BSNO=@GID and actname='放单通知')>0 then '放单通知' "
varcmdupdate=db.GetSqlStringCommand("update op_blissue set BLSTATUS=(case when (select count(1) from worklog where BSNO=@GID and actname='放单通知')>0 then '可放单' "
+" else '' end),QRDATE='' where GID=@GID and BLSTATUS ='提单签入' ");
// sql = sql + getAndConSql(sql, RB, " ((B.ISSUETYPE='正本' or B.ISSUETYPE='SEAWAY' or B.ISSUETYPE='海运单') and (isnull(ob.BLSTATUS,'')='' or ob.BLSTATUS='换签(背书)' or (select COUNT(*) from worklog where bsno=ob.GID and ACTNAME='提单签入')<=0) ) ");
}else
if(RB=='1'){//可签出
sql=sql+getAndConSql(sql,RB," ( ( isnull(ob.BLSTATUS,'')='放单通知' or (isnull(ob.BLSTATUS,'')='提单签入' and (select COUNT(*) from worklog where bsno=ob.GID and ACTNAME='放单通知')>0 ) ) or (sp.BLSTATUS='审核通过' and isnull(ob.BLSTATUS,'')<>'提单签出') ) ");
sql=sql+getAndConSql(sql,RB," ( ( isnull(ob.BLSTATUS,'')='可放单' or (isnull(ob.BLSTATUS,'')='提单签入' and (select COUNT(*) from worklog where bsno=ob.GID and ACTNAME='可放单')>0 ) ) or (sp.BLSTATUS='审核通过' and isnull(ob.BLSTATUS,'')<>'提单签出') ) ");
}else
if(RB=='2'){//已扣单
sql=sql+getAndConSql(sql,RB," (select COUNT(*) from worklog where bsno=ob.GID and ACTNAME='扣单')<>(select COUNT(*) from worklog where bsno=ob.GID and ACTNAME='取消扣单') ");
sql=sql+getAndConSql(sql,RB," ( (B.ISSUETYPE='正本' and isnull(ob.BLSTATUS,'') in ('提单签入','放单通知','驳回放单通知')) or (B.ISSUETYPE in('电放','seawaybill','SEAWAY','海运单') and isnull(ob.BLSTATUS,'') in ('','提单签入','放单通知') )) ");
sql=sql+getAndConSql(sql,RB," ( (B.ISSUETYPE='正本' and isnull(ob.BLSTATUS,'') in ('提单签入','可放单','驳回放单通知')) or (B.ISSUETYPE in('电放','seawaybill','SEAWAY','海运单') and isnull(ob.BLSTATUS,'') in ('','提单签入','可放单') )) ");
}else
if(RB=='2'){//已扣单
sql=sql+getAndConSql(sql,RB," (select COUNT(*) from worklog where bsno=ob.GID and ACTNAME='扣单')<>(select COUNT(*) from worklog where bsno=ob.GID and ACTNAME='取消扣单') ");
varsql=" not exists (select 1 from op_blissueList_Detail ob1 where ob1.bsno=B.bsno) and isnull(ob.BLSTATUS,'') <>'提单签出' and isnull(ob.BLSTATUS,'') <>'已放货' and isnull(ob.BLSTATUS,'') <>'放单通知' ";
varsql=" not exists (select 1 from op_blissueList_Detail ob1 where ob1.bsno=B.bsno) and isnull(ob.BLSTATUS,'') <>'提单签出' and isnull(ob.BLSTATUS,'') <>'已放货' and isnull(ob.BLSTATUS,'') <>'可放单' ";
varMBLNO=form.findField('MBLNO').getValue();
sql=sql+getAndConSql(sql,MBLNO," (isnull(b.CUSTNO,'')+' '+isnull(b.MBLNO,'')+' '+isnull(b.HBLNO,'') like '%"+MBLNO+"%') ");