/// <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
        }
 private void BindTopicType()
 {
     #region 主题分类绑定
     TopicTypeDataGrid.BindData(TopicTypes.GetTopicTypes());
     TopicTypeDataGrid.TableHeaderName = "当前版块:  " + forumInfo.Name;
     #endregion
 }
        /// <summary>
        /// 删除主题分类
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void delButton_Click(object sender, EventArgs e)
        {
            #region  除主题分类
            if (this.CheckCookie())
            {
                if (DNTRequest.GetString("id") != "")
                {
                    //取得要删除的ID列表,以“,”分隔
                    string idlist = DNTRequest.GetString("id");

                    //调用更新版块的方法
                    DeleteForumTypes(idlist);

                    //从主题分类表(dnt_topictypes)中删除相应的分类并写日志
                    TopicTypes.DeleteTopicTypes(idlist);
                    AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "删除主题分类", "删除主题分类,ID为:" + DNTRequest.GetString("id").Replace("0 ", ""));

                    //更新主题分类缓存
                    DNTCache.GetCacheService().RemoveObject("/Forum/TopicTypes");
                    Response.Redirect("forum_topictypesgrid.aspx");
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('您未选中任何选项');window.location.href='forum_attachtypesgrid.aspx';</script>");
                }
            }
            #endregion
        }
示例#4
0
    public void ChooseTopicType(int type)
    {
        switch (type)
        {
        case 1:
            selectedTopicType = TopicTypes.Locations;
            break;

        case 2:
            selectedTopicType = TopicTypes.Creatures;
            break;

        case 3:
            selectedTopicType = TopicTypes.Items;
            break;

        case 4:
            selectedTopicType = TopicTypes.Quest;
            break;

        default:
            selectedTopicType = TopicTypes.People;
            break;
        }
        ListTopics();
    }
 /// <summary>
 /// 绑定主题
 /// </summary>
 public void BindData(string searthKeyWord)
 {
     #region 绑定主题
     DataGrid1.AllowCustomPaging = false;
     DataGrid1.TableHeaderName   = "主题分类";
     DataGrid1.BindData(TopicTypes.GetTopicTypes(searthKeyWord));
     #endregion
 }
        /// <summary>
        /// 删除版块中的主题分类
        /// </summary>
        /// <param name="idlist">要删除主题分类的ID列表</param>
        private void DeleteForumTypes(string idlist)
        {
            #region  除所选的主题分类

            TopicTypes.DeleteForumTopicTypes(idlist);

            #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 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
        }
示例#9
0
 public Topic(string topicName, TopicTypes type)
 {
     topicTitle = topicName;
     topicType  = type;
 }
        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
        }