public static commodity Findcommodity() { var newcom = new commodity() { }; readercommodity(); Console.WriteLine("Enter id or name order "); string name = Console.ReadLine(); if (name[0].Equals("1")) { foreach (var item in root4.commodities) { string tam = Convert.ToString(item.Idproduct); if (name == tam) { newcom = (item); break; } } } else { foreach (var item in root4.commodities) { if (name == item.nameproduct) { newcom = (item); break; } } } return(newcom); }
public static void creatOrder() { reader(); readeracc(); readercommodity(); newdatabase.ID = root.databases[root.databases.Count - 1].ID + 1; int amount1 = 0; var neworder = new commodity(); while (true) { neworder = Findcommodity(); if (neworder == null) { Console.WriteLine("not find commodity"); } else { Console.WriteLine("Enter amount"); amount1 = Int32.Parse(Console.ReadLine()); } newdatabase.Order.Add(new order() { amount = amount1, Idproduct = neworder.Idproduct, nameproduct = neworder.nameproduct, price = neworder.price }); Console.WriteLine("1. add more"); Console.WriteLine("2. exit"); string choice = Console.ReadLine(); if (choice == "2") { break; } } foreach (var item in newdatabase.Order) { newdatabase.totalprice += item.Total; } string tam = ""; while (true) { Console.WriteLine("Enter name Staff:"); tam = Console.ReadLine(); bool check = true; foreach (var item in root2.staffs) { if (item.name == tam) { check = false; break; } } if (check) { Console.WriteLine("staff not exits"); } else { break; } } newdatabase.InformationStaff.nameStaff = tam; Console.WriteLine("Enter info custom: "); Console.Write("name :"); newdatabase.Info.name = Console.ReadLine(); Console.Write("age :"); newdatabase.Info.age = Convert.ToInt32(Console.ReadLine()); Console.Write("numberphone :"); newdatabase.Info.numberphone = Console.ReadLine(); Console.Write("address : "); newdatabase.Info.address = Console.ReadLine(); root.databases.Add(newdatabase); writer(); }