public void delete() { Console.WriteLine("\n\t╔══════════════════════════════════╗"); Console.WriteLine("\t║ DELETING AN EMPLOYEE ║"); Console.WriteLine("\t╚══════════════════════════════════╝"); Console.WriteLine("\n\tWhich one would you like to delete? (type the id)"); Console.Write("\n\t>>"); int idToDelete = Convert.ToInt32(Console.ReadLine()); Employee itemToRemove = employeeList.SingleOrDefault(r => r.IdEmployee == idToDelete); if (itemToRemove != null) { employeeList.Remove(itemToRemove); Seerializer.serializeEmployees(employeeList, "Employees.xml"); Console.WriteLine("\n\t╔═════════════════════════════════════════╗"); Console.WriteLine("\t║ EMPLOYEE DELETED SUCCESSFULLY ║"); Console.WriteLine("\t╚═════════════════════════════════════════╝"); Console.ReadKey(); } else { Console.WriteLine("\n\t╔════════════════════════════════════════════════════════╗"); Console.WriteLine("\t║ THE EMPLOYEE YOU WANT TO DROP WAS NOT FOUND ║"); Console.WriteLine("\t╚════════════════════════════════════════════════════════╝"); Console.ReadKey(); } }
public void edit() { Console.WriteLine("\n\t╔════════════════════════════════════╗"); Console.WriteLine("\t║ EDITING AN EMPLOYEE ║"); Console.WriteLine("\t╚════════════════════════════════════╝"); Console.WriteLine("\n\tWhich one would you like to edit? (type the id)"); Console.Write("\n\t>>"); int idToEdit = Convert.ToInt32(Console.ReadLine()); Employee specific = searchById(idToEdit); if (specific != null) { Console.WriteLine("{0}{1}", "\n\tID: ", specific.IdEmployee); Console.WriteLine("{0}{1}", "\tName: ", specific.Name); Console.WriteLine("{0}{1}", "\tLast name: ", specific.LastName); Console.WriteLine("{0}{1}", "\tAddress: ", specific.Address); Console.WriteLine("{0}{1}", "\tPhone number: (+502) ", specific.PhoneNumber); Console.WriteLine("{0}{1}", "\tSalary: Q ", specific.Salary); Console.WriteLine("{0}{1}", "\tJob: ", specific.WorkStation.JobName); Console.WriteLine("{0}{1}", "\tDepartment: ", specific.Section.DepartmentName); Console.Write("\n\tNew name: "); employee.Name = Console.ReadLine(); Console.Write("\tNew last name: "); employee.LastName = Console.ReadLine(); Console.Write("\tNew address: "); employee.Address = Console.ReadLine(); Console.Write("\tNew phone number: "); employee.PhoneNumber = Console.ReadLine(); Console.Write("\tNew salary: "); employee.Salary = Convert.ToDouble(Console.ReadLine()); JobController.Instance.show(); Console.WriteLine("\n\tWhich job would you like to assign to this new employee? (type the id)"); Console.Write("\tNew workstation: "); int workStation = Convert.ToInt32(Console.ReadLine()); employee.WorkStation = JobController.Instance.searchByIdToAddAnEmployee(workStation); DepartmentController.Instance.show(); Console.WriteLine("\n\tWhich department would you like to assign to this new employee? (type the id)"); Console.Write("\tNew department: "); int dept = Convert.ToInt32(Console.ReadLine()); employee.Section = DepartmentController.Instance.searchByIdToAddAnEmployee(dept); Seerializer.serializeEmployees(employeeList, "Employees.xml"); Console.WriteLine("\n\t╔═════════════════════════════════════════╗"); Console.WriteLine("\t║ EMPLOYEE EDITED SUCCESSFULLY ║"); Console.WriteLine("\t╚═════════════════════════════════════════╝"); Console.ReadKey(); } else { Console.WriteLine("\n\t╔════════════════════════════════════════════════════════╗"); Console.WriteLine("\t║ THE EMPLOYEE YOU WANT TO EDIT WAS NOT FOUND ║"); Console.WriteLine("\t╚════════════════════════════════════════════════════════╝"); Console.ReadKey(); } }
public void add() { Console.WriteLine("\n\t╔═══════════════════════════════════╗"); Console.WriteLine("\t║ ADDING A NEW EMPLOYEE ║"); Console.WriteLine("\t╚═══════════════════════════════════╝"); idEmployee++; employee = new Employee(); employee.IdEmployee = idEmployee; Console.Write("\n\tName: "); employee.Name = Console.ReadLine(); Console.Write("\tLast name: "); employee.LastName = Console.ReadLine(); Console.Write("\tAddress: "); employee.Address = Console.ReadLine(); Console.Write("\tPhone number: "); employee.PhoneNumber = Console.ReadLine(); Console.Write("\tSalary: "); employee.Salary = Convert.ToDouble(Console.ReadLine()); JobController.Instance.show(); Console.WriteLine("\n\tWhich job would you like to assign to this new employee? (type the id)"); Console.Write("\tWorkstation: "); int workStation = Convert.ToInt32(Console.ReadLine()); employee.WorkStation = JobController.Instance.searchByIdToAddAnEmployee(workStation); DepartmentController.Instance.show(); Console.WriteLine("\n\tWhich department would you like to assign to this new employee? (type the id)"); Console.Write("\tDepartment: "); int dept = Convert.ToInt32(Console.ReadLine()); employee.Section = DepartmentController.Instance.searchByIdToAddAnEmployee(dept); this.employeeList.Add(employee); Seerializer.serializeEmployees(employeeList, "Employees.xml"); Console.WriteLine("\n\t╔═════════════════════════════════════════╗"); Console.WriteLine("\t║ NEW EMPLOYEE ADDED SUCCESSFULLY ║"); Console.WriteLine("\t╚═════════════════════════════════════════╝"); Console.ReadKey(); }