public void orders() { while (true) { Console.Clear(); Console.WriteLine(" Create Order"); Console.WriteLine("================================================================="); Console.Write("Input Item ID : "); int itemid = valid(Console.ReadLine()); item item = ibl.Getitembyid(itemid); list.Add(item); if (item != null) { Console.WriteLine("====================================================="); Console.WriteLine("|Item ID|Item name |Unit price |"); Console.WriteLine("====================================================="); foreach (var i in list) { Console.WriteLine("|{0,-7}|{1,-28}|{2,-14}|", i.item_id, i.item_name, moneyformat(i.unit_price)); Console.WriteLine("====================================================="); } Console.Write("Input quantity : "); int quantity = valid(Console.ReadLine()); if (quantity > item.quantity) { list.Remove(item); Console.Clear(); Console.WriteLine("Only have" + item.quantity); Console.Write("Press enter to input item id !"); Console.ReadLine(); } else { obl.AddItem(itemid, quantity, order); Console.Write("Add more item ? (Y/N) : "); char add = valid2(Console.ReadLine()); if (add == 'n' || add == 'N') { Console.WriteLine("**************************"); Console.WriteLine("a.Pay and print bill\n\nb.Cancel order"); Console.WriteLine("**************************"); Console.Write("Choice : "); char pay = valid4(Console.ReadLine()); if (pay == 'b' || pay == 'B') { Console.Clear(); Console.WriteLine("Order was canceled !\nPress enter to back"); Console.ReadKey(); main.orders(); } else if (pay == 'a' || pay == 'A') { Console.Clear(); bool re = obl.CreateOrder(order); if (re == true) { Console.WriteLine(" Item List"); Console.WriteLine("======================================================================"); Console.WriteLine("|Item |Unit price |Quantity|Price |"); Console.WriteLine("======================================================================"); foreach (var i in obl.GetOrderDetail()) { decimal price = i.amount * i.price; Console.WriteLine("|{0,-22}|{1,-17}|{2,-8}|{3,-18}|", i.item_name, moneyformat(i.price), i.amount, moneyformat(price)); Console.WriteLine("======================================================================"); } Console.WriteLine(" Total Money :" + moneyformat(obl.Money(order))); Console.WriteLine("======================================================================"); Console.Write("Input money get from customer : "); decimal paid = valid(Console.ReadLine()); while (paid < obl.Money(order)) { Console.Write("Not enough, please re-enter : "); paid = valid(Console.ReadLine()); } decimal payback = paid - obl.Money(order); Console.WriteLine("Pay success!\nPress enter to print bill !"); Console.ReadLine(); Console.Clear(); Console.WriteLine(" BILL"); Console.WriteLine("=============================================================="); Console.WriteLine("Store : Luxury shop"); Console.WriteLine("Address : 300 Kim Nguu, Ha Noi"); Console.WriteLine("Phone number : 01627344748"); order or = obl.GetLastOrder(); Console.WriteLine("Order ID : " + order.order_id); Console.WriteLine("Order time : " + or.order_date); Console.WriteLine("Staff : " + or.user_name); Console.WriteLine(" Item list"); Console.WriteLine("=============================================================="); Console.WriteLine("|Item |Unit price |Quantity|Price |"); Console.WriteLine("=============================================================="); foreach (var i in obl.GetOrderDetail()) { decimal price = i.amount * i.price; Console.WriteLine("|{0,-22}|{1,-13}|{2,-8}|{3,-14}|", i.item_name, moneyformat(i.price), i.amount, moneyformat(price)); Console.WriteLine("=============================================================="); } Console.WriteLine(" Total money : " + moneyformat(obl.Money(order))); Console.WriteLine(" Get from customer : " + moneyformat(paid)); Console.WriteLine(" Pay back : " + moneyformat(payback)); Console.WriteLine("....................................................................."); Console.WriteLine(" Thanks You"); Console.WriteLine(" SEE YOU AIGAIN"); Console.WriteLine("Press enter to back to menu!"); Console.ReadKey(); main.orders(); } else { Console.WriteLine("Tạo đơn hàng thất bại!"); Console.Write("Nhấn phím [Enter] để quay lại menu chính..."); Console.ReadLine(); main.orders(); } } } } } else if (item == null) { Console.WriteLine("Not exist item !"); Console.Write("Press enter to re-enter !"); Console.ReadLine(); } } }
public void CreateOrderSuccess() { order.itemlist.Add(ibl.Getitembyid(1)); order.itemlist[0].quantity = 1; Assert.True(obl.CreateOrder(order)); }