Esempio n. 1
0
 private bool TryRemoveUncheckedProjects()
 {
     foreach (var projectItem in ProjectListBox.Items)
     {
         if (ProjectListBox.CheckedItems.Contains(projectItem))
         {
             continue;
         }
         if (!RelationProjectEmployeeRepo.IsEmployeeOnProject(OldOib, projectItem.ToString().GetProjectName())
             )
         {
             continue;
         }
         if (RelationProjectEmployeeRepo.TryRemove(
                 RelationProjectEmployeeRepo.GetRelation(OldOib, projectItem.ToString().GetProjectName())))
         {
             continue;
         }
         var lastEmployeeError = new ErrorForm($"{NameTextBox.Text} could not be removed from project {projectItem.ToString().GetProjectName()}\n" +
                                               "He is the last employee on that project");
         lastEmployeeError.ShowDialog();
         return(false);
     }
     return(true);
 }
Esempio n. 2
0
 private static void Delete(Project toDelete)
 {
     ProjectRepo.Remove(toDelete);
     foreach (var employee in RelationProjectEmployeeRepo.GetEmployeesOnProject(toDelete.Name))
     {
         RelationProjectEmployeeRepo.Remove(RelationProjectEmployeeRepo.GetRelation(employee.Oib, toDelete.Name));
     }
 }
Esempio n. 3
0
 private void RemoveUncheckedEmployees()
 {
     foreach (var employeeItem in EmployeeListBox.Items)
     {
         if (EmployeeListBox.CheckedItems.Contains(employeeItem))
         {
             continue;
         }
         if (RelationProjectEmployeeRepo.IsEmployeeOnProject(employeeItem.ToString().GetOib(),
                                                             OldName))
         {
             RelationProjectEmployeeRepo.Remove(
                 RelationProjectEmployeeRepo.GetRelation(employeeItem.ToString().GetOib(),
                                                         OldName));
         }
     }
 }
Esempio n. 4
0
        private static void TryDelete(Employee toRemove)
        {
            var errorCount = 0;

            foreach (var project in RelationProjectEmployeeRepo.GetProjectsByEmployee(toRemove.Oib))
            {
                if (RelationProjectEmployeeRepo.TryRemove(
                        RelationProjectEmployeeRepo.GetRelation(toRemove.Oib, project.Name)))
                {
                    continue;
                }
                errorCount++;
                var lastEmployeeOnProjectError = new ErrorForm($"Employee {toRemove.Name} {toRemove.LastName} could not be deleted!\nHe is the last employee on one or more projects!");
                lastEmployeeOnProjectError.ShowDialog();
                break;
            }
            if (errorCount == 0)
            {
                EmployeeRepo.Remove(toRemove);
            }
        }
Esempio n. 5
0
        private void RefreshProjectDetails()
        {
            var detailsText = "";

            foreach (var project in ProjectsToShow)
            {
                detailsText += $"{project.Name}\n{project.StartOfProject:d} - {project.EndOfProject:d}\n\n";

                foreach (var position in Enum.GetNames(typeof(Position)))
                {
                    var positionEmployees = new List <Employee>();
                    foreach (var employee in RelationProjectEmployeeRepo.GetEmployeesOnProject(project.Name))
                    {
                        if (employee.Position.ToString() == position)
                        {
                            positionEmployees.Add(employee);
                        }
                    }

                    if (positionEmployees.Count == 0)
                    {
                        continue;
                    }

                    detailsText += $"{position} ({positionEmployees.Count})\n";

                    foreach (var employee in positionEmployees)
                    {
                        detailsText +=
                            $"\t{employee.Name} {employee.LastName} ({RelationProjectEmployeeRepo.GetRelation(employee.Oib, project.Name).HoursOfWork} hours)\n";
                    }

                    detailsText += "\n";
                }

                detailsText += "\n";
            }

            ProjectDetailsTextBox.Text = detailsText;
        }