static string CheckIdExists() { Console.WriteLine("Enter employee id: "); string idcheck = Convert.ToString(Console.ReadLine()); string idfinal; DataManipulation check = new DataManipulation(); var idlist = check.idList(); int count = idlist.Count; var list = check.ForUse(); if (!list.ContainsKey(idcheck)) { idfinal = idcheck; } else { do { Console.WriteLine("Employee id already exist\nPlease enter a new Employee id:(Suggested Employee ID: {0})", count); idcheck = Convert.ToString(Console.ReadLine()); } while (list.ContainsKey(idcheck)); idfinal = idcheck; } return(idfinal); }
static void Main(string[] args) { Console.WriteLine("To Log In, Choose an option\nFor Admin Log In Press: A\nFor Employee Log In Press: E\nTo Exit Press: X\n "); string select = Convert.ToString(Console.ReadLine()); Admin accessAdmin = new Admin(); DataManipulation value = new DataManipulation(); Employee accessEmployee = new Employee(); if (select == "A" || select == "E") { Choice(select); } else if (select == "X") { Choice(select); } else { do { Console.WriteLine("Wrong Choice."); Console.WriteLine("To Log In, Choose an option\nFor Admin Log In Press: A\nFor Employee Log In Press: E\nTo Exit Press: X\n "); select = Convert.ToString(Console.ReadLine()); } while (select != "A" && select != "E" && select != "X"); Choice(select); } }
public void AdminLogIn() { Console.WriteLine("To create new employee press: C\nTo edit employee press: R\nTo delete employee press: D\nTo Log Out press: X "); string select = Convert.ToString(Console.ReadLine()); if (select == "C") { CreateUser(); Console.WriteLine("New user created successfully."); } else if (select == "R") { DataManipulation edit = new DataManipulation(); edit.Edit(); Console.WriteLine("Employee details changed successful."); } else if (select == "D") { RemoveEmployee(); } else if (select == "X") { Console.WriteLine("You have Loged Out successful. Press Enter to close the program"); } else { Console.WriteLine("Wrong Choice."); } }
static void Choice(string choose) { DataManipulation value = new DataManipulation(); if (choose == "A") { value.Readcsv(); // accessAdmin.AdminLogIn(); } else if (choose == "E") { value.Readcsv(); //accessEmployee.EmployeeLogIn(); } else if (choose == "X") { Console.WriteLine("You have exited. Press Enter to close."); } }
static void RemoveEmployee() { DataManipulation delete = new DataManipulation(); var collect = delete.ForUse(); Console.WriteLine(string.Join(", ", collect.Keys)); Console.WriteLine(string.Join(", ", collect["2"])); Console.WriteLine("Enter employee id: "); string empID = Convert.ToString(Console.ReadLine()); var edit = delete.idList(); if (collect.ContainsKey(empID)) { collect.Remove(empID); Console.WriteLine(string.Join(", ", collect.Keys)); Console.WriteLine("Employee details of Employee ID {0} successfully deleted.", empID); } else if (!edit.Contains(empID)) { Console.WriteLine("Employee details of Employee ID {0} does not exist.", empID); } }