//Adds clients public static void AddClient(SuperDume s) { string name, adress, email, phoneNumber, cc, nif; Client client; Console.WriteLine("\n-> Enter ID card"); cc = Console.ReadLine(); client = CheckClientExists(s, cc); if (client == null) { Console.WriteLine("-> Enter Full Name"); name = Console.ReadLine(); Console.WriteLine("\n-> Enter Adress"); adress = Console.ReadLine(); Console.WriteLine("\n-> Enter Email"); email = Console.ReadLine(); Console.WriteLine("\n-> Enter Phone Number"); phoneNumber = Console.ReadLine(); Console.WriteLine("\n-> Enter Tax Number"); nif = Console.ReadLine(); s.AddClient(name, adress, phoneNumber, email, cc, nif); } else { Utils.PrintError("Client already exists."); } }
static void Main(string[] args) { Console.ForegroundColor = System.ConsoleColor.Green; SuperDume superdume = new SuperDume(); int option = -1; int optionStockManager = -1; do { Console.WriteLine("-------:.SuPeRDuMe.:------"); Console.WriteLine("1 - Stock Manager"); Console.WriteLine("2 - Client Manager"); Console.WriteLine("3 - Save Data"); Console.WriteLine("4 - Load Data"); Console.WriteLine("0 - Exit"); Console.WriteLine("--------------------------"); Console.WriteLine("Input option:"); option = int.Parse(Console.ReadLine()); switch (option) { case 1: { // stock manager do { Console.WriteLine("--------------------------"); Console.WriteLine("1 - List Products"); Console.WriteLine("2 - Add New Product"); Console.WriteLine("3 - Update Stock"); Console.WriteLine("4 - Delete Product"); Console.WriteLine("0 - Back"); Console.WriteLine("--------------------------"); optionStockManager = int.Parse(Console.ReadLine()); switch (optionStockManager) { case 1: // list products superdume.ListProducts(); break; case 2: // add new product AddProduct(superdume); break; case 3: // update stock UpdateStock(superdume); break; case 4: { // delete product Product p; Console.WriteLine("Select Product: "); p = CheckProductExists(superdume, int.Parse(Console.ReadLine())); if (p == null) { Utils.PrintError("Wrong code/Product does not exist"); } else { superdume.DeleteProduct(p); } break; } } } while (optionStockManager != 0); break; } case 2: { ClientManagerMenu(superdume); break; } case 3: { WriteBinFile(superdume, Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\superdume.bin"); break; } case 4: { superdume = ReadBinFile(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\superdume.bin"); if (superdume == null) { Utils.PrintError("There is no saved data."); superdume = new SuperDume(); /* Easter Egg * * Adding some default clients and products */ Utils.PrintEaster("You found our Easter Egg! Check clients and products."); superdume.AddClient("Francisco Santos", "Braga", "915874156", "*****@*****.**", "001", "001"); superdume.AddClient("Pedro Fernandes", "Algures", "961813492", "*****@*****.**", "002", "002"); superdume.AddClient("Jorge Noro", "Viana", "935814921", "*****@*****.**", "003", "003"); superdume.AddProduct(123, "Potatoes", 0.99f, 250); superdume.AddProduct(124, "Ham", 1.99f, 100); superdume.AddProduct(125, "Cheese", 5.41f, 100); superdume.AddProduct(126, "Gold", 100.0f, 5); superdume.AddProduct(127, "Easter Egg", 500.0f, 1); } break; } case 0: break; } ; } while (option != 0); }