procedure TzwxxForm.Button2Click(Sender: TObject);
var
ske,fke:Currency;
date1,date2:TDate;
begin
date1:=dtp1.Date;
date2:=dtp2.Date;
tmpQuery.Close;
tmpQuery.SQL.Clear;
tmpQuery.SQL.Add('Select Sum(JE) as ske From SKB ');
tmpQuery.SQL.Add('Where ');
tmpQuery.SQL.Add('RQ>=#'+DateToStr(Date1)+'# and RQ<=#'+DateToStr(Date2)+'#');
tmpQuery.Open;
if tmpQuery.RecordCount>0 then
ske:=tmpQuery.FieldByName('ske').AsCurrency
else
ske:=0;
tmpQuery.Close;
tmpQuery.SQL.Clear;
tmpQuery.SQL.Add('Select Sum(JE) as fke From FKB ');
tmpQuery.SQL.Add('Where ');
tmpQuery.SQL.Add('RQ>=#'+DateToStr(Date1)+'# and RQ<=#'+DateToStr(Date2)+'#');
tmpQuery.Open;
if tmpQuery.RecordCount>0 then
fke:=tmpQuery.FieldByName('fke').AsCurrency
else
fke:=0;
skEdit.Text:=CurrToStr(ske);
fkEdit.Text:=CurrToStr(fke);
jyEdit.Text:=CurrToStr(ske-fke);
end;
query1.Close ;
query1.sql.Clear;
query1.sql.add('select * from 表 where 日期字段>=T1 and 日期字段<=T2');
query1.Parameters[0].Value:=datetimepicker1.date;
query1.Parameters[1].Value:=datetimepicker2.date;
query1.open;