示例#1
0
        private void AddNewEmployee(object sender, RoutedEventArgs e)
        {
            var nextId      = _employees.Count + 1;
            var newEmployee = new Employee();
            AddChangeEmployee addEmployee = new AddChangeEmployee(newEmployee, _departments);

            addEmployee.Show();
            addEmployee.Closed += (s, ew) => _employees.Add(new Employee()
            {
                Id = nextId, Name = newEmployee.Name, Department = newEmployee.Department, Age = newEmployee.Age, Salary = newEmployee.Salary
            });
        }
示例#2
0
        private void ChangeEmployee(object sender, RoutedEventArgs e)
        {
            var selectedEmployee = lbEmployee.SelectedItem as Employee;
            var selectedIndex    = lbEmployee.SelectedIndex;

            if (selectedEmployee is null)
            {
                MessageBox.Show("Выберите сотрудника");
                return;
            }
            AddChangeEmployee changeEmoloyee = new AddChangeEmployee(selectedEmployee, _departments);

            changeEmoloyee.Show();
            changeEmoloyee.Closed += (s, ea) => _employees.RemoveAt(selectedIndex);
            changeEmoloyee.Closed += (s, ea) => _employees.Add(selectedEmployee);
        }