/// <summary>
        /// 增加新主题分类
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void AddNewRec_Click(object sender, EventArgs e)
        {
            #region 增加新主题分类
            //检查输入是否合法
            if (!CheckValue(typename.Text, displayorder.Text, description.Text))
            {
                return;
            }

            //检查是否有同名分类存在
            if (TopicTypes.IsExistTopicType(typename.Text))
            {
                base.RegisterStartupScript("", "<script>alert('数据库中已存在相同的主题分类名称');window.location.href='forum_topictypesgrid.aspx';</script>");
                return;
            }

            //增加分类到dnt_topictypes,并写日志
            TopicTypes.CreateTopicTypes(typename.Text, int.Parse(displayorder.Text), description.Text);
            AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加主题分类", "添加主题分类,名称为:" + typename.Text);

            //更新分类缓存
            DNTCache.GetCacheService().RemoveObject("/Forum/TopicTypes");
            base.RegisterStartupScript("", "<script>window.location.href='forum_topictypesgrid.aspx';</script>");
            return;

            #endregion
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string typename        = DNTRequest.GetString("typename");
            string typeorder       = DNTRequest.GetString("typeorder");
            string typedescription = DNTRequest.GetString("typedescription");

            //检查是否有同名分类存在
            if (TopicTypes.IsExistTopicType(typename))
            {
                result = false;
                return;
            }

            //增加分类到dnt_topictypes,并写日志
            TopicTypes.CreateTopicTypes(typename, int.Parse(typeorder), typedescription);
            maxId = TopicTypes.GetMaxTopicTypesId();
            //更新分类缓存
            DNTCache.GetCacheService().RemoveObject("/Forum/TopicTypes");
            return;
        }
        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
        }