温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:小白留言板源码
当前文件:
XiaobaiLiuyanban/messagereplay.aspx.cs[2K,2009-6-12 11:59:24],打开代码结构图
XiaobaiLiuyanban/messagereplay.aspx.cs[2K,2009-6-12 11:59:24],打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using System.Data.SqlClient; 12
13
public partial class messagereplay : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
if (Session["name"] == null) 18
{ 19
Response.Redirect("Login.aspx"); 20
} 21
if (!Page.IsPostBack) 22
{ 23
showmessage(); 24
} 25
} 26
private void showmessage() 27
{ 28
try 29
{ 30
string m_id = Request["m_id"].ToString(); 31
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["getcon"].ConnectionString); 32
con.Open(); 33
string sql = "select * from message where m_id='" + m_id + "'"; 34
SqlCommand com = new SqlCommand(sql, con); 35
SqlDataReader dr = com.ExecuteReader(); 36
if (dr.Read()) 37
{ 38
this.labname.Text = dr["m_name"].ToString(); 39
this.labsubject.Text = dr["m_subject"].ToString(); 40
this.labcontent.Text = dr["m_content"].ToString(); 41
this.trepaly.Text = dr["m_replay"].ToString(); 42
} 43
dr.Close(); 44
con.Close(); 45
} 46
catch (Exception) 47
{ 48
49
Response.Redirect("showmessage.aspx"); 50
} 51
52
} 53
protected void btnreplay_Click(object sender, EventArgs e) 54
{ 55
string m_id = Request["m_id"].ToString(); 56
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["getcon"].ConnectionString); 57
con.Open(); 58
string sql = "update message set m_replay=@replay,m_replaytime=@datetime where m_id='" + m_id + "'"; 59
SqlCommand com = new SqlCommand(sql, con); 60
com.Parameters.Add("@replay", SqlDbType.Text).Value = this.trepaly.Text.ToString(); 61
com.Parameters.Add("@datetime", SqlDbType.DateTime).Value = DateTime.Now.ToString(); 62
try 63
{ 64
com.ExecuteNonQuery(); 65
Response.Write("<script>alert('回复成功!')</script>"); 66
} 67
catch (Exception ex) 68
{ 69
throw new System.Exception(ex.Message); 70
71
} 72
finally 73
{ 74
con.Close(); 75
} 76
} 77
protected void btncan_Click(object sender, EventArgs e) 78
{ 79
Response.Redirect("showmessage.aspx"); 80
} 81
} 82






}
}