SQL.Add('Insert into t_op_fangdan (<28><><EFBFBD><EFBFBD>, <20>ŵ<EFBFBD>״̬,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)');
str:=str+' and ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> like '+''''+'%'+Edit1.text+'%'+'''';
if Edit4.text<>''then
str:=str+' and ί<>б<EFBFBD><D0B1><EFBFBD> like '+''''+'%'+Edit4.text+'%'+'''';
if Edit2.text<>''then
str:=str+' and <20><><EFBFBD>ᵥ<EFBFBD><E1B5A5> like '+''''+'%'+Edit2.text+'%'+'''';
if Edit3.text<>''then
str:=str+' and <20><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD> like '+''''+'%'+Edit3.text+'%'+'''';
if wwDBDateTimePicker1.text<>''then
str:=str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+wwDBDateTimePicker1.text+'''';
if wwDBDateTimePicker2.text<>''then
str:=str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+wwDBDateTimePicker2.text+'''';
if wwDBDateTimePicker3.text<>''then
str:=str+' and <20><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>>='+''''+wwDBDateTimePicker3.text+'''';
if wwDBDateTimePicker4.text<>''then
str:=str+' and <20><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><='+''''+wwDBDateTimePicker4.text+'''';
if RxDBLookupCombo2.DisplayValues[1]<>''then
str:=str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
// if RxDBLookupCombo6.DisplayValues[1]<>''then
// str:=str+' and <20><><EFBFBD><EFBFBD>Ա='+''''+RxDBLookupCombo6.DisplayValues[1]+'''';
if wwDBLookupCombo49.text<>''then
str:=str+' and <20><><EFBFBD><EFBFBD> like '+''''+'%'+wwDBLookupCombo49.text+'%'+'''';
if Edit7.text<>''then
str:=str+' and <20><><EFBFBD><EFBFBD> like '+''''+'%'+Edit7.text+'%'+'''';
if wwDBLookupCombo52.text<>''then
str:=str+' and ж<><D0B6><EFBFBD><EFBFBD> like '+''''+'%'+wwDBLookupCombo52.text+'%'+'''';
str:=str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+FormatDateTime('yyyy-mm-dd',date)+'''';
str:=str+' and (((ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' ) and EXISTS (SELECT 1 FROM t_op_state WHERE t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' AND t_op_seae.<2E><><EFBFBD><EFBFBD>=t_op_state.<2E><><EFBFBD><EFBFBD>) )';
str:=str+' or ((ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' or ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''Seaway'' or ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD><EFBFBD>ᵥ'') and EXISTS (SELECT 1 FROM t_op_state WHERE t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' AND t_op_seae.<2E><><EFBFBD><EFBFBD>=t_op_state.<2E><><EFBFBD><EFBFBD>))) ';
str:=str+'and <20><><EFBFBD><EFBFBD> not in (select <20><><EFBFBD><EFBFBD> from t_op_fangdan)';
str:=str+'and <20><><EFBFBD><EFBFBD> not in (select <20><><EFBFBD><EFBFBD> from t_op_state where ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' or ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'')';
t_op_seae.close;
t_op_seae.sql.clear;
t_op_seae.sql.add('select * from t_op_seae '+str+default_sort(53,'t_op_seae','','desc'));
SQL.Add('Select <20><><EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ģʽ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales');
SQL.Add('where <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=:<3A>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>=:aDate and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>''<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>''');
end;
if (t_op_bill.FieldByName('״̬').asstring='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')then
sql.add('select <20><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD> from t_crm_client where <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+t_op_bill.FieldByName('ί<>е<EFBFBD>λ').AsString+'''');
open;
if not IsEmpty then begin
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>').AsString='<27><>' then begin
if MessageDlg(t_op_bill.FieldByName('ί<>е<EFBFBD>λ').AsString+'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>Ϊ:'+fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>').AsString+#13#10+'ȷʵҪ<CAB5>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>',mtWarning,[mbyes,mbno],0)<>mryes then
SQL.Add('SUM(CASE t_ch_fee.<2E><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (case t_ch_fee.<2E>ұ<EFBFBD> when ''USD'' then t_ch_fee.<2E><><EFBFBD><EFBFBD>-t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> else 0 end) ELSE 0 END ) as USD ');
SQL.Add(',');
SQL.Add('SUM(CASE t_ch_fee.<2E><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (case t_ch_fee.<2E>ұ<EFBFBD> when ''RMB'' then t_ch_fee.<2E><><EFBFBD><EFBFBD>-t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> else 0 end) ELSE 0 END) as RMB ');
SQL.Add(' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>շѣ<D5B7>'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''MCCREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''<27><><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD>(<28>շ<EFBFBD>)'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''SMTREF''');
SQL.Add(' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''<27>ݷ<EFBFBD><DDB7>Ƶ<EFBFBD><C6B5>շ<EFBFBD>'' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''AUSREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''APLREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''ONEREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''SAFREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''SUDREF'' ');
SQL.Add('SUM(CASE t_ch_fee.<2E><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (case t_ch_fee.<2E>ұ<EFBFBD> when ''USD'' then t_ch_fee.<2E><><EFBFBD><EFBFBD>-t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> else 0 end) ELSE 0 END ) as USD ');
SQL.Add(',');
SQL.Add('SUM(CASE t_ch_fee.<2E><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (case t_ch_fee.<2E>ұ<EFBFBD> when ''RMB'' then t_ch_fee.<2E><><EFBFBD><EFBFBD>-t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> else 0 end) ELSE 0 END) as RMB ');
SQL.Add('From t_ch_fee ');
SQL.Add('Left Join t_op_seae on t_op_seae.<2E><><EFBFBD><EFBFBD>=t_ch_fee.<2E><><EFBFBD><EFBFBD> ');
SQL.Add('where t_op_seae.ί<>е<EFBFBD>λ=:<3A>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> and t_ch_fee.<2E><><EFBFBD><EFBFBD>=''<27><>'' and t_ch_fee.<2E><><EFBFBD><EFBFBD><>t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
SQL.Add(' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>շѣ<D5B7>'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''MCCREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''<27><><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD>(<28>շ<EFBFBD>)'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''SMTREF''');
SQL.Add(' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''<27>ݷ<EFBFBD><DDB7>Ƶ<EFBFBD><C6B5>շ<EFBFBD>'' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''AUSREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''APLREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''ONEREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''SAFREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''SUDREF'' ');
aFeeQuery.SQL.Add('select * from t_ch_fee Left Join t_op_seae on t_op_seae.<2E><><EFBFBD><EFBFBD>=t_ch_fee.<2E><><EFBFBD><EFBFBD> '
+' where t_op_seae.ί<>е<EFBFBD>λ=:<3A>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> and t_ch_fee.<2E><><EFBFBD><EFBFBD><>t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>շѣ<D5B7>'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''MCCREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''<27><><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD>(<28>շ<EFBFBD>)'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''SMTREF'' '
+' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''AUSREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''APLREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''ONEREF'' '
+' and t_ch_fee.<2E><><EFBFBD><EFBFBD>=''<27><>'' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><=:ETD');
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull then jfrq:=0 else jfrq:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Asinteger; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull then jfqx:=0 else jfqx:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Asinteger; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1000<30><30>
+' SUM(CASE <20><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (case <20>ұ<EFBFBD> when ''USD'' then <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> else 0 end) ELSE 0 END ) as USD, '
+' SUM(CASE t_ch_fee.<2E><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (case <20>ұ<EFBFBD> when ''RMB'' then <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> else 0 end) ELSE 0 END) as RMB '
+' From t_ch_fee '
+' inner Join V_op_bscard_All on t_ch_fee.<2E><><EFBFBD><EFBFBD>= V_op_bscard_All.<2E><><EFBFBD><EFBFBD> '
+' where t_ch_fee.<2E><><EFBFBD><EFBFBD><><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=:<3A>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> and V_op_bscard_All.<2E><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><:<3A><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD> '
+' Group by t_ch_fee.<2E><><EFBFBD><EFBFBD>,t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>,V_op_bscard_All.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,V_op_bscard_All.<2E><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>,V_op_bscard_All.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5> ';
+',ch_id from t_ch_fee where <20><><EFBFBD><EFBFBD>=''<27><>'' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='+quotedstr(t_op_bill.fieldByName('ί<>е<EFBFBD>λ').AsString)
+' and <20><><EFBFBD><EFBFBD><><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD>='+quotedstr(aFeeQuery.fieldbyname('<27><><EFBFBD><EFBFBD>').AsString));
if Date>_getzq(aFeeQuery.fieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString,aEtd) then
begin
aBillQuery.Close;
aBillQuery.SQL.Clear;
aBillQuery.SQL.Add('insert into t_op_bill_fee (bill_id,ch_id) values select '+t_op_bill.fieldbyname('Bill_ID').AsString
+',ch_id from t_ch_fee where <20><><EFBFBD><EFBFBD>=''<27><>'' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='+quotedstr(t_op_bill.fieldByName('ί<>е<EFBFBD>λ').AsString)
+' and <20><><EFBFBD><EFBFBD><><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD>='+quotedstr(aFeeQuery.fieldbyname('<27><><EFBFBD><EFBFBD>').AsString));
aBillQuery.ExecSQL;
end;
end;
if jflx='Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
if Date>_getzq(aFeeQuery.fieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString,aEtd) then
begin
aBillQuery.Close;
aBillQuery.SQL.Clear;
aBillQuery.SQL.Add('insert into t_op_bill_fee (bill_id,ch_id) values select '+t_op_bill.fieldbyname('Bill_ID').AsString
+',ch_id from t_ch_fee where <20><><EFBFBD><EFBFBD>=''<27><>'' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='+quotedstr(t_op_bill.fieldByName('ί<>е<EFBFBD>λ').AsString)
+' and <20><><EFBFBD><EFBFBD><><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD>='+quotedstr(aFeeQuery.fieldbyname('<27><><EFBFBD><EFBFBD>').AsString));
sql.Add(' select count(*) rt from t_op_seae where ί<>е<EFBFBD>λ='''+t_op_bill.FieldByName('ί<>е<EFBFBD>λ').Asstring+''' and ');
sql.Add(' (װ<>˷<EFBFBD>ʽ<>''ƴ<><C6B4><EFBFBD><EFBFBD>Ʊ'' and װ<>˷<EFBFBD>ʽ<>''½<><C2BD>'') and ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><>ͨ<EFBFBD><CDA8>'' and <20><><EFBFBD>ᵥ<EFBFBD><E1B5A5><>'''' and ǩ<><C7A9><EFBFBD><EFBFBD>ʽ<>'''' and ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' ');
sql.Add(' and <20><><EFBFBD><EFBFBD> in (select <20><><EFBFBD><EFBFBD> from t_op_state where ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'') and <20><><EFBFBD><EFBFBD> not in (select <20><><EFBFBD><EFBFBD> from t_op_state where ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'') ');
SQL.Add(',SUM(CASE <20><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (case <20>ұ<EFBFBD> when ''USD'' then <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> else 0 end) ELSE 0 END ) as AMTUSD ');
SQL.Add(',');
SQL.Add('SUM(CASE t_ch_fee.<2E><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (case <20>ұ<EFBFBD> when ''RMB'' then <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> else 0 end) ELSE 0 END) as AMTRMB ');
sql.Add('From t_ch_fee');
sql.Add('inner Join v_op_bscard on t_ch_fee.<2E><><EFBFBD><EFBFBD>= v_op_bscard.<2E><><EFBFBD><EFBFBD>');
sql.Add('where t_ch_fee.<2E><><EFBFBD><EFBFBD><><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=:<3A>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> ');
SQL.Add(' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>շѣ<D5B7>'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''MCCREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''<27><><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD>(<28>շ<EFBFBD>)'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''SMTREF''');
SQL.Add(' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''AUSREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''APLREF'' AND t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><>''ONEREF'' ');
// sql.Add('from v_op_bscard ');
sql.Add(' and ί<>е<EFBFBD>λ=:ί<>е<EFBFBD>λ and <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6><><3E>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><:aDate');
sql.Add('Group by SUBSTRING(CONVERT(char(15),<2C><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>,111),1,7)');
ADOQuery2.SQL.Add('select sum(case when ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) ZBCOUNT,sum(case when ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) DFCOUNT ');
ADOQuery2.SQL.Add(' from t_op_seae where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><>ͨ<EFBFBD><CDA8>'' and <20>ᵥǩ<E1B5A5><C7A9>״̬=''<27>ᵥǩ<E1B5A5><C7A9>''');
ADOQuery2.SQL.Add(' and not EXISTS (select 1 from t_op_state where t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' and t_op_state.<2E><><EFBFBD><EFBFBD>=t_op_seae.<2E><><EFBFBD><EFBFBD>) ');
ADOQuery2.SQL.Add(' and ί<>е<EFBFBD>λ='''+t_op_bill.fieldbyname('ί<>е<EFBFBD>λ').AsString+''' ');
sql.Add('where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> between :date1 and :date2 and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
ADOQuery2.SQL.Add(' from t_op_seae where ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' and ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><>ͨ<EFBFBD><CDA8>'' ');
ADOQuery2.SQL.Add(' and <20>ᵥǩ<E1B5A5><C7A9>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' and not EXISTS (select 1 from t_op_state where (t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' or t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'') and t_op_state.<2E><><EFBFBD><EFBFBD>=t_op_seae.<2E><><EFBFBD><EFBFBD>) ');
ADOQuery2.SQL.Add(' and ί<>е<EFBFBD>λ='''+t_op_bill.fieldbyname('ί<>е<EFBFBD>λ').AsString+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><=getdate() ');
ADOQuery2.SQL.Add('select sum(case when ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) DFCOUNT ');
ADOQuery2.SQL.Add(',sum(case when ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD><EFBFBD>ᵥ'' then 1 else 0 end) DZTDCOUNT from t_op_seae where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><>ͨ<EFBFBD><CDA8>'' ');
ADOQuery2.SQL.Add(' and not EXISTS (select 1 from t_op_state where (t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' or t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'') and t_op_state.<2E><><EFBFBD><EFBFBD>=t_op_seae.<2E><><EFBFBD><EFBFBD>) ');
ADOQuery2.SQL.Add(' and ί<>е<EFBFBD>λ='''+t_op_bill.fieldbyname('ί<>е<EFBFBD>λ').AsString+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><=getdate() and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>=''2023-06-01''');
ADOQuery2.SQL.Add(' from t_op_seae where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><>ͨ<EFBFBD><CDA8>'' ');
ADOQuery2.SQL.Add(' and ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''seaway'' and not EXISTS (select 1 from t_op_state where (t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' or t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'') and t_op_state.<2E><><EFBFBD><EFBFBD>=t_op_seae.<2E><><EFBFBD><EFBFBD>) ');
ADOQuery2.SQL.Add(' and ί<>е<EFBFBD>λ='''+t_op_bill.fieldbyname('ί<>е<EFBFBD>λ').AsString+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>=GETDATE()-60 and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><=getdate() ');
if (t_op_bill.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>').AsInteger=0) and (t_op_bill.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>طŵ<D8B7><C5B5><EFBFBD>').AsInteger=0) then begin
function Tfrm_op_seae_teshufandan.checkwy(client:string):Boolean;
var
aAdoQuery:TADOQuery;
i:Integer;
begin
result:=false;
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do
begin
Close;
SQL.Clear;
SQL.Add('select * from t_op_bill_fangdanwy where ί<>е<EFBFBD>λ='+quotedstr(client)+' order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD> desc' );
Open;
end;
aAdoQuery.First;
i:=0;
while not aAdoQuery.Eof do
begin
if aAdoQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־').AsInteger=0 then i:=i+1 else Break;
if not aAdoQuery.FieldByName('ΥԼ<CEA5><D4BC>־').AsBoolean then Break;
if (bsSkinPageControl1.ActivePage=bskntbsht2) then begin
if (not t_op_bill.IsEmpty) then begin
if (ADOQuery2.Active) then ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select sum(case when ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) ZBCOUNT,sum(case when ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) DFCOUNT ');
ADOQuery2.SQL.Add(' from t_op_seae where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><>ͨ<EFBFBD><CDA8>'' and <20>ᵥǩ<E1B5A5><C7A9>״̬=''<27>ᵥǩ<E1B5A5><C7A9>''');
ADOQuery2.SQL.Add(' and not EXISTS (select 1 from t_op_state where t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' and t_op_state.<2E><><EFBFBD><EFBFBD>=t_op_seae.<2E><><EFBFBD><EFBFBD>) ');
ADOQuery2.SQL.Add(' and ί<>е<EFBFBD>λ='''+t_op_bill.fieldbyname('ί<>е<EFBFBD>λ').AsString+''' ');
ADOQuery2.SQL.Add('select sum(case when ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) ZBCOUNT,sum(case when ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) DFCOUNT ');
ADOQuery2.SQL.Add(' from t_op_seae where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><>ͨ<EFBFBD><CDA8>'' and <20>ᵥǩ<E1B5A5><C7A9>״̬=''<27>ᵥǩ<E1B5A5><C7A9>''');
ADOQuery2.SQL.Add(' and not EXISTS (select 1 from t_op_state where t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' and t_op_state.<2E><><EFBFBD><EFBFBD>=t_op_seae.<2E><><EFBFBD><EFBFBD>) ');
ADOQuery2.SQL.Add(' and ί<>е<EFBFBD>λ='''+t_op_bill.fieldbyname('ί<>е<EFBFBD>λ').AsString+''' ');
if (bsSkinPageControl1.ActivePage=bskntbsht2) then begin
if (not t_op_bill.IsEmpty) then begin
if (ADOQuery2.Active) then ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select sum(case when ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) ZBCOUNT,sum(case when ǩ<><C7A9><EFBFBD><EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) DFCOUNT ');
ADOQuery2.SQL.Add(' from t_op_seae where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><>ͨ<EFBFBD><CDA8>'' and <20>ᵥǩ<E1B5A5><C7A9>״̬=''<27>ᵥǩ<E1B5A5><C7A9>''');
ADOQuery2.SQL.Add(' and not EXISTS (select 1 from t_op_state where t_op_state.ҵ<><D2B5>״̬=''<27>ᵥǩ<E1B5A5><C7A9>'' and t_op_state.<2E><><EFBFBD><EFBFBD>=t_op_seae.<2E><><EFBFBD><EFBFBD>) ');
ADOQuery2.SQL.Add(' and ί<>е<EFBFBD>λ='''+t_op_bill.fieldbyname('ί<>е<EFBFBD>λ').AsString+''' ');