F
ff_ff
Unregistered / Unconfirmed
GUEST, unregistred user!
一个小系统,用Ttreeview把菜单的各项都显示出来了.
可是菜单是根据不同用户的权限来显示,但Ttreeview如何才能实现?
qx:array [1..4] of boolean;分配四种不同的权限.
var
MainForm: TMainForm;
username:string;
qx:array [1..4] of boolean;
i:Integer;
implementation
uses uLogin, uBooiIn,uOperator,BookBrower,units, PasswordChange,classmanage,bookfee,
returnfee;
{$R *.dfm}
procedure TMainForm.FormActivate(Sender: TObject);
//var
// i:Integer;
begin
frmLogin.ShowModal;
if Right=False then
begin
for i:=0 to 3 do
begin
// if (i<>4) and (Right=False) then
frmLogin.ShowModal;
if Right=True then Break;
end
end;
if username<>'' then
begin
if qx[1] then[red]这里是菜单的权限分配[/red]
begin
N2.Enabled:=true;
N3.Enabled:=true;
N4.Enabled:=true;
N6.Enabled:=true;
N7.Enabled:=true;
N9.Enabled:=true;
end else
begin
N2.Enabled:=false;
N3.Enabled:=false;
N4.Enabled:=false;
N6.Enabled:=false;
N7.Enabled:=false;
N9.Enabled:=false;
end;
if qx[2] then
begin
N15.Enabled:=true;
N16.Enabled:=true;
end else
begin
N15.Enabled:=false;
N16.Enabled:=false;
end;
if qx[3] then
begin
N11.Enabled:=true;
N12.Enabled:=true;
N13.Enabled:=true;
end
else
begin
N11.Enabled:=false;
N12.Enabled:=false;
N13.Enabled:=false;
end;
if qx[4] then
begin
N18.Enabled:=true;
N19.Enabled:=true;
N20.Enabled:=true;
end
else
begin
N18.Enabled:=false;
N19.Enabled:=false;
N20.Enabled:=false;
end;
end
else
close;
end;
red]下面的TtreeviewChange的代码?[/red]
procedure TMainForm.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
// Node.SelectedIndex:=1;
// if qx[1] then
// begin
// TreeView1.Selected.Text
// end;
if TreeView1.Selected.Text='教材入库' then
frmBookIn.ShowModal();
if TreeView1.Selected.Text='操作员管理' then
frmOperator.ShowModal();
if TreeView1.Selected.Text='库存查询' then
bookbrowerform.ShowModal();
if TreeView1.Selected.Text='单位信息' then
UnitForm.ShowModal();
if TreeView1.Selected.Text='密码修改' then
passwordchangeform.ShowModal();
if TreeView1.Selected.Text='班级管理' then
classform.ShowModal();
if TreeView1.Selected.Text='缴纳书费' then
BookFeeForm.ShowModal;
if TreeView1.Selected.Text='退回书费' then
ReturnFeeForm.ShowModal;
end;
[red]请问如何获得Ttreenode结点,根据权限qx,使它的.enable属性为false[/red]
可是菜单是根据不同用户的权限来显示,但Ttreeview如何才能实现?
qx:array [1..4] of boolean;分配四种不同的权限.
var
MainForm: TMainForm;
username:string;
qx:array [1..4] of boolean;
i:Integer;
implementation
uses uLogin, uBooiIn,uOperator,BookBrower,units, PasswordChange,classmanage,bookfee,
returnfee;
{$R *.dfm}
procedure TMainForm.FormActivate(Sender: TObject);
//var
// i:Integer;
begin
frmLogin.ShowModal;
if Right=False then
begin
for i:=0 to 3 do
begin
// if (i<>4) and (Right=False) then
frmLogin.ShowModal;
if Right=True then Break;
end
end;
if username<>'' then
begin
if qx[1] then[red]这里是菜单的权限分配[/red]
begin
N2.Enabled:=true;
N3.Enabled:=true;
N4.Enabled:=true;
N6.Enabled:=true;
N7.Enabled:=true;
N9.Enabled:=true;
end else
begin
N2.Enabled:=false;
N3.Enabled:=false;
N4.Enabled:=false;
N6.Enabled:=false;
N7.Enabled:=false;
N9.Enabled:=false;
end;
if qx[2] then
begin
N15.Enabled:=true;
N16.Enabled:=true;
end else
begin
N15.Enabled:=false;
N16.Enabled:=false;
end;
if qx[3] then
begin
N11.Enabled:=true;
N12.Enabled:=true;
N13.Enabled:=true;
end
else
begin
N11.Enabled:=false;
N12.Enabled:=false;
N13.Enabled:=false;
end;
if qx[4] then
begin
N18.Enabled:=true;
N19.Enabled:=true;
N20.Enabled:=true;
end
else
begin
N18.Enabled:=false;
N19.Enabled:=false;
N20.Enabled:=false;
end;
end
else
close;
end;
red]下面的TtreeviewChange的代码?[/red]
procedure TMainForm.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
// Node.SelectedIndex:=1;
// if qx[1] then
// begin
// TreeView1.Selected.Text
// end;
if TreeView1.Selected.Text='教材入库' then
frmBookIn.ShowModal();
if TreeView1.Selected.Text='操作员管理' then
frmOperator.ShowModal();
if TreeView1.Selected.Text='库存查询' then
bookbrowerform.ShowModal();
if TreeView1.Selected.Text='单位信息' then
UnitForm.ShowModal();
if TreeView1.Selected.Text='密码修改' then
passwordchangeform.ShowModal();
if TreeView1.Selected.Text='班级管理' then
classform.ShowModal();
if TreeView1.Selected.Text='缴纳书费' then
BookFeeForm.ShowModal;
if TreeView1.Selected.Text='退回书费' then
ReturnFeeForm.ShowModal;
end;
[red]请问如何获得Ttreenode结点,根据权限qx,使它的.enable属性为false[/red]