/// <summary> /// Confirm to close the window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void CloseMethod(object sender, RoutedEventArgs e) { try { SecurityUsersBll secuserbll = new SecurityUsersBll(_userInformation); WPF.MDI.ClosingEventArgs closingev; closingev = (WPF.MDI.ClosingEventArgs)e; if (secuserbll.CheckIsAdminAvailable() == false) { closingev.Cancel = true; MessageBox.Show("Please select ADMIN rights for any one administrator user", "SmartPD", MessageBoxButton.OK, MessageBoxImage.Information); e = closingev; } else { if (ShowConfirmMessageYesNo(PDMsg.CloseForm) == MessageBoxResult.No) { closingev.Cancel = true; e = closingev; } } } catch (Exception ex) { throw ex.LogException(); } }
public SecurityUsersViewModel(UserInformation userInfo, DataRowView selectedItem, string mode) { _securityUsers = new SecurityUsersModel(); _securityUserBll = new SecurityUsersBll(userInfo); this._saveCommand = new DelegateCommand(this.Save); this._closeCommand = new DelegateCommand(this.Close); _selectedItem = selectedItem; SecurityUsers.UserName = _selectedItem.Row["USER_NAME"].ToString(); SecurityUsers.FullName = _selectedItem.Row["FULL_NAME"].ToString(); SecurityUsers.Designation = _selectedItem.Row["DESIGNATION"].ToString(); SecurityUsers.Password = _selectedItem.Row["PASSWORD"].ToString(); SecurityUsers.IsAdmin = _selectedItem.Row["IS_ADMIN"].ToBooleanAsString(); SecurityUsers.Mode = mode; if (mode == "U") { UserNameIsEnable = true; _selectedItem.Row["PASSWORD"] = "******"; SecurityUsers.Password = "******"; } else if (mode == "D") { this.Save(); } _securityUserBll.GetDesignation(SecurityUsers); if (_securityUserBll.CheckIsAdminAvailable()) { if (SecurityUsers.IsAdmin == true) { AdminVisible = Visibility.Visible; } else { AdminVisible = Visibility.Collapsed; } } else { if (_securityUserBll.GetUserRole(SecurityUsers.UserName).ToValueAsString().ToUpper() == "ADMINISTRATOR") { AdminVisible = Visibility.Visible; } else { AdminVisible = Visibility.Collapsed; } } }