sql=sql+getAndConSql(sql,APPLICANT,"APPLICANT like '%"+APPLICANT+"%'");
varMblNo=form.findField('MblNo').getValue();
sql=sql+getAndConSql(sql,MblNo," EXISTS(select 1 from ch_fee_do where BILLNO=cm.BILLNO and EXISTS(select 1 from v_op_bs where bsno=ch_fee_do.BSNO and (CUSTNO like '%" +MblNo+"%' or MBLNO like '%"+MblNo+"%' or HBLNO like '%"+MblNo+"%') ))");
sql=sql+getAndConSql(sql,MblNo," EXISTS(select 1 from ch_fee_do where BILLNO=i.BILLNO and EXISTS(select 1 from v_op_bs where bsno=ch_fee_do.BSNO and (CUSTNO like '%" +MblNo+"%' or MBLNO like '%"+MblNo+"%' or HBLNO like '%"+MblNo+"%') ))");
strSql.Append("ORDNO,VOUALLNO,VOUNO,VKNO,VOUDATE,ACCYEAR,ACCMONTH,ATTACHS,ACCDATE,PREPARED,ISCHECKED,CHECKED,ENTERED,ISEXPORT,SUM(case when FCYNO='RMB' THEN AMTDR ELSE 0 END) as AMTDR,SUM(case when FCYNO='RMB' THEN AMTCR ELSE 0 END) as AMTCR,SUM(FCYDR) as FCYDR,SUM(FCYCR) as FCYCR,SUM(AMTDR) as QTYDR,SUM(AMTCR) as QTYCR,CREATEUSER,CREATETIME,CREATEUSERNAME,MODIFIEDUSER,MODIFIEDTIME,MODIFIEDUSERNAME,ISCOPY,ISAUTO,VOUPROP from VW_cw_vouchers_vouitems_gl WITH(NOLOCK) where STARTGID='"+strCwSTARTGID+"' and (ISDELETE=0 or ISDELETE is null)");
strSql.Append("SUM(case when FCYNO='RMB' THEN AMTDR ELSE 0 END) as AMTDR,SUM(case when FCYNO='RMB' THEN AMTCR ELSE 0 END) as AMTCR,");
strSql.Append("SUM(FCYDR) as FCYDR,SUM(FCYCR) as FCYCR,SUM(AMTDR) as QTYDR,SUM(AMTCR) as QTYCR,CREATEUSER,CREATETIME,CREATEUSERNAME,");
strSql.Append("MODIFIEDUSER,MODIFIEDTIME,MODIFIEDUSERNAME,ISCOPY,ISAUTO,VOUPROP,BLNO,FIELD1 from VW_cw_vouchers_vouitems_gl WITH(NOLOCK) where STARTGID='"+strCwSTARTGID+"' and (ISDELETE=0 or ISDELETE is null)");
if(!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and "+strCondition);
}
strSql.Append(" GROUP BY ORDNO,VOUALLNO,VOUNO,VKNO,VOUDATE,ACCYEAR,ACCMONTH,ATTACHS,ACCDATE,PREPARED,ISCHECKED,CHECKED,ENTERED,ISEXPORT,CREATEUSER,CREATETIME,CREATEUSERNAME,MODIFIEDUSER,MODIFIEDTIME,MODIFIEDUSERNAME,ISCOPY,ISAUTO,VOUPROP");
strSql.Append(" GROUP BY ORDNO,VOUALLNO,VOUNO,VKNO,VOUDATE,ACCYEAR,ACCMONTH,ATTACHS,ACCDATE,PREPARED,ISCHECKED,CHECKED,ENTERED,ISEXPORT,");
strSql.Append("SELECT COUNT(*) FROM (SELECT ORDNO,VOUALLNO,VOUNO,VKNO,VOUDATE,ACCYEAR,ACCMONTH,ATTACHS,ACCDATE,PREPARED,ISCHECKED,CHECKED,ENTERED,ISEXPORT,SUM(case when FCYNO='RMB' THEN AMTDR ELSE 0 END) as AMTDR,SUM(case when FCYNO='RMB' THEN AMTCR ELSE 0 END) as AMTCR,SUM(FCYDR) as FCYDR,SUM(FCYCR) as FCYCR,SUM(AMTDR) as QTYDR,SUM(AMTCR) as QTYCR,CREATEUSER,CREATETIME,CREATEUSERNAME,MODIFIEDUSER,MODIFIEDTIME,MODIFIEDUSERNAME,ISCOPY,ISAUTO,VOUPROP from VW_cw_vouchers_vouitems_gl WITH(NOLOCK) where STARTGID='"+strCwSTARTGID+"' and (ISDELETE=0 or ISDELETE is null) ");// and CORPID='" + companyid + "'
strSql.Append("SELECT COUNT(*) FROM (SELECT ORDNO,VOUALLNO,VOUNO,VKNO,VOUDATE,ACCYEAR,ACCMONTH,ATTACHS,ACCDATE,PREPARED,ISCHECKED,CHECKED,");// and CORPID='" + companyid + "'
strSql.Append("ENTERED,ISEXPORT,SUM(case when FCYNO='RMB' THEN AMTDR ELSE 0 END) as AMTDR,SUM(case when FCYNO='RMB' THEN AMTCR ELSE 0 END) as AMTCR, ");// and CORPID='" + companyid + "'
strSql.Append("SUM(FCYDR) as FCYDR,SUM(FCYCR) as FCYCR,SUM(AMTDR) as QTYDR,SUM(AMTCR) as QTYCR,CREATEUSER,CREATETIME,CREATEUSERNAME,MODIFIEDUSER, ");// and CORPID='" + companyid + "'
strSql.Append("MODIFIEDTIME,MODIFIEDUSERNAME,ISCOPY,ISAUTO,VOUPROP,BLNO,FIELD1 from VW_cw_vouchers_vouitems_gl WITH(NOLOCK) where STARTGID='"+strCwSTARTGID+"' and (ISDELETE=0 or ISDELETE is null) ");// and CORPID='" + companyid + "'
if(!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and "+strCondition);
}
strSql.Append(" GROUP BY ORDNO,VOUALLNO,VOUNO,VKNO,VOUDATE,ACCYEAR,ACCMONTH,ATTACHS,ACCDATE,PREPARED,ISCHECKED,CHECKED,ENTERED,ISEXPORT,CREATEUSER,CREATETIME,CREATEUSERNAME,MODIFIEDUSER,MODIFIEDTIME,MODIFIEDUSERNAME,ISCOPY,ISAUTO,VOUPROP) AS V ");
strSql.Append(" GROUP BY ORDNO,VOUALLNO,VOUNO,VKNO,VOUDATE,ACCYEAR,ACCMONTH,ATTACHS,ACCDATE,PREPARED,ISCHECKED,CHECKED,ENTERED,ISEXPORT, ");
strSql.Append(" CREATEUSER,CREATETIME,CREATEUSERNAME,MODIFIEDUSER,MODIFIEDTIME,MODIFIEDUSERNAME,ISCOPY,ISAUTO,VOUPROP,BLNO,FIELD1) AS V ");