示例#1
0
 public void GetAllItems()
 {
     Assert.NotNull(IBL.GetAllItems());
 }
示例#2
0
        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;
            }
        }