我把我的源程序贴出来,执行起来很慢,很慢…………
(5条记录,C850,128M,约1分钟,如果子100条,真不敢想象)
//计算每个项目的重复值,输入到OutReport2中*********
with DM.AQOutReport2 do begin
First;
while not eof do begin
Edit;
FieldByName('LN').AsString:='';
FieldByName('LNNum').AsFloat:=0;
Post;
Next;
end;
end;
for i:=1 to 24 do begin //1--24为玻璃之前,单位为支,实际共有86个字段
with DM.AQTemp1 do begin
SQL.Clear;
S:=format('select L%s as Lx,sum(N%s) as Nx from outreport1 group by L%s',[inttostr(i),inttostr(i),inttostr(i)]);
SQL.Add(s);
Active:=true;
while not eof do begin
n:=roundto(DM.AQTemp1.FieldValues['lx'],-2)*DM.AQTemp1.FieldValues['nx'];
if n>0 then begin
with DM.AQOutReport2 do begin
Locate('lnx',format('l%s',[inttostr(i)]),[]);
edit;
FieldByName('LN').AsString:=FieldByName('LN').AsString+' '+
floattostr(roundto(DM.AQTemp1.FieldValues['lx'],-2))+'*'+
floattostr(roundto(DM.AQTemp1.FieldValues['nx'],-2))+'支';
FieldByName('LNNum').AsFloat:=FieldByName('LNNum').AsFloat+n;
Post;
end;
end;
Next;
end;
end;
end;
{for i:=25 to 32 do begin //玻璃
//
end;
for i:=33 to 86 do begin //数量
//
end;}
//利用OutReport2的值,打印*************
Application.CreateForm(TFrmAlReport, FrmAlReport);
FrmAlReport.QuickRep1.Prepare;
TotalPage:=FrmAlReport.QuickRep1.QRPrinter.PageCount;
FrmAlReport.QuickRep1.Preview;
end;