procedure TBM_BENMENF.N_deleteClick(Sender: TObject);
var
mynode: Ttreenode;
i:integer;
bm:string;
begin
mynode := Treeview.selected;
//根目录不须删除
if mynode.level = 0 then exit;
//如果删除的是第二级目录
if mynode.level = 2 then
begin
if DM.BUMEN.recordcount <> 0 then
begin
if Application.messagebox('请确认是否要删除?', '北明办公管理系统', mb_iconinformation + mb_yesno) = idyes then
begin
DM.BUMEN.Delete;
DM.BUMEN.UpdateBatch();
Treeview.Items.delete(mynode);
end;
end
else
begin
Application.messagebox('已无记录可删除', '北明办公管理系统', mb_iconinformation + mb_defbutton1);
exit;
end;
EXIT;
end;
//如果删除是第一级目录,还得删除第二级目录
if mynode.level = 1 then
begin
// dm.BUMEN.Close;
with dm.QALL do
begin
close;
sql.Clear ;
sql.Add('select * from 部门 where 部门编码 like "' +copy(mynode.text, 2, 2)+'%"');
open;
first;
if Application.messagebox('请确认是否要删除及包括的子目录?', '北明办公管理系统', mb_iconinformation + mb_yesno) = idyes then
begin
for i:=0 to recordcount-1 do
begin
bm:=dm.QALL.fieldbyname('部门编码').AsString ;
with dm.QALL3 do
begin
close;
sql.Clear ;
sql.Add('delete from 部门 where 部门编码="'+bm+'"');
ExecSQL;
end;
next;
end;
Treeview.Items.delete(mynode);
dm.BUMEN.Close ;
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] ... 下一页 >>