Example #1
0
        private void grdArticleCategories_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex               = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex;
            int categoryId             = (int)this.grdArticleCategories.DataKeys[rowIndex].Value;
            int displaySequence        = int.Parse((this.grdArticleCategories.Rows[rowIndex].FindControl("lblDisplaySequence") as Literal).Text);
            int replaceCategoryId      = 0;
            int replaceDisplaySequence = 0;

            if (e.CommandName == "Fall")
            {
                if (rowIndex < (this.grdArticleCategories.Rows.Count - 1))
                {
                    replaceCategoryId      = (int)this.grdArticleCategories.DataKeys[rowIndex + 1].Value;
                    replaceDisplaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as Literal).Text);
                }
            }
            else if ((e.CommandName == "Rise") && (rowIndex > 0))
            {
                replaceCategoryId      = (int)this.grdArticleCategories.DataKeys[rowIndex - 1].Value;
                replaceDisplaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as Literal).Text);
            }
            if (replaceCategoryId > 0)
            {
                ArticleHelper.SwapArticleCategorySequence(categoryId, replaceCategoryId, displaySequence, replaceDisplaySequence);
            }
            if (e.CommandName == "Delete")
            {
                ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId);
                if (ArticleHelper.DeleteArticleCategory(categoryId))
                {
                    ResourcesHelper.DeleteImage(articleCategory.IconUrl);
                }
            }
            base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
        }
Example #2
0
        public static bool DeleteArticleCategory(int categoryId)
        {
            ArticleCategoryInfo articleCategoryInfo = new ArticleCategoryInfo();

            articleCategoryInfo.CategoryId = categoryId;
            return(new ArticleCategoryDao().CreateUpdateDeleteArticleCategory(articleCategoryInfo, DataProviderAction.Delete));
        }
Example #3
0
        public List <ComboTree> GetComboTreeChildren2(ComboTree comboTree, ArticleCategoryInfo category, List <ArticleCategoryInfo> data)
        {
            var childrens =
                data.Where(s => s.Depth == category.Depth + 1 && s.Lft > category.Lft && s.Rgt < category.Rgt);
            var childs = new List <ComboTree>();

            foreach (var productCategoryInfo in childrens)
            {
                var child = new ComboTree();
                child.Id   = productCategoryInfo.Id;
                child.Text = productCategoryInfo.Name;
                childs.Add(child);
            }

            comboTree.Children = childs;

            foreach (var child in comboTree.Children)
            {
                var temp = data.FirstOrDefault(s => s.Id == child.Id);
                if (temp != null)
                {
                    this.GetComboTreeChildren2(child, temp, data);
                }
            }
            return(comboTree.Children);
        }
        public void UpdateArticleCategory(ArticleCategoryInfo articleCategory)
        {
            if (articleCategory == null)
            {
                throw new HimallException("未指定ArticleCategoryInfo实例");
            }
            if (string.IsNullOrWhiteSpace(articleCategory.Name))
            {
                throw new HimallException("未指定文章分类名称");
            }
            if (articleCategory.ParentCategoryId != 0)
            {
                if (context.ArticleCategoryInfo.Count((ArticleCategoryInfo item) => item.Id == articleCategory.ParentCategoryId) == 0)
                {
                    throw new HimallException(string.Concat("不存在父级为", articleCategory.ParentCategoryId, "的文章分类"));
                }
            }
            ArticleCategoryInfo name = context.ArticleCategoryInfo.FindById <ArticleCategoryInfo>(articleCategory.Id);

            if (name == null)
            {
                throw new HimallException(string.Concat("未找到id为", articleCategory.Id, "的对象"));
            }
            name.Name             = articleCategory.Name;
            name.ParentCategoryId = articleCategory.ParentCategoryId;
            context.SaveChanges();
        }
        public JsonResult GetArticleCategory(long id)
        {
            ArticleCategoryInfo articleCategory = ServiceHelper.Create <IArticleCategoryService>().GetArticleCategory(id);
            var variable = new { id = id, name = articleCategory.Name, parentId = articleCategory.ParentCategoryId };

            return(Json(variable));
        }
        public static bool DeleteArticleCategory(int categoryId)
        {
            ArticleCategoryInfo articleCategory = new ArticleCategoryInfo();

            articleCategory.CategoryId = categoryId;
            return(CommentsProvider.Instance().CreateUpdateDeleteArticleCategory(articleCategory, DataProviderAction.Delete));
        }
Example #7
0
        public void UpdateArticleCategory(ArticleCategoryInfo articleCategory)
        {
            if (articleCategory == null)
            {
                throw new HimallException("未指定ArticleCategoryInfo实例");
            }
            if (string.IsNullOrWhiteSpace(articleCategory.Name))
            {
                throw new HimallException("未指定文章分类名称");
            }

            //检查文章分类是否存在,排除0的父分类,0为根级
            if (articleCategory.ParentCategoryId != 0 && Context.ArticleCategoryInfo.Count(item => item.Id == articleCategory.ParentCategoryId) == 0)
            {
                throw new HimallException("不存在父级为" + articleCategory.ParentCategoryId + "的文章分类");
            }
            ArticleCategoryInfo oriArticleCategory = Context.ArticleCategoryInfo.FindById(articleCategory.Id);

            if (oriArticleCategory == null)
            {
                throw new HimallException("未找到id为" + articleCategory.Id + "的对象");
            }

            //修改
            oriArticleCategory.Name             = articleCategory.Name;
            oriArticleCategory.ParentCategoryId = articleCategory.ParentCategoryId;
            Context.SaveChanges();//保存更改
        }
        public ActionResult Add(long?id, string name, long parentId)
        {
            ArticleCategoryInfo articleCategoryInfo = new ArticleCategoryInfo()
            {
                Id               = id.GetValueOrDefault(),
                Name             = name,
                ParentCategoryId = parentId
            };
            ArticleCategoryInfo     articleCategoryInfo1   = articleCategoryInfo;
            IArticleCategoryService articleCategoryService = ServiceHelper.Create <IArticleCategoryService>();

            if (articleCategoryService.CheckHaveRename(articleCategoryInfo1.Id, articleCategoryInfo1.Name))
            {
                return(Json(new { success = false, msg = "不可添加、修改为同名栏目!" }));
            }
            long?nullable = id;

            if ((nullable.GetValueOrDefault() <= 0 ? true : !nullable.HasValue))
            {
                articleCategoryService.AddArticleCategory(articleCategoryInfo1);
            }
            else
            {
                articleCategoryService.UpdateArticleCategory(articleCategoryInfo1);
            }
            return(Json(new { success = true }));
        }
        private void btnSubmitArticleCategory_Click(object sender, EventArgs e)
        {
            ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(this.categoryId);

            if (articleCategory != null)
            {
                string text2 = articleCategory.IconUrl = this.UploadImage();
                articleCategory.Name        = this.txtArticleCategoryiesName.Text.Trim();
                articleCategory.Description = this.txtArticleCategoryiesDesc.Text.Trim();
                ValidationResults validationResults = Validation.Validate(articleCategory, "ValArticleCategoryInfo");
                string            text3             = string.Empty;
                if (!validationResults.IsValid)
                {
                    foreach (ValidationResult item in (IEnumerable <ValidationResult>)validationResults)
                    {
                        text3 += Formatter.FormatErrorMessage(item.Message);
                    }
                    this.ShowMsg(text3, false);
                }
                else
                {
                    this.UpdateCategory(articleCategory);
                }
            }
        }
        public ActionResult Foot()
        {
            IArticleCategoryService articleCategoryService = ServiceHelper.Create <IArticleCategoryService>();
            IArticleService         articleService         = ServiceHelper.Create <IArticleService>();
            ArticleCategoryInfo     specialArticleCategory = articleCategoryService.GetSpecialArticleCategory(SpecialCategory.PageFootService);

            if (specialArticleCategory == null)
            {
                return(base.PartialView("~/Areas/Web/Views/Shared/Foot.cshtml"));
            }
            IQueryable <ArticleCategoryInfo>   articleCategoriesByParentId = articleCategoryService.GetArticleCategoriesByParentId(specialArticleCategory.Id, false);
            IEnumerable <PageFootServiceModel> array =
                from item in articleCategoriesByParentId.ToArray()
                select new PageFootServiceModel()
            {
                CateogryName = item.Name,
                Articles     =
                    from t in articleService.GetArticleByArticleCategoryId(item.Id)
                    where t.IsRelease
                    select t
            };

            ViewBag.PageFootService = array;
            ViewBag.PageFoot        = base.CurrentSiteSetting.PageFoot;
            ViewBag.QRCode          = base.CurrentSiteSetting.QRCode;
            ViewBag.SiteName        = base.CurrentSiteSetting.SiteName;
            return(base.PartialView("~/Areas/Web/Views/Shared/Foot.cshtml"));
        }
Example #11
0
        public bool CreateUpdateDeleteArticleCategory(ArticleCategoryInfo articleCategory, DataProviderAction action)
        {
            bool result;

            if (null == articleCategory)
            {
                result = false;
            }
            else
            {
                DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_ArticleCategory_CreateUpdateDelete");
                this.database.AddInParameter(storedProcCommand, "Action", DbType.Int32, (int)action);
                this.database.AddOutParameter(storedProcCommand, "Status", DbType.Int32, 4);
                if (action != DataProviderAction.Create)
                {
                    this.database.AddInParameter(storedProcCommand, "CategoryId", DbType.Int32, articleCategory.CategoryId);
                }
                if (action != DataProviderAction.Delete)
                {
                    this.database.AddInParameter(storedProcCommand, "Name", DbType.String, articleCategory.Name);
                    this.database.AddInParameter(storedProcCommand, "IconUrl", DbType.String, articleCategory.IconUrl);
                    this.database.AddInParameter(storedProcCommand, "Description", DbType.String, articleCategory.Description);
                }
                this.database.ExecuteNonQuery(storedProcCommand);
                result = ((int)this.database.GetParameterValue(storedProcCommand, "Status") == 0);
            }
            return(result);
        }
Example #12
0
        public int Insert(ArticleCategoryInfo model)
        {
            var parent = this.GetArticleCategoryById(model.ParentId);

            model.Id = KeyGenerator.Instance.GetNextValue("ArticleCategory");
            using (DataCommand cmd = DataCommandManager.GetDataCommand("InsertArticleCategory"))
            {
                cmd.SetParameterValue("@Id", model.Id);
                cmd.SetParameterValue("@Title", model.Title);
                cmd.SetParameterValue("@Name", model.Name);
                cmd.SetParameterValue("@UrlPath", model.UrlPath);
                cmd.SetParameterValue("@Keywords", model.Keywords);
                cmd.SetParameterValue("@MetaDesc", model.MetaDesc);
                cmd.SetParameterValue("@ParentId", model.ParentId);

                cmd.SetParameterValue("@MyLeft", parent.Lft);

                cmd.SetParameterValue("@Description", model.Description);
                cmd.SetParameterValue("@InUserId", model.InUserId);
                cmd.SetParameterValue("@InDate", model.InDate);
                cmd.SetParameterValue("@EditDate", model.EditDate);
                cmd.SetParameterValue("@EditUserId", model.EditUserId);
                cmd.SetParameterValue("@DisplayOrder", model.DisplayOrder);
                cmd.SetParameterValue("@DataStatus", model.DataStatus);

                cmd.SetParameterValue("@Type", model.CategoryType);

                return(cmd.ExecuteNonQuery());
            }
        }
Example #13
0
        public int Update(ArticleCategoryInfo info)
        {
            int check = 1;
            ArticleCategoryInfo acinfo = getAllById(info.ac_id);

            if (info.ac_id != info.ac_fatherId)
            {
                List <ArticleCategoryInfo> checkinfos = GetallSortData(info.ac_id);
                foreach (ArticleCategoryInfo ckinfo in checkinfos)
                {
                    if (ckinfo.ac_id == info.ac_fatherId)
                    {
                        check = 0;
                    }
                }
                if (check == 1)
                {
                    if (acinfo.ac_fatherId == info.ac_fatherId)
                    {
                        countmath = acinfo.ac_sorting;
                    }
                    else
                    {
                        countmath = GetDataByFatherIdAndLidOrderSortDESC(info.ac_fatherId, lidValue);
                        result    = UpdataSorting(acinfo.ac_fatherId, acinfo.ac_sorting);
                        foreach (ArticleCategoryInfo sortinfo in result)
                        {
                            db.Update(sortinfo.ac_name, sortinfo.ac_sorting - 1, sortinfo.ac_type, sortinfo.ac_fatherId, sortinfo.l_id, sortinfo.ac_id);
                        }
                    }
                    return(db.Update(info.ac_name, countmath, info.ac_type, info.ac_fatherId, info.l_id, info.ac_id));
                }
            }
            return(check);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     btnSubmitArticleCategory.Click += new EventHandler(btnSubmitArticleCategory_Click);
     btnPicDelete.Click             += new EventHandler(btnPicDelete_Click);
     if (!int.TryParse(base.Request.QueryString["CategoryId"], out categoryId))
     {
         base.GotoResourceNotFound();
     }
     else if (!base.IsPostBack)
     {
         ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId);
         if (articleCategory == null)
         {
             base.GotoResourceNotFound();
         }
         else
         {
             Globals.EntityCoding(articleCategory, false);
             txtArticleCategoryiesName.Text = articleCategory.Name;
             txtArticleCategoryiesDesc.Text = articleCategory.Description;
             imgPic.ImageUrl      = articleCategory.IconUrl;
             btnPicDelete.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl);
             imgPic.Visible       = !string.IsNullOrEmpty(imgPic.ImageUrl);
         }
     }
 }
Example #15
0
        public void UpdateArticleCategory(ArticleCategoryInfo articleCategory)
        {
            if (articleCategory == null)
            {
                throw new HimallException("未指定ArticleCategoryInfo实例");
            }
            if (string.IsNullOrWhiteSpace(articleCategory.Name))
            {
                throw new HimallException("未指定文章分类名称");
            }

            //检查文章分类是否存在,排除0的父分类,0为根级
            //if (articleCategory.ParentCategoryId != 0 && Context.ArticleCategoryInfo.Count(item => item.Id == articleCategory.ParentCategoryId) == 0)
            if (articleCategory.ParentCategoryId != 0 && !DbFactory.Default.Get <ArticleCategoryInfo>().Where(item => item.Id == articleCategory.ParentCategoryId).Exist())
            {
                throw new HimallException("不存在父级为" + articleCategory.ParentCategoryId + "的文章分类");
            }
            //ArticleCategoryInfo oriArticleCategory = Context.ArticleCategoryInfo.FirstOrDefault(p => p.Id == articleCategory.Id);
            ArticleCategoryInfo oriArticleCategory = DbFactory.Default.Get <ArticleCategoryInfo>().Where(p => p.Id == articleCategory.Id).FirstOrDefault();

            if (oriArticleCategory == null)
            {
                throw new HimallException("未找到id为" + articleCategory.Id + "的对象");
            }

            //修改
            oriArticleCategory.Name             = articleCategory.Name;
            oriArticleCategory.ParentCategoryId = articleCategory.ParentCategoryId;
            //Context.SaveChanges();//保存更改
            DbFactory.Default.Update(oriArticleCategory);
        }
 protected void Page_Load(object sender, System.EventArgs e)
 {
     this.btnSubmitArticleCategory.Click += new System.EventHandler(this.btnSubmitArticleCategory_Click);
     this.btnPicDelete.Click             += new System.EventHandler(this.btnPicDelete_Click);
     if (!int.TryParse(base.Request.QueryString["CategoryId"], out this.categoryId))
     {
         base.GotoResourceNotFound();
         return;
     }
     if (!base.IsPostBack)
     {
         ArticleCategoryInfo articleCategory = SubsiteCommentsHelper.GetArticleCategory(this.categoryId);
         if (articleCategory == null)
         {
             base.GotoResourceNotFound();
             return;
         }
         Globals.EntityCoding(articleCategory, false);
         this.txtArticleCategoryiesName.Text = articleCategory.Name;
         this.txtArticleCategoryiesDesc.Text = articleCategory.Description;
         this.imgPic.ImageUrl      = articleCategory.IconUrl;
         this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl);
         this.imgPic.Visible       = !string.IsNullOrEmpty(this.imgPic.ImageUrl);
     }
 }
Example #17
0
    protected void InitInfo()
    {
        categoryId = CECRequest.GetQueryInt("categoryid", 0);
        Action     = CECRequest.GetQueryString("action");

        if (Action == "del")
        {
            bool isDelete = ArticleCategoryManage.DeleteCategory(categoryId);
            if (!isDelete)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "DelError", "alert('该分类可能有字分类,请先删掉子分类!');window.location.href='categorylist.aspx';", true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "DeleSuccess", "alert('删除成功!');window.location.href='categorylist.aspx';", true);
            }
            return;
        }

        this.ddlcategoryList.BuildTree(ArticleCategoryManage.GetArticleCategoryTable(), "CategoryName", "CategoryId");
        this.ddlcategoryList.SelectedValue = categoryId.ToString();
        if (Action.ToLower() == "edit")
        {
            categoryInfo = ArticleCategoryManage.GetArticleCategoryInfo(categoryId);
            this.ddlcategoryList.SelectedValue = categoryInfo.ParentId.ToString();
        }
    }
Example #18
0
 protected void Bind()
 {
     ArticleCategoryInfo info = acBLL.getAllById(id);
     if (info.ac_id != 0)
     {
         lbTitle.Text = info.ac_name;
     }
 }
Example #19
0
        protected override void AttachChildControls()
        {
            int.TryParse(this.Page.Request.QueryString["categoryId"], out this.categoryId);
            this.txtCategoryName = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("txtCategoryName");
            this.txtCategoryId   = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("txtCategoryId");
            this.keyWord         = this.Page.Request.QueryString["keyWord"];
            if (!string.IsNullOrWhiteSpace(this.keyWord))
            {
                this.keyWord = this.keyWord.Trim();
            }
            this.rptArticles   = (VshopTemplatedRepeater)this.FindControl("rptArticles");
            this.txtTotalPages = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("txtTotal");
            int pageIndex;

            if (!int.TryParse(this.Page.Request.QueryString["page"], out pageIndex))
            {
                pageIndex = 1;
            }
            int pageSize;

            if (!int.TryParse(this.Page.Request.QueryString["size"], out pageSize))
            {
                pageSize = 20;
            }
            ArticleQuery articleQuery = new ArticleQuery();

            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["CategoryId"]))
            {
                int value = 0;
                if (int.TryParse(this.Page.Request.QueryString["CategoryId"], out value))
                {
                    ArticleCategoryInfo articleCategory = CommentBrowser.GetArticleCategory(value);
                    if (articleCategory != null)
                    {
                        PageTitle.AddSiteNameTitle(articleCategory.Name);
                        articleQuery.CategoryId    = new int?(value);
                        this.txtCategoryId.Value   = value.ToString();
                        this.txtCategoryName.Value = articleCategory.Name;
                    }
                    else
                    {
                        PageTitle.AddSiteNameTitle("文章分类搜索页");
                    }
                }
            }
            articleQuery.Keywords  = this.keyWord;
            articleQuery.PageIndex = pageIndex;
            articleQuery.PageSize  = pageSize;
            articleQuery.SortBy    = "AddedDate";
            articleQuery.SortOrder = SortAction.Desc;
            DbQueryResult articleList = CommentBrowser.GetArticleList(articleQuery);

            this.rptArticles.DataSource = articleList.Data;
            this.rptArticles.DataBind();
            int totalRecords = articleList.TotalRecords;

            this.txtTotalPages.SetWhenIsNotNull(totalRecords.ToString());
        }
Example #20
0
 public static bool UpdateArticleCategory(ArticleCategoryInfo articleCategory)
 {
     if (null == articleCategory)
     {
         return(false);
     }
     Globals.EntityCoding(articleCategory, true);
     return(new ArticleCategoryDao().CreateUpdateDeleteArticleCategory(articleCategory, DataProviderAction.Update));
 }
Example #21
0
 public static bool UpdateArticleCategory(ArticleCategoryInfo articleCategory)
 {
     if (articleCategory == null)
     {
         return(false);
     }
     Globals.EntityCoding(articleCategory, true);
     return(new ArticleCategoryDao().Update(articleCategory, null));
 }
 public static bool CreateArticleCategory(ArticleCategoryInfo articleCategory)
 {
     if (null == articleCategory)
     {
         return(false);
     }
     Globals.EntityCoding(articleCategory, true);
     return(CommentsProvider.Instance().CreateUpdateDeleteArticleCategory(articleCategory, DataProviderAction.Create));
 }
Example #23
0
    public string getTitle(int id)
    {
        if (id == 0)
        {
            return("此項目為主類別");
        }
        ArticleCategoryInfo info = acBLL.getAllById(id);

        return(info.ac_name);
    }
Example #24
0
        private void SearchHierarchyVailNow(int fid)
        {
            ArticleCategoryInfo info = getAllById(fid);

            if (info.ac_id != 0)
            {
                HerichCountMath += 1;
                SearchHierarchyVailNow(info.ac_fatherId);
            }
        }
Example #25
0
        public JsonResult List(int rows, int page)
        {
            ArticleCategoryInfo     specialArticleCategory = ServiceHelper.Create <IArticleCategoryService>().GetSpecialArticleCategory(SpecialCategory.PlatformNews);
            PageModel <ArticleInfo> pageModel = ServiceHelper.Create <IArticleService>().Find(new long?(specialArticleCategory.Id), "", rows, page, false);
            var array =
                from item in pageModel.Models.ToArray()
                select new { id = item.Id, addDate = item.AddDate.ToString("yyyy-MM-dd"), title = item.Title };

            return(Json(new { rows = array, total = pageModel.Total }));
        }
Example #26
0
 private void AddNewCategory(ArticleCategoryInfo category)
 {
     if (SubsiteCommentsHelper.CreateArticleCategory(category))
     {
         this.Reset();
         this.ShowMsg("成功添加了一个文章分类", true);
         return;
     }
     this.ShowMsg("未知错误", false);
 }
Example #27
0
        public List <ArticleCategoryInfo> UpdataSorting(int fatherid, int sorting)
        {
            List <ArticleCategoryInfo> infos = new List <ArticleCategoryInfo>();
            IDataReader reader = db.UpdataSorting(fatherid, sorting, lidValue).CreateDataReader();

            while (reader.Read())
            {
                infos.Add(ArticleCategoryInfo.Populate(reader));
            }
            return(infos);
        }
 private void UpdateCategory(ArticleCategoryInfo category)
 {
     if (ArticleHelper.UpdateArticleCategory(category))
     {
         base.CloseWindow(null);
     }
     else
     {
         this.ShowMsg("未知错误", false);
     }
 }
        public void UpdateArticleCategoryDisplaySequence(long id, long displaySequence)
        {
            ArticleCategoryInfo articleCategoryInfo = context.ArticleCategoryInfo.FindById <ArticleCategoryInfo>(id);

            if (articleCategoryInfo == null)
            {
                throw new HimallException(string.Concat("未找到id为", id, "的对象"));
            }
            articleCategoryInfo.DisplaySequence = displaySequence;
            context.SaveChanges();
        }
        public void UpdateArticleCategoryName(long id, string name)
        {
            ArticleCategoryInfo articleCategoryInfo = context.ArticleCategoryInfo.FindById <ArticleCategoryInfo>(id);

            if (articleCategoryInfo == null)
            {
                throw new HimallException(string.Concat("未找到id为", id, "的对象"));
            }
            articleCategoryInfo.Name = name;
            context.SaveChanges();
        }