using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class SysAdmin_Msg_reply : System.Web.UI.Page { public static string id; public static DateTime dates; public static string repCent; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["id"] != null) { id = Request.QueryString["id"].ToString(); show(); } } dates = DateTime.Now; } public void show() { string sql = "select a.names,a.contents,b.replymsg from msgtab as a,msg_reply as b where a.id=b.msgid and a.id='" + id + "'"; DataTable dt = DBH.DBHelper.GetDataSet(sql); if (dt.Rows.Count > 0) { this.txtname.Text = dt.Rows[0]["names"].ToString(); this.txtcontent.Text = dt.Rows[0]["contents"].ToString(); this.txtreply.Text = dt.Rows[0]["replymsg"].ToString(); repCent = dt.Rows[0]["replymsg"].ToString(); } else { string str = "select names,contents,mDate,note from msgtab where id='"+id+"'"; DataTable dts = DBH.DBHelper.GetDataSet(str); this.txtname.Text = dts.Rows[0]["names"].ToString(); this.txtcontent.Text = dts.Rows[0]["contents"].ToString(); } } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string sql = "update msgtab set note='已审核' where id='"+id+"'"; int i = DBH.DBHelper.ExecuteNonQuery(sql); if (i > 0) { Methods1.Methods1.Alert(this, "审核已通过"); } else { Methods1.Methods1.Alert(this, "未通过审核"); } } protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { if (repCent == null)//没有回复过的留言 添加回复留言的信息 { string sql = "insert into msg_reply(msgid,replymsg,auDate) values('" + id + "','" + txtreply.Text + "','" + dates + "')"; int i = DBH.DBHelper.ExecuteNonQuery(sql); if (i > 0) { Methods1.Methods1.Alert(this, "回复留言成功"); string str = "update msgtab set IsNo='已回复' where id='" + id + "'"; int j = DBH.DBHelper.ExecuteNonQuery(str); if (j > 0) { Methods1.Methods1.Alert(this, "回复留言成功"); } else { Methods1.Methods1.Alert(this, "未成功回复留言"); } } else { Methods1.Methods1.Alert(this, "未成功回复留言"); } } else //已回复过的留言 修改回复信息和时间 { string sql = "update msg_reply set replymsg='"+txtreply.Text+"',auDate='"+dates+"' where msgid='"+id+"'"; int i = DBH.DBHelper.ExecuteNonQuery(sql); if (i > 0) { Methods1.Methods1.Alert(this, "回复留言成功"); string str = "update msgtab set IsNo='已回复' where id='" + id + "'";//回复之后 修改留言状态 int j = DBH.DBHelper.ExecuteNonQuery(str); if (j > 0) { Methods1.Methods1.Alert(this, "回复留言成功"); } else { Methods1.Methods1.Alert(this, "未成功回复留言"); } } else { Methods1.Methods1.Alert(this, "未成功回复留言"); } } } protected void ImageButton3_Click(object sender, ImageClickEventArgs e) { this.txtreply.Text = ""; } }