示例#1
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="role_name"></param>
        /// <param name="parent_title"></param>
        /// <returns></returns>
        public string Add(int myrole_id, string role_name, int parent_id)
        {
            if (parent_id == 0)
            {
                return("pdelete");
            }
            //只能把角色添加到自己管辖的科目范围内
            DataTable dtRole = GetManagerRole(myrole_id);

            DataRow[] drs = dtRole.Select("Role_id=" + parent_id);
            if (drs.Length == 0)
            {
                return("nopower");
            }

            if (Exists(role_name))
            {
                return("exists");
            }
            Model.sys_role model = new Model.sys_role();
            model.Role_name      = role_name;
            model.Role_parent_id = parent_id;
            if (Add(model) > 0)
            {
                DeleteCache(parent_id);
                return("success");
            }
            else
            {
                return("error");
            }
        }
示例#2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="mo"></param>
        /// <returns></returns>
        public string SaveSysRole(Model.sys_role mo)
        {
            string savetype = Request.QueryString["savetype"].ToString();

            mo.r_state = string.IsNullOrEmpty(Request.Form["r_state"]) ? 0 : 1;

            bool b = false;

            if (savetype == "0")
            {
                if (new DAL.sys_role().Add(mo) >= 0)
                {
                    b = true;
                }
            }
            else
            {
                mo.id = Convert.ToInt32(savetype);
                b     = new DAL.sys_role().Update(mo);
            }
            return(b ? "success" : "fail");
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="myrole_id">提交修改的角色ID</param>
        /// <param name="role_id">要修改的角色ID</param>
        /// <param name="role_name">要修改的角色名称</param>
        /// <param name="parent_title">要修改为的角色父角色</param>
        /// <returns></returns>
        public string Edit(int myrole_id, int role_id, string role_name, string parent_title)
        {
            if (dal.Exists(role_id, role_name))
            {
                return("exists");
            }
            int parent_id = GetIDByText(parent_title.Trim());

            if (parent_id == 0)//添加时有人删除了父科目
            {
                return("pdelete");
            }
            //只能把角色添加到自己管辖的科目范围内
            DataTable dtRole = GetManagerRole(myrole_id);

            DataRow[] drs = dtRole.Select("Role_id=" + parent_id);
            if (drs.Length == 0)
            {
                return("nopower");
            }
            Model.sys_role model = GetModel(role_id);
            if (model == null)
            {
                return("delete");
            }
            model.Role_name      = role_name;
            model.Role_parent_id = parent_id;
            if (Update(model))
            {
                DeleteCache(parent_id);
                return("success");
            }
            else
            {
                return("error");
            }
        }