public void Cinema() { while (true) { Console.Clear(); MenuCinema(); int number; while (true) { bool isINT = Int32.TryParse(Console.ReadLine(), out number); if (!isINT) { Console.WriteLine("Giá trị sai vui lòng nhập lại. "); Console.Write("#Chọn: "); } else if (number < 0 || number > 4) { Console.WriteLine("Giá trị sai vui lòng nhập lại từ 1 - 4."); Console.Write("#Chọn : "); } else { break; } } /* * TryParse phương pháp không ném một ngoại lệ nếu chuyển đổi thất bại. Nó loại bỏ sự cần thiết phải sử dụng xử lý ngoại lệ * để kiểm tra cho một Format Exception trong trường hợp không hợp lệ và không thể được thành công phân tích cú pháp. */ Console.WriteLine("============================================================="); switch (number) { case 1: Console.Clear(); MoviesInformation infomovie = new MoviesInformation(); infomovie.ShowInformationMovie(); break; case 2: BookingTicker ticker = new BookingTicker(); ticker.MenuBookingTicker(); Console.Clear(); break; case 3: Information info = new Information(); // info.Information_acc (); Console.ReadLine(); break; case 4: UserInterface user = new UserInterface(); user.InterfaceCinema(); return; } } }
public static void ComeBackMenu(Schedules scheduleUp, int count) { while (true) { if (count == 0) { Console.WriteLine("\n 1. Đặt Lại Ghế\n\n 2. Quay Lại Menu Chính"); } if (count == 1) { Console.WriteLine("\n 1. Đặt thêm vé cho bộ phim khác.\n\n 2. Quay Lại Menu Chính"); } Console.WriteLine(" ------------------------------------------------------------------------------"); Console.Write("\n Chọn : "); int number; while (true) { bool isINT = Int32.TryParse(Console.ReadLine(), out number); if (!isINT) { Console.WriteLine(" Giá trị sai vui lòng nhập lại."); Console.Write(" #Chọn : "); } else if (number < 0 || number > 2) { Console.WriteLine(" Giá trị sai vui lòng nhập lại 1 hoặc 2. "); Console.Write(" #Chọn : "); } else { break; } } switch (number) { case 1: Console.Clear(); if (count == 0) { MenuChoiceSeats(scheduleUp); } if (count == 1) { BookingTicker bookig = new BookingTicker(); bookig.MenuBookingTicker(); } return; case 2: CinemaInterface.Cinema(); Console.Clear(); return; } } }
private static void ChoiceMenuBookingAndComeBack(int movie_id) { Console.WriteLine($""); Console.WriteLine("--------------------------------------------------------------------------------------------"); Console.WriteLine("1. Đặt vé."); Console.WriteLine("\n2. Trở lại."); Console.WriteLine("\n3. Trở về menu chính."); Console.WriteLine("--------------------------------------------------------------------------------------------"); Console.Write("#Chọn : "); int number; while (true) { bool isINT = Int32.TryParse(Console.ReadLine(), out number); if (!isINT) { Console.WriteLine("Giá trị sai vui lòng nhập lại"); Console.Write("#Chọn : "); } else if (number < 0 || number > 3) { Console.WriteLine("Giá trị sai vui lòng nhập lại 1 - 3. "); Console.Write("#Chọn : "); } else { break; } } switch (number) { case 1: BookingTicker ticket = new BookingTicker(); ticket.ChooseMovieScheduleForYou(movie_id); break; case 2: InformationMovieById(movie_id); Console.Clear(); return; case 3: CinemaInterface.Cinema(); break; } Console.WriteLine(); }
public static void MenuChoiceSeats(Schedules scheduleUp) { List <string> choicedSeat = new List <string> (); while (true) { // ------------------------ Map Seats in Database with Schedule. ScheduleBL schechuleBl = new ScheduleBL(); string showdate = scheduleUp.Show_date.ToString($"{scheduleUp.Show_date:yyyy-MM-dd}"); string starttime = string.Format("{0:D2}:{1:D2}:{2:D2}", scheduleUp.Start_time.Hours, scheduleUp.Start_time.Minutes, scheduleUp.Start_time.Seconds); Schedules schedule = schechuleBl.SelectTimeBy(scheduleUp.Movie_id, showdate, starttime); string map = schedule.Schedule_room_seat; Console.Clear(); string[] mapArr = map.Split(";"); string[] rowsArr = mapArr[0].Split(" "); int cols = Int32.Parse(mapArr[1]); List <string> succer = new List <string> (); string[] seated = mapArr[2].Split(","); succer = AddlistByMapSeat(succer, seated); // -------------- Map not RoomBL room = new RoomBL(); Rooms ro = room.GetRoomById(schedule.Room_id); string map_ = ro.Chaire_not_placed; string[] map_chaire_not_placed = map_.Split(","); // ----------------------------------- ShowSeatChoice(rowsArr, cols, seated, choicedSeat, schedule, map_chaire_not_placed); Console.WriteLine("\n 0. Quay lại."); Console.WriteLine("\n *: Nhập số số ghế theo định dạng A1, A2, A3 để chọn ghế."); Console.WriteLine("\n _______________________________________________________________________________________________"); string choice; string[] choiced; // Cho khánh hàng nhập các ghế mà khách hàng muốn chọn, Phải nhập đúng định dạng thì mới được break ra khỏi While(true). while (true) { Console.Write("\n •√ Bạn chọn ghế :"); choice = Console.ReadLine().Trim().ToUpper(); if (choice == "0") { BookingTicker tick = new BookingTicker(); tick.MenuBookingTicker(); return; } try { if (choice[choice.Length - 1] == ',') { choice = choice.Remove(choice.Length - 1, 1); } } catch (System.Exception) { } choiced = choice.Split(","); if (CheckInsertIntoChoice(choiced) == true) { break; } else { Console.Clear(); ShowSeatChoice(rowsArr, cols, seated, choicedSeat, schedule, map_chaire_not_placed); Console.WriteLine("\n #: Bạn đã nhập sai định dạng ghế VD : A1, A2, A3. Vui lòng nhập lại!! Hoặc chọn 0 để thoát"); } } string test = ""; test = CheckSeatInSchedule(choiced, succer, test, rowsArr, cols, map_chaire_not_placed); if (test != "") { Console.Clear(); Console.WriteLine("\n -------------------------------------------------------------------------------"); Console.WriteLine(" #: Ghế " + test + " mà bạn chọn không có trong danh sách hoặc đã được đặt rồi. "); Console.WriteLine(" Vui lòng chọn lại ghế hoặc thoát"); Console.WriteLine("\n -------------------------------------------------------------------------------"); ComeBackMenu(scheduleUp, 0); return; } string checkedSeat = ""; // List<string> choicedSeat = new List<string> (); for (int i = 0; i < choiced.Length; i++) { if (succer.FindIndex(x => x == choiced[i]) == -1) { if (choicedSeat.FindIndex(x => x == choiced[i]) == -1) { succer.Add(choiced[i]); choicedSeat.Add(choiced[i]); } else { checkedSeat = checkedSeat + " " + choiced[i]; } } } ShowSeatChoice(rowsArr, cols, seated, choicedSeat, schedule, map_chaire_not_placed); ChoiceBookingAndContinue(); if (checkedSeat != "") { Console.WriteLine(" Bạn vừa chọn ghế " + checkedSeat + " này rồi ! "); } Console.Write("\n #Chọn : "); int number; while (true) { bool isINT = Int32.TryParse(Console.ReadLine(), out number); if (!isINT) { Console.Clear(); ShowSeatChoice(rowsArr, cols, seated, choicedSeat, schedule, map_chaire_not_placed); ChoiceBookingAndContinue(); Console.WriteLine("\n • Giá trị sai vui lòng nhập lại."); Console.Write("\n #Chọn : "); } else if (number < 0 || number > 2) { Console.Clear(); ShowSeatChoice(rowsArr, cols, seated, choicedSeat, schedule, map_chaire_not_placed); ChoiceBookingAndContinue(); Console.WriteLine("\n • Giá trị sai vui lòng nhập lại 1 hoặc 2. "); Console.Write("\n #Chọn : "); } else { break; } } Console.WriteLine(); switch (number) { case 1: map = AddSeatsForSchedule(choicedSeat, seated, map); InformationMovieBookingTickets(schedule, choicedSeat, map); choicedSeat = null; choicedSeat = new List <string> (); break; case 2: Console.Clear(); break; } } }
// Show toàn bộ các lịch chiếu của phim, so sách với mốc thời gian hiện tại nếu thời gian đã qua thì k in nữa. public static void Schedule_Infor_By_IDMOVIE_DATE(int movie_id) { Console.Clear(); MoviesBL movie = new MoviesBL(); Movies informatin = movie.getMovieById(movie_id); ScheduleBL sch = new ScheduleBL(); List <DateTime> list = sch.SelectDatetime(movie_id); List <string> array = new List <string> (); TimeSpan datefortimespan = DateTime.Now.TimeOfDay; DateTime comparedatetime = DateTime.Now; string comparedatetime1 = comparedatetime.ToString($"{comparedatetime:dd/MM/yyyy}"); int dem = 0; // Khai báo 2 mảng để in ra thứ nhờ Date.DayOfWeek return về 1 ngày trong tuần. string[] arr1 = new string[] { "Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy", "Chủ nhật" }; string[] arr2 = new string[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; Console.WriteLine("============================================================================================"); Console.WriteLine($"----------------- Lịch chiếu phim : {informatin.Name} "); Console.WriteLine("============================================================================================"); Console.WriteLine("Ngày chiếu | Thời gian chiếu ( Thời gian bắt đầu - Thời gian kết thúc )"); Console.WriteLine("============================================================================================"); for (int i = 0; i < list.Count; i++) { string date = list[i].Date.ToString($"{list[i].Date:dd/MM/yyyy}"); // So sánh các mốc thời gian chiếu của phim nếu lớn hơn hoặc bằng thời gian hiện tại thì show ra GUI. Nếu < thì k show. if (list[i].Date > DateTime.Now && comparedatetime1.CompareTo(date) < 0 || comparedatetime1.CompareTo(date) == 0) { string date1 = list[i].Date.ToString($"{list[i].Date:yyyy-MM-dd}"); array.Add(date1); int count = -1; // Lấy ra ngày trong tuần và so sánh để lấy ra index. Chuyền vào arr1 để dịch ngày đó sang tiếng việt. string week = $"{list[i].Date.DayOfWeek}"; for (int j = 0; j < arr2.Length; j++) { if (arr2[j] == week) { count = j; break; } } string format = string.Format($"{dem+1,2}. {list[i].Date:dd/MM/yyyy} {arr1[count],-10} | "); Console.Write($"{format}"); // Format time HH:MM:SS List <Schedules> demons = sch.SelectTime(movie_id, array[dem]); string tym_one = string.Format("{0:D2}:{1:D2}:{2:D2}", datefortimespan.Hours, datefortimespan.Minutes, datefortimespan.Seconds); // Add tất cả thời gian chiếu trong ngày vào. List <string> list1 = new List <string> (); foreach (var item in demons) { string timeText = string.Format("{0:D2}:{1:D2}:{2:D2}", item.Start_time.Hours, item.Start_time.Minutes, item.Start_time.Seconds); list1.Add(timeText); } for (int j = 0; j < demons.Count; j++) { // Nếu ngày hiện tại bằng ngày chiếu của phim. Thì so sánh các khoảng thời gian chiếu trong ngày với thời gian hiện tại. if (comparedatetime1.CompareTo(date) == 0) { if (tym_one.CompareTo(list1[j]) < 0) { string start = string.Format("{0:D2}:{1:D2}", demons[j].Start_time.Hours, demons[j].Start_time.Minutes); string end = string.Format("{0:D2}:{1:D2}", demons[j].End_time.Hours, demons[j].End_time.Minutes); Console.Write($" {start} - {end} "); if (j == 3) { Console.WriteLine(); Console.Write(" | "); } } } else { string start = string.Format("{0:D2}:{1:D2}", demons[j].Start_time.Hours, demons[j].Start_time.Minutes); string end = string.Format("{0:D2}:{1:D2}", demons[j].End_time.Hours, demons[j].End_time.Minutes); Console.Write($" {start} - {end} "); if (j == 3) { Console.WriteLine(); Console.Write(" | "); } } } dem++; Console.WriteLine(""); Console.WriteLine("__________________________|_________________________________________________________________"); } } Console.WriteLine($""); Console.WriteLine("--------------------------------------------------------------------------------------------"); Console.WriteLine("1. Đặt vé."); Console.WriteLine("\n2. Trở lại."); Console.WriteLine("\n3. Trở về menu chính."); Console.WriteLine("--------------------------------------------------------------------------------------------"); Console.Write("#Chọn : "); int number; while (true) { bool isINT = Int32.TryParse(Console.ReadLine(), out number); if (!isINT) { Console.WriteLine("Giá trị sai vui lòng nhập lại"); Console.Write("#Chọn : "); } else if (number < 0 || number > 3) { Console.WriteLine("Giá trị sai vui lòng nhập lại 1 - 3. "); Console.Write("#Chọn : "); } else { break; } } switch (number) { case 1: BookingTicker ticket = new BookingTicker(); ticket.ChooseMovieScheduleForYou(movie_id); break; case 2: Console.Clear(); return; case 3: CinemaInterface cinema = new CinemaInterface(); cinema.Cinema(); break; } Console.WriteLine(); }