private void Button_Click_1(object sender, RoutedEventArgs e) { //Update Employee if (!(employee is Employee)) { label_current_emp.Content = "Select an Employee to Update!"; return; } var dialog = new UI.Widgets.AddEmployeeDialog(_appServices, employee); dialog.label_header.Content = "Update Employee details."; dialog.combo_depts.SelectedIndex = _Selected_index; dialog.Owner = this; var v = dialog.ShowDialog(); if (v == true) { employee.EmployeeID = employee.EmployeeID; employee.SALARY = Convert.ToDouble(dialog.txt_salary.Text); employee.FIRST_NAME = dialog.txt_firstname.Text; employee.lAST_NAME = dialog.txt_lastname.Text; employee.EMAIL = dialog.txt_email.Text; employee.PHONE_NUMBER = dialog.txt_phone.Text; employee.HIRE_DATE = dialog.hire_date.SelectedDate.Value; employee.DepartmentID = dialog.deptSelectedID; employee.STATE = dialog.txt_state.Text; if (_appServices.UpdateEmployee(employee)) { MessageBox.Show("Employee Updated!"); } } }
private void Button_Click(object sender, RoutedEventArgs e) { // Creates and Adds a new employee into Db var dialog = new UI.Widgets.AddEmployeeDialog(_appServices); dialog.Owner = this; var v = dialog.ShowDialog(); if (v == true) { var emp = new Employee() { FIRST_NAME = dialog.txt_firstname.Text, lAST_NAME = dialog.txt_lastname.Text, EMAIL = dialog.txt_email.Text, PHONE_NUMBER = dialog.txt_phone.Text, HIRE_DATE = dialog.hire_date.SelectedDate.Value, SALARY = Convert.ToInt32(dialog.txt_salary.Text), DepartmentID = dialog.deptSelectedID, STATE = dialog.txt_state.Text }; if (_appServices.AddEmployee(emp)) { datagrid.ItemsSource = _appServices.GetEmployees(); MessageBox.Show("Employee Created!"); } } }