Ejemplo n.º 1
0
        public ActionResult Add([ModelBinder(typeof(JsonBinder <SysRoleEntity>))] SysRoleEntity entity)
        {
            SysRoleProvider provider = new SysRoleProvider();

            if (entity.RoleNum.IsEmpty())
            {
                entity.RoleNum    = SequenceProvider.GetSequence(typeof(SysRoleEntity));
                entity.IsDelete   = (int)EIsDelete.NotDelete;
                entity.CreateTime = DateTime.Now;
                int line = provider.AddRole(entity);
                if (line > 0)
                {
                    this.ReturnJson.AddProperty("d", "success");
                }
            }
            else
            {
                entity.IsDelete = (int)EIsDelete.NotDelete;
                int line = provider.UpdateRole(entity);
                if (line > 0)
                {
                    this.ReturnJson.AddProperty("d", "success");
                }
            }
            return(Content(this.ReturnJson.ToString()));
        }
Ejemplo n.º 2
0
 public JsonResult Save(SysRoleEntity newObj)
 {
     try
     {
         string     Condition = " and RoleName='" + newObj.RoleName + "'";
         int        itemCount = roleLogic.Count(Condition);
         JsonResult result    = new JsonResult();
         if (itemCount > 0)
         {
             result.Data = new { status = 200, msg = "此名称已经存在" };
             return(Json(result));
         }
         newObj.RoleId = this.GetMaxRoleId();
         bool isOK = roleLogic.Save(newObj);
         if (isOK == true)
         {
             result.Data = new { status = 100, msg = "" };
             return(Json(result));
         }
         else
         {
             result.Data = new { status = 200, msg = "保存失败" };
             return(Json(result));
         }
     }
     catch (Exception ex)
     {
         JsonResult result = new JsonResult();
         result.Data = new { status = 200, msg = ex.Message };
         return(Json(result));
     }
 }
Ejemplo n.º 3
0
        public ActionResult AddRole()
        {
            string RoleNum   = WebUtil.GetQueryStringValue <string>("RoleNum", string.Empty);
            string CompanyID = this.CompanyID;

            SysRoleEntity entity = null;

            if (!RoleNum.IsEmpty())
            {
                ITopClient client = new TopClientDefault();
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("CompanyID", CompanyID);
                dic.Add("SnNum", RoleNum);
                string result = client.Execute(RoleApiName.RoleApiName_Single, dic);

                if (!result.IsEmpty())
                {
                    DataResult <SysRoleEntity> dataResult = JsonConvert.DeserializeObject <DataResult <SysRoleEntity> >(result);
                    entity = dataResult.Result;
                }
            }
            entity         = entity.IsNull() ? new SysRoleEntity() : entity;
            ViewBag.Entity = entity;
            return(View());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 编辑角色
        /// </summary>
        /// <returns></returns>
        public ActionResult Edit()
        {
            string RoleName  = WebUtil.GetFormValue <string>("RoleName");
            string CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            string Remark    = WebUtil.GetFormValue <string>("Remark");
            string RoleNum   = WebUtil.GetFormValue <string>("RoleNum");
            string SnNum     = WebUtil.GetFormValue <string>("SnNum");

            SysRoleEntity entity = new SysRoleEntity();

            entity.SnNum      = SnNum;
            entity.RoleNum    = RoleNum;
            entity.RoleName   = RoleName;
            entity.CompanyID  = CompanyID;
            entity.RoleNum    = RoleNum;
            entity.IsDelete   = (int)EIsDelete.NotDelete;
            entity.CreateTime = DateTime.Now;
            entity.Remark     = Remark;

            SysRoleProvider provider = new SysRoleProvider(CompanyID);
            int             line     = provider.UpdateRole(entity);
            DataResult      result   = new DataResult();

            if (line > 0)
            {
                result.Code    = (int)EResponseCode.Success;
                result.Message = "角色修改成功";
            }
            else
            {
                result.Code    = (int)EResponseCode.Exception;
                result.Message = "角色修改失败";
            }
            return(Content(JsonHelper.SerializeObject(result)));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 查询用户管理员分页
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <AdminEntity> GetList(AdminEntity entity, ref PageInfo pageInfo)
        {
            entity.IncludeAll();
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
            SysRoleEntity roleEntity = new SysRoleEntity();

            roleEntity.Include("RoleName", "RoleName");
            entity.Left <SysRoleEntity>(roleEntity, new Params <string, string>()
            {
                Item1 = "RoleNum", Item2 = "RoleNum"
            });
            SysDepartEntity departEntity = new SysDepartEntity();

            departEntity.Include("DepartName", "DepartName");
            entity.Left <SysDepartEntity>(departEntity, new Params <string, string>()
            {
                Item1 = "DepartNum", Item2 = "DepartNum"
            });
            int rowCount = 0;
            List <AdminEntity> listResult = this.Admin.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;
            return(listResult);
        }
Ejemplo n.º 6
0
        public int UpdateRoleMenu(SysRoleEntity model, List <SysRoleMenuEntity> listModel)
        {
            bool resulte = SqlHelper.ExecuteTranSql((con, tran) =>
            {
                int r = 0;
                try
                {
                    StringBuilder strsql = new StringBuilder();
                    strsql.Append("update sys_role set  ");
                    strsql.Append("rolecode=@rolecode,rolename=@rolename,roleseq=@roleseq,remark=@remark,createby=@createby,createdate=@createdate");
                    strsql.Append(" where id=@id ");
                    r = SqlHelper.ExecuteCon(strsql.ToString(), model, tran, null, CommandType.Text, con);

                    if (listModel != null && listModel.Count > 0)
                    {
                        string sqlrolemenu = "delete from  sys_rolemenu where rolecode=@Rolecode";
                        r = SqlHelper.ExecuteCon(sqlrolemenu.ToString(), new { Rolecode = model.Rolecode }, tran, null, CommandType.Text, con);
                        StringBuilder strsqlfun = new StringBuilder();
                        strsqlfun.Append("insert into sys_rolemenu(menucode,rolecode,funcode) ");
                        strsqlfun.Append(" values(@menucode,@rolecode,@funcode)");
                        r = SqlHelper.ExecuteCon(strsqlfun.ToString(), listModel, tran, null, CommandType.Text, con);
                    }
                }
                catch (Exception ex)
                {
                    Log4NetHelper.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Debug(ex.Message);
                    r = 0;
                }

                return(r);
            });

            return(resulte ? 1 : 0);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 查询用户管理员分页
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <AdminEntity> GetList(AdminEntity entity, ref PageInfo pageInfo)
        {
            entity.IncludeAll();
            entity.Exclude(a => a.PassWord);
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
            entity.And(a => a.CompanyID == entity.CompanyID);
            entity.And(item => item.UserCode != "DA_0000");

            if (!entity.UserName.IsEmpty())
            {
                entity.And("UserName", ECondition.Like, "%" + entity.UserName + "%");
            }
            if (!entity.UserCode.IsEmpty())
            {
                entity.And("UserCode", ECondition.Like, "%" + entity.UserCode + "%");
            }

            if (!entity.RoleNum.IsEmpty())
            {
                entity.And(a => a.RoleNum == entity.RoleNum);
            }

            if (!entity.DepartNum.IsEmpty())
            {
                DepartProvider         provider   = new DepartProvider(this.CompanyID);
                List <SysDepartEntity> listDepart = provider.GetChildList(entity.DepartNum);
                string[] items = null;
                if (!listDepart.IsNullOrEmpty())
                {
                    items = listDepart.Select(item => item.SnNum).ToArray();
                    entity.And("DepartNum", ECondition.In, items);
                }
            }

            int rowCount = 0;
            List <AdminEntity> listResult = this.Admin.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;

            if (!listResult.IsNullOrEmpty())
            {
                SysRoleProvider RoleProvider   = new SysRoleProvider(this.CompanyID);
                DepartProvider  DepartProvider = new DepartProvider(this.CompanyID);
                foreach (AdminEntity item in listResult)
                {
                    if (item.RoleNum.IsNotEmpty())
                    {
                        SysRoleEntity RoleEntity = RoleProvider.GetRoleEntity(item.RoleNum);
                        item.RoleName = RoleEntity != null ? RoleEntity.RoleName : string.Empty;
                    }
                    if (item.DepartNum.IsNotEmpty())
                    {
                        SysDepartEntity DepartEntity = DepartProvider.GetSingle(item.DepartNum);
                        item.DepartName = DepartEntity != null ? DepartEntity.DepartName : string.Empty;
                    }
                }
            }
            return(listResult);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 使用工号扫描
        /// </summary>
        /// <param name="UserCode"></param>
        /// <returns></returns>
        public AdminEntity Scan(string UserCode)
        {
            AdminEntity entity = new AdminEntity();

            entity.IncludeAll();
            entity.Exclude(a => a.PassWord);
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)
            .And <AdminEntity>(a => a.CompanyID == CompanyID)
            .And(item => item.UserCode == UserCode)
            ;
            entity = this.Admin.GetSingle(entity);
            if (entity != null)
            {
                SysRoleProvider RoleProvider   = new SysRoleProvider(this.CompanyID);
                DepartProvider  DepartProvider = new DepartProvider(this.CompanyID);

                if (entity.RoleNum.IsNotEmpty())
                {
                    SysRoleEntity RoleEntity = RoleProvider.GetRoleEntity(entity.RoleNum);
                    entity.RoleName = RoleEntity != null ? RoleEntity.RoleName : string.Empty;
                }
                if (entity.DepartNum.IsNotEmpty())
                {
                    SysDepartEntity DepartEntity = DepartProvider.GetSingle(entity.DepartNum);
                    entity.DepartName = DepartEntity != null ? DepartEntity.DepartName : string.Empty;
                }
            }
            return(entity);
        }
Ejemplo n.º 9
0
        public int Insert(SysRoleEntity model)
        {
            StringBuilder strsql = new StringBuilder();

            strsql.Append("insert into sys_role(rolecode,rolename,roleseq,remark,createby,createdate) ");
            strsql.Append(" values(@rolecode,@rolename,@roleseq,@remark,@createby,@createdate)");
            return(SqlHelper.Execute(strsql.ToString(), model));
        }
Ejemplo n.º 10
0
        public string SaveRoleFunRel(HttpContext context)
        {
            string status = "{\"status\":0;}";

            int    roleID      = 0;
            string roleName    = context.Request.Form["rname"];
            string functionsid = context.Request.Form["functionsid"];

            if (!int.TryParse(context.Request.Form["pid"], out roleID) || string.IsNullOrEmpty(functionsid) || string.IsNullOrEmpty(roleName))
            {
                status = "{\"status\":-1}";  //传递参数不完整
            }
            else
            {
                BCtrl_SysRole bllRole = new BCtrl_SysRole();
                List <SysRoleFunctionRelEntity> roleFunlist = new List <SysRoleFunctionRelEntity>();
                SysRoleEntity roleEntity = null;

                String[] funid = functionsid.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (String var in funid)
                {
                    SysRoleFunctionRelEntity fe = new SysRoleFunctionRelEntity();
                    fe.RFRel_FunctionID = Convert.ToInt32(var);
                    fe.RFRel_RoleID     = roleID;
                    roleFunlist.Add(fe);
                }

                if (roleID > 0)
                {
                    //修改
                    roleEntity           = bllRole.QueryEntity(roleID);
                    roleEntity.Role_Name = roleName;

                    if (roleEntity != null)
                    {
                        if (bllRole.Update(roleEntity, roleFunlist))
                        {
                            status = "{\"status\":1}";
                        }
                    }
                }
                else
                {
                    //添加
                    roleEntity            = new SysRoleEntity();
                    roleEntity.Role_Name  = roleName;
                    roleEntity.CreateTime = DateTime.Now;

                    if (bllRole.Insert(roleEntity, roleFunlist))
                    {
                        status = "{\"status\":1}";
                    }
                }
            }

            return(status);
        }
Ejemplo n.º 11
0
        public int Update(SysRoleEntity model)
        {
            StringBuilder strsql = new StringBuilder();

            strsql.Append("update sys_role set  ");
            strsql.Append("rolecode=@rolecode,rolename=@rolename,roleseq=@roleseq,remark=@remark,createby=@createby,createdate=@createdate");
            strsql.Append(" where id=@id ");
            return(SqlHelper.Execute(strsql.ToString(), model));
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 编辑
 /// </summary>
 /// <param name="orgid"></param>
 /// <returns></returns>
 public ActionResult Edit(string roleid)
 {
     if (!string.IsNullOrEmpty(roleid))
     {
         SysRoleEntity entity = roleLogic.Load(roleid);
         return(View(entity));
     }
     return(View(new OrganizationEntity()));
 }
Ejemplo n.º 13
0
        public RoleOutputDto GetForm(string keyword)
        {
            SysRoleEntity userEntityList = _sysRoleRepository.Get(keyword);
            RoleDto       RoleDtoList    = AutoMapper.Mapper.Map <RoleDto>(userEntityList);
            RoleOutputDto outputDto      = new RoleOutputDto();

            outputDto.RoleDtoSingle = RoleDtoList;
            return(outputDto);
        }
Ejemplo n.º 14
0
        public ActionResult CreateRole()
        {
            SysPower(SysMenuConstant.MENU_ROLE_MANAGE, SysMenuConstant.FUN_ADD, UserInfo.UserCode);
            var model = new SysRoleEntity();

            ViewBag.MenuFunList = JsonConvert.SerializeObject(ISysFunctionService.Query(string.Empty));

            return(View("EditRole", model));
        }
Ejemplo n.º 15
0
        public ActionResult ToExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo()
            {
                PageIndex = 1, PageSize = Int32.MaxValue
            };
            string               roleName   = WebUtil.GetFormValue <string>("roleName", string.Empty);
            SysRoleProvider      provider   = new SysRoleProvider();
            SysRoleEntity        entity     = new SysRoleEntity();
            List <SysRoleEntity> list       = provider.GetList();
            List <SysRoleEntity> listResult = new List <SysRoleEntity>();

            if (!list.IsNullOrEmpty())
            {
                listResult = list.Where(a => a.RoleNum.Contains(roleName) || a.RoleName.Contains(roleName)).OrderByDescending(a => a.ID).ToList();
            }

            if (!listResult.IsNullOrEmpty())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号"));
                dt.Columns.Add(new DataColumn("角色编号"));
                dt.Columns.Add(new DataColumn("角色名"));
                dt.Columns.Add(new DataColumn("创建时间"));
                dt.Columns.Add(new DataColumn("备注"));
                int count = 1;
                foreach (SysRoleEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.RoleNum;
                    row[2] = t.RoleName;
                    row[3] = t.CreateTime;
                    row[4] = t.Remark;
                    count++;
                    dt.Rows.Add(row);
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string filename = string.Format("角色管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));

                NPOIExcel excel = new NPOIExcel("角色管理", "角色", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!")
                ;
            }

            return(Content(this.ReturnJson.ToString()));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="entity"></param>
        public int AddRole(SysRoleEntity entity)
        {
            entity.IncludeAll();
            int line = this.SysRole.Add(entity);

            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_SYSROLE_CACHE);
            }
            return(line);
        }
Ejemplo n.º 17
0
 public SysRoleEntity Load(string code)
 {
     try
     {
         SysRoleEntity orgInfo = QueryForObject <SysRoleEntity>("SysRoleMap.Load", code);
         return(orgInfo);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 18
0
 public bool Update(SysRoleEntity obj)
 {
     try
     {
         Update("SysRoleMap.Update", obj);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 添加角色并和菜单关联
        /// </summary>
        /// <param name="roleEntity"></param>
        /// <param name="roleFunRelList"></param>
        /// <returns></returns>
        public bool Insert(SysRoleEntity roleEntity, List <SysRoleFunctionRelEntity> roleFunRelList)
        {
            bool           isSuccess = false;
            SqlTransaction trans     = null;

            try
            {
                SqlParameter[] rolePrms =
                {
                    new SqlParameter("@Role_Name",  SqlDbType.NVarChar, 20),
                    new SqlParameter("@CreateTime", SqlDbType.DateTime)
                };
                rolePrms[0].Value = roleEntity.Role_Name;
                rolePrms[1].Value = roleEntity.CreateTime;


                string roleSql       = " INSERT INTO M_System_Role(Role_Name, CreateTime) VALUES (@Role_Name, @CreateTime);SELECT @@IDENTITY; ";
                string roleFunRelSql = "INSERT INTO M_System_Role_Fun_Rel(RFRel_FunctionID, RFRel_RoleID) VALUES(@RFRel_FunctionID, @RFRel_RoleID)";

                using (SqlConnection conn = new SqlConnection(SQlHelper.MyConnectStr))
                {
                    conn.Open();
                    trans = conn.BeginTransaction();

                    object result = SQlHelper.ExecuteScalar(trans, CommandType.Text, roleSql, rolePrms);
                    int    pkid   = Convert.ToInt32(result);

                    foreach (SysRoleFunctionRelEntity entity in roleFunRelList)
                    {
                        SqlParameter[] roleFunRelPrms =
                        {
                            new SqlParameter("@RFRel_FunctionID", entity.RFRel_FunctionID),
                            new SqlParameter("@RFRel_RoleID",     pkid)
                        };
                        SQlHelper.ExecuteNonQuery(trans, CommandType.Text, roleFunRelSql, roleFunRelPrms);
                    }

                    trans.Commit();
                    isSuccess = true;
                }
            }
            catch (Exception ex)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                LogUtil.WriteLog(ex);
                return(false);
            }

            return(isSuccess);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 根据主键编号获得角色信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public SysRoleEntity GetRoleEntity(int id)
        {
            List <SysRoleEntity> listSource = GetList();

            if (listSource.IsNullOrEmpty())
            {
                return(null);
            }
            SysRoleEntity entity = listSource.SingleOrDefault(item => item.ID == id);

            return(entity);
        }
Ejemplo n.º 21
0
        public static SysRole_CE ToCE(SysRoleEntity item)
        {
            SysRole_CE target = new SysRole_CE();

            target.ID         = item.ID;
            target.RoleNum    = item.RoleNum;
            target.RoleName   = item.RoleName;
            target.IsDelete   = item.IsDelete;
            target.CreateTime = item.CreateTime;
            target.Remark     = item.Remark;
            return(target);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 查询角色信息
        /// </summary>
        /// <returns></returns>
        public ActionResult Single()
        {
            string                     CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            string                     SnNum     = WebUtil.GetFormValue <string>("SnNum");
            SysRoleProvider            provider  = new SysRoleProvider(CompanyID);
            SysRoleEntity              entity    = provider.GetRoleEntity(SnNum);
            DataResult <SysRoleEntity> result    = new DataResult <SysRoleEntity>()
            {
                Code = (int)EResponseCode.Success, Message = "响应成功", Result = entity
            };

            return(Content(JsonHelper.SerializeObject(result)));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 修改角色信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int UpdateRole(SysRoleEntity entity)
        {
            entity.IncludeRoleName(true).IncludeIsDelete(true).IncludeRemark(true)
            .Where(a => a.RoleNum == entity.RoleNum)
            ;
            int line = this.SysRole.Update(entity);

            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_SYSROLE_CACHE);
            }
            return(line);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 修改角色信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int UpdateRole(SysRoleEntity entity)
        {
            string key = string.Format(CacheKey.JOOSHOW_SYSROLE_CACHE, this.CompanyID);

            entity.IncludeRoleName(true).IncludeRemark(true);
            entity.Where(a => a.SnNum == entity.SnNum)
            .And(a => a.CompanyID == entity.CompanyID);
            int line = this.SysRole.Update(entity);

            if (line > 0)
            {
                CacheHelper.Remove(key);
            }
            return(line);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="entity"></param>
        public int AddRole(SysRoleEntity entity)
        {
            string key = string.Format(CacheKey.JOOSHOW_SYSROLE_CACHE, this.CompanyID);

            entity.SnNum   = entity.SnNum.IsEmpty() ? ConvertHelper.NewGuid() : entity.SnNum;
            entity.RoleNum = entity.RoleNum.IsEmpty()? new TNumProvider(this.CompanyID).GetSwiftNum(typeof(SysRoleEntity), 5):entity.RoleNum;
            entity.IncludeAll();
            int line = this.SysRole.Add(entity);

            if (line > 0)
            {
                CacheHelper.Remove(key);
            }
            return(line);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="roleNum"></param>
        /// <returns></returns>
        public int DeleteRole(string roleNum)
        {
            SysRoleEntity roleEntity = new SysRoleEntity();

            roleEntity.IsDelete = (int)EIsDelete.Deleted;
            roleEntity.IncludeIsDelete(true);
            roleEntity.Where(a => a.RoleNum == roleNum);
            int line = this.SysRole.Update(roleEntity);

            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_SYSROLE_CACHE);
            }
            return(line);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="SnNum"></param>
        /// <returns></returns>
        public int DeleteRole(string SnNum)
        {
            string        key        = string.Format(CacheKey.JOOSHOW_SYSROLE_CACHE, this.CompanyID);
            SysRoleEntity roleEntity = new SysRoleEntity();

            roleEntity.IsDelete = (int)EIsDelete.Deleted;
            roleEntity.IncludeIsDelete(true);
            roleEntity.Where(a => a.SnNum == SnNum);
            int line = this.SysRole.Update(roleEntity);

            if (line > 0)
            {
                CacheHelper.Remove(key);
            }
            return(line);
        }
Ejemplo n.º 28
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool Insert(SysRoleEntity entity)
 {
     try
     {
         string sql = " INSERT INTO M_System_Role(Role_Name, CreateTime) VALUES (@Role_Name, @CreateTime)";
         using (SqlConnection conn = new SqlConnection(SQlHelper.MyConnectStr))
         {
             conn.Execute(sql, new { Role_Name = entity.Role_Name, CreateTime = entity.CreateTime });
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogUtil.WriteLog(ex);
         return(false);
     }
 }
Ejemplo n.º 29
0
 public bool Update(SysRoleEntity entity)
 {
     try
     {
         string sql = " UPDATE M_System_Role SET Role_Name=@Role_Name, CreateTime=@CreateTime WHERE Role_ID=@Role_ID";
         using (SqlConnection conn = new SqlConnection(SQlHelper.MyConnectStr))
         {
             conn.Execute(sql, new { Role_Name = entity.Role_Name, CreateTime = entity.CreateTime, Role_ID = entity.Role_ID });
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogUtil.WriteLog(ex);
         return(false);
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// 删除角色信息
        /// </summary>
        /// <param name="list"></param>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public int DeleteRole(IEnumerable <string> list)
        {
            string        key        = string.Format(CacheKey.JOOSHOW_SYSROLE_CACHE, this.CompanyID);
            SysRoleEntity roleEntity = new SysRoleEntity();

            roleEntity.IsDelete = (int)EIsDelete.Deleted;
            roleEntity.IncludeIsDelete(true);
            roleEntity.Where("SnNum", ECondition.In, list.ToArray());
            roleEntity.And(a => a.CompanyID == CompanyID);
            int line = this.SysRole.Update(roleEntity);

            if (line > 0)
            {
                CacheHelper.Remove(key);
            }
            return(line);
        }