Ejemplo n.º 1
0
        static private void InitRole()
        {
            if (lstRoleEnums == null)
            {
                QcNode.NodeUpdateToDb += QcNode_NodeUpdateToDb;
            }
            lstRoleEnums = new List <QcRoleEnum>();
            var Roles = DbHelper.Query("select * from QC_USE_RoleENUM");

            foreach (var v in Roles)
            {
                var qr = new QcRoleEnum(v);
                qr.InitPermission();
                lstRoleEnums.Add(qr);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 重载,完成分组编码和分组名称的转换
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>

        void InitRoles()
        {
            lstRoleEnums = new List <QcRoleEnum>();
            lstRoles     = new List <QcRole>();
            var sql = "select * from QC_USE_ROLE where 用户ID='" + this.UserID + "'";

            foreach (var v in DbHelper.Query(sql))
            {
                var qp = new QcRole(v);

                var qpe = QcRoleEnum.GetRoleFromCode(v.Field <string>("角色编码"));
                qp.roleenum = qpe;
                lstRoles.Add(qp);
                lstRoleEnums.Add(qpe);
            }
            RefreshPermission();
        }
Ejemplo n.º 3
0
        public bool AddRole(string rolename, string content = "")
        {
            QcRoleEnum role = QcRoleEnum.GetRoleFromName(rolename);

            if (role != null)
            {
                var qr = new QcRole();
                qr["用户ID"]  = this.Code;
                qr["角色编码"]  = role.RoleCode;
                qr["备注"]    = content;
                qr.roleenum = role;
                bool ret = qr.Update();
                if (ret)
                {
                    InitRoles();
                }
                return(ret);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public override bool Update(QcDbTransaction trans = null)
        {
            if (IsNew())
            {
                this.Code = QcRoleEnum.GetNextCode();
            }
            bool ret = base.Update(trans);

            if (ret == false && IsNew())
            {
                this.Code = "";
            }
            //新建的角色加入到列表
            if (ret && !RolesEnums.Contains(this))
            {
                RolesEnums.Add(this);
            }

            return(ret);
        }
Ejemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="code">角色编码</param>
 /// <param name="name">角色名称</param>
 /// <param name="content"> 备注</param>
 public QcRoleEnum(string name, string content = "") : this(null)
 {
     RoleCode    = QcRoleEnum.GetNextCode();
     RoleName    = name;
     RoleContent = content;
 }