ASP.NET 기초 강의실

시삽: 레드플러스 님 
게시판 이동:
 제목 : ~/Schedule/ScheduleList.ascx.cs
글번호: 248
작성자: 레드플러스
작성일: 2008/07/02 오전 9:42:00
조회수: 4348
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.EnterpriseLibrary.Data;

public partial class Schedule_ScheduleListControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Empty : 인증과 연동(관리자만 글쓰기 버튼 보이기)
        //[1] 사용자 1명 비교
        if (Page.User.Identity.Name.ToLower() == "admin") {
            this.btnWrite.Visible = false;    
        }
        else {
            this.btnWrite.Visible = true;
        }
        ////[2] Administrators 그룹(역할)에 포함된 사용자에게 허가
        //if (Roles.IsUserInRole("Administrators")) {
        //    this.btnWrite.Visible = true;
        //}
        //else {
        //    this.btnWrite.Visible = false;
        //}
    }
    protected void btnWrite_Click(object sender, EventArgs e)
    {
        Response.Redirect("ScheduleWrite.aspx");
    }
    // 날짜(셀 하나)가 하나 만들어질 때마다 발생
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        CalendarDay d = e.Day;// 현재 날짜
        TableCell c = e.Cell;// 현재 셀(td)

        if (d.IsOtherMonth) // 다른 월이라면...
        {
            c.Controls.Clear(); // 셀 클리어    
        }
        else
        {
            string strTitle = ""; // 일정 상세 보기로 이동할 때 URL을 담을 그릇
            using (IDataReader objDr = DatabaseFactory.CreateDatabase("ConnectionString").ExecuteReader("GetSchedule", d.Date.Year, d.Date.Month, d.Date.Day))
            {
                while (objDr.Read())
                {
                    strTitle += String.Format("<br /><a href='ScheduleView.aspx?SYear={0}&SMonth={1}&SDay={2}&Num={3}'>{4}</a>", d.Date.Year, d.Date.Month, d.Date.Day, objDr["Num"], objDr["Title"]);
                }
                if (!String.IsNullOrEmpty(strTitle)) // 해당 날짜에 데이터가 있다면
                {
                    c.Controls.Add(new LiteralControl(strTitle)); // 셀에 링크 포함
                }
            }
        }
    }
    // 날짜를 클릭할 때마다 실행
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        // 년/월/일 값을 가지고 일정 등록 페이지로 이동
        string strUrl = String.Format("ScheduleWrite.aspx?SYear={0}&SMonth={1}&SDay={2}", this.Calendar1.SelectedDate.Year, this.Calendar1.SelectedDate.Month, this.Calendar1.SelectedDate.Day);
        Response.Redirect(strUrl);
    }
}
 
이전 글   다음 글 삭제 수정 답변 글쓰기 리스트


관련 아티클 리스트
  제       목 파일 작성자 작성일 조회
이전글 이전 10개 / 다음 10개 페이징 처리 메서드 - 레드플러스 2008-07-07 5844
  [!] 일정관리 모듈 : /WebSchedule/Schedule/ - 레드플러스 2008-07-01 8179
  [1] 테이블과 저장 프로시저 : ~/Schedule/Documents/Schedul... - 레드플러스 2008-07-01 4685
  [2] 일정 입력 : ~/Schedule/ScheduleWrite.ascx - 레드플러스 2008-07-01 4650
  ~/Schedule/ScheduleWrite.ascx.cs - 레드플러스 2008-07-01 4056
  [3] 일정 출력 : ~/Schedule/ScheduleList.ascx - 레드플러스 2008-07-02 4120
현재글 ~/Schedule/ScheduleList.ascx.cs - 레드플러스 2008-07-02 4348
  [4] 일정 수정 / 삭제 : ~/Schedule/ScheduleView.ascx - 레드플러스 2008-07-02 4084
  ~/Schedule/ScheduleView.ascx.cs - 레드플러스 2008-07-02 4248
다음글 3계층 프로그래밍 관련 단어 - 레드플러스 2008-06-30 4730
 
손님 사용자 Anonymous (손님)
로그인 Home