Пример #1
0
        /**
         * @ 创建菜单的路径
         * */
        private void CreatePath(MenuData menu)
        {
            if (menu.PID.IsNullOrEmpty())
            {
                menu.PID        = "";
                menu.ParentPath = "";
                menu.Level      = 1;
                return;
            }

            MssqlGetSomeOne pager = new MssqlGetSomeOne(TableName);

            pager.AddWhere("ID", menu.PID);
            List <MenuData> list = pager.Select <MenuData>();

            if (list.Count == 0)
            {
                menu.PID        = "";
                menu.ParentPath = "";
                menu.Level      = 1;
                return;
            }
            string joinchar = list[0].ParentPath.IsNullOrEmpty() ? "" : ".";

            menu.ParentPath = string.Format("{0}{1}{2}", list[0].ParentPath, joinchar, menu.PID);
            menu.Level      = list[0].Level + 1;
        }
Пример #2
0
        /**
         * @ 获取单条记录
         * */
        public virtual T Get(string id)
        {
            MssqlGetSomeOne pager = new MssqlGetSomeOne(TableName);

            pager.AddWhere(Primarykey, id);
            List <T> list = pager.Select <T>();

            if (list.IsNotNullAndGtEq(1))
            {
                return(list[0]);
            }
            return(null);
        }
Пример #3
0
        /**
         * @ 检查菜单是否存在下级
         * */
        public bool HasChildren(string id)
        {
            if (id.IsNullOrEmpty())
            {
                return(false);
            }

            MssqlGetSomeOne getsome = new MssqlGetSomeOne(TableName);

            getsome.AddWhere("PID", id);
            getsome.AddWhere("ParentPath", SQLExpression.ExprOperator.Like, id, SQLExpression.JoinType.OR);
            string[]             fields = { "TOP 1 ID" };
            List <SQLDataResult> list   = getsome.Select(fields, "");
            bool has = list.Count > 0 && (list[0]["ID"] as string).IsNotNullOrEmpty();

            return(has);
        }