public static void PayOrderByIdOrder() { Method.ReadOnMember(); int idorder = Management.CreateInteger("id Order", 1); int pos = Method.Find_IdOrder(idorder, out int index_custumer); if (pos != -1 && data.custumers[index_custumer].oders[pos].status == "Waiting") { string Path = @"E:\CODEGYM\Module2\BaitapModule2_lan2\BaitapModule2_lan2\Bai3\PayOrder"; string fileName = $"{DateTime.Now.ToString("dd-MM-yyyy")}__{idorder}"; PayOrder payOrder = new PayOrder(); payOrder.Id_Custumer = data.custumers[index_custumer].id_custumer; payOrder.Name_Custumer = data.custumers[index_custumer].name_custumer; payOrder.Adrres = data.custumers[index_custumer].adress_custumer; payOrder.Phone_number = data.custumers[index_custumer].number_phone; payOrder.status = "Payed"; payOrder.products = data.custumers[index_custumer].oders[pos].products; data.custumers[index_custumer].oders[pos].status = "Payed"; using (StreamWriter sw = File.CreateText($@"{Path}\{fileName}")) { var dada = JsonConvert.SerializeObject(payOrder); sw.Write(dada); } Method.PushInDATA(); Console.WriteLine("Payment success"); } else { Console.WriteLine("Not found Order or Order Payed!"); } }
public static void changePassword(int id_Custumer) { Console.Clear(); Method.ReadOnMember(); Console.WriteLine("- - - - Change Password - - - -"); Console.Write("Enter current password: "******"Enter again current password: "******"Enter new user password: "******"Enter new user password minimum of 8 characters and non-Space : "); pass1 = (Console.ReadLine()).Trim(); } Console.Write("Enter reenter password: "******"Enter again confirm password: "); data.members[pos].user_password = (Console.ReadLine()).Trim(); } Method.PushInDATA(); }
public static void UpdateOrdersAccording() { Method.ReadOnMember(); int idorder = Management.CreateInteger("id of Order", 1); int pos1 = Method.Find_IdOrder(idorder, out int index_custumer); int keyof = index_custumer; if (pos1 != -1) { int choose = -1; while (choose != 4) { Find_Order_byIdOrder(idorder); Console.WriteLine("\n1. Add product on Order"); Console.WriteLine("2. Remove product on Order"); Console.WriteLine("3. Update product on Order"); Console.WriteLine("4. Exit"); choose = Management.CreateInteger("choose", 1, 4); Console.Clear(); Find_Order_byIdOrder(idorder); switch (choose) { case 1: string key = "Y"; do { Console.Clear(); Console.WriteLine("\n * * Add product on Order * * \n"); Find_Order_byIdOrder(idorder); Product product = new Product(); Console.WriteLine("\nProduct list in store"); Management.ShowProduct(); Console.Write("\nEnter the Code to select the product: "); string code = Console.ReadLine(); int pos = Management.Find(code); while (pos == -1) { Console.Write("\nNot found! Enter again the Code to select the product: "); code = Console.ReadLine(); pos = Management.Find(code); } product.code_product = code; product.name_product = Management.management.listProduct[pos].name_product; product.price_product = Management.management.listProduct[pos].price_product; product.quantity_product = Management.CreateInteger("quantity", 1, 10000); int j; if (data.custumers[keyof].oders[pos1].products.Count == 0) { data.custumers[keyof].oders[pos1].products.Add(product); } else { for (j = 0; j < data.custumers[keyof].oders[pos1].products.Count; j++) { if (data.custumers[keyof].oders[pos1].products[j].code_product == product.code_product) { data.custumers[keyof].oders[pos1].products[j].quantity_product += product.quantity_product; break; } } if (j == data.custumers[keyof].oders[pos1].products.Count) { data.custumers[keyof].oders[pos1].products.Add(product); } } Method.PushInDATA(); Console.Write("Continue? (Y/N): "); key = Console.ReadLine(); }while (key.ToUpper() != "N"); Console.Clear(); break; case 2: key = "Y"; do { Console.Clear(); Console.WriteLine("\n * * Update product on Order * * \n"); Find_Order_byIdOrder(idorder); //Management.ShowProduct(); Console.Write("\nEnter the Code to select the product: "); string code = Console.ReadLine(); for (int i = 0; i < data.custumers[keyof].oders[pos1].products.Count; i++) { if (data.custumers[keyof].oders[pos1].products[i].code_product == code) { data.custumers[keyof].oders[pos1].products.RemoveAt(i); Console.WriteLine("Product deleted"); break; } } Method.PushInDATA(); Console.Write("Continue? (Y/N): "); key = Console.ReadLine(); }while (key.ToUpper() != "N"); Console.Clear(); break; case 3: key = "Y"; do { Console.Clear(); Console.WriteLine("\n * * Remove product on Order * * \n"); Find_Order_byIdOrder(idorder); //Management.ShowProduct(); Console.Write("\nEnter the Code to select the product: "); string code = Console.ReadLine(); int quan = Management.CreateInteger("quantity", 1); for (int i = 0; i < data.custumers[keyof].oders[pos1].products.Count; i++) { if (data.custumers[keyof].oders[pos1].products[i].code_product == code) { data.custumers[keyof].oders[pos1].products[i].quantity_product = quan; Console.WriteLine("Purchase quantity has been changed"); break; } } Method.PushInDATA(); Console.Write("Continue? (Y/N): "); key = Console.ReadLine(); }while (key.ToUpper() != "N"); Console.Clear(); break; } } } else { Console.WriteLine("Not found Order!"); } //Method.PushInDATA(); }
public static void CreateNewOder(int id_Custumer) { Oder oder = new Oder(); Method.ReadOnMember(); int pos_Custumer = Management.FindIndexOfIdCustumer(id_Custumer); if (pos_Custumer != -1) { if (Method.data.custumers[pos_Custumer].oders.Count == 0) { oder.OrderItem = 1; } else { int max = Method.data.custumers[pos_Custumer].oders[0].OrderItem; for (int i = 1; i < Method.data.custumers[pos_Custumer].oders.Count; i++) { if (Method.data.custumers[pos_Custumer].oders[i].OrderItem > max) { max = Method.data.custumers[pos_Custumer].oders[i].OrderItem; } } oder.OrderItem = max + 1; } oder.status = "Waiting"; oder.OrderId = int.Parse($"{id_Custumer}{ oder.OrderItem}"); string key = "Y"; do { Product product = new Product(); Console.WriteLine("Product list in store"); Management.ShowProduct(); Console.Write("\nEnter the Code to select the product: "); string code = Console.ReadLine(); int pos = Management.Find(code); while (pos == -1) { Console.Write("\nNot found! Enter again the Code to select the product: "); code = Console.ReadLine(); pos = Management.Find(code); } product.code_product = code; product.name_product = management.listProduct[pos].name_product; product.price_product = management.listProduct[pos].price_product; product.quantity_product = Management.CreateInteger("quantity", 1, 10000); int j; if (oder.products.Count == 0) { oder.products.Add(product); } else { for (j = 0; j < oder.products.Count; j++) { if (oder.products[j].code_product == product.code_product) { oder.products[j].quantity_product += product.quantity_product; break; } } if (j == oder.products.Count) { oder.products.Add(product); } } Console.Write("Continue? (Y/N): "); key = Console.ReadLine(); }while (key.ToUpper() != "N"); Method.data.custumers[pos_Custumer].oders.Add(oder); Method.PushInDATA(); } }