コード例 #1
0
        public void ShowAnItem(int?itemId, int amount)
        {
            while (true)
            {
                Console.Clear();
                Console.Clear();
                var   shoeList = new List <Shoes>();
                Shoes shoes    = new Shoes();
                shoes = shoesBL.GetShoesById(itemId);
                var table = new ConsoleTable("Name:", Convert.ToString(shoes.ShoesName));
                table.AddRow("Size:", SubStringSize(shoes.ShoesSize));
                table.AddRow("Price:", FormatCurrency(shoes.ShoesPrice));
                table.AddRow("Color:", shoes.ShoesColor);
                table.AddRow("Material:", shoes.ShoesMaterial);
                table.AddRow("Brand:", shoes.ShoesBrand);
                table.Write();
                Console.WriteLine();
                OrderBL  orderBL = new OrderBL();
                string[] choice  = { "Add To Cart", "Back" };
                short    choose  = Utility.MenuDetail("Menu", choice);
                switch (choose)
                {
                case 1:
                    AddToCart(shoes, amount);

                    break;
                }
                break;
            }
        }
コード例 #2
0
        public void GetShoesById_Test(int id)
        {
            Shoes sh = sbl.GetShoesById(id);

            Assert.NotNull(sh);
        }
コード例 #3
0
 public void GetShoesByIdTest(int?itemId)
 {
     Assert.NotNull(shoesBL.GetShoesById(itemId));
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: dungnvVtcA/MenShoesStore
        public bool CreateOrder()
        {
            OrderBL obl    = new OrderBL();
            UserBl  ubl    = new UserBl();
            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.Write("Do you want to use the number of phone and current address to get unsigned ? :");
            string chon = Console.ReadLine();

            if (chon == "n")
            {
                Console.WriteLine("Please enter  phone number and address! ");
                while (true)
                {
                    Console.Write("-Enter recipient address :");
                    orders.Address = Console.ReadLine();
                    if (orders.Address != " ")
                    {
                        break;
                    }
                }
                Console.Write("-Enter the recipient's phone number :");
                while (true)
                {
                    orders.phone = Console.ReadLine();
                    if (IsValidString(orders.phone) == true)
                    {
                        break;
                    }
                    else
                    {
                        Console.Write("Please re-enter the recipient's phone number correctly : ");
                    }
                }
            }
            else
            {
                var userdt = ubl.GetUserByid(id);
                orders.Address = userdt.Address;
                orders.phone   = userdt.Phone;
            }

            Console.WriteLine("Create Order: " + (obl.CreateOrder(orders) ? "completed!" : "not complete!"));
            Console.ReadLine();
            Displaylistshoes();
            return(true);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: dungnvVtcA/MenShoesStore
        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();
            }
        }
コード例 #6
0
ファイル: MenuStaff.cs プロジェクト: dungnvVtcA/MenShoesStore
        public static bool BrowseOrders()
        {
            Console.Clear();
            string  line1   = "------------------------------------------------------------------------------------\n";
            Decimal a       = 0;
            int     dem     = 0;
            OrderBL obl     = new OrderBL();
            Orders  orderss = new Orders();

            orderss.shoesList = new List <Shoes>();
            var list = obl.GetAllOrderbyStatus(1);

            if (list.Count != 0)
            {
                decimal k;
                int     sl   = 0;
                string  line = "================================================================================================================================================================";
                Console.WriteLine(line);
                Console.WriteLine(" Order_id        |        Customer Name                                |   Date Create                 |    Total            |     Status Order                 |");
                Console.WriteLine(line);
                foreach (var orders in list)
                {
                    k = 0;
                    if (orders.Order_status != 0)
                    {
                        var orderdetail = obl.GetOrderDetailsByID(orders.Order_id);
                        foreach (var item in orderdetail.shoesList)
                        {
                            decimal price = item.Price * item.Amount;
                            k    += price;
                            money = String.Format("{0:0,0}vnđ", k);
                            if (orderdetail.shoesList.Count > 1)
                            {
                                sl    = orderdetail.shoesList.Count - 1;
                                full2 = orderdetail.user.User_name + "(" + orderdetail.shoesList[0].Shoes_name + " " + "..and" + sl + " " + "other products " + ")";
                            }
                            else
                            {
                                full2 = orderdetail.user.User_name + "(" + orderdetail.shoesList[0].Shoes_name + ")";
                            }
                        }
                        if (orderdetail.Order_status == 1)
                        {
                            b = "The order is pending . . ";
                        }
                        else if (orderdetail.Order_status == 2)
                        {
                            b = "The order has been processed .. ";
                        }
                        Console.WriteLine("{0,-20}{1,-53}{2,-32} {3,-19} {4}", orders.Order_id, full2, orders.Date_Order, money, b);
                    }
                }
                Console.WriteLine(line);
                Console.Write("Do you want to view customer order details? (y/n):");
                char choicce = Convert.ToChar(Console.ReadLine());
                if (choicce == 'y')
                {
                    while (true)
                    {
                        Console.Write("Enter the ID to view the customer's order details: ");
                        while (true)
                        {
                            try
                            {
                                int or_id       = Convert.ToInt32(Console.ReadLine());
                                var orderdetail = obl.GetOrderDetailsByID(or_id);
                                if (orderdetail != null && orderdetail.Order_status == 2)
                                {
                                    throw new valueexception("Order  does not exist or has been approved,please re-enter : ");
                                }
                                else if (orderdetail != null && orderdetail.Order_status == 1)
                                {
                                    Console.Clear();
                                    Console.WriteLine("          Order Detail of Customer Information        ");
                                    Console.WriteLine("-ID                : {0}", orderdetail.Order_id);
                                    Console.WriteLine("-Order date        : {0}", orderdetail.Date_Order);
                                    Console.WriteLine("-Customer name     : {0}", orderdetail.user.User_name);
                                    Console.WriteLine("-Phone             : {0}", orderdetail.phone);
                                    Console.WriteLine("-Address           : {0}", orderdetail.Address);
                                    Console.WriteLine("-Customer Email    : {0}", orderdetail.user.Email);
                                    Console.Write(line1);
                                    Console.Write(" Product name      |  Unitprice          |  Amount          |  Size     |     Total          \n");
                                    foreach (var order in orderdetail.shoesList)
                                    {
                                        Decimal b      = order.Price * order.Amount;
                                        string  money  = String.Format("{0:0,0}vnđ", b);
                                        string  money3 = String.Format("{0:0,0}vnđ", order.Price);
                                        Console.WriteLine("{0,-20} {1,-26} {2,-15} {3,-10} {4}", order.Shoes_name, money3, order.Amount, order.Size, money);
                                        a     += b;
                                        money2 = String.Format("{0:0,0}vnđ", a);
                                    }
                                    Console.Write(line1);
                                    Console.WriteLine("-The total amount payable                                                  {0}", money2);
                                    Console.Write("Do you want to Browse this Order?(y/n) :");
                                    string choice3 = Console.ReadLine();
                                    if (choice3 == "y")
                                    {
                                        var result = obl.GetOrderDetailsByID(or_id);
                                        orderss.Order_id = or_id;
                                        ShoesBL sbl = new ShoesBL();
                                        foreach (var shoes in result.shoesList)
                                        {
                                            orderss.shoesList.Add(sbl.GetShoesById(shoes.Shoes_id));
                                            orderss.shoesList[dem].Amount = shoes.Amount;
                                            dem++;
                                        }
                                        Console.WriteLine("Create Order: " + (obl.update(orderss) ? "completed!" : "not complete!"));
                                        Console.WriteLine("...Browse  Order successful!");
                                    }
                                }
                            }
                            catch (valueexception e)
                            {
                                Console.Write(e.Message);
                                continue;
                            }
                            catch
                            {
                                Console.Write("Please enter a valid value :");
                                continue;
                            }
                            break;
                        }

                        Console.Write("You want to browse order?(y/n) :");
                        string choice = Console.ReadLine();
                        if (choice == "n")
                        {
                            break;
                        }
                        else if (choice == "y")
                        {
                            BrowseOrders();
                            break;
                        }
                    }
                }

                return(true);
            }
            else if (list.Count == 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The orders has been processed!");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.ReadLine();
            }
            return(true);
        }
コード例 #7
0
        public bool Addshoppingcart()
        {
            OrderBL obl1       = new OrderBL();
            var     listorders = obl1.GetAllOrderByIDUser(id);
            Orders  order      = new Orders();

            order.user      = new User();
            order.shoesList = new List <Shoes>();
            int b = listorders.FindIndex(x => x.Order_status == 2);

            if (b != -1)
            {
                var shoes  = sbl.GetShoesById(sh_id);
                int amount = 0;
                while (true)
                {
                    Console.Write("Input amount : ");
                    try{
                        amount = Convert.ToInt32(Console.ReadLine());
                        if ((amount > shoes.Amount && shoes.Amount == 0) || (amount == shoes.Amount && shoes.Amount == 0))
                        {
                            Console.WriteLine("Quantity no longer please put another product .. !");
                            Console.ReadLine();
                            break;
                        }
                        else if (amount > shoes.Amount)
                        {
                            throw new valueexception("so luong khong du vui long nhap lai");
                        }
                        else if (0 < amount && amount < shoes.Amount)
                        {
                            break;
                        }
                    }
                    catch (valueexception e)
                    {
                        Console.Write(e.Message);
                        continue;
                    }catch {
                        Console.Write("Please enter a valid  :");
                        continue;
                    }
                }
                int dem = 0;
                foreach (var or in listorders)
                {
                    if (or.Order_status == 2)
                    {
                        var detail = obl1.GetOrderDetailsByID(or.Order_id);
                        foreach (var shoess in detail.shoesList)
                        {
                            if (shoess.Shoes_id == sh_id)
                            {
                                obl1.updateAmount(amount, shoess.Shoes_id);
                                dem = 1;
                            }
                            else if (shoes.Shoes_id != sh_id)
                            {
                                dem = 0;
                            }
                        }
                    }
                }
                if (dem == 0)
                {
                    Console.WriteLine("Add in shopping cart: " + (obl1.InsertShoppingCarrt(listorders[b].Order_id, sh_id, amount) ? "completed!" : "not complete!"));
                    Console.ReadLine();
                    Displaylistshoes();
                }
                Console.WriteLine("Add in shopping cart completed ");
                Console.ReadLine();
                Displaylistshoes();
            }
            else if (b == -1)
            {
                order.user.User_id = id;
                order.Order_status = 2;
                order.shoesList.Add(sbl.GetShoesById(sh_id));
                var shoes = sbl.GetShoesById(sh_id);
                int amount;
                while (true)
                {
                    Console.Write("Input amount : ");
                    try{
                        amount = Convert.ToInt32(Console.ReadLine());
                        if ((amount > shoes.Amount && shoes.Amount == 0) || (amount == shoes.Amount && shoes.Amount == 0))
                        {
                            Console.WriteLine("Quantity no longer please put another product .. !");
                            Console.ReadLine();
                            break;
                        }
                        else if (amount > shoes.Amount)
                        {
                            throw new valueexception("so luong khong du vui long nhap lai");
                        }
                        else if (0 < amount && amount < shoes.Amount)
                        {
                            break;
                        }
                    }
                    catch (valueexception e)
                    {
                        Console.Write(e.Message);
                        continue;
                    }catch {
                        Console.Write("Please enter a valid  :");
                        continue;
                    }
                }
                order.shoesList[index].Amount = amount;
                index++;

                Console.WriteLine("Add in shopping cart: " + (obl1.AddShppingCart(order) ? "completed!" : "not complete!"));
                Console.ReadLine();
                Displaylistshoes();
            }
            return(true);
        }
コード例 #8
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();
            }
        }