public List <liuyan> viewAll() { List <liuyan> list = new List <liuyan>(); con.Open(); cmd = new SqlCommand("select * from liuyantable order by liuyan_time desc", con); SqlDataReader sdr = cmd.ExecuteReader(); liuyan ac; while (sdr.Read()) { ac = new liuyan(); ac.id = sdr["ID"].ToString(); ac.author = sdr["CNAME"].ToString(); ac.content = sdr["liuyan_content"].ToString(); ac.huifu = sdr["LIUYAN_HUIFU"].ToString(); ac.huifutime = Convert.ToDateTime(sdr["LIUYAN_HUIFU_TIME"]); ac.time = Convert.ToDateTime(sdr["LIUYAN_TIME"]); list.Add(ac); } sdr.Close(); con.Close(); return(list); }
protected void Btn_summit_Click(object sender, EventArgs e) { liuyan ly = new liuyan(); LiuyanOperation lyop = new LiuyanOperation(); ly.author = TextBox1.Text.ToString(); ly.content = FCKeditor1.Value.ToString(); lyop.insert_ly(ly); this.Data_list_liuyan.DataBind(); Response.Redirect("liuyan.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { id = Request.QueryString["id"].ToString(); liuyan ly = new liuyan(); LiuyanOperation lyo = new LiuyanOperation(); ly = lyo.getByAid(id); string t = TextBox1.Text.ToString(); ly.huifu = t; bool b=lyo.update(ly); if (b) Response.Write("回复更新成功!"); Response.Redirect("../Liuyan.aspx"); }
//获取文章内容 public liuyan getByAid(string aid) { con.Open(); cmd = new SqlCommand("select * from liuyantable where id='" + aid + "'", con); SqlDataReader dr = cmd.ExecuteReader(); liuyan ac = null; while (dr.Read()) { ac = new liuyan(dr); } con.Close(); return ac; }
public liuyan getByAid(string aid)//获取文章内容 { con.Open(); cmd = new SqlCommand("select * from liuyantable where id='" + aid + "'", con); SqlDataReader dr = cmd.ExecuteReader(); liuyan ac = null; while (dr.Read()) { ac = new liuyan(dr); } con.Close(); return(ac); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { id = Request.QueryString["id"].ToString(); liuyan ly = new liuyan(); LiuyanOperation lyo = new LiuyanOperation(); ly = lyo.getByAid(id); TextBox1.Text = ly.huifu; } catch { } } }
public bool insert_ly(liuyan at)//插入留言函数! { con.Open(); cmd = new SqlCommand("insert into liuyantable(CNAME,LIUYAN_CONTENT) values(@author,@content)", con); cmd.Parameters.Add(new SqlParameter("@content", at.content)); cmd.Parameters.Add(new SqlParameter("@author", at.author)); if (cmd.ExecuteNonQuery() > 0) { con.Close(); return(true); } else { con.Close(); return(false); } }
//插入留言函数! public bool insert_ly(liuyan at) { con.Open(); cmd = new SqlCommand("insert into liuyantable(CNAME,LIUYAN_CONTENT) values(@author,@content)", con); cmd.Parameters.Add(new SqlParameter("@content", at.content)); cmd.Parameters.Add(new SqlParameter("@author", at.author)); if (cmd.ExecuteNonQuery() > 0) { con.Close(); return true; } else { con.Close(); return false; } }
protected void Button1_Click(object sender, EventArgs e) { id = Request.QueryString["id"].ToString(); liuyan ly = new liuyan(); LiuyanOperation lyo = new LiuyanOperation(); ly = lyo.getByAid(id); string t = TextBox1.Text.ToString(); ly.huifu = t; bool b = lyo.update(ly); if (b) { Response.Write("回复更新成功!"); } Response.Redirect("../Liuyan.aspx"); }
public bool update(liuyan ac) { con.Open(); cmd = new SqlCommand("update liuyantable set liuyan_huifu=@huifu where id=@aid", con); cmd.Parameters.Add(new SqlParameter("@aid", ac.id)); cmd.Parameters.Add(new SqlParameter("@huifu", ac.huifu)); // cmd.Parameters.Add(new SqlParameter("@huifu_time", ac.huifutime)); if (cmd.ExecuteNonQuery() > 0) { con.Close(); return(true); } else { con.Close(); return(false); } }
public bool update(liuyan ac) { con.Open(); cmd = new SqlCommand("update liuyantable set liuyan_huifu=@huifu where id=@aid", con); cmd.Parameters.Add(new SqlParameter("@aid", ac.id)); cmd.Parameters.Add(new SqlParameter("@huifu", ac.huifu)); // cmd.Parameters.Add(new SqlParameter("@huifu_time", ac.huifutime)); if (cmd.ExecuteNonQuery() > 0) { con.Close(); return true; } else { con.Close(); return false; } }
public List<liuyan> viewAll() { List<liuyan> list = new List<liuyan>(); con.Open(); cmd = new SqlCommand("select * from liuyantable order by liuyan_time desc", con); SqlDataReader sdr = cmd.ExecuteReader(); liuyan ac; while (sdr.Read()) { ac = new liuyan(); ac.id = sdr["ID"].ToString(); ac.author = sdr["CNAME"].ToString(); ac.content = sdr["liuyan_content"].ToString(); ac.huifu = sdr["LIUYAN_HUIFU"].ToString(); ac.huifutime = Convert.ToDateTime(sdr["LIUYAN_HUIFU_TIME"]); ac.time = Convert.ToDateTime(sdr["LIUYAN_TIME"]); list.Add(ac); } sdr.Close(); con.Close(); return list; }