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; using System.IO; namespace SampleCS.Upload { /// /// Delete¿¡ ´ëÇÑ ¿ä¾à ¼³¸íÀÔ´Ï´Ù. /// public class Delete : System.Web.UI.Page { protected System.Web.UI.WebControls.Label lblNum; protected System.Web.UI.WebControls.TextBox txtPassword; protected System.Web.UI.WebControls.Button btnDelete; protected System.Web.UI.WebControls.Label lblMessage; protected System.Web.UI.WebControls.Button btnCancel; protected string strNum;// protected string strPassword;// protected string strFileName;// private void Page_Load(object sender, System.EventArgs e) { strNum = Request.QueryString["Num"]; if(strNum == null) Response.Redirect("./List.aspx"); if(!IsPostBack) { lblNum.Text = strNum; } } #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.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void btnDelete_Click(object sender, System.EventArgs e) { SqlConnection objCon = new SqlConnection(); objCon.ConnectionString = Application["CONNECTION_STRING"].ToString(); objCon.Open(); SqlCommand objCmd = new SqlCommand(); objCmd.Connection = objCon; objCmd.CommandText = "procViewUpload";// objCmd.CommandType = CommandType.StoredProcedure; objCmd.Parameters.Add("@Num", SqlDbType.Int); objCmd.Parameters["@Num"].Value = int.Parse(strNum); SqlDataReader objDr = objCmd.ExecuteReader(); if(objDr.Read()) { strPassword = objDr["Password"].ToString(); strFileName = objDr["FileName"].ToString(); } objDr.Close(); if(strPassword == txtPassword.Text.ToString()) { objCmd.CommandText = "procDeleteUpload"; objCmd.CommandType = CommandType.StoredProcedure; objCmd.ExecuteNonQuery(); objCon.Close(); //¾÷·Îµå µÈ ÆÄÀÏ »èÁ¦ FileInfo objFi = new FileInfo(Server.MapPath("/") + "\\redplusboardfiles\\Upload\\" + strFileName); if(objFi.Exists) { objFi.Delete(); } Response.Redirect("./List.aspx"); } else { lblMessage.Text = "ºñ¹Ð¹øÈ£°¡ Ʋ¸³´Ï´Ù."; } } private void btnCancel_Click(object sender, System.EventArgs e) { Response.Redirect("./View.aspx?Num=" + strNum); } } }