if(worktype=="SALEORDER")strSql.Append(" and ch_fee.IsCrmOrderFee=1 ");
elseif(worktype!="")strSql.Append(" and isnull(ch_fee.IsCrmOrderFee,0)=0 ");
if(worktype=="BLAUDIT")strSql.Append(" and wu.TYPENO=602 ");
elseif(worktype=="FEEAUDIT")strSql.Append(" and (wu.TYPENO=1 or wu.TYPENO=3 or wu.TYPENO=11 or wu.TYPENO=13 or wu.TYPENO=101 or wu.TYPENO=103 or wu.TYPENO=104 or wu.TYPENO=106 or wu.TYPENO=107 or wu.TYPENO=109 or wu.TYPENO=204 or wu.TYPENO=206 or wu.TYPENO=301 or wu.TYPENO=303 or wu.TYPENO=304 or wu.TYPENO=601) ");
elseif(worktype=="FEEAUDIT")strSql.Append(" and (wu.TYPENO=1 or wu.TYPENO=3 or wu.TYPENO=11 or wu.TYPENO=13 or wu.TYPENO=101 or wu.TYPENO=103 or wu.TYPENO=104 or wu.TYPENO=106 or wu.TYPENO=107 or wu.TYPENO=109 or wu.TYPENO=111 or wu.TYPENO=112 or wu.TYPENO=204 or wu.TYPENO=206 or wu.TYPENO=301 or wu.TYPENO=303 or wu.TYPENO=304 or wu.TYPENO=601) ");
this.BillSql=this.BillSql+" and ch_fee.IsCrmOrderFee=1 "
elseif(this.worktype!='')this.BillSql=this.BillSql+" and isnull(ch_fee.IsCrmOrderFee,0)=0 "
if(this.worktype=='BLAUDIT')this.BillSql=this.BillSql+" and wu.TYPENO=602 "
elseif(this.worktype=='FEEAUDIT')this.BillSql=this.BillSql+" and (wu.TYPENO=1 or wu.TYPENO=3 or wu.TYPENO=11 or wu.TYPENO=13 or wu.TYPENO=101 or wu.TYPENO=103 or wu.TYPENO=104 or wu.TYPENO=106 or wu.TYPENO=107 or wu.TYPENO=109 or wu.TYPENO=204 or wu.TYPENO=206 or wu.TYPENO=301 or wu.TYPENO=303 or wu.TYPENO=304 or wu.TYPENO=601) "
elseif(this.worktype=='FEEAUDIT')this.BillSql=this.BillSql+" and (wu.TYPENO=1 or wu.TYPENO=3 or wu.TYPENO=11 or wu.TYPENO=13 or wu.TYPENO=101 or wu.TYPENO=103 or wu.TYPENO=104 or wu.TYPENO=106 or wu.TYPENO=107 or wu.TYPENO=109 or wu.TYPENO=111 or wu.TYPENO=112 or wu.TYPENO=204 or wu.TYPENO=206 or wu.TYPENO=301 or wu.TYPENO=303 or wu.TYPENO=304 or wu.TYPENO=601) "
this.BillSql=this.BillSql+" and isnull((power(2,(ST.STEPNO)) & wu.stepno),0)>0 and st.AUDITOR='"+userid+"' and (ch_fee.FEESTATUS=2 or ch_fee.FEESTATUS=3 or ch_fee.FEESTATUS=4)) ";
varStrAudit=" EXISTS (select 1 from ch_fee left join workflow_using wu on wu.bsno=ch_fee.GID left join workflow_step st "
StrAudit=StrAudit+" on (st.WORKFLOWID=wu.WORKFLOWID and st.GROUPID=WU.CurrentID) where v_op_bill.BSNO=ch_fee.BSNO "
if(this.worktype=='BLAUDIT')StrAudit=StrAudit+" and wu.TYPENO=602 "
elseif(this.worktype=='FEEAUDIT')StrAudit=StrAudit+" and (wu.TYPENO=1 or wu.TYPENO=3 or wu.TYPENO=11 or wu.TYPENO=13 or wu.TYPENO=101 or wu.TYPENO=103 or wu.TYPENO=104 or wu.TYPENO=106 or wu.TYPENO=107 or wu.TYPENO=109 or wu.TYPENO=204 or wu.TYPENO=206 or wu.TYPENO=301 or wu.TYPENO=303 or wu.TYPENO=304 or wu.TYPENO=601) "
elseif(this.worktype=='FEEAUDIT')StrAudit=StrAudit+" and (wu.TYPENO=1 or wu.TYPENO=3 or wu.TYPENO=11 or wu.TYPENO=13 or wu.TYPENO=101 or wu.TYPENO=103 or wu.TYPENO=104 or wu.TYPENO=106 or wu.TYPENO=107 or wu.TYPENO=109 or wu.TYPENO=111 or wu.TYPENO=112 or wu.TYPENO=204 or wu.TYPENO=206 or wu.TYPENO=301 or wu.TYPENO=303 or wu.TYPENO=304 or wu.TYPENO=601) "
StrAudit=StrAudit+" and isnull((power(2,(ST.STEPNO)) & wu.stepno),0)>0 and st.AUDITOR='"+userid+"' and (ch_fee.FEESTATUS=2 or ch_fee.FEESTATUS=3 or ch_fee.FEESTATUS=4)"
strSql.Append(",CASE WHEN ISNULL(TTLINVDR,0)=0 THEN '未开票' WHEN ISNULL(TTLINVDR,0)=ISNULL(TTLDR,0) THEN '已开票' WHEN ISNULL(TTLINVDR,0)!=ISNULL(TTLDR,0) THEN '部分开票' END DRINVSTATUS ");
strSql.Append(",CASE WHEN ISNULL(TTLINVCR,0)=0 THEN '未开票' WHEN ISNULL(TTLINVCR,0)=ISNULL(TTLCR,0) THEN '已开票' WHEN ISNULL(TTLINVCR,0)!=ISNULL(TTLCR,0) THEN '部分开票' END CRINVSTATUS ");
strSql.Append(",CASE WHEN ISNULL(TTLDUIDR,0)=0 THEN '未对账' WHEN ISNULL(TTLDUIDR,0)=ISNULL(TTLDR,0) THEN '已对账' WHEN ISNULL(TTLDUIDR,0)!=ISNULL(TTLDR,0) THEN '部分对账' END DRDUISTATUS ");
strSql.Append(",APPLYCOUNT ISAPPLY,AMENDCOUNT AMEND from (");
varcmdUpdateFee=db.GetSqlStringCommand("update ch_fee set EXCHANGERATE="+modifydata.AMOUNTUSD.ToString()+" where CURRENCY='USD' AND BSNO='"+enumValue.ORDNO+"'");
+"update user_authority_range_op set OPERATERANGE=@OPERATERANGE,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=@MODIFIEDTIME where USERID=@USERID and OPID=@OPID AND AUTHORITYID=@AUTHORITYID");
varcmdInsert=
varcmdInsertVs=
db.GetSqlStringCommand(
@"insert into user_authority_range_op (GID,USERID,AUTHORITYID,OPID,VISIBLERANGE,OPERATERANGE,CREATEUSER,CREATETIME)
+"update user_authority_range_op set VISIBLERANGE=@VISIBLERANGE,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=@MODIFIEDTIME where USERID=@USERID and OPID=@OPID AND AUTHORITYID=@AUTHORITYID");
strSqlBs.Append(" AND not EXISTS (SELECT 1 FROM op_auto_fee_detail D WHERE D.BSNO=B.BSNO AND D.FEEGROUP='"+enumFeeproject.PROJECTTYPE+"' AND D.FEETYPE="+enumFeeproject.FEETYPE+") ");