Windows应用程序C#如何创建会话类型用户 [英] Windows Application C# how to create session type user

查看:100
本文介绍了Windows应用程序C#如何创建会话类型用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

各位你好





我正在使用C#在(.net)的Windows应用程序中进行项目。问题是我有创建3部门类型的用户授权我们自己的部门,但是b $ b

i想要创建一个授权人员,他们在部门中更新或更新但在窗口应用程序中我们可以''创建Session所以任何人都可以帮助我创建会话类型的任何想法

窗口是为每个用户创建的,并且只有一个用户可以编辑或Delteing可以delet或编辑(授权用户的编辑/删除按钮启用)或任何其他未授权编辑或删除按钮的人将被禁用。 Plz帮助我,如果你可以



在此先感谢:)

解决方案

在这种情况下你需要具有权限概念。一旦用户登录到您的系统,那么您应该拥有一组权限,指定是否为该特定用户提供编辑或删除权限。这可以实现使用数据库表或简单文本文件你可以存储该用户的权限,并且只有你可以启用或禁用编辑或删除按钮。



祝你好运


< blockquote>最快捷的解决方案



创建3个表



1.带列名的ControlPoint名称:ControlId, ControlName,ControlProperty

示例1,btnSave,启用/可见(它是该控件的属性)



2.列的角色名称:RoleId,RoleDesc

例101,管理员

102,经理

103,StoreKeeper



3. RolePermission,列名为RolePermissionsId,FK_RoleId,FK_ControlId,IsAllowed

示例:1,101,1,True Check基于你想要设置的那个角色

2,102,1,False





< pre lang =c#> // 根据表中定义的角色读取控制点,并在表单加载时调用此方法。

protected bool SetFormAccess(Form frm)
{
控制项= null ;
string ctrlName = ;
bool isAllow = false ;
// 写函数以根据角色获取实体
DataTable dt = GetControlList ( string RoleId);

foreach (DataRow dr in dt.Rows)
{
ctrlName = dr [ ControlName]。ToString();
isAllow = Convert.ToBoolean(dr [ IsAllowed]);

// 在表单控件集合中查找对象
foreach (控制c in frm.Controls)
{
if (c.Name == ctrlName)
item = c;
}

if (item!= null
{
if (dr [ ControlProperty]。ToString()== 已启用
项.Enabled = isAllow;
else if (dr [ ControlProperty]。ToString()== 可见
item.Visible = isAllow;
else
item.Enabled = isAllow;
}

}
返回 true ;
}


hello every one


I am doing project in windows Application in(.net) using C# .my problem is i have create 3 department type of user those who Authorised of our own department but

i want to create one Authorised person whose delte or update in department but In Window Application we can''t create Session so any one can help me out is any idea to create session type
window is create for each and every on e user and only one of user those one Athorised for Editing or Delteing that can delet or edit (Edit/delte button enable for authorised user) or any other those who has not authorised the edit or delete button is disable . Plz help me if u can

Thanks in Advance :)

解决方案

In this situation you need to have the Permission concept.Once the user is login to your system then you should have a set of permissions which specify wheather the edit or delete permission is given to that particular user or not.This you can achieve using database table or simple text file where you can store permissions of that user and based on that only you can enable or disable the edit or delete button.

Good luck


Best and quick solution

Create 3 table

1. ControlPoint with column Names: ControlId,ControlName,ControlProperty
Example 1, btnSave, Enable/Visible (It''s property of that controls)

2. Roles with column Names: RoleId,RoleDesc
Example 101, Admin
102, Manager
103, StoreKeeper

3. RolePermission with Column named RolePermissionsId,FK_RoleId,FK_ControlId,IsAllowed
Example : 1, 101 , 1, True Check based on what you wants to set to that role
2, 102 , 1, False


//Read Control points based on Roles defined in table and call this method on form load.

protected bool SetFormAccess(Form frm)
        {
            Control item = null;
            string ctrlName = "";
            bool isAllow = false;
            //write function to get entity based on role
            DataTable dt = GetControlList(string RoleId);

            foreach (DataRow dr in dt.Rows)
            {
                ctrlName = dr["ControlName"].ToString();
                isAllow = Convert.ToBoolean(dr["IsAllowed"]);

                //Find object in forms control collection 
                foreach (Control c in frm.Controls)
                {
                   if (c.Name == ctrlName)
                       item = c;
                }

                if (item != null)
                {
                    if (dr["ControlProperty"].ToString() == "Enabled")
                        item.Enabled = isAllow;
                    else if (dr["ControlProperty"].ToString() == "Visible")
                        item.Visible = isAllow;
                    else
                        item.Enabled = isAllow;
                }

            }
            return true;
        }


这篇关于Windows应用程序C#如何创建会话类型用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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