Example #1
0
 /// <summary>
 /// 验证用户名是否改变
 /// </summary>
 /// <param name="name">用户名</param>
 /// <returns></returns>
 public bool CheckName(SysPerson sysPerson)
 {
     using (SysEntities dbCheckName = new SysEntities())
     {
         SysPerson person = dbCheckName.SysPerson.FirstOrDefault(f => f.Id == sysPerson.Id);
         if (person != null)
         {
             if (sysPerson.Name == person.Name)
             {
                 return false;//没有修改用户名
             }
             else
             {
                 return CheckName(sysPerson.Name);
             }
         }
     }
     return true;
 }
Example #2
0
        /// <summary>
        /// 编辑一个人员
        /// </summary>
        /// <param name="validationErrors">返回的错误信息</param>
        /// <param name="db">数据上下文</param>
        /// <param name="entity">一个人员</param>
        /// <returns>是否编辑成功</returns>
        public bool Edit(ref ValidationErrors validationErrors, SysEntities db, SysPerson entity)
        {
            /*
                           * 不操作 原有 现有
                           * 增加   原没 现有
                           * 删除   原有 现没
                           */
            if (entity == null)
            {
                return false;
            }
            if (CheckName(entity))
            {
                validationErrors.Add("用户名已被占用,请换一个新的用户名");
                return false;
            }

            int count = 1;
            SysPerson editEntity = repository.Edit(db, entity);

            List<string> addSysRoleId = new List<string>();
            List<string> deleteSysRoleId = new List<string>();
            DataOfDiffrent.GetDiffrent(entity.SysRoleId.GetIdSort(), entity.SysRoleIdOld.GetIdSort(), ref addSysRoleId, ref deleteSysRoleId);
            if (addSysRoleId != null && addSysRoleId.Count() > 0)
            {
                foreach (var item in addSysRoleId)
                {
                    SysRole sys = new SysRole { Id = item };
                    db.SysRole.Attach(sys);
                    editEntity.SysRole.Add(sys);
                    count++;
                }
            }
            if (deleteSysRoleId != null && deleteSysRoleId.Count() > 0)
            {
                List<SysRole> listEntity = new List<SysRole>();
                foreach (var item in deleteSysRoleId)
                {
                    SysRole sys = new SysRole { Id = item };
                    listEntity.Add(sys);
                    db.SysRole.Attach(sys);
                }
                foreach (SysRole item in listEntity)
                {
                    editEntity.SysRole.Remove(item);//查询数据库
                    count++;
                }
            }

            if (count == repository.Save(db))
            {
                return true;
            }
            else
            {
                validationErrors.Add("编辑人员出错了");
            }
            return false;
        }
Example #3
0
 /// <summary>
 /// 已有数据访问上下文的方法中调用
 /// </summary>
 /// <param name="entities">数据访问上下文</param>
 public SysLogBLL(SysEntities entities)
 {
     db = entities;
 }
Example #4
0
 /// <summary>
 /// 构造函数,默认加载数据访问上下文
 /// </summary>
 public SysLogBLL()
 {
     db = new SysEntities();
 }
Example #5
0
        /// <summary>
        /// 根据PersonId获取已经启用的菜单
        /// </summary>
        /// <param name="personId">人员的Id</param>
        /// <returns>菜单拼接的字符串</returns>
        public string GetMenuByAccount(ref Common.Account person)
        {
            using (SysEntities db = new SysEntities())
            {
                string personId = person.Id;
                var roleIds =
                           (
                           from r in db.SysRole
                           from p in r.SysPerson
                           where p.Id == personId
                           select r.Id
                           ).ToList();
                person.RoleIds = roleIds;

                List<SysMenu> menuNeed =
                            (
                            from m2 in db.SysMenu
                            from f in m2.SysMenuSysRoleSysOperation

                            where roleIds.Any(a => a == f.SysRoleId) && f.SysOperationId == null
                            select m2
                            ).Distinct().OrderBy(o => o.Remark).ToList();//此方法由临海人(qq:1012999282)提供
                //person.MenuIds = menuNeed.Where(w => w.IsLeaf == null).Select(s => s.Url).ToList();

                StringBuilder strmenu2 = new StringBuilder();//拼接菜单的字符串
                int lever = 0;//上一个菜单的层级
                int current = 0;//当前菜单的层级
                //在1.2版本中修改
                if (menuNeed.Count > 1)
                {
                    for (int i = 0; i < menuNeed.Count; i++)
                    {
                        current = menuNeed[i].Remark.Length / 4;//按照4位数字的编码格式

                        if (current == 1)//加载根目录的菜单
                        {
                            //解决ie6下没有滚动条的问题
                            strmenu2.Replace('^', ' ')
                                .Append(string.Format(" <div data-options=@iconCls:'{0}'@ title=@{1}@> <div class=@easyui-panel@ fit=@true@ border=@false@><ul class=@easyui-tree@ >^</ul></div></div>", menuNeed[i].Iconic, menuNeed[i].Name));
                        }
                        else if (current < lever)//进入上一个菜单层级
                        {
                            string replace = string.Empty;
                            for (int c = 0; c < lever - current; c++)//减少了几个层级
                            {
                                replace += ("</ul></li>");
                            }
                            if ((i == menuNeed.Count - 1) || (menuNeed[i].Remark.Length >= menuNeed[i + 1].Remark.Length))
                                strmenu2.Replace("^" + replace, replace + GetNode(menuNeed[i], true));
                            else
                                strmenu2.Replace("^" + replace, replace + GetNode(menuNeed[i], false));
                        }
                        else//进入本级菜单或者下一个菜单
                        {

                            if ((i == menuNeed.Count - 1) || (menuNeed[i].Remark.Length >= menuNeed[i + 1].Remark.Length))//最后一个,或者下一个长度不小于这个的长度
                                strmenu2.Replace("^", GetNode(menuNeed[i], true));
                            else
                                strmenu2.Replace("^", GetNode(menuNeed[i], false));

                        }
                        lever = current;
                    }
                }
                return strmenu2.ToString().Replace('@', '"').Replace('^', ' ');
            }
        }
Example #6
0
 /// <summary>
 /// 已有数据访问上下文的方法中调用
 /// </summary>
 /// <param name="entities">数据访问上下文</param>
 public SysExceptionBLL(SysEntities entities)
 {
     db = entities;
 }
Example #7
0
 /// <summary>
 /// 已有数据访问上下文的方法中调用
 /// </summary>
 /// <param name="entities">数据访问上下文</param>
 public SysExceptionBLL(SysEntities entities)
 {
     db = entities;
 }
Example #8
0
 /// <summary>
 /// 已有数据访问上下文的方法中调用
 /// </summary>
 /// <param name="entities">数据访问上下文</param>
 public UNCERTAINTYBLL(SysEntities entities)
 {
     db = entities;
 }
Example #9
0
 /// <summary>
 /// 构造函数,默认加载数据访问上下文
 /// </summary>
 public MatchDetailBLL()
 {
     db = new SysEntities();
 }
 /// <summary>
 /// 已有数据访问上下文的方法中调用
 /// </summary>
 /// <param name="entities">数据访问上下文</param>
 public THEAPPROVALPROCESSBLL(SysEntities entities)
 {
     db = entities;
 }
Example #11
0
 /// <summary>
 /// 构造函数,默认加载数据访问上下文
 /// </summary>
 public UNCERTAINTYBLL()
 {
     db = new SysEntities();
 }
 /// <summary>
 /// 构造函数,默认加载数据访问上下文
 /// </summary>
 public THEAPPROVALPROCESSBLL()
 {
     db = new SysEntities();
 }
Example #13
0
 /// <summary>
 /// 已有数据访问上下文的方法中调用
 /// </summary>
 /// <param name="entities">数据访问上下文</param>
 public SchoolBLL(SysEntities entities)
 {
     db = entities;
 }
Example #14
0
 /// <summary>
 /// 构造函数,默认加载数据访问上下文
 /// </summary>
 public SchoolBLL()
 {
     db = new SysEntities();
 }
Example #15
0
 /// <summary>
 /// 构造函数,默认加载数据访问上下文
 /// </summary>
 public SysPersonBLL()
 {
     db = new SysEntities();
 }
Example #16
0
 /// <summary>
 /// 已有数据访问上下文的方法中调用
 /// </summary>
 /// <param name="entities">数据访问上下文</param>
 public MatchDetailBLL(SysEntities entities)
 {
     db = entities;
 }
Example #17
0
 /// <summary>
 /// 已有数据访问上下文的方法中调用
 /// </summary>
 /// <param name="entities">数据访问上下文</param>
 public SysPersonBLL(SysEntities entities)
 {
     db = entities;
 }
Example #18
0
 /// <summary>
 /// 构造函数,默认加载数据访问上下文
 /// </summary>
 public SysExceptionBLL()
 {
     db = new SysEntities();
 }
Example #19
0
        /// <summary>
        /// 创建一个人员
        /// </summary>
        /// <param name="validationErrors">返回的错误信息</param>
        /// <param name="db">数据库上下文</param>
        /// <param name="entity">一个人员</param>
        /// <returns></returns>
        public bool Create(ref ValidationErrors validationErrors, SysEntities db, SysPerson entity)
        {
            int count = 1;
            if (CheckName(entity.Name))
            {
                validationErrors.Add("用户名已被占用,请换一个新的用户名");
                return false;
            }
            foreach (string item in entity.SysRoleId.GetIdSort())
            {
                SysRole sys = new SysRole { Id = item };
                db.SysRole.Attach(sys);
                entity.SysRole.Add(sys);
                count++;
            }

            repository.Create(db, entity);
            if (count == repository.Save(db))
            {
                return true;
            }
            else
            {
                validationErrors.Add("创建出错了");
            }
            return false;
        }
Example #20
0
 /// <summary>
 /// 构造函数,默认加载数据访问上下文
 /// </summary>
 public SysExceptionBLL()
 {
     db = new SysEntities();
 }