void InitInfo() { this.ddlcategoryList.BuildTree(ArticleCategoryManage.GetArticleCategoryTable(), "CategoryName", "CategoryId"); categoryId = CECRequest.GetQueryInt("CategoryId", 0); this.ddlcategoryList.SelectedValue = this.SqlDataSource_rptList.SelectParameters[0].DefaultValue = categoryId.ToString(); }
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(); } }
/// <summary> /// 获得此ID的类别详细信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public static CategoryInfo Get(int id) { var item = ArticleCategoryManage.Get(id); LoadExtionsion(item); return(item); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Action.ToLower() == "edit") { if (categoryId > 0) { this.txtName.Text = categoryInfo.CategoryName; this.txtSort.Text = categoryInfo.Sort.ToString(); this.ddlcategoryList.Enabled = false; } } DataTable dt = ArticleCategoryManage.GetArticleCategoryTable(); ViewState["dt"] = dt; if (dt.Rows.Count > 0) { AddTree(0, dt.Select("Layer=0 AND [ParentId]=0"), ""); str = "<script type=\"text/javascript\">\r\n var obj = [" + str; str = str.Substring(0, str.Length - 3); str += "];\r\n var newtree = new tree(\"newtree\",obj,\"reSetTree\");"; str += "</script>"; } ShowTreeLabel.Text = str; } }
/// <summary> /// 是否存在别名,别名不允许重复 /// </summary> /// <param name="appId"></param> /// <param name="cid"></param> /// <param name="englishName"></param> /// <returns></returns> public static bool ExistsAlias(int cid, string englishName, WebLanguage lang) { if (string.IsNullOrEmpty(englishName)) { return(false); } return(ArticleCategoryManage.ExistsAlias(cid, englishName, lang)); }
/// <summary> /// 根据父ID获取此ID下一级栏目,只显示一级子分类,包含删除的和未启用的 /// </summary> /// <param name="parentId"></param> /// <returns></returns> public static IList <CategoryInfo> ListByParentId(int parentId) { var _list = ArticleCategoryManage.ListByParentId(parentId); foreach (var item in _list) { LoadExtionsion(item); } return(_list); }
/// <summary> /// 获得某语言下的全部分类,包含删除的和未启用的 /// </summary> /// <param name="lang"></param> /// <returns></returns> public static IList <CategoryInfo> ListByLanguage(WebLanguage lang) { var list = ArticleCategoryManage.ListByLanguage(lang); foreach (var item in list) { LoadExtionsion(item); } return(list); }
void btnSave_Click(object sender, EventArgs e) { if (Action.ToLower() == "edit") { categoryInfo = new ArticleCategoryInfo(); categoryInfo.CategoryName = txtName.Text; categoryInfo.Sort = Convert.ToInt32(txtSort.Text); categoryInfo.CategoryId = categoryId; ArticleCategoryManage.UpdateArticleCategory(categoryInfo); } else { if (this.ddlcategoryList.SelectedValue != "0") { int _id = Utils.StrToInt(this.ddlcategoryList.SelectedValue, 0); categoryInfo = ArticleCategoryManage.GetArticleCategoryInfo(_id); if (categoryInfo != null) { string parentIdList = string.Empty; if (categoryInfo.ParentIdList == "0") { parentIdList = categoryInfo.CategoryId.ToString(); } else { parentIdList = categoryInfo.ParentIdList + "," + categoryInfo.CategoryId; } int maxOrder = 0; DataTable dt = ArticleCategoryManage.GetSubCategoryListTable(_id); if (dt.Rows.Count > 0) { maxOrder = TypeConverter.ObjectToInt(dt.Compute("Max(Sort)", "")); } else { maxOrder = categoryInfo.Sort; } InsertCategory(_id, categoryInfo.Layer + 1, parentIdList, 0, maxOrder); ArticleCategoryManage.UpdateSubCategoryCount(_id); } } else { int maxdisplayorder = TypeConverter.ObjectToInt(ArticleCategoryManage.GetArticleCategoryTable().Compute("Max(Sort)", "")) + 1; InsertCategory(0, 0, "0", 0, maxdisplayorder); } } Page.ClientScript.RegisterStartupScript(this.GetType(), "SaveSuccess", "alert('添加成功!');window.location.href='categorylist.aspx';", true); }
/// <summary> /// 添加或更新分类信息 /// </summary> /// <param name="model"></param> /// <returns>主键ID</returns> public static int Create(CategoryInfo model) { if (model.Id == 0) { //Insert int i = ArticleCategoryManage.Insert(model); model.Id = i; } else { //Update ArticleCategoryManage.Update(model); } return(model.Id); }
void InsertCategory(int parentId, int layer, string parentIdList, int subCategoryCount, int order) { categoryInfo = new ArticleCategoryInfo(); categoryInfo.CategoryId = categoryId; categoryInfo.CategoryName = txtName.Text; categoryInfo.ParentId = parentId; categoryInfo.ParentIdList = parentIdList; categoryInfo.Layer = layer; categoryInfo.SubCategoryCount = subCategoryCount; categoryInfo.Sort = order; ArticleCategoryManage.InsertArticleCategory(categoryInfo); this.txtName.Text = string.Empty; }
public static IList <CategoryInfo> ListBySiteId(int siteId, bool useCache) { if (!useCache) { return(ArticleCategoryManage.ListBySiteId(siteId)); } string KEY = string.Format("SITE_LIST_{0}", siteId); var list = (IList <CategoryInfo>)webCache[KEY]; if (list == null) { list = ArticleCategoryManage.ListBySiteId(siteId); webCache.Insert(KEY, list, null, DateTime.Now.AddMinutes(CACHETIMEOUT), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null); } //在这需要加缓存 return(list); }
public static CategoryInfo Get(int id, bool useCache) { if (!useCache) { return(ArticleCategoryManage.Get(id)); } //需要加缓存 string KEY = string.Format("GET_CATEGORY_INFO_{0}", id); var info = (CategoryInfo)webCache[KEY]; if (info == null) { info = ArticleCategoryManage.Get(id); webCache.Insert(KEY, info, null, DateTime.Now.AddMinutes(CACHETIMEOUT), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null); } return(info); }
void InitInfo() { articleId = CECRequest.GetQueryInt("articleid", 0); action = CECRequest.GetQueryString("action"); categoryId = CECRequest.GetQueryInt("categoryid", 0); if (action.ToLower() == "del") { ArticleManage.Delete(articleId); Response.Redirect("articlelist.aspx"); return; } this.PublishDate.SelectedDate = DateTime.Now; this.ddlcategoryList.BuildTree(ArticleCategoryManage.GetArticleCategoryTable(), "CategoryName", "CategoryId"); this.ddlcategoryList.SelectedValue = categoryId.ToString(); }
/// <summary> /// 根据父ID获取此ID下一级栏目,不能获取此栏目下的所有节点 /// </summary> /// <param name="parentId"></param> /// <param name="useCache">是否使用缓存</param> /// <param name="showEnabled">是否显示启用项</param> /// <param name="showDeleted">是否显示删掉项</param> /// <returns></returns> public static IList <CategoryInfo> ListByParentId(int parentId, bool useCache, bool showEnabled, bool showDeleted) { if (!useCache) { IEnumerable <CategoryInfo> _list = ArticleCategoryManage.ListByParentId(parentId); if (showEnabled) { //显示启用的 _list = _list.Where(p => p.IsEnabled == true); } if (!showDeleted) { //显示已删除掉的 _list = _list.Where(p => p.IsDeleted == false); } return(_list.ToList()); } ; //需要加缓存 string CACHEKEY = string.Format("LIST_BY_PARENT_ID_{0}", parentId); var list = (IEnumerable <CategoryInfo>)webCache[CACHEKEY]; if (list == null) { list = ArticleCategoryManage.ListByParentId(parentId); if (showEnabled) { //显示启用的 list = list.Where(p => p.IsEnabled == true); } if (!showDeleted) { //显示已删除掉的 list = list.Where(p => p.IsDeleted == false); } webCache.Insert(CACHEKEY, list, null, DateTime.Now.AddMinutes(CACHETIMEOUT), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null); } return(list.ToList()); }
/// <summary> ///分类名是否存在,在同一语言下 /// </summary> /// <param name="id"></param> /// <param name="name"></param> /// <param name="parentId"></param> /// <param name="lang"></param> /// <returns></returns> public static bool ExistsName(int id, string name, int parentId, WebLanguage lang) { return(ArticleCategoryManage.ExistsName(id, name, parentId, lang)); }
/// <summary> /// 是否存在别名,别名不允许重复 /// </summary> /// <param name="appId"></param> /// <param name="cid"></param> /// <param name="englishName"></param> /// <returns></returns> public static bool ExistsAlias(int appId, int cid, string englishName) { return(ArticleCategoryManage.ExistsAlias(appId, cid, englishName)); }
/// <summary> /// 恢复分类 /// </summary> /// <param name="id"></param> public static void Restore(int id) { ArticleCategoryManage.Restore(id); }
/// <summary> /// 删除 /// </summary> /// <param name="id"></param> /// <returns></returns> public static void Delete(int id) { ArticleCategoryManage.Delete(id); }
public static bool ExistsName(int siteId, int id, string name, int parentId) { return(ArticleCategoryManage.ExistsName(siteId, id, name, parentId)); }