public void Comanda(object obj) { string[] lines = File.ReadAllLines(@"..\..\..\Comanda.txt"); string[] lines1 = File.ReadAllLines(@"..\..\..\PretCuDiscount.txt"); string str = RandomString(5, true); foreach (var it in lines) { if (it != "") { string[] words = it.Split(','); restaurant.AddComanda(Int32.Parse(words[0]), 1, Double.Parse(lines1[0]), DateTime.Now.Date, str); } break; } List <Comanda> comenzi = restaurant.Comandas.ToList(); List <int> id_prep = new List <int>(); List <int> id = new List <int>(); int id_comanda = 0; foreach (var comanda in comenzi) { id.Add(comanda.id); } id_comanda = id.Max(); foreach (var it in lines) { if (it != "") { string[] words = it.Split(','); if (Int32.Parse(words[5]) == 1) { restaurant.AddPreparatForComands(Int32.Parse(words[1]), id_comanda); restaurant.ModifyCantitatePreparat(Int32.Parse(words[1]), Int32.Parse(words[4])); } else if (Int32.Parse(words[5]) == 2) { restaurant.AddMeniuForComands(Int32.Parse(words[1]), id_comanda); foreach (var i in restaurant.GetIdPreparatFromPM(Int32.Parse(words[1])).ToList()) { int cantitate = Int32.Parse(restaurant.GetCantitate(i).ToString()); restaurant.ModifyCantitatePreparat((int)i, cantitate); } } } } MessageBox.Show("Comanda dumneavoastra s-a realizat cu succes!", "Information", MessageBoxButton.OK, MessageBoxImage.Information); if (File.Exists(@"..\..\..\Comanda.txt")) { File.Delete(@"..\..\..\Comanda.txt"); } }