我的一个例子,你看看: if not subTreeView.Selected.HasChildren then begin iCaption :=subTreeView.Selected.Text ; if iCaption <>'家庭理财' then accessOk :=true else accessOK := getAccess; //进入家庭理财前,进行密码确认 if subAdoQuery.Locate('名称',subTreeView.Selected.Parent.Text ,[]) then iTableName :=subAdoQuery.fieldByName('代号').asString else begin application.MessageBox('数据库发生了致命错误,退出程序!','数据库错误',mb_IconError); exit; end; if accessOK then begin with diaryAdoQuery do begin close; sql.clear; sql.add('select * from '); sql.add(iTableName); sql.add(' where 名称=:名称'); parameters.paramByName('名称').value :=iCaption; open; Last ; end; end; storyGroupBox.Caption :=' '+iCaption+' : ' +intToStr(diaryAdoQuery.RecordCount ) +'条记录'; end else begin iCaption :=subTreeView.Selected.Text; storyGroupBox.Caption :=' '+iCaption+' :' end;
if not subTreeView.Selected.HasChildren then begin
iCaption :=subTreeView.Selected.Text ;
if iCaption <>'家庭理财' then accessOk :=true else
accessOK := getAccess; //进入家庭理财前,进行密码确认
if subAdoQuery.Locate('名称',subTreeView.Selected.Parent.Text ,[]) then
iTableName :=subAdoQuery.fieldByName('代号').asString else begin
application.MessageBox('数据库发生了致命错误,退出程序!','数据库错误',mb_IconError);
exit;
end;
if accessOK then begin
with diaryAdoQuery do begin
close;
sql.clear;
sql.add('select * from ');
sql.add(iTableName);
sql.add(' where 名称=:名称');
parameters.paramByName('名称').value :=iCaption;
open;
Last ;
end;
end;
storyGroupBox.Caption :=' '+iCaption+' : '
+intToStr(diaryAdoQuery.RecordCount )
+'条记录';
end else begin
iCaption :=subTreeView.Selected.Text;
storyGroupBox.Caption :=' '+iCaption+' :'
end;