1 using System;
 2
using System;
 2 using System.Data;
 3
using System.Data;
 3 using Microsoft.Practices.EnterpriseLibrary.Data; //
 4
using Microsoft.Practices.EnterpriseLibrary.Data; //
 4 5
 5 public partial class Upload_DeleteControl : System.Web.UI.UserControl
 6
public partial class Upload_DeleteControl : System.Web.UI.UserControl
 6
 ...{
 7
...{
 7
 protected void Page_Load(object sender, EventArgs e) ...{
 8
    protected void Page_Load(object sender, EventArgs e) ...{
 8 // 넘겨져 온 쿼리스트링 값 검사
 9
        // 넘겨져 온 쿼리스트링 값 검사
 9
 if (String.IsNullOrEmpty(Request["Num"])) ...{
10
        if (String.IsNullOrEmpty(Request["Num"])) ...{
10 Response.Write("잘못된 요청입니다.");
11
            Response.Write("잘못된 요청입니다.");
11 Response.End();
12
            Response.End();
12 }
13
        }
13
 else ...{
14
        else ...{
14 lblNum.Text = Request["Num"];
15
            lblNum.Text = Request["Num"];
15 }
16
        }
16 }
17
    }
17
 protected void btnDelete_Click(object sender, EventArgs e) ...{
18
    protected void btnDelete_Click(object sender, EventArgs e) ...{
18 // 이미 업로드된 파일명 얻기
19
        // 이미 업로드된 파일명 얻기
19 string FileName = DatabaseFactory.CreateDatabase(
20
        string FileName = DatabaseFactory.CreateDatabase(
20 "ConnectionString").ExecuteScalar(
21
                "ConnectionString").ExecuteScalar(
21 CommandType.Text
22
                    CommandType.Text
22 , "Select FileName From Upload Where Num = " 
23
                        , "Select FileName From Upload Where Num = " 
23 + Request["Num"]).ToString();        
24
                        + Request["Num"]).ToString();        
24 // 넘겨온 번호 값에 해당하는 데이터 삭제(단, 예전 암호가 맞다면...)
25
        // 넘겨온 번호 값에 해당하는 데이터 삭제(단, 예전 암호가 맞다면...)
25 int result = DatabaseFactory.CreateDatabase("ConnectionString").
26
        int result = DatabaseFactory.CreateDatabase("ConnectionString").
26 ExecuteNonQuery(
27
            ExecuteNonQuery(
27 "DeleteUpload", txtPassword.Text, Request["Num"]);
28
                "DeleteUpload", txtPassword.Text, Request["Num"]);
28
 if (result == -1) ...{
29
        if (result == -1) ...{
29 lblError.Text = "암호가 틀립니다.";
30
            lblError.Text = "암호가 틀립니다.";
30 }
31
        }
31
 else ...{
32
        else ...{
32 //Response.Write(FileName); Response.End();
33
            //Response.Write(FileName); Response.End();
33 // 실제 파일 삭제
34
            // 실제 파일 삭제
34 try
35
            try
35
 ...{
36
            ...{
36 System.IO.File.Delete(
37
                System.IO.File.Delete(
37 Server.MapPath(".") + "\\files\\" + FileName);
38
                    Server.MapPath(".") + "\\files\\" + FileName);
38 }
39
            }
39 catch (Exception)
40
            catch (Exception)
40
 ...{
41
            ...{
41 }
42
            }
42 Response.Redirect("List.aspx"); // 리스트로 이동
43
            Response.Redirect("List.aspx"); // 리스트로 이동
43 }
44
        }
44 }
45
    }
45 }
46
}
46