Esempio n. 1
0
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            if (UserAction.HasPostRight(ddl_Class.SelectedValue.ToInt32()) == false)
            {
                Js.AlertAndGoback("对不起,对于本栏目您没有提问的权限!如有疑问,请联系管理员");
                return;
            }

            User   u       = UserAction.opuser;
            int    rclass  = WS.RequestInt("ddl_Class", WS.RequestInt("class"));
            string content = WS.RequestString("txt_Content").TrimDbDangerousChar().Trim().HtmlDeCode();
            string title   = WS.RequestString("txt_Title").TrimDbDangerousChar().Trim();

            if (rclass < 0)
            {
                Js.AlertAndGoback("栏目不能为空");
                return;
            }
            if (content.IsNullOrEmpty())
            {
                Js.AlertAndGoback("提问内容不能为空");
                return;
            }
            if (title.IsNullOrEmpty())
            {
                Js.AlertAndGoback("标题不能为空");
                return;
            }

            Question qs = new Question();

            qs.AskTime    = DateTime.Now;
            qs.ClassID    = rclass;
            qs.ClickCount = 0;
            qs.Content    = content;
            qs.Title      = title;
            qs.UserID     = u.ID;
            qs.UserName   = u.UserName;
            qs.ZtID       = 0;
            QuestionView.Insert(qs);

            CreatePage.CreateContentPage(qs, qs.GetClass());
            CreatePage.CreateListPage(qs.GetClass(), 1);
            string url = BasePage.GetQuestionUrl(qs, qs.GetClass());

            Js.AlertAndChangUrl("提问发布成功!", url);
        }
Esempio n. 2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            Class cls = ClassView.GetModelByID(ddl_Class.SelectedValue);

            Question qu = QuestionView.GetModelByID(WS.RequestString("id"));

            qu.ClassID    = ddl_Class.SelectedValue.ToInt32();
            qu.Title      = txt_Title.Text.TrimDbDangerousChar();
            qu.UserID     = ddl_Author.SelectedValue.ToInt32();
            qu.UserName   = ddl_Author.SelectedItem.Text;
            qu.ClickCount = txt_ClickCount.Text.ToInt32(0);
            if (qu.ID <= 0)
            {
                qu.AskTime = DateTime.Now;
            }
            qu.Content = txt_Content.Text.TrimDbDangerousChar();

            qu.Title = txt_Title.Text;
            qu.ZtID  = 0;

            if (qu.ID > 0)
            {
                QuestionView.Update(qu);
            }
            else
            {
                QuestionView.Insert(qu);
            }



            //生成页面

            CreatePage.CreateContentPage(qu, cls);

            Question pre = GetPreQuestion(qu, cls);

            if (pre != null)
            {
                CreatePage.CreateContentPage(pre, cls);
            }
            CreatePage.CreateListPage(cls, 1);


            Js.AlertAndChangUrl("保存成功!", url);
        }