Пример #1
0
 private void BtSaveForm_Click(object sender, RoutedEventArgs e)
 {
     if (LblEmployeeId.Content == null) //Is this a new employee?
     {
         if (MessageBox.Show($"Create new Employee {TbEmpFirstName.Text} {TbEmpLastName.Text}?", "Create New Employee", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             empControl.AddNewEmployee(this);                            //Add new Employee
             LbEmployeeList.ItemsSource = empControl.FillEmployeeList(); //Rebuild list
         }
     }
     else //Existing employee
     {
         if (MessageBox.Show($"Update Employee {TbEmpFirstName.Text} {TbEmpLastName.Text}?", "Update Employee", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             empControl.UpdateEmployee(this);                            //Update Employee record
             LbEmployeeList.ItemsSource = empControl.FillEmployeeList(); //Rebuild list
         }
     }
 }