Exemple #1
0
        public void To_String_Test()
        {
            EmployeeClass myEmployee = new EmployeeClass(123, "Yulia Svit", "Manager");

            Console.WriteLine(myEmployee);
        }
Exemple #2
0
        public void NewEmployee()
        {
            tbLog.Text = string.Empty;

            if (tbName.Text == "" | tbSurname.Text == "" | tbWage.Text == "" | cbBirthyear.SelectedIndex == -1 | cbEducation.SelectedIndex == -1 | cbPosition.SelectedIndex == -1)
            {
                tbLog.Foreground = Brushes.Red;
                tbLog.Text       = "prosím vyplňte všecha pole";
            }
            else
            {
                EmployeeClass newEmployee = new EmployeeClass(cbEducation.Text, cbPosition.Text, Convert.ToInt32(tbWage.Text), tbName.Text, tbSurname.Text, Convert.ToInt32(cbBirthyear.Text));

                if (newEmployee.errLongName | newEmployee.errShortName | newEmployee.errLongSurname | newEmployee.errShortSurname | newEmployee.errWageBig | newEmployee.errWageSmall)
                {
                    tbLog.Foreground = Brushes.Red;

                    if (newEmployee.errLongName)
                    {
                        tbLog.Text = "Moc dlouhé jméno\n";
                    }
                    else if (newEmployee.errShortName)
                    {
                        tbLog.Text = "Moc krátké jméno\n";
                    }
                    if (newEmployee.errLongSurname)
                    {
                        tbLog.Text += "Moc dlouhé příjmení\n";
                    }
                    else if (newEmployee.errShortSurname)
                    {
                        tbLog.Text += "Moc krátké příjmení\n";
                    }
                    if (newEmployee.errWageBig)
                    {
                        tbLog.Text += "Moc velký plat\n";
                    }
                    else if (newEmployee.errWageSmall)
                    {
                        tbLog.Text += "Moc malý plat\n";
                    }
                }
                else if (employeesList.Any(x => (x.FirstName.ToLower() == newEmployee.FirstName.ToLower()) && (x.Surname.ToLower() == newEmployee.Surname.ToLower()) && (x.birthyear == newEmployee.birthyear)))
                {
                    tbLog.Foreground = Brushes.Red;
                    tbLog.Text       = "už je v listu";
                }
                else
                {
                    employeesList.Add(newEmployee);
                    tbLog.Foreground = Brushes.Black;
                    tbLog.Text       = "zaměstnanec přidán";

                    tbName.Text               = string.Empty;
                    tbSurname.Text            = string.Empty;
                    tbWage.Text               = string.Empty;
                    cbBirthyear.SelectedIndex = -1;
                    cbEducation.SelectedIndex = -1;
                    cbPosition.SelectedIndex  = -1;
                }
            }
        }