示例#1
0
        private void AddProject()
        {
            List <Project> projectList = ProjectDB.GetData();

            project.ProjectName = txtProjectname.Text;
            if (txtProjectManager.Text != "")
            {
                project.ProjectManager = FindManager();
            }
            else
            {
                project.ProjectManager = null;
            }
            if (ProjectStatus.Text != "")
            {
                project.ProjectStatus = ProjectStatus.Text;
            }
            else
            {
                ProjectStatus.SelectedIndex = 0;
                project.ProjectStatus       = ProjectStatus.Text;
            }
            projectList.Add(project);
            ProjectDB.SaveData(projectList);
            MessageBox.Show("Project with Id " + txtId.Text + " Added Successfully", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
示例#2
0
        public static List <string> GetAllProjectNames()
        {
            List <string> projectList = new List <string>();

            foreach (Project project in ProjectDB.GetData())
            {
                projectList.Add(project.ProjectName);
            }
            return(projectList);
        }
示例#3
0
 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;
         }
     }
 }
示例#4
0
        public static List <Project> SearchProjectByStatus(string status)
        {
            List <Project> projectList = new List <Project>();

            foreach (Project project in ProjectDB.GetData())
            {
                if (project.ProjectStatus.Equals(status))
                {
                    projectList.Add(project);
                }
            }
            return(projectList);
        }
示例#5
0
        public static List <Project> SearchProjectByName(string name)
        {
            List <Project> projectList = new List <Project>();

            foreach (Project project in ProjectDB.GetData())
            {
                if (project.ProjectName.Equals(name))
                {
                    projectList.Add(project);
                }
            }
            return(projectList);
        }
示例#6
0
        public static List <string> GetAllProjectManagerNames()
        {
            List <string> projectList = new List <string>();

            foreach (Project project in ProjectDB.GetData())
            {
                if (project.ProjectManager != null)
                {
                    projectList.Add(project.ProjectManager.FirstName);
                }
            }
            return(projectList);
        }
示例#7
0
        public static List <Project> SearchProjectByManager(string managerId)
        {
            List <Project> projectList = new List <Project>();

            foreach (Project project in ProjectDB.GetData())
            {
                if (project.ProjectManager != null)
                {
                    if (project.ProjectManager.EmpID.Equals(managerId))
                    {
                        projectList.Add(project);
                    }
                }
            }
            return(projectList);
        }
示例#8
0
 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);
 }