if (bsSkinCheckRadioBox1.Checked) then datetype:='Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
S:='';
aperweek:=EncodeDate(aYear, 1, 1);
i:=DayOfWeek(aperweek);
if i=1 then
FirstweekDay:=aPerWeek-6
else
FirstweekDay:=aPerWeek-(i-2);
firstweekday:=firstweekday+7*(aWeek-1);
endWeekday:=FirstweekDay+6;
if S='' then begin
if (bsSkinCheckRadioBox1.Checked) then
S:=' t_op_seae.'+datetype+'>='''+FormatDateTime('YYYY-MM-DD',FirstweekDay)+''' and t_op_seae.'+datetype+'<'''+FormatDateTime('YYYY-MM-DD',FirstweekDay+7)+''''
else begin
S:=' t_op_seae.'+datetype+'>='''+FormatDateTime('YYYY-MM-DD',FirstweekDay)+''' and t_op_seae.'+datetype+'<='''+FormatDateTime('YYYY-MM-DD',FirstweekDay+6)+'''';
end;
end;
Result:=S;
end;
function Tfrm_rp_zou_linehistry.GetZhangQi(SaleID,Cust:String):String;
var
aQuery:TADOQuery;
S:String;
begin
if (FmDate='') then begin
FmDate:='2006-01-01';
end;
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
// SQL.Add('Select * from t_crm_client_sales where ״̬=''<27><><EFBFBD><EFBFBD>'' and <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><='''+FmDate+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+ToDate+''' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+SaleID+'''');
SQL.Add('Select * from t_crm_client_sales where ״̬=''<27><><EFBFBD><EFBFBD>'' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>'''+FmDate+''' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+SaleID+'''');
function Tfrm_rp_zou_linehistry.GetZhangQiNum(SaleID, Cust: String;
aetd: TDateTime): Double;
var
aQuery:TAdoQuery;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select <20><><EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD> from t_crm_client_sales where ״̬=''<27><><EFBFBD><EFBFBD>'' and <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+SaleID+'''');
Open;
if not IsEmpty then begin
if FieldByName('<27><><EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD>').IsNull or (FieldByName('<27><><EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD>').AsFloat<=0) then begin
function Tfrm_rp_zou_linehistry.GetZhangQiStr(SaleID, Cust: String): String;
var
aQuery:TADOQuery;
begin
aQuery:=CreateAdoQuery;
Result:='';
try
with aQuery do begin
Close;SQL.Clear;
sql.Add(' select distinct SUBSTRING(CONVERT(char(15), dbo.v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 111), 1, 7) from v_op_bscard left join t_ch_fee on t_ch_fee.<2E><><EFBFBD><EFBFBD>=v_op_bscard.<2E><><EFBFBD><EFBFBD> ');
sql.Add(sqlstr);
sql.Add(' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+''' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+SaleID+'''');
SQL.Add(' and t_op_seae.ί<>е<EFBFBD>λ='''+RxDBLookupCombo5.DisplayValues[1]+'''');
if RxDBLookupCombo3.DisplayValue<>'' then begin
if wwDBComboBox14.Text='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>'''+RxDBLookupCombo3.DisplayValues[0]+'''')
else
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+RxDBLookupCombo3.DisplayValues[0]+'''');
end;
if RxDBLookupCombo10.DisplayValue<>'' then begin
SQL.Add(' and t_op_seae.<2E><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='''+RxDBLookupCombo10.DisplayValues[0]+'''');
end;
if RxDBLookupCombo2.DisplayValue<>'' then begin
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD>˾='''+RxDBLookupCombo2.DisplayValues[1]+'''');
end;
if cntrstr<>'' then begin
SQL.Add(' and t_op_ctn.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ in '+cntrstr);
end;
if (wwDBComboBox58.Value<>'') then begin
SQL.Add(' and t_op_seae.<2E>Ƿ<EFBFBD>ռ<EFBFBD><D5BC>='''+wwDBComboBox58.Value+'''');
end;
if linestr<>'' then begin
if bsSkinRadioGroup3.ItemIndex=1 then
SQL.Add(' and EXISTS (select * from t_code_disport where t_code_disport.EDI<44><49><EFBFBD><EFBFBD>=t_op_seae.ж<><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and t_code_disport.<2E><><EFBFBD><EFBFBD> in '+linestr+')')
else
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD> in '+linestr)
end;
if wwDBLookupCombo52.Text<>'' then begin
SQL.Add(' and t_op_seae.ж<><D0B6><EFBFBD><EFBFBD> like ''%'+wwDBLookupCombo52.Text+'%''')
end;
SQL.Add(' and '+open_data('9009','t_op_seae.<2E><><EFBFBD><EFBFBD>Ա','t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','no','no','no','no'));
Open;
// showmessage(sql.Text);
if not IsEmpty then
begin
first;
while not eof do
begin
if memtblDetail.Locate('<27><><EFBFBD><EFBFBD>',Ydate,[]) then
SQL.Add(' and t_op_seae.ί<>е<EFBFBD>λ='''+RxDBLookupCombo5.DisplayValues[1]+'''');
if RxDBLookupCombo3.DisplayValue<>'' then begin
if wwDBComboBox14.Text='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>'''+RxDBLookupCombo3.DisplayValues[0]+'''')
else
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+RxDBLookupCombo3.DisplayValues[0]+'''');
end;
if RxDBLookupCombo10.DisplayValue<>'' then begin
SQL.Add(' and t_op_seae.<2E><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='''+RxDBLookupCombo10.DisplayValues[0]+'''');
end;
if RxDBLookupCombo2.DisplayValue<>'' then begin
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD>˾='''+RxDBLookupCombo2.DisplayValues[1]+'''');
end;
if (wwDBComboBox58.Value<>'') then begin
SQL.Add(' and t_op_seae.<2E>Ƿ<EFBFBD>ռ<EFBFBD><D5BC>='''+wwDBComboBox58.Value+'''');
end;
if cntrstr<>'' then begin
SQL.Add(' and EXISTS (select * from t_op_ctn where t_op_ctn.<2E><><EFBFBD><EFBFBD>=t_op_seae.<2E><><EFBFBD><EFBFBD> and t_op_ctn.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ in '+cntrstr+')');
end;
if linestr<>'' then begin
if bsSkinRadioGroup3.ItemIndex=1 then
SQL.Add(' and EXISTS (select * from t_code_disport where t_code_disport.EDI<44><49><EFBFBD><EFBFBD>=t_op_seae.ж<><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and t_code_disport.<2E><><EFBFBD><EFBFBD> in '+linestr+')')
else
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD> in '+linestr)
end;
if wwDBLookupCombo52.Text<>'' then begin
SQL.Add(' and t_op_seae.ж<><D0B6><EFBFBD><EFBFBD> like ''%'+wwDBLookupCombo52.Text+'%''')
end;
SQL.Add(' and '+open_data('9009','t_op_seae.<2E><><EFBFBD><EFBFBD>Ա','t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','no','no','no','no'));
Open;
if not IsEmpty then begin
first;
while not eof do begin
if memtblDetail.Locate('<27><><EFBFBD><EFBFBD>',Ydate,[]) then begin
SQL.Add(',sum(isnull(t_op_ctn.TEU,0)) as <20><><EFBFBD><EFBFBD> ');
SQL.Add('from t_op_ctn,t_op_seae ');
SQL.Add('where t_op_seae.<2E><><EFBFBD><EFBFBD>=t_op_ctn.<2E><><EFBFBD><EFBFBD> and '+GetEtdStr(years,weeks));
if RxDBLookupCombo5.DisplayValues[1]<>'' then
SQL.Add(' and t_op_seae.ί<>е<EFBFBD>λ='''+RxDBLookupCombo5.DisplayValues[1]+'''');
if RxDBLookupCombo3.DisplayValue<>'' then begin
if wwDBComboBox14.Text='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>'''+RxDBLookupCombo3.DisplayValues[0]+'''')
else
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+RxDBLookupCombo3.DisplayValues[0]+'''');
end;
if RxDBLookupCombo10.DisplayValue<>'' then begin
SQL.Add(' and t_op_seae.<2E><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='''+RxDBLookupCombo10.DisplayValues[0]+'''');
end;
if RxDBLookupCombo2.DisplayValue<>'' then begin
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD>˾='''+RxDBLookupCombo2.DisplayValues[1]+'''');
end;
if cntrstr<>'' then begin
SQL.Add(' and t_op_ctn.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ in '+cntrstr);
end;
if linestr<>'' then begin
if bsSkinRadioGroup3.ItemIndex=1 then
SQL.Add(' and EXISTS (select * from t_code_disport where t_code_disport.EDI<44><49><EFBFBD><EFBFBD>=t_op_seae.ж<><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and t_code_disport.<2E><><EFBFBD><EFBFBD> in '+linestr+')')
else
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD> in '+linestr)
end;
if wwDBLookupCombo52.Text<>'' then begin
SQL.Add(' and t_op_seae.ж<><D0B6><EFBFBD><EFBFBD> like ''%'+wwDBLookupCombo52.Text+'%''')
end;
SQL.Add(' and '+open_data('9009','t_op_seae.<2E><><EFBFBD><EFBFBD>Ա','t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','no','no','no','no'));
SQL.Add('Group by t_op_seae.<2E><><EFBFBD><EFBFBD>,t_op_seae.<2E><><EFBFBD><EFBFBD>˾,t_op_seae.ί<>е<EFBFBD>λ,t_op_seae.<2E><>װ<EFBFBD><D7B0>,t_op_seae.ж<><D0B6><EFBFBD><EFBFBD>,t_op_seae.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,t_op_seae.ί<>е<EFBFBD>λ');