public void DisplayAllItems(Customers Cus) { Console.Clear(); Console.WriteLine("================================================================================================"); Console.WriteLine("------------------------------------- DANH SÁCH SẢN PHẨM ---------------------------------------"); Console.WriteLine("================================================================================================\n"); Item_BL IBL = new Item_BL(); List <Items> items = IBL.GetAllItems(); table = new ConsoleTable("Mã sản phẩm", "Tên sản phẩm", "Hãng", "Thuộc tính", "Giá sản phẩm"); foreach (Items i in items) { table.AddRow(i.Produce_Code, i.Item_Name, i.Trademark, i.Attribute, U.FormatMoney(i.Item_Price)); } table.Write(Format.Alternative); string[] choice1 = { "Xem chi tiết sản phẩm", "Thêm vào giỏ hàng", "Quay về trang chính" }; int number1 = Product.SubMenu(null, choice1); switch (number1) { case 1: Console.Write("Chọn mã sản phẩm: "); int showdetal = input(Console.ReadLine()); while (IBL.GetItemByProduceCode(showdetal) == null) { string a; Console.WriteLine("Mã sản phẩm không tồn tại!"); Console.Write("Bạn có muốn nhập lại mã sản phẩm không ? (Y/N): "); a = Console.ReadLine().ToUpper(); while (true) { if (a != "Y" && a != "N") { Console.Write("Bạn chỉ được nhập (Y/N): "); a = Console.ReadLine().ToUpper(); continue; } break; } if (a == "Y" || a == "y") { Console.Write("\nChọn mã sản phẩm: "); showdetal = input(Console.ReadLine()); } else { DisplayProduct(Cus); } } DisplayItemDetails(showdetal, Cus); break; case 2: Console.Write("Chọn mã sản phẩm: "); int pc = input(Console.ReadLine()); while (IBL.GetItemByProduceCode(pc) == null) { string a; Console.WriteLine("Mã sản phẩm không tồn tại!"); Console.Write("Bạn có muốn nhập lại mã sản phẩm không ? (Y/N): "); a = Console.ReadLine().ToUpper(); while (true) { if (a != "Y" && a != "N") { Console.Write("Bạn chỉ được nhập (Y/N): "); a = Console.ReadLine().ToUpper(); continue; } break; } if (a == "Y" || a == "y") { Console.Write("\nChọn mã sản phẩm: "); pc = input(Console.ReadLine()); } else { DisplayProduct(Cus); } } Items item = IBL.GetItemByProduceCode(pc); InputQuantity(Cus, item, pc); break; case 3: U.UserMenu(Cus); break; } }
public void GetItemByProduceCode(int id) { Assert.NotNull(IBL.GetItemByProduceCode(id)); }
public void DisplayItemDetails(int id, Customers Cus) { Item_BL IBL = new Item_BL(); Items item = IBL.GetItemByProduceCode(id); Console.Clear(); Console.WriteLine("=================================================================================="); Console.WriteLine("-------------------------------- CHI TIẾT SẢN PHẨM -------------------------------\n"); table = new ConsoleTable("Mã sản phẩm", "Tên sản phẩm", "Hãng", "Thuộc tính", "Giá sản phẩm"); table.AddRow(item.Produce_Code, item.Item_Name, item.Trademark, item.Attribute, U.FormatMoney(item.Item_Price)); table.Write(Format.Alternative); Console.WriteLine("Mô tả sản phẩm : {0}\n", item.Item_Description); while (true) { string[] choice = { "Thêm vào giỏ hàng", "Trở về danh sách sản phẩm", "Trở về trang chính" }; int number = SubMenu(null, choice); switch (number) { case 1: InputQuantity(Cus, item, id); break; case 2: DisplayProduct(Cus); break; case 3: if (Cus.User_Name != null && Cus.User_Password != null) { U.UserMenu(Cus); } else { Console.Clear(); Menu m = new Menu(); Product Product = new Product(); string[] choice1 = { "Danh sách sản phẩm", "Xem giỏ hàng", "Đăng nhập", "Thoát" }; int number1 = Product.SubMenu($"Chào mừng đến với cửa hàng", choice1); switch (number1) { case 1: Product.DisplayProduct(Cus); break; case 2: U.DisplayCart(Cus); break; case 3: U.ScreenLogin(); break; case 4: Environment.Exit(0); break; } } break; } } }