예제 #1
0
        private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            NewEmployee      cw = new NewEmployee();
            EmployeeDataForm employeeDataForm = new EmployeeDataForm();

            employeeDataForm.Margin      = new Thickness(3);
            employeeDataForm.Width       = 450;
            employeeDataForm.TheEmployee = new Employee();
            employeeDataForm.IsLocked    = false;

            cw.LayoutRoot.Children.Add(employeeDataForm);
            cw.HasCloseButton = false;
            cw.Title          = "New Employee Details";
            cw.Closed        += (s, args) =>
            {
                if (cw.DialogResult.Value && employeeDataForm.IsValid)
                {
                    EmployeesManager em = this.Resources["employeeManagerViewSource"] as EmployeesManager;
                    em.Employees.Add(employeeDataForm.TheEmployee);
                }
            };
            cw.Closing += (s, args) =>
            {
                if (!employeeDataForm.IsValid && cw.DialogResult.Value)
                {
                    MessageBox.Show("Some of field values are not valid.\nPlease fix all 					marked fielsd and try agan");
                    args.Cancel = true;
                }
            };
            cw.Show();
        }
예제 #2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            EmployeesManager em = this.Resources["employeeManagerViewSource"]
                                  as EmployeesManager;

            em.Employees.Remove(dg.SelectedItem as Employee);
        }