Пример #1
0
        private void UpdateCat(int catId)
        {
            int parentId;
            if (!int.TryParse(Request.Form["parCatName"], out parentId))
                return;
            int catSort;
            int.TryParse(Request.Form["catSort"], out catSort);

            ClassInfoBll catbll = new ClassInfoBll();
            var oldCat = new ClassInfoBll().getCat(catId);
            if (oldCat == null)
                return;
            oldCat.UpdateTime = DateTime.Now;

            oldCat.SpellWord = new WordCenter().GetPyString(oldCat.CatName);
            oldCat.SEOWords = Request.Form["seoKey"];
            oldCat.Sort = catSort;
            if (oldCat.ParentId == parentId && oldCat.CatName == Request.Form["catName"])
            {
                catbll.UpdateCat(oldCat);
                return;
            }

            oldCat.CatName = Request.Form["catName"];
            if (parentId != 0)
            {
                ClassInfo parCat = catbll.getCat(parentId);
                oldCat.ParentId = parCat.Id;
                oldCat.Level = parCat.Level + 1;
                oldCat.ParentName = parCat.CatName;
                if (!string.IsNullOrEmpty(parCat.CatCrumbleIds))
                {
                    oldCat.CatCrumbleIds = parCat.CatCrumbleIds + "," + parCat.Id;
                    oldCat.CatCrumbleNames = parCat.CatCrumbleNames + "," + parCat.CatName;
                }
                else
                {
                    oldCat.CatCrumbleIds = parCat.Id.ToString(CultureInfo.InvariantCulture);
                    oldCat.CatCrumbleNames = parCat.CatName;
                }
                if (!parCat.HasChild)
                {
                    parCat.HasChild = true;
                    catbll.UpdateCat(parCat);
                }
            }
            else
            {
                oldCat.ParentId = 0;
                oldCat.Level = 1;
                oldCat.ParentName = "";
                oldCat.CatCrumbleIds = "";
                oldCat.CatCrumbleNames = "";
            }
            catbll.UpdateCat(oldCat);

            if (oldCat.HasChild)
            {
                UpdateChildCat(oldCat);
            }
        }
Пример #2
0
        /// <summary>
        /// 添加分类
        /// </summary>
        private void addCat()
        {
            if (Request.Form.Count < 3 || string.IsNullOrEmpty(Request.Form["catName"]) ||
                string.IsNullOrEmpty(Request.Form["parCatName"]))
                return;

            int parentId;
            if (!int.TryParse(Request.Form["parCatName"], out parentId))
                return;

            int catSort;
            int.TryParse(Request.Form["catSort"], out catSort);

            ClassInfo cat = new ClassInfo();
            cat.CatName = Request.Form["catName"];
            cat.SpellWord = new WordCenter().GetPyString(cat.CatName);
            cat.SEOWords = Request.Form["seoKey"];
            cat.Sort = catSort;
            cat.CreateDate = DateTime.Now;
            cat.UpdateTime = DateTime.Now;
            cat.HasChild = false;
            cat.IsDel = false;
            ClassInfoBll catbll = new ClassInfoBll();
            if (parentId != 0)
            {
                ClassInfo parCat = catbll.getCat(parentId);
                cat.ParentId = parCat.Id;
                cat.Level = parCat.Level + 1;
                cat.ParentName = parCat.CatName;
                if (!string.IsNullOrEmpty(parCat.CatCrumbleIds))
                {
                    cat.CatCrumbleIds = parCat.CatCrumbleIds + "," + parCat.Id;
                    cat.CatCrumbleNames = parCat.CatCrumbleNames + "," + parCat.CatName;
                }
                else
                {
                    cat.CatCrumbleIds = parCat.Id.ToString(CultureInfo.InvariantCulture);
                    cat.CatCrumbleNames = parCat.CatName;
                }
                if (!parCat.HasChild)
                {
                    parCat.HasChild = true;
                    catbll.UpdateCat(parCat);
                }
            }
            else
            {
                cat.ParentId = 0;
                cat.Level = 1;
                cat.ParentName = "";
                cat.CatCrumbleIds = "";
                cat.CatCrumbleNames = "";
            }
            catbll.AddCat(cat);
        }
Пример #3
0
        /// <summary>
        /// 批量添加分类
        /// </summary>
        /// <param name="catid"></param>
        private void bathAddCat(string catid)
        {
            SiteClassBll bll = new SiteClassBll();

            int siteClassId;
            int parentId;
            SiteClassInfo siteCat = new SiteClassInfo();
            if (int.TryParse(catid, out siteClassId))
            {
                siteCat = bll.GetCatById(siteClassId);
                SiteCatName = siteCat.ClassName.Replace(" ","");
            }
            if (!int.TryParse(Request.Form["parCatName"], out parentId))
                return;
            #region 添加分类
            ClassInfo cat = new ClassInfo();
            cat.CatName = SiteCatName;
            cat.SpellWord = WordCenter.GetShortPinyin(cat.CatName);
            cat.SEOWords = "";
            cat.Sort = 0;
            cat.CreateDate = DateTime.Now;
            cat.UpdateTime = DateTime.Now;
            cat.HasChild = false;
            ClassInfoBll catbll = new ClassInfoBll();
            if (parentId != 0)
            {
                ClassInfo parCat = catbll.getCat(parentId);
                cat.ParentId = parCat.Id;
                cat.Level = parCat.Level + 1;
                cat.ParentName = parCat.CatName;
                if (!string.IsNullOrEmpty(parCat.CatCrumbleIds))
                {
                    cat.CatCrumbleIds = parCat.CatCrumbleIds + "," + parCat.Id;
                    cat.CatCrumbleNames = parCat.CatCrumbleNames + "," + parCat.CatName;
                }
                else
                {
                    cat.CatCrumbleIds = parCat.Id.ToString(CultureInfo.InvariantCulture);
                    cat.CatCrumbleNames = parCat.CatName;
                }
                if (!parCat.HasChild)
                {
                    parCat.HasChild = true;
                    catbll.UpdateCat(parCat);
                }
            }
            else
            {
                cat.ParentId = 0;
                cat.Level = 1;
                cat.ParentName = "";
                cat.CatCrumbleIds = "";
                cat.CatCrumbleNames = "";
            }
            cat.Id = catbll.AddCat(cat);
            #endregion
            #region 添加子分类

            AllSiteCat = bll.GetClassInfo(siteCat.SiteId);

            addChildCat(siteCat.ClassId, cat);

            #endregion
        }