private void InitializeUIBasedOnUpdateType(EmployeeViewModelUpdate.UpdateType updateType) { Visibility makeVisibleEmpIdFields = updateType != EmployeeViewModelUpdate.UpdateType.AddEmployee ? Visibility.Visible : Visibility.Hidden; TextBoxEmployeeId.Visibility = makeVisibleEmpIdFields; LabelEmployeeId.Visibility = makeVisibleEmpIdFields; ButtonFind.Visibility = makeVisibleEmpIdFields; switch (updateType) { case EmployeeViewModelUpdate.UpdateType.AddEmployee: GridUpdateEmployee.Margin = new Thickness(0, -10, 0, 0); TextBoxEmployeeName.Focus(); ButtonAdd.Content = "Add"; Title = "Add Employee Details"; break; case EmployeeViewModelUpdate.UpdateType.EditEmployee: TextBoxEmployeeId.Focus(); ButtonAdd.Content = "Modify"; Title = "Modify Employee Details"; break; case EmployeeViewModelUpdate.UpdateType.RemoveEmployee: TextBoxEmployeeId.Focus(); ButtonAdd.Content = "Remove"; Title = "Remove Employee Details"; break; default: break; } }
public UpdateEmployeePage(IConnectionHandler connectionHandler, EmployeeViewModelUpdate.UpdateType updateType) { InitializeComponent(); EmployeeUpdateHandlerWebServer employeeUpdateHandlerWebServer = new EmployeeUpdateHandlerWebServer(connectionHandler); _employeeViewModelUpdate = new EmployeeViewModelUpdate(employeeUpdateHandlerWebServer, updateType); _employeeViewModelUpdate.ShowMessageToUserEvent += _employeeViewModel_ShowMessageToUserEvent; DataContext = _employeeViewModelUpdate; TextBoxEmployeeId.Clear(); InitializeUIBasedOnUpdateType(updateType); if (updateType == EmployeeViewModelUpdate.UpdateType.EditEmployee || updateType == EmployeeViewModelUpdate.UpdateType.RemoveEmployee) { EmployeeQueryHandlerWebServer employeeQueryHandlerWebServer = new EmployeeQueryHandlerWebServer(connectionHandler); _employeeViewModelQuery = new EmplyeeViewModelQuery(employeeQueryHandlerWebServer, EmplyeeViewModelQuery.SearchFilter.ByEmployeeId); } }