private void LblUser_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { //Make a new employee form and give it the employee to be edited NewEmployee employeeForm = new NewEmployee(_employee); employeeForm.editingSelf(true); employeeForm.ShowDialog(); //Logout or update employee information if (employeeForm.deleteButtonPressed) { this.Close(); } else { //Try to send the update to the database Employee temp = employeeForm._employee; try { _employeeManager.updateEmployee(temp); _employee = temp; lblStatusMessage.Content = "Update Success"; lblUser.Content = _employee.getEmployeeName(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void BtnNewEmployee_Click(object sender, RoutedEventArgs e) { //Make a new employee form and return the resulting employee NewEmployee empForm = new NewEmployee(); empForm.editingSelf(false); empForm.ShowDialog(); Employee emp = empForm._employee; //Try to add the employee to the database try { _employeeManager.newEmployee(emp); lblStatusMessage.Content = "Update Success"; } catch (Exception ex) { lblStatusMessage.Content = ex.Message; } }
private void LvwEmployees_MouseDoubleClick(object sender, MouseButtonEventArgs e) { //Grab the selected employee Employee emp = employees[lvwEmployees.SelectedIndex]; //Make an employee form and give it the current employee NewEmployee newEmployee = new NewEmployee(emp); newEmployee.editingSelf(false); newEmployee.ShowDialog(); //Delete or update employee information Employee temp = newEmployee._employee; if (!newEmployee.deleteButtonPressed) { //Update the employee try { _employeeManager.updateEmployee(temp); lblStatusMessage.Content = "Update success"; } catch (Exception ex) { lblStatusMessage.Content = ex.Message; } } else { //Delete the employee try { _employeeManager.deleteEmployee(temp.getEmployeeID()); lblStatusMessage.Content = "Update success"; } catch (Exception ex) { lblStatusMessage.Content = ex.Message; } } }