protected void plfabu_Click(object sender, EventArgs e) { Button bt = (Button)sender; if (Session["user_name"] != null) { try { Write_Comment wc = new Write_Comment(); wc.Wc_user_id1 = int.Parse(Session["user_id"].ToString()); wc.Wc_wri_id1 = Convert.ToInt32(Request.QueryString["Wri_id"].ToString()); wc.Wc_mess1 = plshuru.Text; wc.Wc_time1 = DateTime.Now; if (Write_CommentManager.write_comment(wc) == 1) { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('回复成功');</script>"); plshuru.Text = ""; BingWC(); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('评论失败');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('请先登录!');</script>"); } }
protected void BingWC() { int write_id = Convert.ToInt32(Request.QueryString["wri_id"].ToString()); DataTable wc = Write_CommentManager.plwri(write_id); if (wc != null) { ListView1.DataSource = wc; ListView1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { BindView(); string wcid; if (!IsPostBack) { try { if (Request.QueryString["wc_id"] != null) { wcid = Request.QueryString["wc_id"].ToString(); Write_CommentManager.delete(wcid); BindView(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除成功!');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } } }
protected void BindView() { ListView1.DataSource = Write_CommentManager.allwc(); ListView1.DataBind(); }