ASP.NET 기초 강의실

시삽: 레드플러스 님 
게시판 이동:
 제목 : [5] Business Layer : Controller Class : MemoController.cs
글번호: 303
작성자: 레드플러스
작성일: 2008/07/16 오전 10:47:00
조회수: 4885
using System;
using System.Data;
using System.Collections.Generic;//

namespace RedPlus.Modules.Memo
{
    public class MemoController
    {
        public static void AddMemo(MemoInfo objMemo)
        {
            DataProvider.Instance().AddMemo(objMemo.Name, objMemo.Email, objMemo.Title, objMemo.PostIP);
        }
        public static List<MemoInfo> GetMemos(int page)
        {
            //[1] Input : MemoInfo 타입의 List 제네릭 클래스 선언
            List<MemoInfo> lstMemo = new List<MemoInfo>();
            //[2] Process : 넘겨온 데이터만큼 lstMemo에 행 추가
            using (IDataReader objDr = // using구문이 끝나면 objDr닫힘
                DataProvider.Instance().GetMemos(page))
            {
                while (objDr.Read())
                {
                    MemoInfo objMemo = new MemoInfo();//레코드 하나씩 받기
                    objMemo.Num = Convert.ToInt32(objDr["Num"]);
                    objMemo.Name = objDr.GetString(1);
                    objMemo.Email = objDr["Email"].ToString();
                    objMemo.Title = objDr["Title"].ToString();
                    objMemo.PostDate = Convert.ToDateTime(objDr["PostDate"]);
                    objMemo.PostIP = objDr["PostIP"].ToString();
                    lstMemo.Add(objMemo);// 레코드 하나씩 저장
                }
            }
            //[3] Output
            return lstMemo; // List<T> 형태로 반환
        }

        public static int GetTotalMemo()
        {
            return DataProvider.Instance().GetTotalMemo();
        }

        public static int GetTotalFindMemo(string searchField, string searchQuery)
        {
            return DataProvider.Instance().GetTotalFindMemo(searchField, searchQuery);
        }

        public static List<MemoInfo> FindMemos(
            string strSearchField, string strSearchQuery)
        {
            //[1] Input : MemoInfo 타입의 List 제네릭 클래스 선언
            List<MemoInfo> lstMemo = new List<MemoInfo>();
            //[2] Process : 넘겨온 데이터만큼 lstMemo에 행 추가
            using (IDataReader objDr = // using구문이 끝나면 objDr닫힘
                DataProvider.Instance().FindMemos(strSearchField, strSearchQuery))
            {
                while (objDr.Read())
                {
                    MemoInfo objMemo = new MemoInfo();//레코드 하나씩 받기
                    objMemo.Num = Convert.ToInt32(objDr["Num"]);
                    objMemo.Name = objDr.GetString(1);
                    objMemo.Email = objDr["Email"].ToString();
                    objMemo.Title = objDr["Title"].ToString();
                    objMemo.PostDate = Convert.ToDateTime(objDr["PostDate"]);
                    objMemo.PostIP = objDr["PostIP"].ToString();
                    lstMemo.Add(objMemo);// 레코드 하나씩 저장
                }
            }
            //[3] Output
            return lstMemo; // List<T> 형태로 반환        }
        }

        public static List<MemoInfo> GetFindMemos(
            int intPage, string strSearchField, string strSearchQuery)
        {
            //[1] Input : MemoInfo 타입의 List 제네릭 클래스 선언
            List<MemoInfo> lstMemo = new List<MemoInfo>();
            //[2] Process : 넘겨온 데이터만큼 lstMemo에 행 추가
            using (IDataReader objDr = // using구문이 끝나면 objDr닫힘
                DataProvider.Instance().GetFindMemos(intPage, strSearchField, strSearchQuery))
            {
                while (objDr.Read())
                {
                    MemoInfo objMemo = new MemoInfo();//레코드 하나씩 받기
                    objMemo.Num = Convert.ToInt32(objDr["Num"]);
                    objMemo.Name = objDr.GetString(1);
                    objMemo.Email = objDr["Email"].ToString();
                    objMemo.Title = objDr["Title"].ToString();
                    objMemo.PostDate = Convert.ToDateTime(objDr["PostDate"]);
                    objMemo.PostIP = objDr["PostIP"].ToString();
                    lstMemo.Add(objMemo);// 레코드 하나씩 저장
                }
            }
            //[3] Output
            return lstMemo; // List<T> 형태로 반환        }
        }
    }
}
 
이전 글   다음 글 삭제 수정 답변 글쓰기 리스트


관련 아티클 리스트
  제       목 파일 작성자 작성일 조회
이전글 GridView로 리스트 출력시 번호를 순서대로 - 레드플러스 2009-08-13 6213
  [!] 3Tier + Enterprise Library 한줄 메모장(Memo Appl... - 레드플러스 2008-07-16 5905
  [1]한줄메모장 작성을 위한 테이블 및 저장 프로시저 작성 - 레드플러스 2008-07-16 6357
  [2] Visual Studio 2008 Solution Explorer 구성 WebMemoEL.jpg(59 KB) 레드플러스 2008-07-16 5092
  [3] DB Layer : Database Abstract Class : DataPr... - 레드플러스 2008-07-16 5335
  [3][1] SQL Server 전용 DB 처리 : SqlDataProvider.cs - 레드플러스 2008-07-16 5677
  [4] Biz로직 : Entity Class : MemoInfo.cs - 레드플러스 2008-07-16 4321
현재글 [5] Business Layer : Controller Class : MemoCon... - 레드플러스 2008-07-16 4885
  [6] Presentation Layer : UI : RedPlusMemo.ascx - 레드플러스 2008-07-16 7198
  [6][1] RedPlusMemo.ascx.cs - 레드플러스 2008-07-16 4454
다음글 [!] 답변형 게시판 : /WebReply/ - 레드플러스 2008-07-14 5464
 
손님 사용자 Anonymous (손님)
로그인 Home