protected void Page_Load(object sender, EventArgs e) { //init LoginedMember = (Member)Session["MEMBER"]; dbManager = (DBManager)Session["DBadmin"]; int ColCount = 5; TableRow tr = new TableRow(); TableCell td = new TableCell(); tr.Cells.Add(td); //테이블 제목열 //개선필요(isjeong 7. 27) for (int i = 0; i < ColCount; i++) { td = new TableCell(); switch (i) { case 0: td.Text = "영화제목"; break; case 1: td.Text = "상영시작일"; break; case 2: td.Text = "상영종료일"; break; case 3: td.Text = "상영관"; break; case 4: td.Text = "관람등급"; break; } tr.Cells.Add(td); } tr.BackColor = Color.FromName("#ccccff"); Table1.Rows.Add(tr); //영화 목록 호출 string Command = "SELECT * FROM Movie"; SqlDataReader reader = dbManager.GetDataList(Command, new List <Tuple <string, object> >()); List <Movie> Movies = Movie.SqlDataReaderToMember(reader); foreach (var Movie in Movies) { tr = new TableRow(); td = new TableCell(); //테이블의 열마다 체크박스를 추가하고 ID를 열의 ID와 매핑시킨다. CheckBox chkbox = new CheckBox(); chkbox.ID = Movie.MovieID.ToString(); td.Controls.Add(chkbox); tr.Cells.Add(td); // 루프를 돌면서 각 셀을 설정한다. for (int j = 0; j < ColCount; j++) { td = new TableCell(); //임시 switch (j) { case 0: td.Text = Movie.MovieID; break; case 1: td.Text = Movie.Moviename; break; case 2: td.Text = Movie.Playstartdatetime; break; case 3: td.Text = Movie.Playenddatetime; break; case 4: td.Text = Movie.Viewingclass; break; } tr.Cells.Add(td); } tr.BackColor = Color.White; Table1.Rows.Add(tr); } }
protected void Page_Load(object sender, EventArgs e) { //DB관리자를 1개 생성하여 세션으로 관리하여 무분별하게 생성되는 것을 막습니다. dbManager = new DBManager("server=(local);database=MovieBookingDB;Integrated Security=SSPI"); Session["DBAdmin"] = dbManager; }
//페이지로드 protected void Page_Load(object sender, EventArgs e) { SelectedTheater = DropDownList_Theater.SelectedValue.Trim(); LoginedMember = (Member)Session["MEMBER"]; dbManager = (DBManager)Session["DBAdmin"]; //사용자가 아무 영화를 클릭하지 않은 초기화 상태라면 if (DropDownList_MovieName.SelectedValue == "") { String Command = "Select * From Movie"; SqlDataReader reader = dbManager.GetDataList(Command, new List <Tuple <string, object> >()); List <Movie> Movies = Movie.SqlDataReaderToMember(reader); DropDownList_MovieName.DataTextField = "Moviename"; DropDownList_MovieName.DataValueField = "MovieID"; DropDownList_MovieName.DataSource = Movies; DropDownList_MovieName.DataBind(); } //영화를 선택하였으니 해당 영화에 맞는 시간을 보여줌. else { SelectedMovieID = DropDownList_MovieName.SelectedValue.Trim(); String Command = "Select * From Movieschedule Where MovieID = @MovieID"; List <Tuple <string, object> > Params = new List <Tuple <string, object> >(); Params.Add(new Tuple <string, object>("@MovieID", SelectedMovieID)); SqlDataReader reader = dbManager.GetDataList(Command, Params); List <Movieschedule> PlayTimes = Movieschedule.SqlDataReaderToMember(reader); DropDownList_PlayDate.DataTextField = "Playtime"; DropDownList_PlayDate.DataValueField = "Playtime"; DropDownList_PlayDate.DataSource = PlayTimes; DropDownList_PlayDate.DataBind(); Params.Clear(); //상영관을 선택하지 않았음. if (DropDownList_PlayDate.SelectedValue == "") { ; } //상영관을 선택하였으면 관이랑 남은 좌석수 표시 else { SelectedPlayDate = DropDownList_PlayDate.SelectedValue.Trim(); DropDownList_Theater.DataTextField = "RemaindSeatMent"; DropDownList_Theater.DataValueField = "TheaterID"; DropDownList_Theater.DataSource = PlayTimes; DropDownList_Theater.DataBind(); Params.Clear(); if (TextBox_TicketCount.Text != "") { remainTicket = Convert.ToInt32(TextBox_TicketCount.Text); } if (remainTicket != 0) { if (SelectedMovieID == "" || SelectedPlayDate == "" || SelectedTheater == "") { return; } SetTable(); } } } }
protected void Page_Load(object sender, EventArgs e) { int ColCount = 4; LoginedMember = (Member)Session["MEMBER"]; dbManager = (DBManager)Session["DBadmin"]; //Table 셋팅 TableRow tr = new TableRow(); TableCell td = new TableCell(); tr.Cells.Add(td); //테이블 이름중 1번은 계정명이므로 제외하고 테이블 제목으로 만든다. List <string> TableNames = dataSet.Point.GetMemberNameToSting(); //테이블 제목열 for (int i = 0; i < ColCount; i++) { td = new TableCell(); td.Text = TableNames[i + 1]; tr.Cells.Add(td); } tr.BackColor = Color.FromName("#ccccff"); Table1.Rows.Add(tr); //테이블 내용을 채우기 전에 포인트 사용내역을 받아온다. string Command = "SELECT * FROM Point WHERE ID=@id ORDER BY Occuredatetime ASC"; List <Tuple <string, object> > Params = new List <Tuple <string, object> >(); Params.Add(new Tuple <string, object>("@id", LoginedMember.ID)); SqlDataReader reader = dbManager.GetDataList(Command, Params); List <dataSet.Point> points = dataSet.Point.SqlDataReaderToMember(reader); //포인트 사용내역만큼 열을 만들어 채워준다. foreach (var point in points) { tr = new TableRow(); td = new TableCell(); tr.Cells.Add(td); // 루프를 돌면서 각 셀을 설정한다. for (int j = 0; j < ColCount; j++) { td = new TableCell(); //임시 switch (j) { case 0: td.Text = point.Occuredatetime; break; case 1: td.Text = point.Usedvalue; break; case 2: td.Text = point.Rechargedvalue; break; case 3: td.Text = point.Remainvalue; RecentlyRemainPoint = Convert.ToInt32(td.Text); break; } tr.Cells.Add(td); } tr.BackColor = Color.White; Table1.Rows.Add(tr); } }
//페이지로드 protected void Page_Load(object sender, EventArgs e) { //세션 로드 LoginedMember = (Member)Session["MEMBER"]; dbManager = (DBManager)Session["DBAdmin"]; //preSelectedValue input SelectedMovieID = DropDownList_MovieName.SelectedValue.Trim(); SelectedPlayDate = DropDownList_PlayDate.SelectedValue.Trim(); SelectedTheater = DropDownList_Theater.SelectedValue.Trim(); //사용자가 아무 영화를 클릭하지 않은 초기화 상태라면 if (DropDownList_MovieName.SelectedValue == "" || DropDownList_MovieName.SelectedValue == NotSelected) { String Command = "Select * From Movie"; SqlDataReader reader = dbManager.GetDataList(Command, new List <Tuple <string, object> >()); List <Movie> Movies = Movie.SqlDataReaderToMember(reader); Movie notSelectValue = new Movie(); notSelectValue.Moviename = NotSelected; notSelectValue.MovieID = NotSelected; Movies.Add(notSelectValue); DropDownList_MovieName.DataTextField = "Moviename"; DropDownList_MovieName.DataValueField = "MovieID"; DropDownList_MovieName.DataSource = Movies; DropDownList_MovieName.DataBind(); DropDownList_MovieName.SelectedValue = NotSelected; } //영화를 선택하였으니 해당 영화에 맞는 시간을 보여줌. else { SelectedMovieID = DropDownList_MovieName.SelectedValue.Trim(); string Command = "Select * From Movieschedule Where MovieID = @MovieID"; List <Tuple <string, object> > Params = new List <Tuple <string, object> >(); Params.Add(new Tuple <string, object>("@MovieID", SelectedMovieID)); SqlDataReader reader = dbManager.GetDataList(Command, Params); List <Movieschedule> PlayTimes = Movieschedule.SqlDataReaderToMember(reader); Movieschedule notSelectValue = new Movieschedule(); notSelectValue.Playtime = NotSelected; PlayTimes.Add(notSelectValue); //상영날짜 선택하지 않았음. if (SelectedPlayDate == "" || SelectedPlayDate == NotSelected) { DropDownList_PlayDate.DataTextField = "Playtime"; DropDownList_PlayDate.DataValueField = "Playtime"; DropDownList_PlayDate.DataSource = PlayTimes; DropDownList_PlayDate.DataBind(); DropDownList_PlayDate.SelectedValue = NotSelected; Params.Clear(); } //상영날짜를 선택하였으면 관이랑 남은 좌석수 표시 else { //날짜별 영화관중에서 선택한 날짜의 영화관만 도시한다. List <Movieschedule> PlayTheaters = new List <Movieschedule>(); foreach (Movieschedule playTime in PlayTimes) { if (playTime.Playtime == SelectedPlayDate) { PlayTheaters.Add(playTime); } } DropDownList_Theater.DataTextField = "RemaindSeatMent"; DropDownList_Theater.DataValueField = "TheaterID"; if (PlayTheaters.Count == 0) { ; } else { DropDownList_Theater.DataSource = PlayTheaters; } DropDownList_Theater.DataBind(); Params.Clear(); //예약인원이 정해져있는 상태이면서 예약내용이 모두 null값이 아닐경우 좌석배치표를 생성한다. if (TextBox_TicketCount.Text != "") { remainTicket = Convert.ToInt32(TextBox_TicketCount.Text); } if (remainTicket != 0) { if (SelectedMovieID == "" || SelectedPlayDate == "" || SelectedTheater == "" || SelectedMovieID == NotSelected || SelectedPlayDate == NotSelected || SelectedTheater == NotSelected) { return; } SetTable(); } } } }
protected void Page_Load(object sender, EventArgs e) { LoginedMember = (Member)Session["MEMBER"]; dbManager = (DBManager)Session["DBadmin"]; //쿠키로 이전페이지에서 입력받은 날짜를 받는다. string start = Request.Cookies["Start"].Value; string end = Request.Cookies["End"].Value; /* 가용가능 사용관 지정방법 * 1. 각 영화의 시간을 검색해서 겹치는 영화를 뽑아낸다. * 2. 겹치는 영화가 설정된 상영관을 전체 상영관 목록에서 제거한다. */ #region 사용가능 상영관 추출 string Command = "SELECT * FROM Movie WHERE Playstartdatetime <= @end AND Playenddatetime >= @start"; List <Tuple <string, object> > Params = new List <Tuple <string, object> >(); Params.Add(new Tuple <string, object>("@start", DateTime.ParseExact(start, "yyyyMMddHHmmss", null).ToString("yyyy-MM-dd HH:mm:ss"))); Params.Add(new Tuple <string, object>("@end", DateTime.ParseExact(end, "yyyyMMddHHmmss", null).ToString("yyyy-MM-dd HH:mm:ss"))); SqlDataReader reader = dbManager.GetDataList(Command, Params); List <Movie> Movies = Movie.SqlDataReaderToMember(reader); List <Theater> AbleTheaters = new List <Theater>(); // DEBUG : 시간 겹치는 영화만 나오는지 확인해 if (Movies == null || Movies.Count == 0) { //기간이 겹치는 영화가 없으므로 모든 상영관을 테이블로 도시한다. Command = "SELECT * FROM Theater"; reader = dbManager.GetDataList(Command, new List <Tuple <string, object> >()); AbleTheaters = Theater.SqlDataReaderToMember(reader); } else { //기간이 겹치는 영화들이 있다. //1.영화 스케쥴에 사용되고있는 상영관 리스트를 추출 //명령어 셋팅 Command = "SELECT * FROM Movieschedule WHERE MovieID IN ("; int i = 1; foreach (var movie in Movies) { if (Movies.Count != i) { Command += "@movieID" + Convert.ToString(i) + ", "; } else { Command += "@movieID" + Convert.ToString(i); } i++; } Command += ")"; //명령어에 해당하는 변수 설정. Params = new List <Tuple <string, object> >(); i = 1; foreach (var movie in Movies) { //DB에서 값 가져올때 공백이 생겨서 공백 제거를합니다. Movies[i - 1].MovieID = Movies[i - 1].MovieID.Trim(' '); Params.Add(new Tuple <string, object>("@movieID" + Convert.ToString(i), Movies[i - 1].MovieID)); i++; } reader = dbManager.GetDataList(Command, Params); //뽑아온 곳은 영화 스케쥴 테이블인데 영화관 객체에 넣으면 안되기때문에 영화관 ID만 받아서 리스트로 생성한다. List <string> DisAbleTheaters = new List <string>(); DisAbleTheaters = Theater.OlnyTheaterID(reader); //2. 1.에서 뽑은 상영관을 전체 상영관에서 제거한다. Command = "SELECT * FROM Theater WHERE TheaterID NOT IN ("; i = 1; foreach (var Theater in DisAbleTheaters) { if (DisAbleTheaters.Count != i) { Command += "@TheaterID" + Convert.ToString(i) + ", "; } else { Command += "@TheaterID" + Convert.ToString(i); } i++; } Command += ")"; Params = new List <Tuple <string, object> >(); //사용불가능한 상영관이 없으면 전체 상영관을 불러오는 코드를 수행하고 //그렇지 않다면 전체 상영관에서 사용불가능한 상영관을 제거한 사용가능상영관을 불러온다. if (DisAbleTheaters.Count == 0) { Command = "SELECT * FROM Theater"; reader = dbManager.GetDataList(Command, new List <Tuple <string, object> >()); AbleTheaters = Theater.SqlDataReaderToMember(reader); } else { for (int j = 1; j <= DisAbleTheaters.Count; j++) { //DB에서 값 가져올때 공백이 생겨서 공백 제거를합니다. DisAbleTheaters[j - 1] = DisAbleTheaters[j - 1].Trim(' '); Params.Add(new Tuple <string, object>("@TheaterID" + Convert.ToString(j), DisAbleTheaters[j - 1])); } reader = dbManager.GetDataList(Command, Params); AbleTheaters = Theater.SqlDataReaderToMember(reader); } } #endregion // AbleTheaters 에 값이 들어있고 라디오버튼과 상영관명으로 이루어진 테이블을 셋팅한다. #region 테이블 셋팅 int ColCount = 2; TableRow tr = new TableRow(); TableCell td = new TableCell(); tr.Cells.Add(td); //테이블 제목열 //개선필요(isjeong 7. 27) for (int i = 0; i < ColCount; i++) { td = new TableCell(); switch (i) { case 0: td.Text = "상영관 번호"; break; case 1: td.Text = "상영관 인원수"; break; } tr.Cells.Add(td); } tr.BackColor = Color.FromName("#ccccff"); Table1.Rows.Add(tr); foreach (var theater in AbleTheaters) { tr = new TableRow(); td = new TableCell(); //테이블의 열마다 체크박스를 추가하고 ID를 열의 ID와 매핑시킨다. RadioButton radiobtn = new RadioButton(); radiobtn.ID = theater.TheaterID.ToString(); radiobtn.GroupName = "Group1"; td.Controls.Add(radiobtn); tr.Cells.Add(td); // 루프를 돌면서 각 셀을 설정한다. for (int j = 0; j < ColCount; j++) { td = new TableCell(); //임시 switch (j) { case 0: td.Text = theater.TheaterID; break; case 1: td.Text = theater.Seatcount; break; } tr.Cells.Add(td); } tr.BackColor = Color.White; Table1.Rows.Add(tr); } #endregion }
protected void Page_Load(object sender, EventArgs e) { //init LoginedMember = (Member)Session["MEMBER"]; dbManager = (DBManager)Session["DBadmin"]; int ColCount = 4; TableRow tr = new TableRow(); TableCell td = new TableCell(); tr.Cells.Add(td); //테이블 제목열 //개선필요(isjeong 7. 27) for (int i = 0; i < ColCount; i++) { td = new TableCell(); switch (i) { case 0: td.Text = "ID"; break; case 1: td.Text = "이름"; break; case 2: td.Text = "나이"; break; case 3: td.Text = "잔여포인트"; break; } tr.Cells.Add(td); } tr.BackColor = Color.FromName("#ccccff"); Table1.Rows.Add(tr); //멤버 목록 호출 string Command = "SELECT * FROM Member WHERE ID <> @id"; List <Tuple <string, object> > Params = new List <Tuple <string, object> >(); Params.Add(new Tuple <string, object>("@ID", "admin")); SqlDataReader reader = dbManager.GetDataList(Command, Params); List <dataSet.Member> Members = dataSet.Member.SqlDataReaderToMember(reader); foreach (var member in Members) { Command = "Select * From Point Where ID = @ID ORDER BY Occuredatetime ASC"; Params.Clear(); Params.Add(new Tuple <string, object>("@ID", member.ID.Trim())); reader = dbManager.GetDataList(Command, Params); List <dataSet.Point> Point = dataSet.Point.SqlDataReaderToMember(reader); tr = new TableRow(); td = new TableCell(); //테이블의 열마다 체크박스를 추가하고 ID를 열의 ID와 매핑시킨다. CheckBox chkbox = new CheckBox(); chkbox.ID = member.ID.ToString(); td.Controls.Add(chkbox); tr.Cells.Add(td); // 루프를 돌면서 각 셀을 설정한다. for (int j = 0; j < ColCount; j++) { td = new TableCell(); switch (j) { case 0: td.Text = member.ID; break; case 1: td.Text = member.Name; break; case 2: td.Text = member.Age; break; case 3: //null exception 처리 if (Point != null && Point.Count > 0) { td.Text = Point[0].Remainvalue; } else { td.Text = "0"; } break; } tr.Cells.Add(td); } tr.BackColor = Color.White; Table1.Rows.Add(tr); } }
//페이지로드 protected void Page_Load(object sender, EventArgs e) { LoginedMember = (Member)Session["MEMBER"]; dbManager = (DBManager)Session["DBAdmin"]; int ColCount = 6; TableRow tr = new TableRow(); TableCell td = new TableCell(); tr.Cells.Add(td); //테이블 제목열 //개선필요(isjeong 7. 27) for (int i = 0; i < ColCount; i++) { td = new TableCell(); switch (i) { case 0: td.Text = "상영일시"; break; case 1: td.Text = "영화명"; break; case 2: td.Text = "상영관"; break; case 3: td.Text = "좌석열"; break; case 4: td.Text = "좌석번호"; break; case 5: td.Text = "관람등급"; break; } tr.Cells.Add(td); } tr.BackColor = Color.FromName("#ccccff"); Table1.Rows.Add(tr); //영화 목록 호출 string Command = "SELECT * FROM Booking Where ID = @ID"; List <Tuple <string, object> > Params = new List <Tuple <string, object> >(); Params.Add(new Tuple <string, object>("@ID", LoginedMember.ID)); SqlDataReader reader = dbManager.GetDataList(Command, Params); List <Bookinginfo> Bookings = Bookinginfo.SqlDataReaderToBooking(reader); int ID_i = 0; foreach (var booking in Bookings) { tr = new TableRow(); td = new TableCell(); //테이블의 열마다 체크박스를 추가하고 ID를 열의 ID와 매핑시킨다. CheckBox chkbox = new CheckBox(); //BookingID가 복합키라서... 설계 오류. chkbox.ToolTip = booking.ID.ToString().Trim() + "_" + booking.MovieID.ToString().Trim() + "_" + booking.TheaterID.ToString().Trim() + "_" + booking.Playdatetime.ToString().Trim() + "_" + booking.Seatrow.ToString().Trim() + "_" + booking.Seatnumber.ToString().Trim(); chkbox.ID = "CHECKBOXID_" + ID_i; ID_i++; td.Controls.Add(chkbox); tr.Cells.Add(td); //영화 상영시간이 현재시간보다 느리면 예매취소 불가능. long TimeNOW = Convert.ToInt64(DateTime.Now.ToString("yyyyMMddHHmmss")); long TimeBOOK = Convert.ToInt64(DateTime.ParseExact(booking.Playdatetime, "yyyy-MM-dd tt h:mm:ss", null).ToString("yyyyMMddHHmmss")); if (TimeNOW > TimeBOOK) { chkbox.Enabled = false; } // 루프를 돌면서 각 셀을 설정한다. for (int j = 0; j < ColCount; j++) { td = new TableCell(); //임시 switch (j) { case 0: td.Text = booking.Playdatetime; break; case 1: td.Text = booking.Moviename; break; case 2: td.Text = booking.TheaterID + "관"; break; case 3: td.Text = booking.Seatrow + "열"; break; case 4: td.Text = booking.Seatnumber + "번"; break; case 5: td.Text = booking.Viewingclass; break; } tr.Cells.Add(td); } tr.BackColor = Color.White; Table1.Rows.Add(tr); } }
//페이지로드 protected void Page_Load(object sender, EventArgs e) { LoginedMember = (Member)Session["MEMBER"]; dbManager = (DBManager)Session["DBAdmin"]; int ColCount = 6; TableRow tr = new TableRow(); TableCell td = new TableCell(); //테이블 제목열 //개선필요(isjeong 7. 27) for (int i = 0; i < ColCount; i++) { td = new TableCell(); switch (i) { case 0: td.Text = "상영일시"; break; case 1: td.Text = "영화명"; break; case 2: td.Text = "상영관"; break; case 3: td.Text = "좌석열"; break; case 4: td.Text = "좌석번호"; break; case 5: td.Text = "관람등급"; break; } tr.Cells.Add(td); } tr.BackColor = Color.FromName("#ccccff"); Table1.Rows.Add(tr); //영화 목록 호출 string Command = "SELECT * FROM Booking Where ID = @ID"; List <Tuple <string, object> > Params = new List <Tuple <string, object> >(); Params.Add(new Tuple <string, object>("@ID", LoginedMember.ID)); SqlDataReader reader = dbManager.GetDataList(Command, Params); List <Bookinginfo> Bookings = Bookinginfo.SqlDataReaderToBooking(reader); foreach (var booking in Bookings) { tr = new TableRow(); td = new TableCell(); // 루프를 돌면서 각 셀을 설정한다. for (int j = 0; j < ColCount; j++) { td = new TableCell(); //임시 switch (j) { case 0: td.Text = booking.Playdatetime; break; case 1: td.Text = booking.Moviename; break; case 2: td.Text = booking.TheaterID + "관"; break; case 3: td.Text = booking.Seatrow + "열"; break; case 4: td.Text = booking.Seatnumber + "번"; break; case 5: td.Text = booking.Viewingclass; break; } tr.Cells.Add(td); } tr.BackColor = Color.White; Table1.Rows.Add(tr); } }
protected void Page_Load(object sender, EventArgs e) { dbManager = (DBManager)Session["DBadmin"]; TextBox_TheaterNumber.Attributes.Add("readonly", "readonly"); TextBox_TheaterNumber.Style.Add("color", "gray"); }