示例#1
0
        public string DeleteDepartment(int depid)
        {
            int    k   = 0;
            string msg = "删除失败";
            var    dep = DepartmentDal.Instance.Get(depid);

            if (UserDal.Instance.GetUsersCountByDepartment(depid) > 0)
            {
                msg = "部门中有员工数据不能删除!";
            }
            else if (dep.children.Any())
            {
                msg = "有下级部门数据,不能删除。";
            }
            else
            {
                k = DepartmentDal.Instance.Delete(depid);
                if (k > 0)
                {
                    msg = "删除成功。";
                    LogBll <Department> log = new LogBll <Department>();
                    log.DeleteLog(dep);
                }
            }

            return(new JsonMessage {
                Data = k.ToString(), Message = msg, Success = k > 0
            }.ToString());
        }
示例#2
0
        public string Delete(int roleid)
        {
            string msg = "删除失败。";

            //判断是否有用户在使用该角色
            if (HasUsers(roleid))
            {
                msg = "该角色使用中,不能删除!";
                return(new JsonMessage {
                    Success = true, Data = "0", Message = msg
                }.ToString());
            }

            var r = RoleDal.Instance.Get(roleid);

            //先删除角色中分配的权限
            SqlEasy.ExecuteNonQuery("delete Sys_RoleNavBtns where roleid=@roleid", new SqlParameter("@roleid", roleid));
            int k = RoleDal.Instance.Delete(roleid);

            if (k > 0)
            {
                msg = "删除成功。";
                LogBll <Role> log = new LogBll <Role>();
                log.DeleteLog(r);
            }
            return(new JsonMessage {
                Success = true, Data = k.ToString(), Message = msg
            }.ToString());
        }
示例#3
0
        public string DeleteNav(string navids)
        {
            var oldNavList = from n in NavigationDal.Instance.GetAll().ToList()
                             where navids.Split(',').Contains(n.KeyId.ToString())
                             select n;
            string msg = "删除失败。";
            int    k   = NavigationDal.Instance.Delete(navids);

            if (k > 0)
            {
                // 删除与导航菜单分配的按钮列表 2013-07-05
                DeleteNavButtons(navids);

                msg = "删除成功。";
                var log = new LogBll <Navigation>();
                foreach (var n in oldNavList)
                {
                    log.DeleteLog(n);
                }
            }

            return(new JsonMessage {
                Data = k.ToString(), Message = msg, Success = k > 0
            }.ToString());
        }
示例#4
0
        public int Delete(int dicid)
        {
            Dic d = DicDal.Instance.Get(dicid);

            if (d != null)
            {
                if (d.children.Any())
                {
                    return(2); //有子节点不能删除
                }

                int i = DicDal.Instance.Delete(dicid);
                if (i > 0)
                {
                    LogBll <Dic> log = new LogBll <Dic>();
                    log.DeleteLog(d);
                }
                return(i);
            }
            return(0); //参数错误
        }
示例#5
0
        public string DeleteDepartment(int depid)
        {
            string msg = "删除失败";
            var    dep = DepartmentDal.Instance.Get(depid);

            if (dep.children.Any())
            {
                msg = "有下级部门数据,不能删除。";
            }

            int k = DepartmentDal.Instance.Delete(depid);

            if (k > 0)
            {
                msg = "删除成功。";
                LogBll <Department> log = new LogBll <Department>();
                log.DeleteLog(dep);
            }

            return(new JsonMessage {
                Data = k.ToString(), Message = msg, Success = k > 0
            }.ToString());
        }