public static void Main() { Console.Title = "reSchedule"; while (true) { Console.Clear(); Shows.entry(Entries.entries3); Console.Write("Pilihan Anda: "); string opt = Console.ReadLine(); switch (opt) { case "1": Func.Pick("User"); break; case "2": Func.Add("User"); break; case "3": Func.Delete("User"); break; case "0": Shows.delay("Bye bye " + User.getName() + " ~"); Environment.Exit(0); break; default: Shows.delay("Pilihan Salah!"); break; } } }
public override void Fungsi() { while (true) { Console.Write("\nPilihan anda: "); string op = Console.ReadLine(); switch (op) { case "1": Func.Add("Tugas"); new UserOpt().Fungsi(); break; case "2": Func.Delete("Tugas"); new UserOpt().Fungsi(); break; case "3": string opt = "1"; while (opt != "0") { Func.Show("Tugas"); Console.Write("Ketik 0 untuk kembali! "); opt = Console.ReadLine(); } new UserOpt().Fungsi(); break; case "0": new UserOpt().Menu(); break; default: Shows.delay("Pilihan Salah! "); new UserOpt().Fungsi(); break; } Shows.entry(Entries.entries2); } }
public static void Pick(string obj) { using ReScContext context = new ReScContext(); int opt = 1; while (opt != 0) { Show(obj); Console.Write("Pilih Id " + obj + " yang diinginkan / 0 untuk kembali: "); opt = Convert.ToInt32(Console.ReadLine()); if (opt != 0) { foreach (User user in context.Users) { if (user.Id == opt) { new UserOpt().Menu(); } } Shows.delay("Id tidak valid"); } } }
public override void Menu() { while (true) { Console.Write("\nPilihan anda: "); string op = Console.ReadLine(); switch (op) { case "1": new UserOpt().Fungsi(); break; case "0": Program.Main(); break; default: Shows.delay("Pilihan Salah! "); Menu(); break; } Shows.entry(Entries.entries1); } }
public static void Delete(string obj) { using ReScContext context = new ReScContext(); string opt = "1"; while (opt != "0") { Show(obj); Console.Write("Pilih Id " + obj + " yang ingin dihapus / 0 untuk kembali: "); opt = Console.ReadLine(); int ops = Convert.ToInt32(opt); if (opt != "0") { bool x = false; if (obj == "Tugas") { Tugas newTu = new Tugas(); foreach (Tugas tugas in context.listTugas) { if (tugas.Id == ops) { newTu = tugas; x = true; break; } } if (!x) { Shows.delay("Id " + ops + " tidak ditemukan!"); Delete(obj); } context.listTugas.Remove(newTu); } else if (obj == "User") { User newUs = new User(); foreach (User user in context.Users) { if (user.Id == ops) { newUs = user; x = true; break; } } if (!x) { Shows.delay("Id " + ops + " tidak ditemukan!"); Delete(obj); } foreach (Tugas tugas in context.listTugas) { if (tugas.userId == ops) { context.listTugas.Remove(tugas); } } context.Users.Remove(newUs); } context.SaveChanges(); Show(obj); } } }