Esempio n. 1
0
        //the method that create window wherein you can write data about employee which you wanna add
        private void Add_Button_Click(object sender, RoutedEventArgs e)
        {
            AddEmployeeWindow AddWindow = new AddEmployeeWindow();             // creating window

            AddWindow.Owner = this;
            if (AddWindow.ShowDialog() == true)
            {
                string[] fields =
                {
                    AddWindow.DatePickerAddEmployee.SelectedDate.ToString(),
                    AddWindow.EmployeeFirstName.Text,
                    AddWindow.EmployeeLastName.Text,
                    AddWindow.EmployeeUserName.Text,
                    AddWindow.EmployeeCity.Text,
                    AddWindow.EmployeeCountry.Text
                };
                context.Employees.Add(new Employee(fields));                 // add employee to the context
                EmployeesGrid.SelectedItem = EmployeesGrid.Items[EmployeesGrid.Items.Count - 1];
                EmployeesGrid.ScrollIntoView(EmployeesGrid.Items[EmployeesGrid.Items.Count - 1]);
            }
            else
            {
                MessageBox.Show("Добавление отменено", "Уведомление", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }