如何通过Diferent登录用户访问不同的表单? [英] How to access the Different forms by Diferent login users?

查看:66
本文介绍了如何通过Diferent登录用户访问不同的表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dear Techs,



我是C#和ASP.Net的初学者。我正在使用一个登录表单,MDI表单,FormA,FormB,FormC ..,如果第一个我是执行登录表单,有两个文本框作为txtusername,txtpassword和一个组合框用于类型的用户(Admin,A,B ,C)。现在,我以登录表单输入用户名和密码,然后显示MDI表单。在MDI表格中,我使用Menustrip访问FormA,FormB和Formc。



如果我以管理员身份登录,我想访问所有表格,如frmA,frmB,FrmC。除了,如果我以A登录,我只想访问FormA(frmA),因为它太过所有其他用户。这该怎么做。请帮我解决这个问题。数据库(SQL SERVER2005)。



谢谢与问候

Sreenivashan

Dear Techs,

I am beginner in C# and ASP.Net. I am using One Login Forms, MDI form, FormA, FormB,FormC.., if 1st I am Execute Login form, There are Two Text boxes as txtusername, txtpassword and One Combo box for type of user like(Admin, A,B,C). Now, I enter user name and password in login form then show the MDI form. In MDI form I am using Menustrip for Access the FormA,FormB, and Formc.

If I am login as Admin, I want to access all forms like frmA,frmB,FrmC. other than, if I am login as A, I want access FormA (frmA) only as its too all other users. How to do this. Please help me to solve this. Database(SQL SERVER2005).

Thanks & Regards
Sreenivashan

推荐答案

您只需在打开表格的代码中添加一张支票,以确保允许用户使用。



有两个地方可以做到这一点:当您调用Show以显示表单时,或者在Form.Load事件中(您只需检查,然后如果不允许用户,请调用Close方法)。

前者是更安全,但后者更容易确保允许访问 - 您无需记住在打开表单的任何地方进行检查。
All you have to do is add a check in the code where you are opening the form to ensure the user is permitted.

There are two places you can do this: When you call Show to display the form, or in the Form.Load event (all you have to do is check, then if the user is not permitted, call the Close method).
The former is "safer" but the later is easier to ensure that access is permitted - you don't need to remember to check everywhere you open the form.


这篇关于如何通过Diferent登录用户访问不同的表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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