Esempio n. 1
0
        public void Displaylistshoes()
        {
            Console.Clear();
            ShoesBL sbl   = new ShoesBL();
            var     lists = sbl.GetAllShoes();
            string  line  = ("===================================================================================================================\n");

            Console.WriteLine(line);
            Console.Write(" Shoes_Id  |  Shoes_Name           |    Price         |  Size  |      Style             |   Color        | Amount |\n");
            Console.WriteLine(line);
            foreach (var Shoes in lists)
            {
                string money = String.Format("{0:0,0}vnđ", Shoes.Price);
                Console.WriteLine("{0,-15}{1,-25}{2,-17}{3,-10}{4,-24}{5,-18}{6} ", Shoes.Shoes_id, Shoes.Shoes_name, money, Shoes.Size, Shoes.Style, Shoes.Color, Shoes.Amount);
            }
            Console.WriteLine(line);
            Console.Write("Do you want to see product details?(y/n)");
            string choice = Console.ReadLine();

            if (choice == "y")
            {
                Console.Write("Input  Shoes_ID: ");
                while (true)
                {
                    try
                    {
                        sh_id = Convert.ToInt32(Console.ReadLine());
                        var shoes = sbl.GetShoesById(sh_id);
                        if (shoes == null)
                        {
                            throw new valueexception("Not find Shoes_ID,please re-enter : ");
                        }
                        else if (shoes != null)
                        {
                            string money = String.Format("{0:0,0}vnđ", shoes.Price);
                            Console.Clear();
                            Console.WriteLine("          Product Information        ");
                            Console.WriteLine("-ID                : {0}", shoes.Shoes_id);
                            Console.WriteLine("-Name              : {0}", shoes.Shoes_name);
                            Console.WriteLine("-Size              : {0}", shoes.Size);
                            Console.WriteLine("-Amount            : {0}", shoes.Amount);
                            Console.WriteLine("-Price             : {0}", money);
                            Console.WriteLine("-Color             : {0}", shoes.Color);
                            Console.WriteLine("-Material          : {0}", shoes.Material);
                            Console.WriteLine("-Manufacture       : {0}", shoes.Manufacture);
                            Console.WriteLine("-Trademark name    : {0}", shoes.TM.Name);
                            Console.WriteLine("-Made in           : {0}", shoes.TM.Origin);
                            Console.WriteLine();
                            while (true)
                            {
                                short    mainChoose = 0;
                                string[] mainMenu   = { "Add in shopping cart", "Order now ", "Return shoes list" };
                                while (mainChoose != mainMenu.Length)
                                {
                                    mainChoose = Menu2("You want to add to your shopping cart, buy or return to the shoes list? ", mainMenu);
                                    switch (mainChoose)
                                    {
                                    case 1:
                                        Addshoppingcart();
                                        break;

                                    case  2:
                                        CreateOrder();
                                        break;

                                    case 3:
                                        Displaylistshoes();
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    catch (valueexception e)
                    {
                        Console.Write(e.Message);
                        continue;
                    }
                    catch
                    {
                        Console.Write("Please enter a valid value :");
                        continue;
                    }
                    break;
                }
            }
            else if (choice == "n")
            {
                MenuCustomer();
            }
        }
Esempio n. 2
0
        public void GetAllShoes_test()
        {
            List <Shoes> listShoes = sbl.GetAllShoes();

            Assert.NotNull(listShoes);
        }
Esempio n. 3
0
        public void Displaylistshoes()
        {
            Console.Clear();
            ShoesBL sbl   = new ShoesBL();
            var     lists = sbl.GetAllShoes();
            string  line  = ("===================================================================================================================\n");

            Console.WriteLine(line);
            Console.Write(" Shoes_Id  |  Shoes_Name           |    Price         |  Size  |      Style             |   Color        | Amount |\n");
            Console.WriteLine(line);
            foreach (var Shoes in lists)
            {
                Console.WriteLine("{0,-15}{1,-25}{2,-17}{3,-10}{4,-24}{5,-18}{6} ", Shoes.Shoes_id, Shoes.Shoes_name, Shoes.Price, Shoes.Size, Shoes.Style, Shoes.Color, Shoes.Amount);
            }
            Console.WriteLine(line);
            Console.Write("Do you want to see product details?(y/n)");
            string choice = Console.ReadLine();

            if (choice == "y")
            {
                Console.Write("Input  Shoes_ID: ");
                while (true)
                {
                    try
                    {
                        sh_id = Convert.ToInt32(Console.ReadLine());
                        var shoes = sbl.GetShoesById(sh_id);
                        if (shoes == null)
                        {
                            throw new valueexception("Not find Shoes_ID,please re-enter : ");
                        }
                        else if (shoes != null)
                        {
                            Console.Clear();
                            Console.WriteLine("          Product Information        ");
                            Console.WriteLine("-ID                : {0}", shoes.Shoes_id);
                            Console.WriteLine("-Name              : {0}", shoes.Shoes_name);
                            Console.WriteLine("-Size              : {0}", shoes.Size);
                            Console.WriteLine("-Amount            : {0}", shoes.Amount);
                            Console.WriteLine("-Price             : {0}dong", shoes.Price);
                            Console.WriteLine("-Color             : {0}", shoes.Color);
                            Console.WriteLine("-Material          : {0}", shoes.Material);
                            Console.WriteLine("-Manufacture       : {0}", shoes.Manufacture);
                            Console.WriteLine("-Trademark name    : {0}", shoes.TM.Name);
                            Console.WriteLine("-Trademark Origin  : {0}", shoes.TM.Origin);
                            while (true)
                            {
                                short    mainChoose = 0;
                                string[] mainMenu   = { "Add in shopping cart", "Order now ", "Return shoes list" };
                                while (mainChoose != mainMenu.Length)
                                {
                                    mainChoose = Menu2("You want to add to your shopping cart, buy or return to the shoes list? ", mainMenu);
                                    switch (mainChoose)
                                    {
                                    case 1:
                                        Addshoppingcart();
                                        break;

                                    case  2:
                                        OrderBL obl    = new OrderBL();
                                        Orders  orders = new Orders();
                                        orders.shoesList    = new List <Shoes>();
                                        orders.Order_status = 1;
                                        orders.user         = new User();
                                        orders.user.User_id = id;
                                        orders.shoesList.Add(sbl.GetShoesById(sh_id));
                                        var getshoes = sbl.GetShoesById(sh_id);
                                        while (true)
                                        {
                                            try
                                            {
                                                Console.Write("Input  Amount: ");
                                                int amount1 = Convert.ToInt32(Console.ReadLine());
                                                if ((amount1 > getshoes.Amount && getshoes.Amount == 0) || (amount1 == getshoes.Amount && getshoes.Amount == 0))
                                                {
                                                    Console.WriteLine("Quantity no longer please put another product .. !");
                                                    Console.ReadLine();
                                                    Displaylistshoes();
                                                }
                                                if (amount1 > getshoes.Amount && getshoes.Amount > 0)
                                                {
                                                    Console.WriteLine("Quantity in stock : {0}", getshoes.Amount);
                                                    throw (new valueexception("Not enough quantity , please re-enter: "));
                                                }
                                                else if (0 < amount1 || amount1 <= getshoes.Amount)
                                                {
                                                    orders.shoesList[0].Amount = amount1;
                                                    break;
                                                }
                                            }
                                            catch (valueexception e)
                                            {
                                                Console.Write(e.Message);
                                                continue;
                                            }
                                            catch
                                            {
                                                Console.Write("Please enter a valid  :");
                                                continue;
                                            }
                                            break;
                                        }
                                        Console.WriteLine("Create Order: " + (obl.CreateOrder(orders) ? "completed!" : "not complete!"));
                                        Console.ReadLine();
                                        Displaylistshoes();
                                        break;

                                    case 3:
                                        Displaylistshoes();
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    catch (valueexception e)
                    {
                        Console.Write(e.Message);
                        continue;
                    }
                    catch
                    {
                        Console.WriteLine("FUCK1");
                        Console.Write("Please enter a valid value :");
                        continue;
                    }
                    break;
                }
            }
            else if (choice == "n")
            {
                MenuCustomer();
            }
        }