public override void Run() { try { EmployeeForm form = new EmployeeForm(employee); IEmployeeRepository dao = new NHibernateEmployeeRepository(); form.EmployeeSave += delegate(object sender, EmployeeEventArgs e) { dao.SaveOrUpdate(e.Employee); form.Close(); }; WorkbenchSingleton.AddChild(form); } catch (Exception ex) { LoggingService.Error(ex.Message); MessageService.ShowError(ex.Message); } }
public void showAdminDashBoard(AdminDashBoard adminDashboard, EmployeeForm employeeForm) { employeeForm.Close(); adminDashboard.Show(); }
private void UpdateButton_Click(object sender, EventArgs e) { var selected = ((ComboBox)_updateForm.Departments).SelectedItem; int?id = null; if (selected != null) { id = ((Model.MyDepartment)selected).Id; } using (var context = new MyDbContext()) { if (_currentTableName == "Projects") { var entry = context.Projects .Where(it => it.id == _updateForm.GetId) .FirstOrDefault(); dynamic employee = ((ComboBox)_updateForm.Departments).SelectedItem; if (employee != null) { entry.department_id = employee.Id; } entry.project_name = _updateForm.GetProjectName; entry.date_begin = _updateForm.GetBeginDate; entry.date_end = _updateForm.GetEndDate; entry.date_end_real = _updateForm.GetEndRealDate; entry.cost = _updateForm.GetCost; //_updateForm.GetApplyButton.Click -= UpdateButton_Click; _updateForm.Close(); } else if (_currentTableName == "Departments") { var entry = context.Departments .Where(it => it.id == _updateFormDepartments.GetId) .FirstOrDefault(); entry.name = _updateFormDepartments.GetDepartmentName; //_updateFormDepartments.GetApplyButton.Click -= UpdateButton_Click; _updateFormDepartments.Close(); } else if (_currentTableName == "Employees") { var entry = context.Employees .Where(it => it.id == _updateFormEmployee.Id) .FirstOrDefault(); entry.name = _updateFormEmployee.EmployeelName; entry.surname = _updateFormEmployee.Surname; entry.patronymic = _updateFormEmployee.Patronymic; entry.position = _updateFormEmployee.Position; entry.salary = _updateFormEmployee.Salary; //_updateFormEmployee.GetApplyButton.Click -= UpdateButton_Click; _updateFormEmployee.Close(); } else if (_currentTableName == "DepartmentsEmployees") { var entry = context.DepartmentsEmployees .Where(it => it.id == _departmentEmployeeForm.Id) .FirstOrDefault(); dynamic employee = ((ComboBox)_departmentEmployeeForm.Employees).SelectedItem; entry.employee_id = employee.Id; dynamic department = ((ComboBox)_departmentEmployeeForm.Departments).SelectedItem; entry.department_id = department.Id; //_departmentEmployeeForm.GetApplyButton.Click -= UpdateButton_Click; _departmentEmployeeForm.Close(); } try { context.SaveChanges(); } catch (Exception ex) { var x = ex; MessageBox.Show("handle trigger"); } } Read(this, new EventArgs()); }