블로그 이미지
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

Category

Recent Post

Recent Comment

Archive

2009. 10. 12. 21:35 .Net Project/ASP.NET 3.5 Sp1
반응형
 Upload/List.aspx



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

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <img src="images/가인.png" style="height: 163px; width: 173px" />
    <asp:GridView ID="ctlUploadList" runat="server"
        AutoGenerateColumns ="false" AllowPaging="true"
       
        PageSize="3">
        <Columns>
            <asp:BoundField DataField="Num" HeaderText="번호" />
            <asp:HyperLinkField DataTextField="Title" HeaderText="제목"
                DataNavigateUrlFormatString="View.aspx?Num={0}"
                DataNavigateUrlFields="Num" />
            <asp:TemplateField HeaderText="파일">
                <ItemTemplate>
                        <a href= 'files/<%# Eval("FileName") %>'>
                        <%# Eval("FileName") %>
                        </a>                    
                                           
                        <asp:HyperLink ID="HyperLink1" runat="server"  
                            NavigateUrl='<%# "~/Upload/files/" + Eval("FileName") %>' >
                            <%# Eval("FileName") %>
                        </asp:HyperLink>
                        
                    <asp:HyperLink ID="HyperLink2" runat="server" 
                     NavigateUrl='<%# "Down.aspx?FileName=" + Eval("FileName") %>'>
                      <img src="images/윤아.png" border="0" alt="다운로드"
                                                                width="30px" height="30px" />       
                      </asp:HyperLink>
                        
                      <%# FuncFileLink(Eval("FileName")) %>            
               
                </ItemTemplate>                      
            </asp:TemplateField>                        
        </Columns>  
    </asp:GridView>
    <asp:DropDownList ID="SearchField" runat="server">
        <asp:ListItem Value="Name">이름</asp:ListItem>
        <asp:ListItem Value="Title">제목</asp:ListItem>
        <asp:ListItem Value="Content">내용</asp:ListItem>
    </asp:DropDownList>
   
    <asp:TextBox ID="SearchQuery" runat="server"></asp:TextBox> <br />
    <asp:Button ID="btnSearch" runat="server" Text="검색" 
                           onclick="btnSearch_Click" /> &nbsp
    <asp:Button ID="btnWrite" runat="server" Text="글쓰기" 
                           onclick="btnWrite_Click" /> <br />
      </div>
    </form>
</body>
</html>


 Upload.List.Cs

using System;

public partial class Upload_List : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Display();
        }
    }

    private void Display()
    {
        UploadBiz ub = new UploadBiz();
        this.ctlUploadList.DataSource = ub.ListUpload();
        this.ctlUploadList.DataBind();
      
    }
   
    /// <summary>
    /// 검색관련
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
   
protected void btnSearch_Click(object sender, EventArgs e)
    {
        Response.Redirect(
                String.Format(
                    "Search.aspx?SearchField={0}&SearchQuery={1}"
                    , SearchField.SelectedValue
                    , SearchQuery.Text));
    }

    /// <summary>
    /// 쓰기관련
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
   
protected void btnWrite_Click(object sender, EventArgs e)
    {
        Response.Redirect("Write.aspx");
    }

    //코드 비하인트 페이지에서 링크 만들기
    protected string FuncFileLink(object fileName)
    {
        string name = Convert.ToString(fileName);
        if (!String.IsNullOrEmpty(name))
        {
            return "<a href='Down.aspx?FileName=" + name + "'>다운</a>";
        }
        else
        {
            return "-"; //파일이 첨부되지 않았다면...
        }
    }
}



반응형
posted by Magic_kit
2009. 10. 12. 21:31 .Net Project/ASP.NET 3.5 Sp1
반응형
 Upload.SQL

 --================================================--
------- 자료실 게시판 응용 프로그램-------
--================================================--

/*================================================*/
--[0] 자료실 게시판(Upload)용 테이블 설계
Create Table dbo.Upload
(
   Num Int Identity(1, 1) Not Null Primary Key,        --번호
   Name VarChar(25) Not Null,                          --이름
   Email VarChar(100) Null,                            --이메일 
   Title VarChar(150) Not Null,                        --제목
   PostDate DateTime Default GetDate() Not Null,       --작성일 
   PostIP VarChar(15) Not Null,                        --작성IP
   Content Text Not Null,                              --내용
   Password VarChar(20) Not Null,                      --비밀번호
   ReadCount Int Default 0,                            --조회수
   Encoding VarChar(10) Not Null,                      --인코딩(HTML/Text)
   Homepage VarChar(100) Null,                         --홈페이지
   ModifyDate DateTime Null,                           --수정일 
   ModifyIP VarChar(15) Null,                          --수정IP
 ---
 FileName VarChar(255) Null,                         --파일명
 FileSize Int Default(0),                            --파일크기
 DownCount Int Default(0)                            --다운수
)
Go
select *From Upload
/*================================================*/
--[1] ~ [6] : 기본 SQL문 예시문 6가지 작성
Insert Into Values
/*================================================*/
--[7]~ : 6개 이상 로직을 처리하는 저장 프로시저 생성
/*================================================*/
--[7] 기본 게시판(Upload)에 글을 작성하는 저장 프로시저 :WriteUpload
Create Proc dbo.WriteUpload
     @Name VarChar(25),
     @Email VarChar(100),
     @Title VarChar(150),
     @PostIP VarChar(15),
     @Content Text,
     @Password VarChar(20),
     @Encoding VarChar(10),
     @Homepage VarChar(100),
     @FileName VarChar(255),
     @FileSize Int 
--With Encryption
As
 Insert Upload
 (
    Name, Email, Title, PostIP, Content, Password,
    Encoding, Homepage, FileName, FileSize
 )
 Values
 (
      @Name, @Email, @Title, @PostIP, @Content,
      @Password, @Encoding,
      @Homepage, @FileName, @FileSize
 )
Go

/*================================================*/
--[8] 기본 게시판(Upload)에서 데이터를 읽어오는 저장 프로시저 :ListUpload

Create Procedure dbo.ListUpload
As
 Select * From Upload Order By Num Desc
Go

/*================================================*/
--[9] 해당 글을 세부적으로 읽어오는 저장 프로시저 :ViewUpload
Create Procedure dbo.ViewUpload
     @Num Int
As
     Update Upload
     Set ReadCount = ReadCount + 1
 Where Num = @Num

Select * From Upload Where Num = @Num
Go
/*================================================*/
--[10] 해당 글에 대한 비밀번호 읽어오는 저장 프로시저 :ReadPassword
Create Proc dbo.ReadPasswordUpload
     @Num Int
As
     Select Password From Upload Where Num = @Num
Go
/*================================================*/
--[11] 해당 글을 수정하는 저장 프로시저 : ModifyUpload
--Create Proc dbo.ModifyUpload
-- @Name VarChar(25),
-- @Email VarChar(100),
-- @Title VarChar(150),
-- @ModifyIP VarChar(15),
-- @ModifyDate DateTime,
-- @Content Text,
-- @Encoding VarChar(10),
-- @Homepage VarChar(100),
-- @Num Int
--As
-- Update Upload
-- Set
--  Name = @Name,
--  Email = @Email,
--  Title = @Title,
--  ModifyIP = @ModifyIP,
--  ModifyDate = @ModifyDate,
--  Content = @Content,
--  Encoding = @Encoding,
--  Homepage = @Homepage
-- Where Num = @Num
--Go
/*================================================*/
--[11] 해당 글을 수정하는 저장 프로시저 : ModifyUpload 수정
Create Proc dbo.ModifyUpload
     @Name VarChar(25),
     @Email VarChar(100),
     @Title VarChar(150),
     @ModifyIP VarChar(15),
     @Content Text,
     @Encoding VarChar(10),
     @Homepage VarChar(100),
     @Password VarChar(20), -- <-- 추가
     @FileName VarChar(255), -- <-- 추가
     @FileSize Int,   -- <-- 추가
     @Num Int
As
     Declare @cnt Int
     Select @cnt = Count(*) From Upload
               Where Num = @Num And Password = @Password

 If @cnt > 0  -- 넘겨져 온 번호와 암호가 맞는 데이터가 있다면...
    Update Upload
  Set
     Name = @Name,
     Email = @Email,
     Title = @Title,
     ModifyIP = @ModifyIP,
     ModifyDate = GetDate(),
     Content = @Content,
     Encoding = @Encoding,
     Homepage = @Homepage, FileName = @FileName, FileSize = @FileSize
                        Where Num = @Num
 Else
     Return -1 -- 암호가 틀리면 -1을 반환하자..
Go

/*================================================*/
--[12] 해당 글 지우는 저장 프로시저 :DeleteUpload
Create Proc dbo.DeleteUpload
     @Num Int
As
     Delete Upload Where Num = @Num
Go

Alter Proc dbo.DeleteUpload
     @Password VarChar(20),
     @Num Int
As
     Declare @cnt Int
 -- 암호와 번호가 맞으면 1을 반환
 Select @cnt = Count(*) From Upload
              Where Num = @Num And Password = @Password

 If @cnt > 0
  Delete Upload Where Num = @Num And Password = @Password
 Else 
  Return -1
Go

/*================================================*/
--[13] 검색 : SearchUpload 

Create Procedure dbo.SearchUpload
     @SearchField VarChar(25),
     @SearchQuery VarChar(25)
As
     Declare @strSql VarChar(250)
            Set @strSql = '
            Select * From Upload 
               Where ' + @SearchField + ' Like ''%' + @SearchQuery + '%'' 
            Order By Num Desc '
 --Print(@strSql)
 Exec(@strSql)
Go

SearchUpload 'FileName', 'gif'
Go
/*================================================*/
--[14] 다운로드 카운트 증가 : IncreaseDownCountUpload

Alter Proc dbo.IncreaseDownCountUpload
      @filename Int
As
      Update Upload
      Set DownCount = DownCount + 1
      Where filename = @filename
Go


<connectionStrings>
  <add name="ConnectionString" 
          connectionString="server=.;database=Upload;uid=Upload;pwd=1234"
          providerName="System.Data.SqlClient">
  </add>
 </connectionStrings> 



 Upload/Write.aspx

 



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

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      
    이름 : <asp:TextBox ID="txtName" runat="server"></asp:TextBox> <br />   
    이메일 : <asp:TextBox ID="txtmail" runat="server"></asp:TextBox><br />  
    홈페이지 : <asp:TextBox ID="txtHomepage" runat="server"></asp:TextBox>    
    제목 : <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox> <br />   
    내용 : <asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine"
                     Columns="20" Rows="5"></asp:TextBox>
            <img src="images/아라가키.png" width="100px"height="100px" /> <br />
    파일첨부 : <asp:FileUpload ID="ctlFileName" runat="server" /><br />
   
    인코딩 : <asp:RadioButtonList ID="LstEncoding" runat="server"
                       RepeatDirection="Horizontal" RepeatLayout="Flow">
                <asp:ListItem Selected="True">Text</asp:ListItem>
                <asp:ListItem>HTML</asp:ListItem>
                <asp:ListItem>Mixed</asp:ListItem>
             </asp:RadioButtonList><br />   
    암호 :<asp:TextBox ID="txtPassword" runat="server"
                                     TextMode="Password"></asp:TextBox><br />
   
    <asp:LinkButton ID="btnWrite" runat="server" onclick="btnWrite_Click">
             저장</asp:LinkButton> &nbsp
        <asp:LinkButton ID="btnList" runat="server" onclick="btnList_Click">리스트
        </asp:LinkButton>
       
    </div>
    </form>
</body>
</html>


 Upload/Write.Cs

using System;
using System.IO;

public partial class Upload_Write : System.Web.UI.Page
{
    //저장 버튼 클릭하였을경우
    protected void btnWrite_Click(object sender, EventArgs e)
    {
        //파일업로드
        string strDirectory = Server.MapPath(".") + "
\\files\\";
        string strFileName = String.Empty;
        if (!String.IsNullOrEmpty(ctlFileName.FileName)) //첨부된 파일이 존재 한다면..
        {
      //파일명추출 GetFilePath 사용하여 중복파일에 번호를 부여하여 처리해주고 싶을때...
      //파일명 중복처리 필요 

      strFileName = GetFilePath(strDirectory,ctlFileName.FileName); 
            //(경로 + 파일명) 으로 저장 실행
            ctlFileName.PostedFile.SaveAs(Path.Combine
                             (strDirectory, strFileName));
        }
        //DB저장
        UploadBiz ub = new UploadBiz();

        #region 엔터티사용
        //UploadEntity ue = new UploadEntity();
        //ue.Name = txtName.Text;
        //ue.Email = txtmail.Text;
        //ue.Title = txtTitle.Text;
        //ue.PostIP = Request.UserHostAddress;
        //ue.Content = txtContent.Text;
        //ue.Password = txtPassword.Text;
        //ue.Encoding = LstEncoding.SelectedValue;
        //ue.Homepage = txtHomepage.Text;
        //ue.FileName = strFileName; //변경
        //ue.FileSize = ctlFileName.PostedFile.ContentLength; //파일사이즈 
        #endregion

        ub.WriteUpload(txtName.Text
            , txtmail.Text
            , txtTitle.Text
            , Request.UserHostAddress
            , txtContent.Text
            , txtPassword.Text
            , LstEncoding.SelectedValue
            , txtHomepage.Text
            , strFileName //변경
            , ctlFileName.PostedFile.ContentLength);

        //리스트로 이동
        btnList_Click(null, null);
    }

    private string GetFilePath(string strBaseDirTemp, string strFileNameTemp)
    {
      string strName = //순수파일명 : Test 
      Path.GetFileNameWithoutExtension(strFileNameTemp); //[1]순수 파일명만 반환

        string strExt = //확장자 : .txt
            Path.GetExtension(strFileNameTemp); //[2]순수 확장자만 : .포함

        bool blnExists = true;
        int i = 0;
        while (blnExists)
        {
            //[3]Path.Combine(경로, 파일명) = 경로+파일명 = 경로 + 파일명
            if (File.Exists(Path.Combine(strBaseDirTemp, strFileNameTemp)))
            {
                strFileNameTemp = strName + "(" + ++i + ")" + strExt; //Text(3).txt
            }
            else
            {
                blnExists = false;
            }
        }
            return strFileNameTemp;
    }
    //리스트버튼 클릭하였을경우
    protected void btnList_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Upload/List.aspx");
    }
}









반응형
posted by Magic_kit
2009. 10. 12. 10:43 .Net Project/.Net C# Ex-Project
반응형
 - 참고사이트 (블로그)
    나모 :  http://www.namo.co.kr
    KOMAS MEDIA : http://www.komasmedia.co.kr
    네이버 : http://www.naver.com
    다음 : http://www.daum.net
    티스토리 : http://www.tistory.com
    예스소프트  : http://yesoft.net/ 

- 블로그 기본적인 기능
   1. 편리한 관리자인터페이스및 기능
   2. 무제한 카테고리등록
   3. RSS지원
   4. 자료입력 
   5. 최고의 접속분석로그 시스템
   6. 최적화면 DB설계모델
   7. 다양한 블로그 관리자 기능제공
   8. 모듈별 구성
   9. 다양한 수익모델 추가확장
   10. 자동안내/팝업창기능/입금계좌관리
   12. 회원관리시스템
   13. 관리자세부기능추가
   14. 태그기능
   15. 블로그설정기능세부화
   16. 엮인글쓰기기능
   17. 관리자 스킨(상단,바탕)관리기능
   18. 무제한사진업로드기능
   19. 외부트래백지원 (다음,야후,네이버등 모든 블로그의 트래백지원)
   20. 메모로그,포토로그,UCC로그기능추가
   21. 블로그관리자인터페이스변경
   22. 블로그상세관리기능추가
   23. 블로그포스트 광고삽입기능 추가
   24. CCL사용 설정기능 추가
   25. 실시간쪽지시스템
   26. 블로그 방문자 통계시스템

  
 
-  관리기능
    기본정보, 카테고리, 통계, 글관리
    글보내기, 개인정보, 스팸관리,
    친구관리, 알리미, 링크, 음악,
    함께쓰기, 애드클리닉, 메신져
   사이드바 설정, 스킨꾸기, 위젯관리

- 기본정보
  주소, 제목Tiltle, 설명Contents,
  내정보관리, 내별명, 내소개, 프로필 

- 카테고리
   새항목추가, 이름, 게시판형태
   게시판(펼쳐보기, 요약, 목록) 

- 방문자 현황 (최근,주별,시간)
   게시글 현황(조회, 스크랩)
   유입경로(키워드, 내부,외부유입)    

 - 글관리
   글보기(화면설정)
   글(카테고리,제목,상태,등록일)
   댓글(내용,작성자,ID, 등록일)
   엮은글(제목, 작성자, 등록일)
   방명록(내용, 작성자, 등록일)

URL 블로그 검색 관련 참고 사이트 정보 
- http://trendbridge.tistory.com/entry/블로그부터-메타형까지-웹20시대-新서비스들 

- 게시판 테이블 DB 작성 (엑셀파일)
   




반응형
posted by Magic_kit
2009. 10. 8. 12:26 .Net Project/ASP.NET 3.5 Sp1
반응형
 FrmFileUpload.aspx 디자인 모드

 




- 파일 업로드시 업로드 하여 저장 할 폴더를 지정하기 위하여 "file" 폴더 생성

- 폴더의 속성은 권한설정이 필요한데 사용자 "쓰기권한" 이상을 체크 하여한다. 

- 업로드 순서 -> 찾아보기 버튼 클릭하여 파일을 선택(대용량 파일) 하여 파일 업로드 

- 실행할 경우 레이블에 "유이.png"라는 파일이 표시되는것을 확인 가능 

- 확인우 파일을 클릭 후 다운로드 혹은 이미지 새로운 웹사이트 실행하여 이미지를 
   자세히 확인 가능 하다. 

- 파일업로드 후 파일 사이즈가 레이블에 표시되는것을 확인 할 수 있으며 파일 선택하지
   않고 업로드시 "파일을 선택해주십시오" 라는 메시지를 화면에 출력 
  
- 업로드 완료시 "업로드 완료 되었습니다" 라는 메시지가 출력된다 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmFileUpload.aspx.cs" Inherits="_10월8일_FrmFileUpload" %>

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <img src="../Image/윤아.png" width="100" height="100" />
        <img src="../Image/유이.png" width="100" height="100" /><br />
        &nbsp;<asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="파일업로드" Height="19px"
            onclick="Button1_Click" />
        <asp:Label ID="Label1" runat="server" Text="Label"
                              ForeColor="Red"></asp:Label>
    </div>
    </form>
</body>
</html>




 FrmFileUplad.aspx.Cs 이벤트 컨트롤 모드

using System;
using System.Drawing;

- 주요 명령
- FileUpload.Hasfile : 파일 첨부되었는지 확인 
- FileUpload.saveAs() : 서버측 경로에 파일 저장 
- Fileupload.postFile.contentLength : 첨부 파일의 사이즈(Byte)
- 대용량 파일 업로드 하고 싶을 때 Configuation 파일 추가

 <system.web>
    <!--
            컴파일된 페이지에 디버깅 기호를 삽입하려면
            compilation debug="true"로 설정하십시오. 이렇게
            하면 성능에 영향을 주므로 개발하는 동안에만
            이 값을 true로 설정하십시오.
        -->대용량 파일 크기를 지정하여 준다....
    추가 : <httpRuntime maxRequestLength="2000000"/> 

public partial class _10월8일_FrmFileUpload : System.Web.UI.Page
{  
    protected void Button1_Click(object sender, EventArgs e)
    {
        //파일이 첨부되었는지 확인
        if (FileUpload1.HasFile)
        {
            //업로드 : 같은 경로의 files라는 폴더에 넘겨온 파일명(폴더명X)으로 저장
            FileUpload1.SaveAs(
                    Server.MapPath(".") + "
\\file\\" + FileUpload1.FileName);

            //다운로드 링크 만들기
            string down = String.Format("<a href='{0}{1}'>{1}</a>", "./file/",
                                FileUpload1.FileName);
            Label1.Text = "업로드 되었습니다 <hr />" + down + "<hr />"
                          + "파일사이즈 : " + 
          //첨부된 파일의 사이즈(Byte)
          FileUpload1.PostedFile.ContentLength.ToString();
        }
        else
        {
            Label1.ForeColor = Color.Red;
            Label1.Text = "파일을 첨부하세요";
        }
    }
}




반응형
posted by Magic_kit