protected void LoadData()
 {
     ArticleCommentController comment_obj = new ArticleCommentController();
     DataTable dt = comment_obj.GetDetailById(_idx);
     if (dt.Rows.Count > 0)
     {
         txtArticle.Text = dt.Rows[0]["Headline"].ToString();
         txtName.Text = dt.Rows[0]["CommentName"].ToString();
         txtEmail.Text = dt.Rows[0]["CommentEmail"].ToString();
         txtCommentText.Text = dt.Rows[0]["CommentText"].ToString();
         LoadStatus2RadioBtnList(dt.Rows[0]["Publish"].ToString().Trim());
     }
 }
 protected void btnOkay_Click(object sender, EventArgs e)
 {
     ArticleCommentController comment_obj = new ArticleCommentController();
     string user_id = Session["UserId"].ToString();
     string status = rdlStatus.SelectedValue;
     Page.Validate("ValidationCheck");
     if (Page.IsValid)
     {
         System.Threading.Thread.Sleep(2000);
         int i = comment_obj.UpdateStatus(user_id, _idx, status);
         if (i == -1)
         {
             lblErrorMsg.Text = "Thông tin không đầy đủ";
             ClientScript.RegisterStartupScript(this.GetType(), "onload", "onError();", true);
             MultiView1.ActiveViewIndex = 0;
         }
         else if (i == -2)
         {
             lblErrorMsg.Text = "Tiến trình xử lý bị lỗi";
             ClientScript.RegisterStartupScript(this.GetType(), "onload", "onError();", true);
             MultiView1.ActiveViewIndex = 2;
         }
         else if (i == -3)
         {
             lblErrorMsg.Text = "Dữ liệu không tồn tại";
             ClientScript.RegisterStartupScript(this.GetType(), "onload", "onError();", true);
             MultiView1.ActiveViewIndex = 2;
         }
         else if (i == 1)
         {
             lblResult.Text = "Cập nhật thành công";
             MultiView1.ActiveViewIndex = 1;
             ClientScript.RegisterStartupScript(this.GetType(), "onload", "onSuccess();", true);
         }
         else
         {
             ClientScript.RegisterStartupScript(this.GetType(), "onload", "onError();", true);
             MultiView1.ActiveViewIndex = 2;
         }
     }
 }
Ejemplo n.º 3
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 = "";
             }
         }
     }
 }