防止创建表单(或任何控件) [英] Prevent form (or any control) creation

查看:105
本文介绍了防止创建表单(或任何控件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.
我的应用程序的授权系统遇到问题.
我将用户,角色和每个角色的权限保留在MySQL数据库上.
我正在尝试按对象类型分配权限:
-菜单选项(Nedim Sabic的凉爽Vista风格菜单,顺便说一句,很好控制) -表格(我开发了基本表格并从其他所有表格中继承)
-按钮(所有按钮也都继承自基本类).

在我的基本表单类中,在LOAD事件中,我正在检查特定用户的授权(基于其角色):

Hi there.
I''m having a trouble with the authorization system of my application.
I persist the users, roles and permission per role on a MySQL database.
I''m trying to assign permission by object type:
- Menu option (Cool Vista-style menu by Nedim Sabic, great control by the way)
- Forms (I developed a basic form and inherit from that all the other forms)
- Buttons (all the buttons are inherited from a basic class too).

At my base form class, at the LOAD event, I''m checking the authorization for the specific user (based on his/her role):

if (!Autorizaciones.Autorizado(this.Name, _Padre)) // Checks permissions
{
   Autorizaciones.Error(); //Display a message
   Close(); // Close the form
}



但是(总是一个but),即使这可以正常工作,该表格也会显示几毫秒.

是否可以防止使用另一个事件来创建表单(或任何其他对象)?

提前谢谢.

VS2008
MySQL 5.5.10
.NET FrameWork 3.5



But (always a but), even if this works correctly, the form is shown for a few milliseconds.

Is it possible to prevent the creation of the form (or any other object) using another event?

Thanks in advance.

VS2008
MySQL 5.5.10
.NET FrameWork 3.5

推荐答案

0)甚至在实例化表单之前进行权限检查

1)或者,您可以将表单设置为初始隐藏(Form.Visible=false;),并且只有在验证用户之后才能使其可见.

2)或者,您可以设置一个类来执行验证并生成一个事件,您的父表单可以对其进行响应(并因此在验证用户之后实例化该表单).
0) Do the permission check before even instantiating the form

1) Or you can set the form to be initially hidden (Form.Visible=false;), and only make it visible after the user has been validated.

2) Or you can setup a class that performs the validation and generates an event that your parent form can respond to (and thus instantiate the form AFTER the user has been validated).


这篇关于防止创建表单(或任何控件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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