예제 #1
0
 protected void btnSend_Click(object sender, EventArgs e)
 {
     Page.Validate("ValidationCheck");
     if (Page.IsValid)
     {
         if (hiddenCaptcha.Value != null)
         {
             if (txtCaptcha.Text == hiddenCaptcha.Value)
             {
                 ArticleController article_obj=new ArticleController();
                 DataTable dt=article_obj.GetDetailByCodeAlias(ViewState["alias"].ToString(),ViewState["code"].ToString());
                 if (dt.Rows.Count > 0)
                 {
                     int articleid = Convert.ToInt32(dt.Rows[0]["ArticleId"].ToString());
                     //string userid = null;
                     string name = txtName.Text;
                     string email = txtEmail.Text;
                     //string comment_text = txtComment.Value;                            
                     string comment_text = Server.HtmlEncode(txtComments.Text);
                     int is_reply = 1;
                     string publish = "2";
                     ArticleCommentController comment_obj = new ArticleCommentController();
                     int i = comment_obj.Insert(articleid, name, comment_text, email, is_reply, publish);
                     if (i == 1)
                     {
                         string scriptCode = "<script>alert('Thông điệp đã được gửi đi.');window.location.href='/trang-chu/';</script>";
                         Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode);
                     }
                     else if (i == -1)
                     {
                         string scriptCode = "<script>alert('Thông tin không đủ.');</script>";
                         Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode);
                     }
                     else
                     {
                         string scriptCode = "<script>alert('Tiến trình gửi bị lỗi.');</script>";
                         Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode);
                     }
                 }
             }
             else if (txtCaptcha.Text != hiddenCaptcha.Value)
             {
                 lblResult.Text = "Vui lòng thử lại lần nữa &nbsp;<div style=\"float:left; background:url(images/icons/OK_not_OK_Icons.png);background-position:100%;height:30px; width:30px\"></div>";
                 txtCaptcha.Text = "";
             }
         }
     }
 }