private void BindTopicType() { #region 主题分类绑定 TopicTypeDataGrid.BindData(TopicTypes.GetTopicTypes()); TopicTypeDataGrid.TableHeaderName = "当前版块: " + forumInfo.Name; #endregion }
/// <summary> /// 绑定主题 /// </summary> public void BindData(string searthKeyWord) { #region 绑定主题 DataGrid1.AllowCustomPaging = false; DataGrid1.TableHeaderName = "主题分类"; DataGrid1.BindData(TopicTypes.GetTopicTypes(searthKeyWord)); #endregion }
private string GetTopicType() { #region 获取主题分类 string tmpType = forumInfo.Topictypes; int i = 0; DataTable topicTypes = TopicTypes.GetTopicTypes(); while (true) { #region if (DNTRequest.GetFormString("type" + i) == "") //循环处理选择的主题分类 { break; } else { if (DNTRequest.GetFormString("type" + i) != "-1") //-1不使用,0平板显示,1下拉显示 { string oldtopictype = DNTRequest.GetFormString("oldtopictype" + i); //旧主题分类 string newtopictype = DNTRequest.GetFormString("type" + i); //新主题分类 if (oldtopictype == null || oldtopictype == "") { //tmpType += newtopictype; int insertOrder = GetDisplayOrder(newtopictype.Split(',')[1], topicTypes); ArrayList topictypesal = new ArrayList(); foreach (string topictype in tmpType.Split('|')) { if (topictype != "") { topictypesal.Add(topictype); } } bool isInsert = false; for (int j = 0; j < topictypesal.Count; j++) { int curDisplayOrder = GetDisplayOrder(topictypesal[j].ToString().Split(',')[1], topicTypes); if (curDisplayOrder > insertOrder) { topictypesal.Insert(j, newtopictype); isInsert = true; break; } } if (!isInsert) { topictypesal.Add(newtopictype); } tmpType = ""; foreach (object t in topictypesal) { tmpType += t.ToString() + "|"; } } else { tmpType = tmpType.Replace(oldtopictype, newtopictype); } } else { if (DNTRequest.GetFormString("oldtopictype" + i) != "") { tmpType = tmpType.Replace(DNTRequest.GetFormString("oldtopictype" + i), ""); } } } #endregion i++; } return(tmpType); #endregion }
private void SaveTopicType_Click(object sender, EventArgs e) { #region 保存主题分类编辑 //下四行取编辑行的更新值 int rowid = 0; bool error = false; foreach (object o in DataGrid1.GetKeyIDArray()) { string id = o.ToString(); string name = DataGrid1.GetControlValue(rowid, "name"); string displayorder = DataGrid1.GetControlValue(rowid, "displayorder"); string description = DataGrid1.GetControlValue(rowid, "description"); //判断主题分类表中是否有与要更新的重名 if (!CheckValue(name, displayorder, description) || TopicTypes.IsExistTopicType(name, int.Parse(id))) { error = true; continue; } //取得主题分类的缓存 Discuz.Common.Generic.SortedList <int, string> topictypearray = new Discuz.Common.Generic.SortedList <int, string>(); topictypearray = Caches.GetTopicTypeArray(); DataTable dt = Forums.GetExistTopicTypeOfForum(); DataTable topicTypes = TopicTypes.GetTopicTypes(); foreach (DataRow dr in dt.Rows) { //用新名更新dnt_forumfields表的topictypes字段 string topictypes = dr["topictypes"].ToString(); if (topictypes.Trim() == "") //如果主题列表为空则不处理 { continue; } string oldTopicType = GetTopicTypeString(topictypes, topictypearray[Int32.Parse(id)].ToString().Trim()); //获取修改名字前的旧主题列表 if (oldTopicType == "") //如果主题列表中不包含当前要修改的主题,则不处理 { continue; } string newTopicType = oldTopicType.Replace("," + topictypearray[Int32.Parse(id)].ToString().Trim() + ",", "," + name + ","); topictypes = topictypes.Replace(oldTopicType + "|", ""); //将旧的主题列表从论坛主题列表中删除 ArrayList topictypesal = new ArrayList(); foreach (string topictype in topictypes.Split('|')) { if (topictype != "") { topictypesal.Add(topictype); } } bool isInsert = false; for (int i = 0; i < topictypesal.Count; i++) { int curDisplayOrder = GetDisplayOrder(topictypesal[i].ToString().Split(',')[1], topicTypes); if (curDisplayOrder > int.Parse(displayorder)) { topictypesal.Insert(i, newTopicType); isInsert = true; break; } } if (!isInsert) { topictypesal.Add(newTopicType); } topictypes = ""; foreach (object t in topictypesal) { topictypes += t.ToString() + "|"; } TopicTypes.UpdateForumTopicType(topictypes, int.Parse(dr["fid"].ToString())); Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TopicTypesOption" + dr["fid"].ToString()); Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TopicTypesLink" + dr["fid"].ToString()); } //更新主题分类表(dnt_topictypes) TopicTypes.UpdateTopicTypes(name, int.Parse(displayorder), description, int.Parse(id)); rowid++; } //更新缓存 DNTCache cache = DNTCache.GetCacheService(); cache.RemoveObject("/Forum/TopicTypes"); if (error) { base.RegisterStartupScript("", "<script>alert('数据库中已存在相同的主题分类名称或为空,该记录不能被更新!');window.location.href='forum_topictypesgrid.aspx';</script>"); } else { base.RegisterStartupScript("PAGE", "window.location.href='forum_topictypesgrid.aspx';"); } return; #endregion }