static void AddEmployee() { string ginNumber = InputHandler.GetGinNumber(); string name = InputHandler.GetName(); string temperature = InputHandler.GetTemperature(); bool symptom = InputHandler.GetSymptom(); bool hubeiExperience = InputHandler.GetHubeiExperience(); healthDataHolder.AddEmployee(ginNumber, name, temperature, symptom, hubeiExperience); Console.WriteLine("\nYou have finished filling today's investigation."); DataPrinter.PrintHeader(); DataPrinter.PrintAnEmployee(ginNumber, name, temperature, symptom.ToString(), hubeiExperience.ToString()); Console.WriteLine("Press any key to continue"); Console.ReadKey(); Console.Clear(); }
public static void LoadDataFromFile() { Program.healthDataHolder = new HealthDataHolder(); if (!File.Exists(@"D:\temp\NewHealthFormApplication.csv")) { Console.WriteLine("The file is not existed."); Console.WriteLine("Press any key to continue"); Console.ReadKey(); Console.Clear(); } else { foreach (string line in File.ReadLines(@"D:\temp\NewHealthFormApplication.csv")) { if (line == "") { Console.WriteLine("The file is empty."); Console.WriteLine("Press any key to continue"); Console.ReadKey(); Console.Clear(); return; } else { string[] employeeData = line.Split(','); string ginNumber = employeeData[0]; string name = employeeData[1]; string temperature = employeeData[2]; bool symptom = employeeData[3] == "Yes"; bool hubeiExperience = employeeData[4] == "Yes"; Program.healthDataHolder.AddEmployee(ginNumber, name, temperature, symptom, hubeiExperience); } } DataPrinter.PrintHeader(); foreach (Employee employee in Program.healthDataHolder.DataHolder.Values) { DataPrinter.PrintAnEmployee(employee.GinNumber, employee.Name, employee.Temperature, employee.Symptom.ToString(), employee.HubeiExperience.ToString()); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Console.Clear(); } }
static void EditEmployee() { Console.WriteLine("Please input the gin number of the employee you would like to edit."); string ginNumber = Console.ReadLine(); if (healthDataHolder.DataHolder.ContainsKey(ginNumber)) { string name = InputHandler.GetName(); string temperature = InputHandler.GetTemperature(); bool symptom = InputHandler.GetSymptom(); bool hubeiExperience = InputHandler.GetHubeiExperience(); healthDataHolder.EditEmployee(healthDataHolder.DataHolder, ginNumber, name, temperature, symptom, hubeiExperience); DataPrinter.PrintHeader(); DataPrinter.PrintAnEmployee(ginNumber, name, temperature, symptom.ToString(), hubeiExperience.ToString()); } else { Console.WriteLine($"\nGin number {ginNumber} is not existed."); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Console.Clear(); }