Esempio n. 1
0
        public void Add(AddRoleInput input)
        {
            input.Validate();
            Sys_Role role = this.CreateEntity <Sys_Role>();

            AceMapper.Map(input, role);
            this.DbContext.DoWithTransaction(() =>
            {
                this.DbContext.Insert(role);
            });
        }
Esempio n. 2
0
        public JsonResult UpdateRole()
        {
            int               roleId = Request["roleId"].ToInt32();
            Sys_Role          role   = _sysRoleService.LoadEntities(c => c.Id == roleId).SingleOrDefault();
            Notify <Sys_Role> result = new Notify <Sys_Role>
            {
                Data = role
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        /// <summary>
        /// 角色分配
        /// </summary>
        /// <param name="UCode"></param>
        /// <param name="role"></param>
        /// <returns></returns>
        public ActionResult AllotRole(string UCode, string role)
        {
            Bse_Employee stuff = hrInstance.GetModelByCode(UCode);
            Sys_Role     rl    = rInstance.GetModel(string.Format("AND SRole_Code='{0}'", role));

            //stuff. = rl.SRole_Code;
            //stuff.Stuff_RoleName = rl.SRole_Name;
            hrInstance.Update(stuff);
            return(new JsonResult {
                Data = new { result = "success", Msg = "数据更新成功!" }
            });
        }
Esempio n. 4
0
        public override bool RoleExists(string roleName)
        {
            bool     exists = false;
            Sys_Role r      = _roleRepository.Find(ApplicationName, roleName);

            if (r != null)
            {
                exists = true;
            }

            return(exists);
        }
Esempio n. 5
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <returns>bool</returns>
        public bool Update(Sys_Role model)
        {
            bool result  = false;
            var  e       = new ModelExceptions();
            int  _rseult = instance.Update(model);

            if (_rseult > 0)
            {
                result = true;
            }
            return(result);
        }
Esempio n. 6
0
        private void EditRole(HttpContext context)
        {
            int      roleid = Convert.ToInt32(context.Request["ItemId"]);
            string   name   = context.Request["Name"];
            Sys_Role role   = new Sys_Role();

            role.Id       = roleid;
            role.Name     = name;
            role.EditUID  = context.Request["LoginUID"];
            role.EditTime = DateTime.Now;
            jsonModel     = bll.EditRole(role, context.Request["Menuids"]);
        }
Esempio n. 7
0
    protected void Del_Btn(object obj, EventArgs e)
    {
        LinkButton        linkButton        = obj as LinkButton;
        RepeaterItem      repeaterItem      = linkButton.Parent as RepeaterItem;
        HtmlInputCheckBox htmlInputCheckBox = repeaterItem.FindControl("chk") as HtmlInputCheckBox;
        int    num     = Convert.ToInt32(htmlInputCheckBox.Value);
        string cmdText = "delete from Sys_Role_Module where RoleID=" + num;

        MsSqlOperate.ExecuteNonQuery(CommandType.Text, cmdText, null);
        Sys_Role.Init().Delete(num);
        this.Show();
    }
Esempio n. 8
0
 public async Task <ActionResult> EditRole(int rid)
 {
     using (Sys_RoleRepository rep = new Sys_RoleRepository())
     {
         var role = new Sys_Role();
         if (rid > 0)
         {
             role = await rep.GetRoleAsync(rid);
         }
         return(View(role));
     }
 }
        private IList <Sys_Role> GetRoleList(string userName)
        {
            IList <Sys_Role>       result = new List <Sys_Role>();
            IList <Sys_UserInRole> list1  = _uirRepository.GetRolesForUser(_applicationName, userName);
            string roleName = string.Empty;

            foreach (Sys_UserInRole uir in list1)
            {
                Sys_Role r = _roleRepository.Find(_applicationName, uir.RoleName);
                result.Add(r);
            }
            return(result);
        }
Esempio n. 10
0
        public void Assigning2Role(int accountId, string roleType)
        {
            //分配到角色
            Sys_Role           role           = uow.Sys_Role.GetAll().Where(r => r.RoleType == roleType).SingleOrDefault();
            Sys_RelAccountRole relAccountRole = new Sys_RelAccountRole()
            {
                AccountId = accountId,
                RoleId    = role.Id
            };

            uow.Sys_RelAccountRole.Add(relAccountRole);
            uow.Commit();
        }
Esempio n. 11
0
 public ActionResult Form(Sys_Role model)
 {
     if (model.Id == null)
     {
         var primaryKey = _roleService.Insert(model);
         return(primaryKey != null?Success() : Error());
     }
     else
     {
         int row = _roleService.Update(model);
         return(row > 0 ? Success() : Error());
     }
 }
Esempio n. 12
0
        /// <summary>
        ///更新字段
        /// </summary>
        /// <param name="role">更新的实体</param>
        /// <returns></returns>
        public int UpdateRole(Sys_Role role)
        {
            var sb = new StringBuilder();

            sb.Append(@" UPDATE sys_Role SET F_Category=@F_Category,F_EnCode=@F_EnCode,F_FullName=@F_FullName,F_SortCode=@F_SortCode,F_DeleteMark=@F_DeleteMark,
            F_EnabledMark = @F_EnabledMark, F_Description = @F_Description, F_ModifyDate = @F_ModifyDate, F_ModifyUserId = @F_ModifyUserId, F_ModifyUserName = @F_ModifyUserName
            WHERE F_RoleId = @F_RoleId; ");

            using (IDbConnection conn = DapperAdapter.MySQLOpenConnection(ConfigurationHelper.MySQLConnectionStr))
            {
                return(conn.Execute(sb.ToString(), role));
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 获取角色列表
        /// </summary>
        /// <param name="report">报表条件obj</param>
        /// <returns></returns>
        public List <Sys_Role> GetListPage(Sys_Role role)
        {
            using (IDbConnection conn = DapperAdapter.MySQLOpenConnection(ConfigurationHelper.MySQLConnectionStr))
            {
                DynamicParameters param = new DynamicParameters();
                StringBuilder     sb    = new StringBuilder();

                sb.Append("SELECT * FROM sys_role where F_DeleteMark=0 and F_EnabledMark=1  ");
                if (!string.IsNullOrWhiteSpace(role.F_FullName))
                {
                    sb.Append("and f_FullName LIKE @RoleName");
                    param.Add("@RoleName", role.F_FullName);
                }


                //获取总记录数
                string sqlCount = "SELECT COUNT(1) as totalCount from (" + sb.ToString() + " ) as tb";

                if (role.pageIndex > -1)
                {
                    if (!string.IsNullOrWhiteSpace(role.orderBy))
                    {
                        sb.Append(role.orderBy);
                    }
                    else
                    {
                        sb.Append(" ORDER BY  F_SortCode asc, F_RoleId ");
                    }
                    sb.Append(" limit " + ((role.pageIndex - 1) * role.pageSize) + "," + role.pageSize);
                }

                //分页记录列表
                var list = conn.Query <Sys_Role>(sb.ToString(), param).ToList();
                if (list != null && list.Count() > 0)
                {
                    //总记录数列表
                    dynamic identity = conn.Query(sqlCount, param).Single();
                    list[0].totalCount = Convert.ToInt64(identity.totalCount);
                    list[0].pageIndex  = role.pageIndex;
                    list[0].pageSize   = role.pageSize;
                }

                return(list);

                /*
                 *  一言以蔽之,就是越往后分页,LIMIT语句的偏移量就会越大,速度也会明显变慢。
                 *      此时,我们可以通过子查询的方式来提高分页效率,大致如下:
                 * select * from sys_user where  id >=(select id from sys_user where id = 123 order by id limit 10000, 1) limit pageSize
                 */
            }
        }
Esempio n. 14
0
    private void InitData()
    {
        IList all = Sys_Role.Init().GetAll(null, "order by id desc");

        this.RoleID.DataSource     = all;
        this.RoleID.DataTextField  = "RoleName";
        this.RoleID.DataValueField = "id";
        this.RoleID.DataBind();
        this.GetFirtNode();
        this.parentID.DataSource     = this.li;
        this.parentID.DataTextField  = "Sh";
        this.parentID.DataValueField = "ID";
        this.parentID.DataBind();
    }
Esempio n. 15
0
        // GET: Admin/Sys_Role/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sys_Role sys_Role = db.Sys_Role.Find(id);

            if (sys_Role == null)
            {
                return(HttpNotFound());
            }
            return(View(sys_Role));
        }
 public void SubmitDutyForm(Sys_Role roleEntity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         roleEntity.Modify(keyValue);
         m_iRepository.Update(roleEntity);
     }
     else
     {
         roleEntity.Create();
         roleEntity.F_Category = 2;
         m_iRepository.Insert(roleEntity);
     }
 }
Esempio n. 17
0
        public object Put(int id, [FromBody] Sys_Role model)
        {
            string currentUserName = "";

            model.F_LastModifyTime   = DateTime.Now;
            model.F_LastModifyUserId = currentUserName;

            var updateResult = sysRoleManager.Update(model);

            return(Ok(new
            {
                success = updateResult
            }));
        }
        public ActionResult Index()
        {
            var       service = CreateService <IAccountAppService>();
            Sys_User  user    = service.GetById <Sys_User>(CurrentSession.UserId);
            Sys_Role  role    = string.IsNullOrEmpty(user.RoleId) ? null : service.GetById <Sys_Role>(user.RoleId);
            UserModel model   = new UserModel
            {
                User     = user,
                RoleName = role?.Name
            };

            ViewBag.UserInfo = model;
            ViewBag.WeChat   = CreateService <IAccountAppService>().GetOperationsWeChatByUserId(CurrentSession.UserId);
            return(View());
        }
Esempio n. 19
0
 protected void Del_All(object sender, EventArgs e)
 {
     foreach (RepeaterItem repeaterItem in this.rpt.Items)
     {
         HtmlInputCheckBox htmlInputCheckBox = repeaterItem.FindControl("chk") as HtmlInputCheckBox;
         if (htmlInputCheckBox.Checked)
         {
             int    num     = Convert.ToInt32(htmlInputCheckBox.Value);
             string cmdText = "delete from Sys_Role_Module where RoleID=" + num;
             MsSqlOperate.ExecuteNonQuery(CommandType.Text, cmdText, null);
             Sys_Role.Init().Delete(num);
         }
     }
     this.Show();
 }
Esempio n. 20
0
        public int Update(UserRoleVM form)
        {
            Sys_Role model = this._roleRepository.Entity(ContextDB.managerDBContext, t => t.Id == form.Id);

            if (model != null)
            {
                model.UpdateDate  = DateTime.Now;
                model.RoleName    = form.RoleName;
                model.Description = form.Description;
                model.OrderSort   = form.OrderSort;
                model.Enabled     = form.Enabled;
            }

            return(this._roleRepository.Update(ContextDB.managerDBContext, model));
        }
Esempio n. 21
0
        public void Update(UpdateRoleInput input)
        {
            input.Validate();

            Sys_Role role = this.DbContext.QueryByKey <Sys_Role>(input.Id, true);

            role.NotNull("角色不存在");

            AceMapper.Map(input, role);

            this.DbContext.DoWithTransaction(() =>
            {
                this.DbContext.Update(role);
            });
        }
Esempio n. 22
0
        /// <summary>
        /// 获取实体数据
        /// </summary>
        /// <param name='strCondition'>条件(AND Code='11')</param>
        /// <returns>model</returns>
        public Sys_Role GetModel(string strCondition)
        {
            List <Sys_Role> list  = instance.GetListByWhere(strCondition);
            Sys_Role        model = new Sys_Role();

            if (list != null && list.Count > 0)
            {
                model = list[0];
            }
            else
            {
                model = null;
            }
            return(model);
        }
Esempio n. 23
0
        public static ArrayList QueryList()
        {
            ArrayList           r   = new ArrayList();
            Sys_UserBll         sub = new Sys_UserBll();
            SqlCondtion         sc  = new SqlCondtion();
            Sys_EmployeeBll     seb = new Sys_EmployeeBll();
            Sys_RoleBll         srb = new Sys_RoleBll();
            SessionUserValidate iv  = SysValidateBll.ValidateSession();

            if (iv.f)
            {
                r.Add(iv.badstr);
                StringBuilder where = new StringBuilder();
                //where.Append(sc.GetSqlWhere(" ulogin ", "true", "", ""));
                if (iv.u.rcode == "xtgl")
                {
                }
                else
                {
                    where.Append(" and eno in (select eno from  Sys_Employee where dcode like '" + iv.u.dcode.Substring(0, 8) + "%')");
                }
                List <Sys_User> ls = sub.QueryList(where.ToString());
                if (ls != null)
                {
                    foreach (Sys_User s in ls)
                    {
                        Sys_Employee sr = seb.Query(" and eno='" + s.eno + "'");
                        ArrayList    al = new ArrayList();
                        if (sr != null)
                        {
                            Sys_Role srs = srb.Query(" and rcode='" + sr.rcode + "'");
                            al.Add(sr.eno);
                            al.Add(s.uname);
                            al.Add(sr.ename);
                            al.Add(sr.dname);
                            al.Add(srs == null ? "" : srs.rname);
                            al.Add(s.ulogin == true ? "<span style='color:green'>正常</span>" : "<span style='color:red'>停用</span>");
                            r.Add(al);
                        }
                    }
                }
            }
            else
            {
                r.Add(iv.badstr);
            }
            return(r);
        }
Esempio n. 24
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="mod"></param>
        /// <returns></returns>
        public string Save(Sys_Role mod)
        {
            ReturnJson Rejson = new ReturnJson();

            if (mod.ID == "")
            {
                mod.ID = Guid.NewGuid().ToString("N");
                //添加
                mod = RoleService.Insert(mod);
                if (mod != null)
                {
                    Rejson.Code   = "0";
                    Rejson.Errmsg = "添加成功";
                }
                else
                {
                    Rejson.Code   = "1";
                    Rejson.Errmsg = "添加失败";
                }
            }
            else
            {
                //修改
                //尝试通过ID获取数据库内已有信息
                Sys_Role DBmod = RoleService.GetModel(s => s.ID == mod.ID);
                if (DBmod != null)
                {
                    EntityToEntity(mod, ref DBmod);
                    DBmod = RoleService.Update(DBmod);
                    if (DBmod != null)
                    {
                        Rejson.Code   = "0";
                        Rejson.Errmsg = "保存成功";
                    }
                    else
                    {
                        Rejson.Code   = "1";
                        Rejson.Errmsg = "保存失败";
                    }
                }
                else
                {
                    Rejson.Code   = "1";
                    Rejson.Errmsg = "保存失败";
                }
            }
            return(ToJson(Rejson));
        }
Esempio n. 25
0
    public void SaveInfo()
    {
        sys_authorizegroup objsys_authorizegroup = objUserRule.sys_authorizegroup.FirstOrDefault(p => p.AuthorizeGroupID == AuthorizeGroupID);

        if (RoleID.IsNull())
        {
            if (objUserRule.Sys_Role.Any(s => s.ModuleTypeID == objsys_authorizegroup.ModuleTypeID && objRole.AuthorizeGroupID == AuthorizeGroupID && s.RoleName == txtRoleName.Text))
            {
                MessageDialog("对不起此角色名称已经存在");
                return;
            }
            objRole.RoleID           = Guid.NewGuid().ToString();
            objRole.AuthorizeGroupID = AuthorizeGroupID;
            objRole.RefUserID        = "";
            objRole.IsUserRole       = false;
            objRole.UserID           = CurrentUser.UserID;
            objRole.RoleName         = txtRoleName.Text.Trim();
            objRole.RoleCode         = objRole.RoleName.ConvertChineseSpell(false);
            objRole.Remark           = txtRemark.Text;
            objRole.IsLockOut        = false;
            objRole.ModuleTypeID     = objsys_authorizegroup.ModuleTypeID;
            objRole.RoleGroupID      = "";
            objRole.IsSystem         = false;
            objRole.AccountTypeID    = CurrentUser.AccountTypeID;
            objUserRule.InsertRole(objRole);
            MessageDialog("新增成功", "RoleList.aspx");
        }
        else
        {
            if (objUserRule.Sys_Role.Any(s => s.ModuleTypeID == objsys_authorizegroup.ModuleTypeID && s.RoleID != RoleID && objRole.AuthorizeGroupID == AuthorizeGroupID && s.RoleName == txtRoleName.Text))
            {
                MessageDialog("对不起此角色名称已经存在");
                return;
            }
            objRole           = objUserRule.Sys_Role.First(p => p.RoleID == RoleID);
            objRole.RoleName  = txtRoleName.Text.Trim();
            objRole.RoleCode  = objRole.RoleName.ConvertChineseSpell(false);
            objRole.Remark    = txtRemark.Text;
            objRole.IsLockOut = false;
            objUserRule.SaveChanges();
            if (chkRoleUser.Items.Count > 0)
            {
                objUserRule.AddRoleUser(RoleID, chkRoleUser.SelectValueString);
                objUserRule.RemoveRoleUser(RoleID, chkRoleUser.SelectNoValueString);
            }
            MessageDialog("修改成功", "RoleList.aspx");
        }
    }
Esempio n. 26
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <param name='model'>是否完成验证</param>
        /// <returns>bool</returns>
        public bool Insert(Sys_Role model, bool IsValid)
        {
            var  e      = new ModelExceptions();
            bool result = false;

            if (e.IsValid && IsValid)
            {
                //完成了验证,开始更新数据库了
                int _result = instance.Add(model);
                if (_result > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
Esempio n. 27
0
 /// <summary>
 /// 数据绑定
 /// </summary>
 public void InitBind()
 {
     if (hid_RoleID.Value != "")
     {
         Sys_Role modelRole = bllRole.Get(p => p.RoleID == hid_RoleID.Value);
         if (modelRole != null)
         {
             FormModel.SetForm(this, modelRole, "txt");
             hid_RoleName.Value = modelRole.Role_Name;
         }
         else
         {
             MessageBox.ShowAndRedirect(this, "该数据不存在!", "RoleList.aspx");
         }
     }
 }
Esempio n. 28
0
        public bool Delete(string applicationName, string roleName)
        {
            String   stmtId = "Sys_Role.DeleteByName";
            Sys_Role role   = new Sys_Role();

            role.ApplicationName = applicationName;
            role.RoleName        = roleName;
            if (SqlMapper.Update(stmtId, role) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 29
0
 /// <summary>
 /// 判断角色名称是否存在
 /// </summary>
 /// <param name="roleTypeModel"></param>
 /// <param name="isEdit"></param>
 /// <returns></returns>
 public bool IsExist_RoleName(Sys_Role roleTypeModel, bool isEdit)
 {
     using (SqlSugarClient _dbMsSql = SugarDao.SugarDao_MsSql.GetInstance())
     {
         bool result = false;
         if (isEdit)//编辑
         {
             result = _dbMsSql.Queryable <Sys_Role>().Any(i => i.Role == roleTypeModel.Role && i.Vguid != roleTypeModel.Vguid);
         }
         else//新增
         {
             result = _dbMsSql.Queryable <Sys_Role>().Any(i => i.Role == roleTypeModel.Role);
         }
         return(result);
     }
 }
Esempio n. 30
0
        /// <summary>
        /// 获取父角色Id
        /// </summary>
        /// <param name="roleId">角色Id</param>
        /// <returns></returns>
        private static Guid GetParentRoleId(Guid roleId)
        {
            if (roleId == Guid.Empty)
            {
                return(Guid.Empty);
            }
            string             errMsg = string.Empty;
            BaseDAL <Sys_Role> dal    = new BaseDAL <Sys_Role>();
            Sys_Role           role   = dal.GetEntityById(out errMsg, roleId);

            if (role != null && role.ParentId.HasValue)
            {
                return(role.ParentId.Value);
            }
            return(Guid.Empty);
        }