Example #1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(NameTextBox.Text))
            {
                NameTextBox.Text = NameTextBox.Text.TrimAndRemoveWhiteSpaces().FirstLetterToUpper();
            }

            foreach (var checkedEmployeeItem in EmployeeListBox.CheckedItems)
            {
                _checkedEmployeesOibList.Add(checkedEmployeeItem.ToString().GetOib());
            }

            if (CheckForErrors())
            {
                return;
            }

            AddEmployeesToProject();
            if (CheckForErrors())
            {
                return;
            }

            RemoveUncheckedEmployees();

            ProjectRepo.Remove(ProjectRepo.GetProjectByName(OldName));
            UpdateProjectName();

            ProjectRepo.TryAdd(NameTextBox.Text, StartDatePicker.Value, EndDatePicker.Value);
            Close();
        }
Example #2
0
        private void DeleteSelectedButton_Click(object sender, EventArgs e)
        {
            var checkedProjects = new List <Project>();

            foreach (var checkedProjectItem in ProjectListBox.CheckedItems)
            {
                checkedProjects.Add(ProjectRepo.GetProjectByName(checkedProjectItem.ToString().GetProjectName()));
            }
            if (checkedProjects.Count == 0)
            {
                return;
            }

            var confirmDeleteProject = new ConfirmForm();

            confirmDeleteProject.ShowDialog();
            if (!confirmDeleteProject.IsConfirmed)
            {
                return;
            }

            foreach (var project in checkedProjects)
            {
                Delete(project);
            }

            RefreshProjectsListBox();
        }
        private void ViewDetailsButton_Click(object sender, EventArgs e)
        {
            var checkedProjects = new List <Project>();

            foreach (var checkedProjectItem in ProjectListBox.CheckedItems)
            {
                checkedProjects.Add(ProjectRepo.GetProjectByName(checkedProjectItem.ToString().GetProjectName()));
            }
            if (checkedProjects.Count == 0)
            {
                return;
            }

            var projectDetails = new ProjectDetailsForm(checkedProjects);

            projectDetails.ShowDialog();
        }
Example #4
0
        private bool CheckForErrors()
        {
            if (string.IsNullOrWhiteSpace(NameTextBox.Text))
            {
                new ErrorForm("You are missing some required fields!").ShowDialog();
                return(true);
            }

            if (_checkedEmployeesOibList.Count == 0)
            {
                new ErrorForm("A project must have at least one employee!").ShowDialog();
                return(true);
            }

            if (IsAdd)
            {
                OldName = NameTextBox.Text;
                if (ProjectRepo.GetProjectByName(OldName) != null)
                {
                    var existingProjectError = new ErrorForm("A project with that name already exists!");
                    existingProjectError.ShowDialog();
                    return(true);
                }
            }
            else
            {
                if (OldName != NameTextBox.Text && ProjectRepo.GetProjectByName(NameTextBox.Text) != null)
                {
                    var existingProjectError = new ErrorForm("A project with that name already exists!");
                    existingProjectError.ShowDialog();
                    return(true);
                }
            }

            if (StartDatePicker.Value <= EndDatePicker.Value)
            {
                return(false);
            }
            var dateError = new ErrorForm("A project cannot end before it has started!");

            dateError.ShowDialog();
            return(true);
        }
Example #5
0
        private void EditProjectButton_Click(object sender, EventArgs e)
        {
            var checkedProjects = new List <Project>();

            foreach (var checkedProjectItem in ProjectListBox.CheckedItems)
            {
                checkedProjects.Add(ProjectRepo.GetProjectByName(checkedProjectItem.ToString().GetProjectName()));
            }
            if (checkedProjects.Count == 0)
            {
                return;
            }

            foreach (var project in checkedProjects)
            {
                var editProject = new EditProjectForm(project);
                editProject.ShowDialog();
            }
            RefreshProjectsListBox();
        }