Home > Back-end > Control the permissions problem, which help me to optimize the teacher, is there a simple way.
Control the permissions problem, which help me to optimize the teacher, is there a simple way.
Time:04-20
The Main. ADOQuery1. SQL. The Clear;//open the permissions list, judgment when you login, Main. ADOQuery1. SQL. The Add (' Select Top 1 * From S_SysUser Where UserName=: UserName '); Main. ADOQuery1. The Parameters. ParamByName (" UserName "). The Value:=Trim (ComboBox1. Text); The Main. ADOQuery1. Open; If the Main. ADOQuery1. FieldByName (' NewBtn). AsString='0' Then/0/1/judge the value of the new button The Begin The Main. NewBitbtn1. Visible:=False; End;
//the problem is, if such assumptions I have 1000 button, you will need to write code article 1000 How can simplify some, will be able to control each button is visible?
CodePudding user response:
A simple method is: Write a generic function, the content of the input parameter is the user name, the button name (is actually need to judge the permissions), return privileges, and then to determine each button,
Do you want to write less code, can be button a derived class, with authority to judge in the new class content, and then use the new class, outside the relatively complex, for you may not use,
Rights management, make the whole system is quite complicated, with simple good, you slowly again after optimization,