private static void CheckLoginSuccessOrFailure(int count, string Email, string password) { if (count != 1) { Console.Clear(); Console.WriteLine("-------------------------------------------------------------"); Console.WriteLine(" *^: Email hoặc mật khẩu của bạn chưa chính xác."); Console.WriteLine("-------------------------------------------------------------"); while (true) { Console.WriteLine("1. Thử lại."); Console.WriteLine("2. Thoát"); 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 > 2) { Console.WriteLine("Giá trị sai vui lòng nhập lại 1 - 2. "); Console.Write("#Chọn : "); } else { break; } } switch (number) { case 1: Console.Clear(); break; case 2: Console.Clear(); InterfaceCinema(); break; } if (number == 1) { break; } } } else { // Customer_Bl cus = new Customer_Bl (); // GetCustomerID (cus.Login (Email, password).Customer_id); CinemaInterface.Cinema(); Console.WriteLine("-------------------------------------------------------------"); 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; } } }
public void MenuBookingTicker() { while (true) { Console.Clear(); // MenuBookingTicker menu cho đặt vé. MoviesBL movie = new MoviesBL(); Console.WriteLine("============================================================================================"); Console.WriteLine("---------------------------- Chọn Phim Bạn Muốn Xem --------------------------------------"); Console.WriteLine("--------------------------------------------------------------------------------------------"); Console.WriteLine(); // Show ra tất cả các phim đang có trong danh sách. foreach (var item in movie.GetMovies()) { string format = string.Format($"{item.Movie_id,1}. {item.Name,-40} {item.Duration,37} Phút\n {item.Genre,-20} \n"); Console.WriteLine(format); } Console.WriteLine("--------------------------------------------------------------------------------------------"); int number; Console.WriteLine("0. Quay lại menu chính."); Console.WriteLine("*: Nhập số thứ tự để chọn phim."); Console.WriteLine("--------------------------------------------------------------------------------------------"); Console.Write("#Chọn : "); 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 > movie.GetMovies().Count) { Console.WriteLine($"Giá trị sai vui lòng nhập lại 0 -> {movie.GetMovies ().Count}."); Console.Write("#Chọn : "); } else { break; } } if (number == 0) { CinemaInterface.Cinema(); } ChooseMovieScheduleForYou(number); Console.ReadLine(); } }
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 ShowInformationMovie() { while (true) { Console.Clear(); Console.WriteLine("============================================================================================"); Console.WriteLine("---------------------------- Danh sách các phim đang chiếu ------------------------------"); Console.WriteLine("--------------------------------------------------------------------------------------------"); ListMovie(); int number; MoviesBL movie = new MoviesBL(); Console.WriteLine("0. Quay lại menu chính."); Console.WriteLine("*: Nhập số thứ tự của phim để xem thông tin chi tiết phim."); Console.WriteLine("--------------------------------------------------------------------------------------------"); Console.Write("#Chọn : "); 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 > movie.GetMovies().Count) { Console.WriteLine($"Giá trị sai vui lòng nhập lại 0 -> {movie.GetMovies ().Count}."); Console.Write("#Chọn : "); } else { break; } } if (number == 0) { CinemaInterface.Cinema(); return; } Console.Clear(); InformationMovieById(number); } }
public void ChooseMovieScheduleForYou(int movie_id) { Console.Clear(); MoviesBL movie = new MoviesBL(); ScheduleBL schechule = new ScheduleBL(); RoomBL room = new RoomBL(); // information . Lấy ra phim nhờ id movie Movies informatin = movie.getMovieById(movie_id); // list lấy ra tất cả lịch chiếu của phim. List <DateTime> list = schechule.SelectDatetime(movie_id); TimeSpan datefortimespan = DateTime.Now.TimeOfDay; DateTime comparedatetime = DateTime.Now; string comparedatetime1 = comparedatetime.ToString($"{comparedatetime:dd/MM/yyyy}"); // Array này lấy ra ngày để connect tới database format by yyyy-MM-dd. List <string> array = new List <string> (); // Array1 này. Lưu lại thời gian để so sách với thời gian hiện tại. List <string> array1 = new List <string> (); int dem = 0; 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($"----------------- Chọn Ngày Chiếu Của Phim : {informatin.Name} "); Console.WriteLine("============================================================================================"); for (int i = 0; i < list.Count; i++) { string date = list[i].Date.ToString($"{list[i].Date:dd/MM/yyyy}"); 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); array1.Add(date); int count = -1; 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}. {date} {arr1[count],-8} "); dem++; Console.WriteLine($"{format}"); Console.WriteLine(); } } Console.WriteLine("--------------------------------------------------------------------------------------------"); int number; Console.WriteLine("0. Quay lại menu chính."); Console.WriteLine("*: Nhập số thứ tự để chọn ngày chiếu."); Console.WriteLine("--------------------------------------------------------------------------------------------"); Console.Write("#Chọn : "); while (true) { bool isINT = Int32.TryParse(Console.ReadLine(), out number); if (!isINT) { Console.WriteLine("Bạn vừa nhập sai giá trị, vui lòng nhập lại."); Console.Write("#Chọn: "); } else if (number < 0 || number > array.Count) { Console.WriteLine($"Giá trị trong khoảng từ 0 - > { array.Count }"); Console.Write("#Chọn: "); } else { break; } } if (number == 0) { CinemaInterface.Cinema(); } ShowScheduleByMovieIdAndDatetime(movie_id, schechule, array1[number - 1], array[number - 1]); }
public static void ShowScheduleByMovieIdAndDatetime(int movie_id, ScheduleBL schechule, string datetime, string datetimeforDatabase) { Console.Clear(); MoviesBL movie = new MoviesBL(); Movies informatin = movie.getMovieById(movie_id); RoomBL room = new RoomBL(); TimeSpan datefortimespan = DateTime.Now.TimeOfDay; DateTime comparedatetime = DateTime.Now; string comparedatetime1 = comparedatetime.ToString($"{comparedatetime:dd/MM/yyyy}"); // Lấy ra lịch chiếu nhờ STT của Ngày chiếu. Console.WriteLine("====================================================================="); Console.WriteLine($"-Chọn Lịch Chiếu Của Phim : {informatin.Name} Ngày {datetime} -"); Console.WriteLine("---------------------------------------------------------------------"); Console.WriteLine("STT | Lịch Chiếu | Phòng | Số ghế còn lại "); Console.WriteLine("---------------------------------------------------------------------"); List <Schedules> demons = schechule.SelectTime(movie_id, datetimeforDatabase); // Lưu tất cả các TimeSpan để so sánh với DateTime.Now.TimeOfDay List <string> list1 = new List <string> (); // List2 để lấy ra các thời gian show ra màn hình. List <string> list2 = new List <string> (); string tym_one = string.Format("{0:D2}:{1:D2}:{2:D2}", datefortimespan.Hours, datefortimespan.Minutes, datefortimespan.Seconds); int count1 = 0; 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++) { Rooms ro = room.GetRoomById(demons[j].Room_id); string date1 = demons[j].Show_date.ToString($"{demons[j].Show_date:yyyy-MM-dd}"); string timeTe = string.Format("{0:D2}:{1:D2}:{2:D2}", demons[j].Start_time.Hours, demons[j].Start_time.Minutes, demons[j].Start_time.Seconds); // Schedules sche = schechule.SelectTimeBy (demons[j].Movie_id,date1,timeTe); if (comparedatetime1.CompareTo(datetime) == 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); count1++; string addtimetolist2 = string.Format("{0:D2}:{1:D2}:{2:D2}", demons[j].Start_time.Hours, demons[j].Start_time.Minutes, demons[j].Start_time.Seconds); list2.Add(addtimetolist2); Schedules sche = schechule.SelectTimeBy(demons[j].Movie_id, date1, timeTe); string[] count = sche.Schedule_room_seat.Trim().Split(";"); string[] seated = count[2].Split(","); string[] chaier = ro.Chaire_not_placed.Split(","); int a = 0; if (seated[0] != "") { a = ro.Number_Of_seats - seated.Length; } else { a = ro.Number_Of_seats; } if (chaier[0] != "") { a = a - chaier.Length; } string format = string.Format($"{count1}. | {start,-5} - {end,-5} | {ro.Name,-10} | {a}"); Console.WriteLine(format); } } 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); count1++; Schedules sche = schechule.SelectTimeBy(demons[j].Movie_id, date1, timeTe); string[] count = sche.Schedule_room_seat.Trim().Split(";"); string[] seated = count[2].Split(","); int a = 0; if (seated[0] != "") { a = ro.Number_Of_seats - seated.Length; } else { a = ro.Number_Of_seats; } string[] chaier = ro.Chaire_not_placed.Split(","); if (chaier[0] != "") { a = a - chaier.Length; } string addtimetolist2 = string.Format("{0:D2}:{1:D2}:{2:D2}", demons[j].Start_time.Hours, demons[j].Start_time.Minutes, demons[j].Start_time.Seconds); list2.Add(addtimetolist2); string format = string.Format($"{count1}. | {start,-5} - {end,-5} | {ro.Name,-10} | {a }"); Console.WriteLine(format); } } Console.WriteLine("---------------------------------------------------------------------"); int number1; Console.WriteLine("0. Quay lại menu chính."); Console.WriteLine("*: Nhập số thứ tự để suất chiếu."); Console.WriteLine("---------------------------------------------------------------------"); Console.Write("#Chọn : "); while (true) { bool isINT = Int32.TryParse(Console.ReadLine(), out number1); if (!isINT) { Console.WriteLine("Bạn vừa nhập sai giá trị, vui lòng nhập lại."); Console.Write("#Chọn: "); } else if (number1 < 0 || number1 > list2.Count) { Console.WriteLine($"Giá trị trong khoảng từ 0 - > { list2.Count }"); Console.Write("#Chọn: "); } else { break; } } if (number1 == 0) { CinemaInterface.Cinema(); } Console.Clear(); Schedules sch = schechule.SelectTimeBy(movie_id, datetimeforDatabase, list2[number1 - 1]); ChoiceMapSeats.MenuChoiceSeats(sch); }
// 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(); }
public void Login() { while (true) { Console.WriteLine("============================================================="); Console.WriteLine("------------------- Đăng Nhập "); Console.WriteLine("============================================================="); Customer_Bl ad = new Customer_Bl(); string Email; Console.Write("- Nhập Email : "); while (true) { Email = Console.ReadLine(); // - Regex Email validation if (Regex.IsMatch(Email, @"^[^@]+@[^@.]+\.[^@]*\w\w$|^0[0-9]{9,10}$") != true) { Console.WriteLine("-----\n*^: Bạn đã nhập sai định dạng email. VD: [email protected]\n------"); Console.Write("- Nhập lại email: "); } else { break; } } string password = ""; Console.Write("- Nhập Mật Khẩu : "); ConsoleKeyInfo keyInfo; while (true) { do { keyInfo = Console.ReadKey(true); // Skip if Backspace or Enter is Pressed if (keyInfo.Key != ConsoleKey.Backspace && keyInfo.Key != ConsoleKey.Enter) { password += keyInfo.KeyChar; Console.Write("*"); } else { // Remove last charcter if Backspace is Pressed if (keyInfo.Key == ConsoleKey.Backspace && password.Length > 0) { password = password.Substring(0, (password.Length - 1)); Console.Write("\b \b"); } } } while (keyInfo.Key != ConsoleKey.Enter); if (password != "") { break; } else { Console.Clear(); Console.WriteLine("Bạn chưa nhập mật khẩu, vui lòng nhập lại."); Console.Write("- Nhập mật khẩu : "); } } int count = 0; Customer customer = ad.Login(Email, password); if (ad.Login(Email, password).Email == Email && ad.Login(Email, password).Password == password) { count++; } if (count != 1) { Console.Clear(); Console.WriteLine("-------------------------------------------------------------"); Console.WriteLine(" *^: Email hoặc mật khẩu của bạn chưa chính xác."); Console.WriteLine("-------------------------------------------------------------"); while (true) { Console.WriteLine("1. Thử lại."); Console.WriteLine("2. Thoát"); 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 > 2) { Console.WriteLine("Giá trị sai vui lòng nhập lại 1 - 2. "); Console.Write("#Chọn : "); } else { break; } } switch (number) { case 1: Console.Clear(); break; case 2: Console.Clear(); return; } if (number == 1) { break; } } } else { CinemaInterface cinema = new CinemaInterface(); cinema.Cinema(); Console.WriteLine("-------------------------------------------------------------"); return; } } }