为用户设置菜单栏选项 [英] Setting menu strip options to users

查看:64
本文介绍了为用户设置菜单栏选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我需要设置/允许用户使用表格选项的帮助
要显示,我有一个具有5种以上形式的应用程序,从
调用 在菜单栏上,用户将使用存储在SQL 2008服务器中的有效用户名和密码登录,我必须为user1和user2进行设置,应该只能查看form1和form2.
:confused:
请帮助解决此问题,管理员登录用户可以为用户设置选项,如何在SQL中存储用户的权限

高级感谢

Hi All, i need an help on setting / permitting options to users for the forms
to display, i have an Application with more than 5 forms which is called from
the menu strip, the users will login with the valid username and password stored in SQL 2008 server, i have to set for user1 and user2 should be able to view only form1 and form2.
:confused:
Please help on getting into this, the Admin login user can set the options for the users, how do i store the permissions for the users in SQL

Advanced thanks

推荐答案

一种方法是在存在菜单的表单上设置权限.然后,您可以执行以下操作:(非常简单的代码)

One way to do this would be to set the permissions on the form in which the menus exist. Then you could do something like: (very simplistic code)

int userPermission = [get_user_permission_level];

if (userPermission == 1)
{
    mnuItem1.visible = true;
    mnuItem2.visible = false;
}
else if (userPermission == 2)
{
    // ...
}

// and so on as required.



您需要解决如何以更复杂的方式执行此操作,但这应该可以助您一臂之力.

关于将权限存储在数据库中,大概您的模式有一个描述用户的表?在其中添加一个列来保存权限级别,这可能是对包含一个权限级别列表的表的引用.



You''ll need to work out how to do this in a more sophisticated way but this should get you going.

In terms of storing the permissions in the database presumably your schema has a table that describes the users? Add a column in there that holds the permissions level and this might be a reference to a table that holds a list of permission levels.


您可以创建一个包含用户名和访问级别的表. br/>
即用户名varchar(50)和级别int

登录时查询该表,并根据级别配置菜单项,这些菜单项链接到您不想授予其访问权限的表单.

为所有用户分配一个级别.
You can create a table with usernames and access levels.

ie username varchar(50) and level int

Query this table in login and according to the level dispose the menuitems that link to the forms that you don''t want to give access to.

Assign a level to all users.


这篇关于为用户设置菜单栏选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆