C
cnbobo
Unregistered / Unconfirmed
GUEST, unregistred user!
我有两个数据库表“包厢,餐饮预订”,在 listview1导入包厢名时要完成这样的功能:
包厢被预订:NewItem.ImageIndex:=2;
没被预订:NewItem.ImageIndex:=1;
下面这段程序虽然完成了这功能,但是速度很慢慢,没有效率,请大家帮忙!!![]
procedure TForm3.SpeedButton1Click(Sender: TObject);
var lc:integer;
NewItem:TListItem;
begin
with form1.adoquery1 do
begin
Close;
sql.Clear; // ,餐饮预订
sql.Add('select * from 包厢 ');
// sql.Add('where 包厢.包厢名=餐饮预订.包厢 ');
sql.Add('order by 包厢名');
open;
first;
end;
rc:=form1.ADOQuery1.RecordCount;
for lc:=0 to rc-1 do
begin
NewItem:=ListView1.Items.Add;
//listview1.Items.Add;
listview1.Items.Item[lc].Caption:=form1.ADOQuery1.fieldbyname('包厢名').AsString;
/////////////////////////////////////////////////////////
with adoquery1 do
begin
Close;
sql.Clear;
sql.Add('select * from 餐饮预订 ');
sql.Add('where 包厢='+''''+listview1.Items.Item[lc].Caption+'''');
open;
end;
////////////////////////////////////////////////////////
if adoquery1.RecordCount>0 then
NewItem.ImageIndex:=2
else
NewItem.ImageIndex:=1;
form1.ADOQuery1.Next;
end;
end;
包厢被预订:NewItem.ImageIndex:=2;
没被预订:NewItem.ImageIndex:=1;
下面这段程序虽然完成了这功能,但是速度很慢慢,没有效率,请大家帮忙!!![]
procedure TForm3.SpeedButton1Click(Sender: TObject);
var lc:integer;
NewItem:TListItem;
begin
with form1.adoquery1 do
begin
Close;
sql.Clear; // ,餐饮预订
sql.Add('select * from 包厢 ');
// sql.Add('where 包厢.包厢名=餐饮预订.包厢 ');
sql.Add('order by 包厢名');
open;
first;
end;
rc:=form1.ADOQuery1.RecordCount;
for lc:=0 to rc-1 do
begin
NewItem:=ListView1.Items.Add;
//listview1.Items.Add;
listview1.Items.Item[lc].Caption:=form1.ADOQuery1.fieldbyname('包厢名').AsString;
/////////////////////////////////////////////////////////
with adoquery1 do
begin
Close;
sql.Clear;
sql.Add('select * from 餐饮预订 ');
sql.Add('where 包厢='+''''+listview1.Items.Item[lc].Caption+'''');
open;
end;
////////////////////////////////////////////////////////
if adoquery1.RecordCount>0 then
NewItem.ImageIndex:=2
else
NewItem.ImageIndex:=1;
form1.ADOQuery1.Next;
end;
end;