-- 创建 操作员信息表(Operator)
Id
OperatorName -- 操作员姓名
Password
RightsList -- 操作员权限列表
State -- 用户当前状态
-- 创建 权限组信息表(RightsGroup)
Id
GroupName -- 权限组名称
GroupRightsList -- 组权限列表
-- 创建 权限关系表(RightsRelation)
Id
OperatorId -- 操作员 Id
RightsGroupId -- 权限组 Id
1、实体模型基类(ModelBase)
int _id;
string _modelName;
public ModelBase() { }
public ModelBase(int id, string modelName)
{
this.Id = id;
this.ModelName = modelName;
}
2、操作员实体类(Operator)
string _password;
Dictionary<string, Rights> _rightsCollection; 权限集合(键值用于存储菜单/工具栏项的 Name 属性)
bool _state;
public Operator() { }
public Operator(
int operatorId,
string name,
string password,
Dictionary<string, Rights> rightsCollection,
bool state): base(operatorId, name)
{
this.Password = password;
this.RightsCollection = rightsCollection;
this.State = state;
}
3、权限组实体类(RightsGroup)
Dictionary<string, Rights> _groupRightsCollection;
public RightsGroup() { }
public RightsGroup(
int groupId,
string groupName,
Dictionary<string, Rights> groupRightsCollection): base(groupId, groupName)
{
this.GroupRightsCollection = groupRightsCollection;
}
4、权限关系实体类(RightsRelation)
int _id;
int _operatorId;
string _operatorName;
int _rightsGroupId;
string rightsGroupName;
public RightsRelation() { }
public RightsRelation(
int id,
int operatorId,
string operatorName,
int rightsGroupId,
string rightsGroupName)
{
this.Id = id;
this.OperatorId = operatorId;
this.OperatorName = operatorName;
this.RightsGroupId = rightsGroupId;
this.RightsGroupName = rightsGroupName;
}
// 读取权限集合
System.Data.SqlTypes.SqlBytes bytes = myReader.GetSqlBytes(3); // 只能指定列序号
// 将流反序列化为权限集合对象
BinaryFormatter bf = new BinaryFormatter();
throw new Exception("用户密码长度不能小于六位!");
// 转换操作员权限集合为数据库可存取的 Byte[] 数组
MemoryStream ms = new MemoryStream();
internal
currentChildTreeNode.Tag.ToString()
// 递归添加到当前节点及其所有子节点
currentChildTreeNode.Nodes.Add(LoadAllChildTreeNode(newChildTreeNode, rightsCollection));
this._dgvOperatorList.Columns["ModelName"].ToolTipText = "[只读列]";
this._dgvOperatorList.Columns["Password"].DisplayIndex = 2; 索引列
this._dgvOperatorList.Columns["RightsCollection"].ReadOnly = true; 提示工具
Id
OperatorName -- 操作员姓名
Password
RightsList -- 操作员权限列表
State -- 用户当前状态
-- 创建 权限组信息表(RightsGroup)
Id
GroupName -- 权限组名称
GroupRightsList -- 组权限列表
-- 创建 权限关系表(RightsRelation)
Id
OperatorId -- 操作员 Id
RightsGroupId -- 权限组 Id
1、实体模型基类(ModelBase)
int _id;
string _modelName;
public ModelBase() { }
public ModelBase(int id, string modelName)
{
this.Id = id;
this.ModelName = modelName;
}
2、操作员实体类(Operator)
string _password;
Dictionary<string, Rights> _rightsCollection; 权限集合(键值用于存储菜单/工具栏项的 Name 属性)
bool _state;
public Operator() { }
public Operator(
int operatorId,
string name,
string password,
Dictionary<string, Rights> rightsCollection,
bool state): base(operatorId, name)
{
this.Password = password;
this.RightsCollection = rightsCollection;
this.State = state;
}
3、权限组实体类(RightsGroup)
Dictionary<string, Rights> _groupRightsCollection;
public RightsGroup() { }
public RightsGroup(
int groupId,
string groupName,
Dictionary<string, Rights> groupRightsCollection): base(groupId, groupName)
{
this.GroupRightsCollection = groupRightsCollection;
}
4、权限关系实体类(RightsRelation)
int _id;
int _operatorId;
string _operatorName;
int _rightsGroupId;
string rightsGroupName;
public RightsRelation() { }
public RightsRelation(
int id,
int operatorId,
string operatorName,
int rightsGroupId,
string rightsGroupName)
{
this.Id = id;
this.OperatorId = operatorId;
this.OperatorName = operatorName;
this.RightsGroupId = rightsGroupId;
this.RightsGroupName = rightsGroupName;
}
// 读取权限集合
System.Data.SqlTypes.SqlBytes bytes = myReader.GetSqlBytes(3); // 只能指定列序号
// 将流反序列化为权限集合对象
BinaryFormatter bf = new BinaryFormatter();
throw new Exception("用户密码长度不能小于六位!");
// 转换操作员权限集合为数据库可存取的 Byte[] 数组
MemoryStream ms = new MemoryStream();
internal
currentChildTreeNode.Tag.ToString()
// 递归添加到当前节点及其所有子节点
currentChildTreeNode.Nodes.Add(LoadAllChildTreeNode(newChildTreeNode, rightsCollection));
this._dgvOperatorList.Columns["ModelName"].ToolTipText = "[只读列]";
this._dgvOperatorList.Columns["Password"].DisplayIndex = 2; 索引列
this._dgvOperatorList.Columns["RightsCollection"].ReadOnly = true; 提示工具