コード例 #1
0
ファイル: AdminNavs.cs プロジェクト: JohnsonYuan/BrnShop
 /// <summary>
 /// 创建导航栏
 /// </summary>
 public static void CreateNav(NavInfo navInfo)
 {
     if (navInfo.Pid > 0)
     {
         List<NavInfo> navList = BrnShop.Data.Navs.GetNavList();
         NavInfo parentNavInfo = navList.Find(x => x.Id == navInfo.Pid);//父导航
         navInfo.Layer = parentNavInfo.Layer + 1;
     }
     else
     {
         navInfo.Layer = 1;
     }
     BrnShop.Data.Navs.CreateNav(navInfo);
     BrnShop.Core.BSPCache.Remove(CacheKeys.SHOP_NAV_LIST);
     BrnShop.Core.BSPCache.Remove(CacheKeys.SHOP_NAV_MAINLIST);
 }
コード例 #2
0
ファイル: AdminNavs.cs プロジェクト: JohnsonYuan/BrnShop
        /// <summary>
        /// 更新导航栏
        /// </summary>
        public static void UpdateNav(NavInfo navInfo, int oldPid)
        {
            if (navInfo.Pid != oldPid)
            {
                int changeLayer = 0;
                List<NavInfo> navList = BrnShop.Data.Navs.GetNavList();
                NavInfo oldParentNavInfo = navList.Find(x => x.Id == oldPid);
                if (navInfo.Pid > 0)
                {
                    NavInfo newParentNavInfo = navList.Find(x => x.Id == navInfo.Pid);//新的父导航
                    if (oldParentNavInfo == null)
                    {
                        changeLayer = newParentNavInfo.Layer - 1;
                    }
                    else
                    {
                        changeLayer = newParentNavInfo.Layer - oldParentNavInfo.Layer;
                    }
                    navInfo.Layer = newParentNavInfo.Layer + 1;
                }
                else
                {
                    changeLayer = 1 - oldParentNavInfo.Layer;
                    navInfo.Layer = 1;
                }

                foreach (NavInfo info in navList.FindAll(x => x.Pid == navInfo.Id))
                {
                    UpdateChildNavLayer(navList, info, changeLayer);
                }
            }

            BrnShop.Data.Navs.UpdateNav(navInfo);

            BrnShop.Core.BSPCache.Remove(CacheKeys.SHOP_NAV_LIST);
            BrnShop.Core.BSPCache.Remove(CacheKeys.SHOP_NAV_MAINLIST);
        }
コード例 #3
0
ファイル: NavController.cs プロジェクト: JohnsonYuan/BrnShop
        public ActionResult Add(NavModel model)
        {
            if (model.Pid != 0 && AdminNavs.GetNavById(model.Pid) == null)
                ModelState.AddModelError("Pid", "父导航不存在");

            if (ModelState.IsValid)
            {
                NavInfo navInfo = new NavInfo()
                {
                    Pid = model.Pid,
                    Name = model.NavName,
                    Title = model.NavTitle == null ? "" : model.NavTitle,
                    Url = model.NavUrl,
                    Target = model.Target,
                    DisplayOrder = model.DisplayOrder
                };

                AdminNavs.CreateNav(navInfo);
                AddAdminOperateLog("添加导航", "添加导航,导航为:" + model.NavName);
                return PromptView("导航添加成功");
            }
            Load();
            return View(model);
        }
コード例 #4
0
ファイル: AdminNavs.cs プロジェクト: JohnsonYuan/BrnShop
 /// <summary>
 /// 递归更新导航及其子导航的级别
 /// </summary>
 /// <param name="navList">导航列表</param>
 /// <param name="navInfo">导航信息</param>
 /// <param name="changeLayer">变化的级别</param>
 private static void UpdateChildNavLayer(List<NavInfo> navList, NavInfo navInfo, int changeLayer)
 {
     navInfo.Layer = navInfo.Layer + changeLayer;
     BrnShop.Data.Navs.UpdateNav(navInfo);
     foreach (NavInfo info in navList.FindAll(x => x.Pid == navInfo.Id))
     {
         UpdateChildNavLayer(navList, info, changeLayer);
     }
 }
コード例 #5
0
ファイル: ShopStrategy.cs プロジェクト: JohnsonYuan/BrnShop
 /// <summary>
 /// 创建导航栏
 /// </summary>
 public void CreateNav(NavInfo navInfo)
 {
     DbParameter[] param = {
                                  GenerateInParam("@pid",SqlDbType.Int, 4, navInfo.Pid),
                                  GenerateInParam("@layer",SqlDbType.Int, 4, navInfo.Layer),
                                  GenerateInParam("@name",SqlDbType.NChar, 50, navInfo.Name),
                                  GenerateInParam("@title",SqlDbType.NChar, 250, navInfo.Title),
                                  GenerateInParam("@url",SqlDbType.NChar, 250, navInfo.Url),
                                  GenerateInParam("@target",SqlDbType.Int, 4, navInfo.Target),
                                  GenerateInParam("@displayorder",SqlDbType.Int,4,navInfo.DisplayOrder)
                                };
     string commandText = String.Format("INSERT INTO [{0}navs]([pid],[layer],[name],[title],[url],[target],[displayorder]) VALUES(@pid,@layer,@name,@title,@url,@target,@displayorder)",
                                         RDBSHelper.RDBSTablePre);
     RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, param);
 }
コード例 #6
0
ファイル: ShopStrategy.cs プロジェクト: JohnsonYuan/BrnShop
 /// <summary>
 /// 更新导航栏
 /// </summary>
 public void UpdateNav(NavInfo navInfo)
 {
     DbParameter[] param = {
                                  GenerateInParam("@pid",SqlDbType.Int, 4, navInfo.Pid),
                                  GenerateInParam("@layer",SqlDbType.Int, 4, navInfo.Layer),
                                  GenerateInParam("@name",SqlDbType.NChar, 50, navInfo.Name),
                                  GenerateInParam("@title",SqlDbType.NChar, 250, navInfo.Title),
                                  GenerateInParam("@url",SqlDbType.NChar, 250, navInfo.Url),
                                  GenerateInParam("@target",SqlDbType.Int, 4, navInfo.Target),
                                  GenerateInParam("@displayorder",SqlDbType.Int,4,navInfo.DisplayOrder),
                                  GenerateInParam("@id",SqlDbType.Int, 4, navInfo.Id)
                                };
     string commandText = String.Format("UPDATE [{0}navs] SET [pid]=@pid,[layer]=@layer,[name]=@name,[title]=@title,[url]=@url,[target]=@target,[displayorder]=@displayorder WHERE [id]=@id",
                                         RDBSHelper.RDBSTablePre);
     RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, param);
 }