public static Customer GetCustomer() { Customer_Bl cus = new Customer_Bl(); Customer customer = cus.Login(UserName, password); return(customer); }
public static Customer GetCustomer1() { Customer_Bl cus = new Customer_Bl(); Customer customer = cus.Login(_email, _valuePass); return(customer); }
public void Login() { while (true) { Console.Clear(); Console.WriteLine("============================================================="); Console.WriteLine("------------------- Đăng Nhập "); Console.WriteLine("============================================================="); Customer_Bl ad = new Customer_Bl(); string UserName; string password; while (true) { Console.Write("- Nhập Tên người dùng : "); UserName = Console.ReadLine(); Console.Write("- Nhập Mật Khẩu : "); while (true) { password = ""; ConsoleKeyInfo keyInfo; 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); break; } if (CheckNotSpecialCharacters(UserName, password) == true) { break; } else { CheckLoginSuccessOrFailure(0); } } int count = 0; if (ad.Login(UserName, password) != null) { count++; } CheckLoginSuccessOrFailure(count); } }
static bool MessageLogin(string _valueUser, string _valuePass, string _name, string _email, string _phone, string _address, int _count) { Customer cus = UserInterface.LoginCinema.GetCustomer(); Customer customer = new Customer(); customer.User_name = _valueUser; customer.Password = _valuePass; customer.Name = _name; customer.Email = _email; customer.Phone = _phone; customer.Address = _address; customer.Customer_id = cus.Customer_id; Customer_Bl cuBL = new Customer_Bl(); return(cuBL.ChangLogin(customer));; }
public static void Order(Customer c) { string choice1 = ""; OrderBL orderbl = new OrderBL(); Orders o = new Orders(); List <Items> lito = new List <Items>(); CategoryBL cbl = new CategoryBL(); List <Category> lc = new List <Category>(); lc = cbl.GetCategory(); Console.WriteLine("___________________________________________"); Console.WriteLine("|----------- Danh Mục Sản Phẩm -----------|"); Console.WriteLine("|-----------------------------------------|"); foreach (var item in lc) { Console.WriteLine("|" + item.CategoryID + " | " + item.CategoryName); } int choice; do { Console.Write("-chọn: "); choice = Convert.ToInt32(Console.ReadLine()); } while ((choice < 1) || (choice > lc.Count)); Item_BL ibl = new Item_BL(); List <Items> lit = new List <Items>(); lit = ibl.getItemByCategoryId(choice); while (true) { Console.Clear(); Console.WriteLine("___________________________________________________________________________________________________________"); Console.WriteLine("|========================================== Sản Phẩm ======================================================|"); Console.WriteLine("|__________________________________________________________________________________________________________|"); Console.WriteLine("|ID | Tên Sản Phẩm | Giá Sản Phẩm | Số Lượng |"); foreach (var item in lit) { Console.WriteLine("|{0,-3} | {1,-51} | {2,21} VND| {3,-14} ", item.ItemId, item.ItemName, item.ItemPrice, item.ItemAmount); Console.WriteLine("|----------------------------------------------------------------------------------------------------------|"); } Console.Write("1.Chọn ID sản phẩm bạn muốn mua :"); int product; Items io = null; while (true) { product = Validate.InputInt(Console.ReadLine()); int count = 0; foreach (var iteml in lit) { if (product == iteml.ItemId) { count++; } } if (count == 0) { Console.Write("Không có sản phẩm này trong danh mục bạn chọn , mời nhập lại: "); continue; } else { break; } } io = ibl.getItemById(product); int quantity; Console.Write(" Nhập số lượng: "); while (true) { quantity = Validate.InputInt(Console.ReadLine()); if (quantity <= io.ItemAmount) { break; } Console.Write("Số lượng không đúng, mời nhập lại: "); } io.ItemAmount = quantity; int dem = 0; int index = 0; foreach (var item in lito) { if (item.ItemId == product) { dem++; break; } index++; } if (io.ItemAmount != 0 && dem == 0) { lito.Add(io); } else if (dem > 0) { lito[index].ItemAmount += quantity; } while (true) { Console.WriteLine("Bạn có muốn tiếp tục thêm sản phẩm không? (C/K) "); choice1 = Console.ReadLine().ToUpper(); switch (choice1) { case "C": Console.Clear(); break; case "K": Console.Clear(); break; default: continue; } break; } if (choice1 == "C") { Console.Clear(); continue; } else if (choice1 == "K") { Console.Clear(); break; } } // listitem = lito; Console.WriteLine("____________________________________________________________________________________________________"); Console.WriteLine("|-----------------------------------------Đơn Hàng--------------------------------------------------|"); Console.WriteLine("| Tên Sản Phẩm | Số Lượng | Giá Sản Phẩm | Thành Tiền |"); Console.WriteLine("----------------------------------------------------------------------------------------------------"); decimal totalprice = 0; // Console.WriteLine(o.listItems.Count); foreach (var item in lito) { decimal a = 0; a = item.ItemPrice * item.ItemAmount; totalprice += a; Console.WriteLine("|{0,-48}|{1,-14}|{2,15} VND|{3,11} VND|", item.ItemName, item.ItemAmount, pricevalid(item.ItemPrice), a); } Console.WriteLine("_____________________________________________________________________________________________________"); Console.WriteLine("Tổng tiền: {0} VND", pricevalid(totalprice)); while (true) { Console.Write("Bạn có muốn thanh toán đơn hàng? (C/K)?"); choice1 = Console.ReadLine().ToUpper(); switch (choice1) { case "C": break; case "K": Console.Clear(); return; default: continue; } break; } Console.Write("Nhập số tiền khách trả(đồng): "); decimal cusmoney; while (true) { try { cusmoney = Convert.ToDecimal(Console.ReadLine()); if (cusmoney < 0) { Console.Write("Số tiền trả không thể nhỏ hơn 0, mời bạn nhập lại(đồng): "); continue; } else if (cusmoney > 999999999) { Console.Write("Số tiền quá lớn, mời nhập lại(đồng): "); continue; } else if (cusmoney < totalprice) { Console.Write("Số tiền trả không đủ, mời nhập lại(đồng): "); continue; } } catch (System.Exception) { Console.Write("Dữ liệu nhập vào không đúng hoặc số tiền quá lớn, mời bạn nhập lại(đồng): "); continue; } break; } if ((cusmoney - totalprice) > 0) { Console.WriteLine("Tiền trả lại: {0} VND", pricevalid(cusmoney - totalprice)); } Customer_Bl cbl1 = new Customer_Bl(); o.listItems = lito; // Console.WriteLine(o.listItems.ToString()); o.customer = c; o.Status = 1; Console.WriteLine(" Tạo Order " + (orderbl.AddOrder(o) ? "Hoàn tất!" : "Không hoàn tất!") + " Ấn phím bất kì để thoát!"); // listitem = o.listItems; Console.ReadKey(); Console.Clear(); // List<Items> newlit = ibl.GetItemsByOrderId(); }
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; } } }