Наследование: Employee, ICourses
Пример #1
0
 private void addEmployee_MouseUp(object sender, MouseButtonEventArgs e)
 {
     string firstName = firstNameInput.Text;
     string lastName = lastNameInput.Text;
     string egn = egnInput.Text;
     Position position = (Position)positionComboBox.SelectedItem;
     ContractType type = (ContractType)contractTypeComboBox.SelectedItem;
     decimal salary = (decimal)SliderGrade.Value;
     int rating = 1;
     // Get the object with Max ID
     var maxIdEmEmployee = _employeeContainer.EmployeesList.Aggregate((seed, f) => f.Id > seed.Id ? f : seed); // IT is magic but works - don't know how, dont' touch it please :)
     int id = maxIdEmEmployee.Id + 1;
     Employee newEmployee;
     switch (position)
     {
         case Position.Unknown:
             throw new ArgumentException("Please Select Valid Position Type");
         case Position.Principal:
             newEmployee = new Principal(firstName, lastName, egn, type, id, salary, rating);
             break;
         case Position.Administrator:
             newEmployee = new Administrator(firstName, lastName, egn, type, id, salary, rating);
             break;
         case Position.Teacher:
             newEmployee = new Teacher(firstName, lastName, egn, type, id, salary, rating);
             break;
         //case Position.Support:
         //    newEmployee = new Support(firstName, lastName, egn, type, id);
         //    break;
         case Position.Hygienist:
             newEmployee = new Hygienist(firstName, lastName, egn, type, id, salary, rating);
             break;
         default:
             newEmployee = new Teacher(firstName, lastName, egn, type, id, salary, rating);
             break;
     }
     _employeeContainer.Add(newEmployee);
     this.Close();
 }
Пример #2
0
        public EmployeesView(Employee employee)
        { 
            InitializeComponent();
            _employee = employee;

            this.firstName.Text = _employee.FirstName;
            this.lastName.Text = _employee.LastName;
            this.tbxIDNumber.Text = _employee.Id.ToString();
            this.homeTown.Text = _employee.HomeTown;

            if (_employee is Teacher)
            {
                _teacher = (Teacher)_employee;
                this.rank.Text = _teacher.Rank.ToString();
                lvCourses.ItemsSource = _teacher.CoursesList;
            }
            else
            {
 //               promoteBtn.Visibility = System.Windows.Visibility.Hidden;
                addBtn.Visibility = System.Windows.Visibility.Hidden;
                addCourseButton.Visibility = System.Windows.Visibility.Hidden;
                tabMain.Visibility = System.Windows.Visibility.Hidden;
            }
        }