在循环中我想让程序搜索出一条记录后就往表格中加入一行,并且在Label中显示提示,可现在程序运行结果是将全部记录搜索出来后,再全部加入到表格中,然后改变Label的Caption.其中qry1是Query,sg1是StringGrid;lfind和lcount是Label
如果让程序执行代码中的showmessage(....),结果就会是找到一行就加一行,可是总要确定一相showmessage的结果,谁能帮我解决.
var
a:integer; //循环数
cust_cd,consignee_cd,do_dt,inv_no,cur_cd,notes1,notes2:string;
amt_prc,local_amt,invoice_cost,profit,dj,sl:double;
begin
lfind.Caption:='Searching record from DataBase,Please wait...';
findinvoice(dtp1.Date,dtp2.Date);
with frmdata do
begin
if qry1.RecordCount>0 then
begin
sg1.RowCount:=qry1.RecordCount+1; //确定表格sg1的行数
for a:=0 to qry1.RecordCount-1 do //从DOO_H循环
begin //一些固定项赋值
cust_cd:=qry1.fieldbyname('CUST_CD').AsString;
consignee_cd:=qry1.fieldbyname('CONSIGNEE_CD').AsString;
do_dt:=qry1.fieldbyname('DO_DT').AsString;
inv_no:=qry1.fieldbyname('INV_NO').AsString;
cur_cd:=qry1.fieldbyname('CUR_CD').AsString;
notes1:=qry1.fieldbyname('NOTES1').AsString;
notes2:=qry1.fieldbyname('NOTES2').AsString;
//此处是大量的循环计算
//给表格sg1填值
sg1.Cells[0,a+1]:=CUST_CD;
sg1.Cells[1,a+1]:=CONSIGNEE_CD;
sg1.Cells[2,a+1]:=DO_DT;
sg1.Cells[3,a+1]:=INV_NO;
sg1.Cells[4,a+1]:=CUR_CD;
sg1.Cells[5,a+1]:=floattostr(AMT_PRC);
sg1.Cells[6,a+1]:=floattostr(Local_Amt);
sg1.Cells[7,a+1]:=floattostr(Invoice_cost);
sg1.Cells[8,a+1]:=floattostr(profit);
sg1.Cells[9,a+1]:=NOTES1;
sg1.Cells[10,a+1]:=NOTES2;
lcount.Caption:=inttostr(a+1)+' searched';
//showmessage(inttostr(a+1)+' searched');
qry1.Next;
end;
end;
end;
lfind.Caption:='Search Over,have '+inttostr(sg1.RowCount-1)+' record!';
end;
如果让程序执行代码中的showmessage(....),结果就会是找到一行就加一行,可是总要确定一相showmessage的结果,谁能帮我解决.
var
a:integer; //循环数
cust_cd,consignee_cd,do_dt,inv_no,cur_cd,notes1,notes2:string;
amt_prc,local_amt,invoice_cost,profit,dj,sl:double;
begin
lfind.Caption:='Searching record from DataBase,Please wait...';
findinvoice(dtp1.Date,dtp2.Date);
with frmdata do
begin
if qry1.RecordCount>0 then
begin
sg1.RowCount:=qry1.RecordCount+1; //确定表格sg1的行数
for a:=0 to qry1.RecordCount-1 do //从DOO_H循环
begin //一些固定项赋值
cust_cd:=qry1.fieldbyname('CUST_CD').AsString;
consignee_cd:=qry1.fieldbyname('CONSIGNEE_CD').AsString;
do_dt:=qry1.fieldbyname('DO_DT').AsString;
inv_no:=qry1.fieldbyname('INV_NO').AsString;
cur_cd:=qry1.fieldbyname('CUR_CD').AsString;
notes1:=qry1.fieldbyname('NOTES1').AsString;
notes2:=qry1.fieldbyname('NOTES2').AsString;
//此处是大量的循环计算
//给表格sg1填值
sg1.Cells[0,a+1]:=CUST_CD;
sg1.Cells[1,a+1]:=CONSIGNEE_CD;
sg1.Cells[2,a+1]:=DO_DT;
sg1.Cells[3,a+1]:=INV_NO;
sg1.Cells[4,a+1]:=CUR_CD;
sg1.Cells[5,a+1]:=floattostr(AMT_PRC);
sg1.Cells[6,a+1]:=floattostr(Local_Amt);
sg1.Cells[7,a+1]:=floattostr(Invoice_cost);
sg1.Cells[8,a+1]:=floattostr(profit);
sg1.Cells[9,a+1]:=NOTES1;
sg1.Cells[10,a+1]:=NOTES2;
lcount.Caption:=inttostr(a+1)+' searched';
//showmessage(inttostr(a+1)+' searched');
qry1.Next;
end;
end;
end;
lfind.Caption:='Search Over,have '+inttostr(sg1.RowCount-1)+' record!';
end;
解决方案 »
- delphi timer问题,很简单。
- 求助,
- 对象如何销毁?大家给讲讲吧,初学者渴望你的帮助!
- 想设一个共用变量,用两个应用程序(.EXE),一个应用程序给共用变量赋值,另一个应用程序可以取出共用变量的值。
- 有了SQL能不能在PowerDesigner8上生成那种表格的东西(图形),还有哪里有PD的使用说明啊
- 类
- 窗体问题,求救,再线等待
- 我在复制和粘贴过程中发现一个莫名其妙的怪问题?(好困惑我)
- 请问有没有人试过用DELPHI获得硬盘的物理序列号?高分相送
- delphi的RecordNodeList读取XML出错
- 动态报表遇到的问题(连开三贴,共300分求解决)
- 怎样在用TIdBase64Encoder控件加密的时候设置密码?
lcount.Update;另外不要用qry1.RecordCount。改为:
qry1.First;
while not qry1.Eof do
begin
//……
qry1.Next;
end;————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
qry1.Next;