procedure TfrmGroups.itmDeleteClick(Sender: TObject); var strsql,selGroup:string; begin selGroup:=TV.Selected.Text; if (selGroup='系统用户组') or (selGroup='') then exit; {判断是否有用户已经属于该用户组} strsql := 'select Count(gId) As RecCount'; strsql := strsql + ' from Users'; strsql := strsql + ' where gId='+ lblgId.Caption +''; RunSQL(dm.QryTmp,strsql); if dm.QryTmp.FieldByName('RecCount').Value >0 then begin ShowInfo('已经有用户属于该组,不能删除!'); exit; end; ShowWarnInfo('你确定要删除该用户组!'); strsql:='Delete From Groups Where gId='+ lblgId.Caption +''; RunSQL(dm.Groups,strsql); TV.Selected.Delete; end;//TV:TTreeView
你可以利用数据库的特殊结构来处理,例如你记录每一个字段的值的上一级节点的值
然后在删除某节点的时候呢,就在数据库当中查找上级为这个值的值,在删除所有的这些值,最后在把treeview重新创建一下
var
strsql,selGroup:string;
begin
selGroup:=TV.Selected.Text;
if (selGroup='系统用户组') or (selGroup='') then exit; {判断是否有用户已经属于该用户组}
strsql := 'select Count(gId) As RecCount';
strsql := strsql + ' from Users';
strsql := strsql + ' where gId='+ lblgId.Caption +'';
RunSQL(dm.QryTmp,strsql);
if dm.QryTmp.FieldByName('RecCount').Value >0 then begin
ShowInfo('已经有用户属于该组,不能删除!');
exit;
end;
ShowWarnInfo('你确定要删除该用户组!');
strsql:='Delete From Groups Where gId='+ lblgId.Caption +'';
RunSQL(dm.Groups,strsql);
TV.Selected.Delete;
end;//TV:TTreeView
表示层不能写
业务层和访问层写的话都得访问表示层的数据。。
老板说要传参数
不东的说
2。node.data:=该声明;
3。在创建TreeView时,把数据 的关键字段值填充.data;
4。这样,在删除时,提取.data的值,声称相关的SQl;