static void Main(string[] args) { Read_Write.ReadfileProdList(); do { string checkstr = LoginMenu(); if (checkstr == All_Menu_Text.Exit) { break; } else if (checkstr == All_Menu_Text.Boss) { allMenuForBoss(); } else if (checkstr == All_Menu_Text.Staff) { orderService(); } else { Console.WriteLine(All_Menu_Text.WrongMess); } } while (true); }
public static void ProductMenu() { Read_Write.ReadfileProdList(); foreach (var item in Read_Write.ProductList.myProdList) { Console.WriteLine($"{item.prodId}/{item.prodname}"); } Console.WriteLine("0/back"); }
public static Order InputOrder() { Read_Write.ReadfileProdList(); Order order = Order.CreateOrder(); do { All_Menu_Text.ProductMenu(); int chooseProd = Convert.ToInt32(Console.ReadLine()); if (chooseProd == All_Menu_Text.Back_Exit) { break; } Console.WriteLine("enter amount"); int amount = Convert.ToInt32(Console.ReadLine()); order.AddProd(Read_Write.ProductList.FindProdById(chooseProd), amount); } while (true); return(order); }
public static void orderService() { do { All_Menu_Text.ChooseOrderMenu(); int checkpress = Read_Write.GetPress(); if (checkpress == All_Menu_Text.Back_Exit) { break; } Read_Write.ReadfileOrder(); switch (checkpress) { case 1: Read_Write.orderList.AddOrder(InputOrder()); Read_Write.WirteFile(Read_Write.OrderFile, Read_Write.orderList); break; case 2: Read_Write.orderList.ShowAllOrder(); break; case 3: Read_Write.orderList.SearchOrderById(Read_Write.InputId()); break; case 4: Console.Write("enter custumer's name: "); Read_Write.orderList.SearchOrdersByNameCus(Console.ReadLine()); break; case 5: ChangePassService(); break; case 6: do { All_Menu_Text.EditAndPayMenu(); int checkPress = Read_Write.GetPress(); if (checkPress == All_Menu_Text.Back_Exit) { break; } switch (checkPress) { case 1: Read_Write.orderList.Cancel(Read_Write.InputId()); Read_Write.WirteFile(Read_Write.OrderFile, Read_Write.orderList); break; case 2: Order order = Read_Write.orderList.FindOrderByID(Read_Write.InputId()); if (order != null) { Bill bill = Read_Write.orderList.Pay(order); if (bill != null) { Read_Write.WirteFile($@"{Read_Write.billFile}_{order.orderId}", bill); Read_Write.WirteFile(Read_Write.OrderFile, Read_Write.orderList); } else { Console.WriteLine("the order paid or Cancel"); } } else { Console.WriteLine("not found"); } break; case 3: Read_Write.ReadfileOrder(); int orderId = Read_Write.InputId(); if (Read_Write.orderList.FindOrderByID(orderId) != null) { do { All_Menu_Text.EditOrderMennu(); int press = Read_Write.GetPress(); if (press == All_Menu_Text.Back_Exit) { break; } switch (press) { case 1: All_Menu_Text.ProductMenu(); AddProductService(orderId); Read_Write.WirteFile(Read_Write.OrderFile, Read_Write.orderList); Console.WriteLine("Add product success"); break; case 2: Read_Write.orderList.FindOrderByID(orderId).ShowAllProds(); int ProdId = Read_Write.InputId(); if (Read_Write.orderList.FindOrderByID(orderId).FindProd(ProdId) != null) { Read_Write.orderList.FindOrderByID(orderId).RemoveProd(ProdId); Read_Write.WirteFile(Read_Write.OrderFile, Read_Write.orderList); Console.WriteLine("delete success"); } else { Console.WriteLine($"not found {ProdId}"); } break; case 3: Read_Write.orderList.FindOrderByID(orderId).customer = Customer.CreateCustumer(); Read_Write.WirteFile(Read_Write.OrderFile, Read_Write.orderList); break; } } while (true); } else { Console.WriteLine("not found"); } break; } } while (true); break; case 7: do { All_Menu_Text.ProductServiceMenu(); int checkPress = Read_Write.GetPress(); if (checkPress == All_Menu_Text.Back_Exit) { break; } switch (checkPress) { case 1: Read_Write.ReadfileProdList(); All_Menu_Text.ProductMenu(); break; case 2: Read_Write.ReadfileProdList(); int ProductId = Read_Write.InputId(); if (Read_Write.ProductList.FindProdById(ProductId) != null) { Console.WriteLine(Read_Write.ProductList.FindProdById(ProductId)); } else { Console.WriteLine($"not found {ProductId}"); } break; case 3: Read_Write.ReadfileProdList(); int ProdId = Read_Write.InputId(); if (Read_Write.ProductList.FindProdById(ProdId) != null) { Console.Write("enter new name: "); Read_Write.ProductList.FindProdById(ProdId).prodname = Console.ReadLine(); Console.Write("enter new price: "); Read_Write.ProductList.FindProdById(ProdId).price = double.Parse(Console.ReadLine()); Read_Write.WirteFile(Read_Write.ProdListFile, Read_Write.ProductList); Console.WriteLine($"edit {ProdId} success"); } else { Console.WriteLine($"not found {ProdId}"); } break; case 4: Read_Write.ReadfileProdList(); Read_Write.ProductList.AddNewProduct(Product.CreateProduct()); Read_Write.WirteFile(Read_Write.ProdListFile, Read_Write.ProductList); break; case 5: Read_Write.ReadfileProdList(); Read_Write.ProductList.DeleteProduct(Read_Write.InputId()); Read_Write.WirteFile(Read_Write.ProdListFile, Read_Write.ProductList); break; } } while (true); break; } } while (true); }