public static List <string> GetAllReporteeEmails() { List <string> reporteeList = new List <string>(); foreach (Reportee rep in ReporteeDB.GetData()) { reporteeList.Add(rep.Email); } return(reporteeList); }
private void Delete(Object obj) { if (obj.GetType() == typeof(Manager)) { manager = (Manager)obj; if (manager.ProjectList.Count == 0) { managerList = ManagerDB.GetData(); managerList.Remove(manager); ManagerDB.SaveData(managerList); } else { throw new CustomMadeException("Failed to delete manager " + txtId.Text + " as it has projects."); } } else if (obj.GetType() == typeof(Reportee)) { reportee = (Reportee)obj; if (reportee.Project == null) { reporteeList = ReporteeDB.GetData(); reporteeList.Remove(reportee); ReporteeDB.SaveData(reporteeList); } else { throw new CustomMadeException("Failed to delete reportee " + txtId.Text + " as it has project assigned."); } } else if (obj.GetType() == typeof(Project)) { project = (Project)obj; manager = Validator.SearchManagerByProject(project.ProjectID); reporteeList = Validator.SearchReporteeByProject(project.ProjectID); projectList = ProjectDB.GetData(); projectList.Remove(project); ProjectDB.SaveData(projectList); foreach (Project proj in manager.ProjectList) { if (proj.ProjectID.Equals(project.ProjectID)) { manager.ProjectList.Remove(proj); break; } } foreach (Reportee rep in reporteeList) { rep.Project = null; } } }
public static List <Reportee> SearchReporteeByEmail(string email) { List <Reportee> reporteeList = new List <Reportee>(); foreach (Reportee rep in ReporteeDB.GetData()) { if (rep.Email.Equals(email)) { reporteeList.Add(rep); } } return(reporteeList); }
public static List <Reportee> SearchReporteeByLastName(string name) { List <Reportee> reporteeList = new List <Reportee>(); foreach (Reportee rep in ReporteeDB.GetData()) { if (rep.LastName.Equals(name)) { reporteeList.Add(rep); } } return(reporteeList); }
//public static Manager FindManagerByProject(Project project) //{ // foreach(Manager manager in ManagerDB.GetData()) // { // if (manager.ProjectList.Contains(project)) // return manager; // } // return null; //} //public static List<Reportee> FindReporteesByProject(Project project) //{ // List<Reportee> reporteeList = new List<Reportee>(); // foreach(Reportee reportee in ReporteeDB.GetData()) // { // if (reportee.Project == project) // reporteeList.Add(reportee); // } // return reporteeList; //} public static List <Reportee> FindReporteesWithNoProject() { List <Reportee> reporteeList = new List <Reportee>(); foreach (Reportee rep in ReporteeDB.GetData()) { if (rep.Project == null) { reporteeList.Add(rep); } } return(reporteeList); }
private void AddReportee(RadioButton radio) { List <Reportee> reporteeList = ReporteeDB.GetData(); reportee.FirstName = txtFname.Text; reportee.LastName = txtLname.Text; reportee.Email = txtEmail.Text; reportee.ContactNumber = MtxtPhone.Text; reportee.Gender = Convert.ToChar(radio.Text); reportee.Password = txtPassword.Text; reporteeList.Add(reportee); ReporteeDB.SaveData(reporteeList); MessageBox.Show("Reportee with Id " + txtId.Text + " Added Successfully", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information); }
//public static List<Reportee> SearchReporteeByContact(string phone) //{ // List<Reportee> reporteeList = new List<Reportee>(); // foreach (Reportee rep in ReporteeDB.GetData()) // { // if (rep.ContactNumber.Equals(phone)) // reporteeList.Add(rep); // } // return reporteeList; //} public static List <Reportee> SearchReporteeByProject(string projectId) { List <Reportee> reporteeList = new List <Reportee>(); foreach (Reportee rep in ReporteeDB.GetData()) { if (rep.Project != null) { if (rep.Project.ProjectID.Equals(projectId)) { reporteeList.Add(rep); } } } return(reporteeList); }
public static object IsValidInputId(Type t, string Id) { if (t == typeof(Admin)) { foreach (Admin admin in AdminDB.GetData()) { if (admin.EmpID.Equals(Id)) { return(admin); } } } else if (t == typeof(Manager)) { foreach (Manager manager in ManagerDB.GetData()) { if (manager.EmpID.Equals(Id)) { return(manager); } } } else if (t == typeof(Reportee)) { foreach (Reportee reportee in ReporteeDB.GetData()) { if (reportee.EmpID.Equals(Id)) { return(reportee); } } } else { foreach (Project project in ProjectDB.GetData()) { if (project.ProjectID.Equals(Id)) { return(project); } } } return(null); }