Esempio n. 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();

            int clsid = ddl_Class.SelectedValue.ToInt32();
            int quID = WS.RequestInt("id");
            Class cls = ObjectExtents.Class(clsid);

            Question qu = (from l in ent.Question where l.ID == quID select l).FirstOrDefault();

            qu.ClassID = ddl_Class.SelectedValue.ToInt32();
            qu.Title = txt_Title.Text.TrimDbDangerousChar();

            try
            {
                qu.UserID = ddl_Author.SelectedValue.ToInt32();
                qu.UserName = ddl_Author.SelectedItem.Text;
            }
            catch
            {
                qu.UserID = 0;
                qu.UserName = "";
            }

            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)
            {
                ent.AddToQuestion(qu);
            }
            ent.SaveChanges();
            ent.Dispose();

            //生成页面
            try
            {
                CreatePage.CreateContentPage(qu, cls);

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

            Js.AlertAndChangUrl("保存成功!", url);
        }
Esempio n. 2
0
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();

            if (UserAction.HasPostRight(ddl_Class.SelectedValue.ToInt32()) == false)
            {
                Js.AlertAndGoback("对不起,对于本栏目您没有提问的权限!如有疑问,请联系管理员");
                ent.Dispose();
                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;
            ent.AddToQuestion(qs);
            ent.SaveChanges();

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

            Js.AlertAndChangUrl("提问发布成功!", url);
        }