/// <summary> /// 获取所有角色信息 /// </summary> /// <returns>角色集合</returns> public IList <MComRole> GetList(string companyId) { string sql = "SELECT Id,RoleName,RoleChilds,CompanyId,IsSystem FROM tbl_ComRole WHERE IsDelete = '0' AND CompanyId = @CompanyId"; DbCommand comm = this._db.GetSqlStringCommand(sql); this._db.AddInParameter(comm, "@CompanyId", DbType.AnsiStringFixedLength, companyId); IList <MComRole> list = new List <MComRole>(); MComRole item = null; using (IDataReader reader = DbHelper.ExecuteReader(comm, this._db)) { while (reader.Read()) { list.Add(item = new MComRole() { Id = (int)reader["Id"], RoleName = reader["RoleName"].ToString(), RoleChilds = reader["RoleChilds"].ToString(), CompanyId = reader["CompanyId"].ToString(), IsSystem = reader["IsSystem"].ToString() == "1" ? true : false }); } } return(list); }
/// <summary> /// 获取角色信息 /// </summary> /// <param name="id">角色编号</param> /// <param name="companyId">公司编号</param> /// <returns>角色实体</returns> public MComRole GetModel(int id, string companyId) { MComRole item = null; if (!string.IsNullOrEmpty(companyId)) { item = dal.GetModel(id, companyId); } return(item); }
/// <summary> /// 修改角色 /// </summary> /// <param name="item">角色实体</param> /// <returns>0:操作失败 1:操作成功 2:角色名重复</returns> public int Update(MComRole item) { DbCommand comm = this._db.GetStoredProcCommand("proc_ComRole_AddOrUpdate"); this._db.AddInParameter(comm, "@RoleName", DbType.String, item.RoleName); this._db.AddInParameter(comm, "@RoleChilds", DbType.AnsiString, item.RoleChilds); this._db.AddInParameter(comm, "@CompanyId", DbType.AnsiStringFixedLength, item.CompanyId); this._db.AddInParameter(comm, "@Id", DbType.Int32, item.Id); this._db.AddOutParameter(comm, "@Result", DbType.Int32, 2); DbHelper.RunProcedure(comm, _db); return(Convert.ToInt32(_db.GetParameterValue(comm, "Result"))); }
/// <summary> /// 修改角色 /// </summary> /// <param name="item">角色实体</param> /// <returns>0:操作失败 1:操作成功 2:角色名重复</returns> public int Update(MComRole item) { int result = 0; if (item != null) { result = dal.Update(item); if (result == 1) { EyouSoft.BLL.SysStructure.BSysLogHandle.Insert(string.Format("修改角色,编号为:{0}", item.Id)); } } return(result); }
/// <summary> /// 添加角色 /// </summary> /// <param name="item">角色实体</param> /// <returns>0:操作失败 1:操作成功 2:角色名重复</returns> public int Add(MComRole item) { int result = 0; if (item != null) { result = dal.Add(item); if (result == 1) { EyouSoft.BLL.SysStructure.BSysLogHandle.Insert(string.Format("添加角色,角色名称为:{0}", item.RoleName)); } } return(result); }