public static void Main() { ConsoleEx.WriteLine("Hi! This is a program that lets you run a Pharmacy!", ConsoleColor.Green); var options = new List <string>() { "1. Medicines", "2. Orders", "3. Prescriptions", "4. Exit" }; ConsoleEx.WriteLine("This is the list of available commands: ", ConsoleColor.Green); foreach (var option in options) { Console.WriteLine(option); } Console.WriteLine(); string command; do { ConsoleEx.WriteLine("Write your command: ", ConsoleColor.Yellow); command = Console.ReadLine(); command = command.Trim(); if (command == "1") { Console.Clear(); Medicine.Options(); } else if (command == "2") { Console.Clear(); Order.Options(); } else if (command == "3") { Console.Clear(); Prescription.Options(); } else if (command == "4") { break; } else if (command.ToLower() != "exit") { Console.WriteLine("Incorrect Command"); } Console.WriteLine(); } while (command.ToLower() != "exit"); Console.ReadLine(); }
public static void Options() { Console.Clear(); ConsoleEx.WriteLine("Available Options: ", System.ConsoleColor.Blue); Console.WriteLine("1. Show all medicines"); Console.WriteLine("2. Save medicine"); Console.WriteLine("3. Remove medicine"); Console.WriteLine("4. Reload Medicine"); Console.WriteLine("5. Return"); string command = Console.ReadLine(); if (command == "1") { Medicine.ShowAll("Medicines"); Medicine.Options(); } else if (command == "2") { Medicine med = Medicine.NewInstance(); med.Save(med); Medicine.Options(); } else if (command == "3") { Medicine.RemoveMedicine(); } else if (command == "4") { Medicine.Reload(); Medicine.Options(); } else if (command == "5") { Console.Clear(); Pharmacy_Main.Program.Main(); } else { Console.WriteLine("Incorrect Command"); } }
public static void RemoveMedicine() { Medicine.ShowAll("Medicines"); try { Console.WriteLine("Choose ID of the entry you want to remove:"); string id = Console.ReadLine(); DoesEntryExists(id, "Medicines", ""); Medicine.Open(); Medicine.Remove(id, "Medicines", "ID"); ConsoleEx.WriteLine("Successfully removed", ConsoleColor.Green); Console.ReadLine(); } catch (Exception e) { ConsoleEx.WriteLine("The remove action wasn't succesful.", ConsoleColor.Red); Console.WriteLine(e); Console.ReadLine(); } Medicine.Close(); Medicine.Options(); }