using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.SqlClient; namespace SampleCS.Reply { /// /// View¿¡ ´ëÇÑ ¿ä¾à ¼³¸íÀÔ´Ï´Ù. /// public class View : System.Web.UI.Page { protected System.Web.UI.WebControls.Label lblEmail; protected System.Web.UI.WebControls.Label lblPostDate; protected System.Web.UI.WebControls.Label lblReadCount; protected System.Web.UI.WebControls.Label lblTitle; protected System.Web.UI.WebControls.Label lblContent; protected System.Web.UI.WebControls.Button btnDelete; protected System.Web.UI.WebControls.Button btnEdit; protected System.Web.UI.WebControls.Button btnList; protected System.Web.UI.WebControls.Label lblError; protected System.Web.UI.WebControls.Label lblHomepage; protected System.Web.UI.WebControls.Label lblNum; protected System.Web.UI.WebControls.Label lblName; protected System.Web.UI.WebControls.Label lblPostIP; protected System.Web.UI.WebControls.Button btnReply; protected string strNum;//¾Õ¿¡¼­ ³Ñ°ÜÁ® ¿Â ¹øÈ£ ÀúÀå protected int intRef;// protected int intStep; protected System.Web.UI.WebControls.Label lblRef; protected System.Web.UI.WebControls.Label lblStep; protected System.Web.UI.WebControls.Label lblRefOrder;// protected int intRefOrder;// private void Page_Load(object sender, System.EventArgs e) { strNum = Request.QueryString["Num"]; if(strNum == null) { Response.Redirect("./List.aspx"); } if(!this.IsPostBack) { ReadData();//³Ñ°ÜÁ® ¿Â ¹øÈ£¿¡ ÇØ´çÇÏ´Â ±Û¸¸ Àо °¢ ·¹ÀÌºí¿¡ Ãâ·Â } } private void ReadData() { SqlConnection objCon = new SqlConnection(); objCon.ConnectionString = Application["CONNECTION_STRING"].ToString(); objCon.Open(); SqlCommand objCmd = new SqlCommand(); objCmd.Connection = objCon; objCmd.CommandText = "procUpdateReadCountReply"; objCmd.CommandType = CommandType.StoredProcedure; objCmd.Parameters.Add("@Num", SqlDbType.Int); objCmd.Parameters["@Num"].Value = int.Parse(strNum); objCmd.ExecuteNonQuery(); objCmd.CommandText = "procViewReply"; objCmd.CommandType = CommandType.StoredProcedure; SqlDataReader objDr = objCmd.ExecuteReader(); if(objDr.Read()) { lblNum.Text = strNum;//¹øÈ£ lblName.Text = objDr["Name"].ToString();//À̸§ lblEmail.Text = objDr["Email"].ToString(); lblTitle.Text = objDr["Title"].ToString(); string strContent = objDr["Content"].ToString(); if(objDr["Encoding"].ToString() == "Text") { lblContent.Text = strContent.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\r\n", "
"); } else { lblContent.Text = strContent.Replace("\r\n", "
"); } lblReadCount.Text = objDr["ReadCount"].ToString(); lblHomepage.Text = objDr["Homepage"].ToString(); lblPostDate.Text = objDr["PostDate"].ToString(); lblPostIP.Text = objDr["PostIP"].ToString(); lblRef.Text = objDr["Ref"].ToString(); lblStep.Text = objDr["Step"].ToString(); lblRefOrder.Text = objDr["RefOrder"].ToString(); // intRef = Convert.ToInt32(objDr["Ref"]); // intStep = Convert.ToInt32(objDr["Step"]); // intRefOrder = (int)objDr["RefOrder"]; } objDr.Close(); objCon.Close(); } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: ÀÌ È£ÃâÀº ASP.NET Web Form µðÀÚÀ̳ʿ¡ ÇÊ¿äÇÕ´Ï´Ù. // InitializeComponent(); base.OnInit(e); } /// /// µðÀÚÀÌ³Ê Áö¿ø¿¡ ÇÊ¿äÇÑ ¸Þ¼­µåÀÔ´Ï´Ù. /// ÀÌ ¸Þ¼­µåÀÇ ³»¿ëÀ» ÄÚµå ÆíÁý±â·Î ¼öÁ¤ÇÏÁö ¸¶½Ê½Ã¿À. /// private void InitializeComponent() { this.btnReply.Click += new System.EventHandler(this.btnReply_Click); this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click); this.btnList.Click += new System.EventHandler(this.btnList_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void btnDelete_Click(object sender, System.EventArgs e) { Response.Redirect("./Delete.aspx?Num=" + strNum); } private void btnEdit_Click(object sender, System.EventArgs e) { Response.Redirect("./Modify.aspx?Num=" + strNum); } private void btnList_Click(object sender, System.EventArgs e) { Response.Redirect("./List.aspx"); } private void btnReply_Click(object sender, System.EventArgs e) { string strQuery = null; strQuery = "Reply.aspx?Num=" + strNum + "&Ref=" + lblRef.Text; strQuery += "&Step=" + lblStep.Text + "&RefOrder=" + lblRefOrder.Text; Response.Redirect(strQuery); } } }