public static short showListItems(string title, string[] menuItems, List <Shoes> shoes, int UserID) { Console.Clear(); Console.Clear(); short choice = -1; var table = new ConsoleTable("Shoes ID", "Name", "Price", "Size", "Color", "Material", "Brand", "Quantity"); OrderBL orderBL = new OrderBL(); foreach (Shoes item in shoes) { table.AddRow(item.ShoesId, item.ShoesName, FormatCurrency(item.ShoesPrice), item.ShoesSize, item.ShoesColor, item.ShoesMaterial, item.ShoesBrand, item.ShoesQuantity); } table.Write(); if (shoes.Count <= 0) { Console.WriteLine("No shoes information found"); } ShoesBL shoesBL = new ShoesBL(); for (int i = 0; i < menuItems.Length; i++) { Console.WriteLine((i + 1) + ". " + menuItems[i]); } Console.WriteLine(row1); try { Console.Write("#Select: "); choice = Int16.Parse(Console.ReadLine()); } catch (System.Exception) { } if (choice < 0 || choice > menuItems.Length) { do { try { Console.Write("#Please enter the correct selection "); choice = Int16.Parse(Console.ReadLine()); } catch (System.Exception) { continue; } } while (choice < 0 || choice > menuItems.Length); } return(choice); }
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); }
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(); } }
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(); } }