コード例 #1
0
ファイル: AddArticle.aspx.cs プロジェクト: memorylose/vera
        public void Button1_Click(object sender, EventArgs e)
        {
            string username = string.Empty;

            //get user information
            if (Session["user"] != null)
            {
                username = Session["user"].ToString();
                UserRegisterBusiness userReg = new UserRegisterBusiness();
                string validateResult        = userReg.AddArticleValidation(txtTitle.Value, Request["content"].ToString());
                if (string.IsNullOrEmpty(validateResult))
                {
                    int userId = userReg.GetUserId(username);
                    int typeId = Convert.ToInt32(DropDownList1.SelectedValue);
                    int i      = userReg.AddArticle(txtTitle.Value, txtSummary.Value, Request["content"].ToString(), userId, typeId);
                    if (i != 0)
                    {
                        Response.Redirect("Article.aspx");
                    }
                    else
                    {
                        AddErrorMessageshtml += validateResult;
                    }
                }
            }
            else
            {
                Response.Redirect("../Login.aspx");
            }
        }
コード例 #2
0
ファイル: ArticleModify.aspx.cs プロジェクト: memorylose/vera
        protected void Button1_Click(object sender, EventArgs e)
        {
            string username = Session["user"].ToString();

            UserRegisterBusiness userReg = new UserRegisterBusiness();
            int userId = userReg.GetUserId(username);
            int typeId = Convert.ToInt32(DropDownList1.SelectedItem.Value);

            int    articleId = Convert.ToInt32(Request.QueryString["id"]);
            string title     = txtTitle.Value;
            string content   = txtContent.Value;

            int i = userReg.ModifyArticle(title, content, typeId, articleId);

            if (i != 0)
            {
                Response.Redirect("Article.aspx");
            }
            else
            {
                Response.Write("Modify Article Failed, Please Try Again");
            }
        }