⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threadadd.cs

📁 ASP.NET简洁论坛源代码 这是一个简单的论坛
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NetFocus.Web.Core;

namespace NetFocus.Web.Applications.Forum
{
    public class ThreadAdd : UserControl
    {
        protected ValuedTextBox subjectTextBox;
        protected ValuedTextBox tagsTextBox;
        protected ValuedEditor bodyEditor;
        protected ResourceButton saveButton;

        protected override void OnLoad(EventArgs e)
        {
            if (WebContext.Current.User.IsAnonymous)
            {
                Page.Response.Write("<script>window.parent.location='" + SiteUrls.Instance().Login + "'</script>");
                return;
            }
            if (WebContext.Current.SectionId <= 0)
            {
                Globals.ShowMessage(Page, "SectionIdNotExist", "发帖请到小类版块!");
                return;
            }
            saveButton.Click += new EventHandler(SaveThread);
        }

        private void SaveThread(object sender, EventArgs e)
        {
            //检查版块是否存在
            Section section = BusinessManager.GetSection(WebContext.Current.SectionId);
            if (section == null)
            {
                throw new Exception("请确认您所在的版块是存在的。");
            }

            //获取当前帖子
            Thread thread = new Thread();

            //设置帖子属性
            thread.SectionId = WebContext.Current.SectionId;
            thread.Subject = subjectTextBox.Value;
            thread.Body = bodyEditor.Value;
            thread.Tags = tagsTextBox.Value;
            thread.ThreadType = (int)ThreadType.Normal;
            thread.AuthorId = WebContext.Current.User.UserId;
            thread.Author = WebContext.Current.User.UserName;
            thread.CreateDate = DateTime.Now;
            thread.UpdateDate = DateTime.Now;
            thread.TotalViews = 0;

            //添加帖子
            BusinessManager.CreateThread(thread);

            //更新版块回复总数
            section.TotalThreads++;
            BusinessManager.UpdateSection(section);

            //返回列表页面
            Page.Response.Redirect(SiteUrls.Instance().GetThreadsUrl(WebContext.Current.SectionId));

        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -