Beispiel #1
0
        private void EmployeeAddAddButton_Click(object sender, EventArgs e)
        {
            if (ErrorCheck())
            {
                return;
            }

            EmployeAddNameTextbox.Text     = EmployeAddNameTextbox.Text.TrimAndRemoveWhiteSpaces().AllFirstLettersToUpper();
            EmployeeAddSurnameTextbox.Text = EmployeeAddSurnameTextbox.Text.TrimAndRemoveWhiteSpaces().AllFirstLettersToUpper();

            var CheckedNames = new List <string>();

            foreach (var ProjectProperties in EmployeePositioncheckedListBox.CheckedItems)
            {
                CheckedNames.Add(ProjectProperties.ToString().GetProjectNameInCheck());
            }

            if (!RemoveUncheckedProjects())
            {
                return;
            }
            AddProjectsToEmployee(CheckedNames);

            EmployeesList.EmployeeDelete(EmployeesList.FindEmployeeByOIB(OldOIB));
            UpdateOIB();

            EmployeesList.AddEmployee(EmployeAddNameTextbox.Text, EmployeeAddSurnameTextbox.Text, EmployeeAddDateTimePicker.Value, EmployeeAddOIBTextbox.Text,
                                      (CompanyPositions)Enum.Parse(typeof(CompanyPositions), EmployeeAddcomboBox.Text));

            Close();
        }
Beispiel #2
0
        private void AddEmployeesToProject()
        {
            var EmployeesUnchecked = new List <string>();

            foreach (var Oib in CheckedOIBs)
            {
                if (EmployeesOnProject.IsEmployeeOnProject(Oib, OldName))
                {
                    continue;
                }
                var AddTime = new AddProjectWorkHours(ProjectAddNameTextBox.Text, EmployeesList.FindEmployeeByOIB(Oib).Name);
                AddTime.ShowDialog();
                if (AddTime.HoursToAdd == 0)
                {
                    MessageBox.Show("Upozorenje!", "Zaposlenik ne može raditi ništa!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    EmployeesUnchecked.Add(Oib);
                    continue;
                }
                EmployeesOnProject.AddProject(OldName, Oib, AddTime.HoursToAdd);
            }
            UncheckEmployees(EmployeesUnchecked);
        }
Beispiel #3
0
        private void EmployeeDeleteButton_Click(object sender, EventArgs e)
        {
            var Employee = new List <Employees>();

            foreach (var EmployeeProperty in EmployeeMenucheckedListBox.CheckedItems)
            {
                Employee.Add(EmployeesList.FindEmployeeByOIB(EmployeeProperty.ToString().GetOIBInCheck()));
            }

            if (Employee.Count == 0)
            {
                return;
            }

            if (DialogResult.Yes == MessageBox.Show("Jeste li sigurni da zelite izbrisati odabrane stavke?", "Oprez!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation))
            {
                foreach (var employees in Employee)
                {
                    DeleteEmployee(employees);

                    /*var ErrorCounter = 0;
                     * foreach (var Project in EmployeesOnProject.GetProjectsByEmployee(employee.OIB))
                     * {
                     *  if (EmployeesOnProject.TryRemove(
                     *      EmployeesOnProject.GetRelation(employee.OIB, Project.Name))) continue;
                     *  ErrorCounter++;
                     *  EmployeeDeleteError LastEmployeeError = new EmployeeDeleteError();
                     *  LastEmployeeError.ShowDialog();
                     *
                     *  break;
                     * }
                     * if (ErrorCounter == 0)
                     *  EmployeesList.EmployeeDelete(employee);*/
                }
            }

            RefreshEmployeesListBox();
        }
Beispiel #4
0
        private bool ErrorCheck()
        {
            if (string.IsNullOrWhiteSpace(EmployeAddNameTextbox.Text) ||
                string.IsNullOrWhiteSpace(EmployeeAddSurnameTextbox.Text) ||
                string.IsNullOrWhiteSpace(EmployeeAddOIBTextbox.Text) ||
                string.IsNullOrWhiteSpace(EmployeeAddcomboBox.Text))
            {
                MessageBox.Show("Upozorenje!", "Nedostaju podatci!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }

            if (!EmployeeAddOIBTextbox.Text.OIBValidation())
            {
                MessageBox.Show("Upozorenje!", "Nije važeči OIB!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }

            if (Addition)
            {
                OldOIB = EmployeeAddOIBTextbox.Text;
                if (EmployeesList.FindEmployeeByOIB(OldOIB) == null)
                {
                    return(false);
                }
                MessageBox.Show("Upozorenje!", "Već postoji zaposlenik s istim OIB-om!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }
            else
            {
                if (OldOIB == EmployeeAddOIBTextbox.Text || EmployeesList.FindEmployeeByOIB(EmployeeAddOIBTextbox.Text) == null)
                {
                    return(false);
                }
                MessageBox.Show("Upozorenje!", "Već postoji zaposlenik s istim OIB-om!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }
        }