Exemple #1
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;
         }
     }
 }
Exemple #2
0
        private void AddManager(RadioButton radio)
        {
            List <Manager> managerList = ManagerDB.GetData();

            manager.FirstName     = txtFname.Text;
            manager.LastName      = txtLname.Text;
            manager.Email         = txtEmail.Text;
            manager.ContactNumber = MtxtPhone.Text;
            manager.Gender        = Convert.ToChar(radio.Text);
            manager.Password      = txtPassword.Text;
            managerList.Add(manager);
            ManagerDB.SaveData(managerList);
            MessageBox.Show("Manager with Id " + txtId.Text + " Added Successfully", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }