블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Category

Recent Post

Recent Comment

Archive

2009. 11. 2. 14:32 .Net Project/ASP.NET 3.5 Sp1
반응형

 Down.aspx.Cs


 
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;

/// <summary>
/// BoardDown : 완성형(DotNetNote) 게시판의 강제다운로드 페이지
/// </summary>
public partial class DotNetNote_BoardDown : System.Web.UI.Page
{
  #region Private Member Variables
  private int intNum;
  private string strFileName = "";
  private string strBaseDir = "";
  #endregion

  #region Event Handlers
  protected void Page_Load(object sender, System.EventArgs e)
  {
    intNum = Convert.ToInt32(
      Request.QueryString["Num"].ToString());

    SqlConnection objCon = new SqlConnection(
        ConfigurationManager.ConnectionStrings[
          "ConnectionString"].ConnectionString);
    objCon.Open();
    SqlCommand objCmd = new SqlCommand(
        "Select FileName From DotNetNote Where Num = "
        + intNum.ToString(), objCon);
    strFileName = objCmd.ExecuteScalar().ToString();
    objCon.Close();

    // 다운로드 폴더 지정
    strBaseDir = Server.MapPath("./MyFiles/");
    if (strFileName == null)
    {
      Response.Redirect("./BoardList.aspx");
    }
    else
    {
      //강제 다운로드 창 띄우기 주요 로직
      Response.Clear();
      Response.ContentType = "application/octet-stream";
      Response.AddHeader("Content-Disposition", "attachment;filename="
        + Server.UrlPathEncode(strFileName));
      Response.WriteFile(strBaseDir + strFileName);
      UpdateDownCount();//
      Response.End();
    }
  }

  #endregion

  #region Private Methods
  // 다운수 증가 로직
  private void UpdateDownCount()
  {
    SqlConnection objCon = new SqlConnection();
    objCon.ConnectionString =
      ConfigurationManager.ConnectionStrings[
        "ConnectionString"].ConnectionString;
    objCon.Open();

    SqlCommand objCmd = new SqlCommand();
    objCmd.Connection = objCon;

    objCmd.CommandText =
      "Update DotNetNote Set DownCount = DownCount + 1 "
      + "Where FileName = '" + strFileName + "'";
    objCmd.CommandType = CommandType.Text;
    objCmd.ExecuteNonQuery();

    objCon.Close();
    objCon = null;
  }
  #endregion
}





반응형
posted by Magic_kit
2009. 11. 2. 14:29 .Net Project/ASP.NET 3.5 Sp1
반응형
 Search.aspx


 

<!-- BoardSearch.aspx -->

<%@ Page Language="C#" AutoEventWireup="true"
  CodeFile="BoardSearch.aspx.cs"
  Inherits="DotNetNote_BoardSearch" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>검색 결과</title>
  <link href="../DotNetNote/DotNetNote.css"
    rel="stylesheet" type="text/css" />
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <h3>완성형 게시판</h3>
      <font style="font-size: 9pt; color: #ff0000">
        글&nbsp;검색 - 검색 조건에 맞는 항목을 나열합니다.</font>
      <hr width="100%" size="1" />
      <div align="center">
        <table border="0" cellpadding="0"
          cellspacing="0">
          <tr>
            <td>
              <asp:GridView ID="ctlBoardList"
                runat="server" AutoGenerateColumns="False"
                CellPadding="4" ForeColor="Black"
                GridLines="None" AllowPaging="True"
                DataKeyNames="Num"
                OnPageIndexChanging="ctlBoardList_PageIndexChanging"
                PageSize="10">
                <FooterStyle BackColor="#5D7B9D"
                  Font-Bold="True" ForeColor="White" />
                <Columns>
                  <asp:TemplateField HeaderText="번호">
                    <ItemTemplate>
                      <%# Eval("Num") %>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center"
                      Width="30px" />
                  </asp:TemplateField>
                  <asp:TemplateField HeaderText="제 목">
                    <ItemTemplate>
                      <a href='BoardView.aspx?Num=<%# Eval(
                        "Num") %>&SearchField=<%=Request[
                          "SearchField"]%>&SearchQuery=<%=Request[
                            "SearchQuery"]%>'>
                        <%# Eval("Title") %>
                      </a>
                    </ItemTemplate>
                    <HeaderStyle Width="350px" />
                  </asp:TemplateField>
                  <asp:BoundField DataField="Name"
                    HeaderText="작성자">
                    <HeaderStyle HorizontalAlign="Center"
                      Width="60px" />
                  </asp:BoundField>
                  <asp:BoundField DataField="PostDate"
                    HeaderText="작성일" DataFormatString="{0:yyyy-MM-dd}"
                    HtmlEncode="False">
                    <HeaderStyle HorizontalAlign="Center"
                      Width="70px" />
                  </asp:BoundField>
                  <asp:BoundField DataField="ReadCount"
                    HeaderText="조회수">
                    <ItemStyle HorizontalAlign="Right" />
                    <HeaderStyle HorizontalAlign="Center"
                      Width="50px" />
                  </asp:BoundField>
                </Columns>
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <EditRowStyle BackColor="#999999" />
                <SelectedRowStyle BackColor="#E2DED6"
                  Font-Bold="True" ForeColor="#333333" />
                <PagerStyle BackColor="#C0C0FF"
                  ForeColor="Black" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#5D7B9D"
                  Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White"
                  ForeColor="#284775" />
                <PagerSettings Mode="NumericFirstLast" />
              </asp:GridView>
            </td>
          </tr>
          <tr>
            <td>
              <table border="0" width="100%"
                cellpadding="3" cellspacing="0">
                <tr>
                  <td width="25%">
                    &nbsp;</td>
                  <td width="50%" align="center">
                    <font face="굴림"></font>
                  </td>
                  <td width="25%" align="right">
                    <asp:Button ID="btnWrite" runat="server"
                      BorderColor="#404040" BorderStyle="Groove"
                      BorderWidth="1px" Text="검색종료"
                      OnClick="btnWrite_Click"></asp:Button>&nbsp;
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </div>
    </div>
  </form>
</body>
</html>


 Search.aspx.Cs

 using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;

/// <summary>
/// BoardSearch : 완성형(DotNetNote) 게시판의 검색 페이지
/// </summary>
public partial class DotNetNote_BoardSearch : System.Web.UI.Page
{
  #region Event Handlers
  // 검색 결과 출력
  protected void Page_Load(object sender, System.EventArgs e)
  {
    if (!Page.IsPostBack)
    {
      ReadData();
    }
  }

  // 글쓰기 페이지로 이동
  protected void btnWrite_Click(object sender, System.EventArgs e)
  {
    Response.Redirect("./BoardList.aspx");
  }

  // 페이지 링크 이동 구현
  protected void ctlBoardList_PageIndexChanging(
    object sender, GridViewPageEventArgs e)
  {
    this.ctlBoardList.PageIndex = e.NewPageIndex;
    ReadData();
  }
  #endregion

  #region Private Methods
  //데이터 읽어서 그리드뷰에 출력하는 함수(메서드)
  private void ReadData()
  {
    SqlConnection objCon = new SqlConnection(
      ConfigurationManager.ConnectionStrings[
        "ConnectionString"].ConnectionString);
    objCon.Open();

    SqlCommand objCmd = new SqlCommand("SearchDotNetNote", objCon);
    objCmd.CommandType = CommandType.StoredProcedure;

    SqlDataAdapter objDa = new SqlDataAdapter();
    objDa.SelectCommand = objCmd;

    objCmd.Parameters.Add(
      "@SearchField", SqlDbType.VarChar, 25).Value =
        Request["SearchField"];
    objCmd.Parameters.AddWithValue(
      "@searchQuery", Request["SearchQuery"]);

    DataSet objDs = new DataSet();
    objDa.Fill(objDs, "DotNetNote");

    ctlBoardList.DataSource = objDs;
    ctlBoardList.DataBind();
  }
  #endregion
}





반응형
posted by Magic_kit
2009. 11. 2. 14:26 .Net Project/ASP.NET 3.5 Sp1
반응형
 Delete.aspx

 <!-- BoardDelete.aspx -->

<%@ Page Language="C#" AutoEventWireup="true"
  CodeFile="BoardDelete.aspx.cs"
  Inherits="DotNetNote_BoardDelete" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>글 삭제</title>

  <script language="javascript">
  function ConfirmDelete()
  {
   var varFlag = false;
   if(window.confirm("현재 글을 삭제하시겠습니까?"))
   {
    varFlag = true;
   }
   else
   {
    varFlag = false;
   }
   return varFlag;
  }
  </script>

  <link href="../DotNetNote/DotNetNote.css"
    rel="stylesheet" type="text/css" />
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <h3>완성형 게시판</h3>
      <font style="font-size: 9pt; color: #ff0000">
        글&nbsp;삭제 - 글을 삭제하려면 글 작성시에 기록하였던
        비밀번호가 필요합니다.</font>
      <hr width="100%" size="1" />
      <p align="center">
        <asp:Label ID="lblNum" runat="server"
          ForeColor="Red"></asp:Label>
      번 글을 지우시겠습니까?
      <p align="center">
        비밀번호 :
        <asp:TextBox ID="txtPassword" runat="server"
          BorderStyle="Groove" TextMode="Password"></asp:TextBox>
        <asp:Button ID="btnDelete" runat="server"
          BorderStyle="Groove" Text="지우기"
          OnClick="btnDelete_Click"></asp:Button>&nbsp;
        <asp:Button ID="btnCancel" runat="server"
          BorderStyle="Groove" Text="취소"
          OnClick="btnCancel_Click"></asp:Button></p>
      <p align="center">
        <asp:Label ID="lblMessage" runat="server"
          ForeColor="Red" /></p>
    </div>
  </form>
</body>
</html>


 Delete.aspx.Cs

 using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;

/// <summary>
/// BoardDelete : 완성형(DotNetNote) 게시판의 삭제 페이지
/// </summary>
public partial class DotNetNote_BoardDelete : System.Web.UI.Page
{
  #region Private Member Variables
  private string strNum = "";//글 번호
  private string strPassword = "";//비밀번호
  private string strFileName = "";//파일명
  private string strAnswerNum;//답변글 번호
  #endregion

  #region Event Handlers
  //넘겨져 온 번호에 해당하는 글 삭제 메시지
  protected void Page_Load(object sender, System.EventArgs e)
  {
    // 아래 코드는 ClientOnClick과 같은 역할을 하는 코드임
    this.btnDelete.Attributes["OnClick"] = "return ConfirmDelete();";
    strNum = Request.QueryString["Num"];
    if (strNum == null)
      Response.Redirect("./BoardList.aspx");
    if (!IsPostBack)
    {
      lblNum.Text = strNum;
    }
  }

  //글 삭제 처리
  protected void btnDelete_Click(object sender, System.EventArgs e)
  {
    SqlConnection objCon = new SqlConnection();
    objCon.ConnectionString = ConfigurationManager.ConnectionStrings[
      "ConnectionString"].ConnectionString;
    objCon.Open();

    SqlCommand objCmd = new SqlCommand();
    objCmd.Connection = objCon;

    objCmd.CommandText = "ViewDotNetNote";//
    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();
      strAnswerNum = objDr["AnswerNum"].ToString();
    }
    objDr.Close();

    if (strPassword == txtPassword.Text.ToString())
    {
      //업로드 된 파일 삭제
      string strBaseDir = Server.MapPath("./MyFiles");
      FileInfo objFi = new FileInfo(
        Path.Combine(strBaseDir, strFileName));
      if (objFi.Exists)
      {
        objFi.Delete();
      }

      objCmd.CommandText = "DeleteDotNetNote";
      objCmd.CommandType = CommandType.StoredProcedure;
      objCmd.ExecuteNonQuery();
      objCon.Close();

      Response.Redirect("./BoardList.aspx");
    }
    else
    {
      lblMessage.Text = "비밀번호가 틀립니다.";
    }
  }

  //글 삭제 취소 버튼 링크
  protected void btnCancel_Click(object sender, System.EventArgs e)
  {
    Response.Redirect("./BoardView.aspx?Num=" + strNum);
  }
  #endregion
}





반응형
posted by Magic_kit
2009. 11. 2. 14:24 .Net Project/ASP.NET 3.5 Sp1
반응형
 Modify.aspx

 


<!-- BoardModify.aspx -->

<%@ Page Language="C#" AutoEventWireup="true"
  CodeFile="BoardModify.aspx.cs"
  Inherits="DotNetNote_BoardModify" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>글 수정</title>
  <link href="../DotNetNote/DotNetNote.css"
    rel="stylesheet" type="text/css" />
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <h3>
        완성형 게시판</h3>
      <font style="font-size: 9pt; color: #ff0000">
        글&nbsp;수정 - 아래 항목을 수정하세요.</font>
      <hr width="100%" size="1" />
      <table id="Table1" style="border-collapse: collapse"
        bordercolor="black" cellspacing="0"
        rules="none" width="600" align="center"
        bgcolor="white">
        <tr>
          <td align="right" width="100" bgcolor="#efefef">
            번&nbsp; 호
          </td>
          <td width="500">
            <asp:Label ID="lblNum" runat="server"></asp:Label>
          </td>
        </tr>
        <tr>
          <td align="right" width="100" bgcolor="#efefef">
            *이&nbsp; 름
          </td>
          <td width="500">
            <asp:TextBox ID="txtName" runat="server"
              BorderWidth="1px" BorderStyle="Solid"
              MaxLength="10" Width="250px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="valName"
              runat="server" ControlToValidate="txtName"
              Display="None" ErrorMessage="이름을 작성하세요."
              SetFocusOnError="True"></asp:RequiredFieldValidator><font
                face="굴림">&nbsp;</font></td>
        </tr>
        <tr>
          <td align="right" bgcolor="#efefef">
            E-mail
          </td>
          <td>
            <asp:TextBox ID="txtEmail" runat="server"
              BorderWidth="1px" BorderStyle="Solid"
              MaxLength="80" Width="300px"></asp:TextBox>
              <asp:RegularExpressionValidator
                ID="valEmail" runat="server"
                ValidationExpression=
                "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                Display="None" ControlToValidate="txtEmail"
                ErrorMessage="* 메일형식이 올바르지 않습니다">
                </asp:RegularExpressionValidator></td>
        </tr>
        <tr>
          <td align="right" bgcolor="#efefef">
            Homepage
          </td>
          <td>
            <asp:TextBox ID="txtHomepage" runat="server"
              BorderWidth="1px" BorderStyle="Solid"
              MaxLength="80" Width="300px"></asp:TextBox>
              <asp:RegularExpressionValidator
                ID="valHomepage" runat="server"
                ValidationExpression=
                "http://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?"
                Display="None" ControlToValidate="txtHomepage"
                ErrorMessage="* 홈페이지 형식이 올바르지 않습니다">
                </asp:RegularExpressionValidator></td>
        </tr>
        <tr>
          <td align="right" bgcolor="#efefef">
            *제&nbsp; 목
          </td>
          <td>
            <asp:TextBox ID="txtTitle" runat="server"
              BorderWidth="1px" BorderStyle="Solid"
              MaxLength="30" Width="480px"></asp:TextBox><font
                face="굴림">&nbsp;</font>
            <asp:RequiredFieldValidator ID="valTitle"
              runat="server" Display="None"
              ControlToValidate="txtTitle"
              ErrorMessage="* 제목을 기입해 주세요">
              </asp:RequiredFieldValidator></td>
        </tr>
        <tr>
          <td align="right" bgcolor="#efefef">
            *내&nbsp; 용
          </td>
          <td>
            <asp:TextBox ID="txtContent" runat="server"
              BorderWidth="1px" BorderStyle="Solid"
              Width="480px" TextMode="MultiLine"
              Rows="10"></asp:TextBox><br />
            <asp:RequiredFieldValidator ID="valContent"
              runat="server" Display="None"
              ControlToValidate="txtContent"
              ErrorMessage="* 내용을 기입해 주세요"
              SetFocusOnError="True">
              </asp:RequiredFieldValidator>
          </td>
        </tr>
        <tr>
          <td align="right" bgcolor="#efefef">
            *인코딩
          </td>
          <td>
            <font face="굴림">
              <asp:RadioButtonList ID="rdoEncoding"
                runat="server" RepeatDirection="Horizontal">
                <asp:ListItem Value="Text" Selected="True">Text</asp:ListItem>
                <asp:ListItem Value="HTML">HTML</asp:ListItem>
                <asp:ListItem Value="Mixed">Mixed</asp:ListItem>
              </asp:RadioButtonList></font></td>
        </tr>
        <tr>
          <td align="right" bgcolor="#efefef">
            *비밀번호
          </td>
          <td>
            <asp:TextBox ID="txtPassword" runat="server"
              BorderWidth="1px" BorderStyle="Solid"
              MaxLength="20" Width="250px"
              TextMode="Password" EnableViewState="False">
              </asp:TextBox>&nbsp;
            <asp:RequiredFieldValidator ID="valPassword"
              runat="server" Display="None"
              ControlToValidate="txtPassword"
              ErrorMessage="* 비밀번호를 기입해 주세요"
              SetFocusOnError="True"></asp:RequiredFieldValidator>
              </td>
        </tr>
      </table>
      <p align="center">
        <asp:Button ID="btnModify" runat="server"
          BorderWidth="1px" BorderStyle="Solid"
          Width="80px" BorderColor="Gray"
          Text="변경내용저장" OnClick="btnModify_Click">
        </asp:Button><font face="굴림">&nbsp;
        </font>
        <asp:Button ID="btnList" runat="server"
          BorderWidth="1px" BorderStyle="Groove"
          Width="80px" BorderColor="Gray"
          Text="리스트" CausesValidation="False"
          OnClick="btnList_Click"></asp:Button></p>
      <p align="center">
        <asp:Label ID="lblError" runat="server"
          EnableViewState="False" ForeColor="Red"></asp:Label></p>
      <p align="center">
        <asp:ValidationSummary ID="ValidationSummary1"
          runat="server" ShowMessageBox="True"
          ShowSummary="False" DisplayMode="List">
        </asp:ValidationSummary>
      </p>
    </div>
  </form>
</body>
</html>


 Modify.aspx.Cs

 using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;

/// <summary>
/// BoardModify : 완성형(DotNetNote) 게시판의 수정 페이지
/// </summary>
public partial class DotNetNote_BoardModify : System.Web.UI.Page
{
  #region Private Member Variables
  protected string strNum;//앞에서 넘겨져 온 번호 저장
  #endregion

  #region Event Handlers
  //넘겨져 온 번호에 해당하는 데이터 로드
  protected void Page_Load(object sender, System.EventArgs e)
  {
    strNum = Request.QueryString["Num"];
    if (strNum == null)
    {
      Response.Redirect("./BoardList.aspx");
    }
    if (!this.IsPostBack)
    {
      ReadData();//넘겨져 온 번호에 해당하는 글만 읽어서 각 레이블에 출력
    }
  }

  //글 수정 처리
  protected void btnModify_Click(object sender, System.EventArgs e)
  {
    SqlConnection objCon = new SqlConnection();
    objCon.ConnectionString = ConfigurationManager.ConnectionStrings[
      "ConnectionString"].ConnectionString;
    objCon.Open();

    string strName = txtName.Text.Replace("&", "&amp;").Replace(
      "<", "&lt;").Replace(">", "&gt;");
    string strTitle = txtTitle.Text.Replace("&", "&amp;").Replace(
      "<", "&lt;").Replace(">", "&gt;");

    SqlCommand objCmd = new SqlCommand();
    objCmd.Connection = objCon;
    objCmd.CommandText = "ReadPasswordDotNetNote";
    objCmd.CommandType = CommandType.StoredProcedure;
    objCmd.Parameters.Add("@Num", SqlDbType.Int);
    objCmd.Parameters["@Num"].Value = int.Parse(strNum);
    string strPassword = objCmd.ExecuteScalar().ToString();

    objCmd.Parameters.Clear();

    if (strPassword == txtPassword.Text.ToString())
    {
      objCmd.CommandText = "ModifyDotNetNote";

      objCmd.Parameters.Add("@Name", SqlDbType.VarChar, 25);
      objCmd.Parameters.Add("@Email", SqlDbType.VarChar, 100);
      objCmd.Parameters.Add("@Title", SqlDbType.VarChar, 150);
      objCmd.Parameters.Add("@ModifyIP", SqlDbType.VarChar, 15);
      objCmd.Parameters.Add("@ModifyDate", SqlDbType.DateTime);
      objCmd.Parameters.Add("@Content", SqlDbType.Text);
      objCmd.Parameters.Add("@Encoding", SqlDbType.VarChar, 10);
      objCmd.Parameters.Add("@Homepage", SqlDbType.VarChar, 100);
      objCmd.Parameters.Add("@Num", SqlDbType.Int);

      objCmd.Parameters["@Name"].Value = strName;
      objCmd.Parameters["@Email"].Value = txtEmail.Text;
      objCmd.Parameters["@Title"].Value = strTitle;
      objCmd.Parameters["@ModifyIP"].Value = Request.UserHostAddress;
      objCmd.Parameters["@ModifyDate"].Value = DateTime.Now;//수정일
      objCmd.Parameters["@Content"].Value = txtContent.Text;
      objCmd.Parameters["@Encoding"].Value =
        rdoEncoding.SelectedItem.Text;
      objCmd.Parameters["@Homepage"].Value = txtHomepage.Text;
      objCmd.Parameters["@Num"].Value = strNum;

      objCmd.CommandType = CommandType.StoredProcedure;
      objCmd.ExecuteNonQuery();

      Response.Redirect("./BoardView.aspx?Num=" + strNum);//수정했던 글   
    }
    else
    {
      lblError.Text = "비밀번호가 틀립니다.";
    }
    objCon.Close();
  }

  //글 리스트 이동 버튼
  protected void btnList_Click(object sender, System.EventArgs e)
  {
    Response.Redirect("./BoardList.aspx");
  }
  #endregion

  #region Private Methods
  //각 레이블에 데이터 로드
  private void ReadData()
  {
    SqlConnection objCon = new SqlConnection();
    objCon.ConnectionString = ConfigurationManager.ConnectionStrings[
      "ConnectionString"].ConnectionString;
    objCon.Open();

    SqlCommand objCmd = new SqlCommand();
    objCmd.Connection = objCon;
    objCmd.CommandText = "ViewDotNetNote";
    objCmd.CommandType = CommandType.StoredProcedure;
    objCmd.Parameters.Add("@Num", SqlDbType.Int);
    objCmd.Parameters["@Num"].Value = int.Parse(strNum);
    objCmd.ExecuteNonQuery();
    SqlDataReader objDr = objCmd.ExecuteReader();
    if (objDr.Read())
    {
      lblNum.Text = strNum;
      txtName.Text = objDr["Name"].ToString();//이름
      txtEmail.Text = objDr["Email"].ToString();
      txtHomepage.Text = objDr["Homepage"].ToString();
      txtTitle.Text = objDr["Title"].ToString();
      txtContent.Text = objDr["Content"].ToString();
    }
    objDr.Close();
    objCon.Close();
  }
  #endregion
}




반응형
posted by Magic_kit