有一个窗口,有很多个控件,然后有四个角色,分别是“区域主管”、”行销部主管“、”行销部经理“、”BOSS“
我希望达到的效果是,根据不同用户登录,识别该用户可用的控件,其他控件锁死;;如果通过IF代码,达到这样的效果;
我自己编了一段代码,但是实现不了,请老师给予指点;;;;
Dim CanEdit As Boolean = (user.roles = "区域主管") ' 如果是角色,请改用user.roles
e.Form.Controls("Button5").Enabled = CanEdit
e.Form.Controls("Button3").Enabled = CanEdit
e.Form.Controls("Button1").Enabled = CanEdit
e.Form.Controls("Button4").Enabled = CanEdit
e.Form.Controls("textbox4").Enabled = CanEdit
Dim CanEdit As Boolean = (user.roles = "行销部主管") ' 如果是角色,请改用user.roles
e.Form.Controls("TextBox5").Enabled = CanEdit
e.Form.Controls("DateTimePicker2").Enabled = CanEdit
e.Form.Controls("Button6").Enabled = CanEdit
e.Form.Controls("Button7").Enabled = CanEdit
Dim CanEdit As Boolean = (user.roles = "行销部经理") ' 如果是角色,请改用user.roles
e.Form.Controls("TextBox6").Enabled = CanEdit
e.Form.Controls("DateTimePicker3").Enabled = CanEdit
e.Form.Controls("Button8").Enabled = CanEdit
e.Form.Controls("Button9").Enabled = CanEdit
Dim CanEdit As Boolean = (user.roles = "boss") ' 如果是角色,请改用user.roles
e.Form.Controls("TextBox2").Enabled = CanEdit
e.Form.Controls("DateTimePicker1").Enabled = CanEdit
e.Form.Controls("Button10").Enabled = CanEdit
e.Form.Controls("Button11").Enabled = CanEdit
如果将以上代码,结合成一个逻辑性的代码???