private void PopulateRoleInfo() { this.Cursor = Cursors.WaitCursor; try { _RolewiseAccessPermissionList = null; gridAssignedRoleForms.DataSource = null; headerGroupAssignedRoles.ValuesPrimary.Heading = string.Empty; TBL_User_Master dbUser = (new ServiceUsers()).GetUserDBModelByUserID(this.SelectedUserID); if (dbUser != null) { if (dbUser.FK_RoleId != null) { TBL_MP_Master_Role dbRole = (new ServiceRoles()).GetRoleDBRecordByID((int)dbUser.FK_RoleId); if (dbRole != null) { headerGroupAssignedRoles.ValuesPrimary.Heading = dbRole.RoleName.ToUpper() + " (Assigned Role)"; } _RolewiseAccessPermissionList = (new ServiceUsers()).GetRoleWiseAccessPermissionForUser(this.SelectedUserID); gridAssignedRoleForms.DataSource = _RolewiseAccessPermissionList; headerGroupAssignedRoles.ValuesSecondary.Heading = string.Format("{0} Records found.", gridAssignedRoleForms.Rows.Count); } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageUserManager::PopulateRoleInfo", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Default; }
public bool UpdateUserRole(int userId, int roleID) { bool result = false; try { TBL_User_Master model = _dbContext.TBL_User_Master.Where(x => x.PK_UserID == userId).FirstOrDefault(); if (model != null) { model.FK_RoleId = roleID; _dbContext.SaveChanges(); result = true; } } catch (Exception ex) { string errMEssage = ex.Message; if (ex.InnerException != null) { errMEssage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMEssage, "ServiceUsers::UpdateUserRole", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public bool UpdateUser(TBL_User_Master model) { bool result = false; try { TBL_User_Master dbModel = _dbContext.TBL_User_Master.Where(x => x.PK_UserID == model.PK_UserID).FirstOrDefault(); if (dbModel != null) { dbModel.LoginPassword = model.LoginPassword; dbModel.IsActive = model.IsActive; dbModel.FK_RoleId = model.FK_RoleId; //dbModel.ModifiedBy = model.ModifiedBy; //dbModel.ModifiedDateTime = AppCommon.GetServerDateTime(); _dbContext.SaveChanges(); result = true; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceUser::UpdateEmployee", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public string GetEmployeeNameByUserName(string uName) { string empName = string.Empty; try { TBL_User_Master user = _dbContext.TBL_User_Master.Where(x => x.LoginId == uName).FirstOrDefault(); if (user != null) { TBL_MP_Master_Employee emp = _dbContext.TBL_MP_Master_Employee.Where(x => x.PK_EmployeeId == user.FK_EmployeeID).FirstOrDefault(); if (emp != null) { empName = emp.EmployeeName; } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceUser::GetEmployeeNameByUserName", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(empName); }
private void mnuLogOut_Click(object sender, EventArgs e) { backgroundWorker1.CancelAsync(); Application.DoEvents(); foreach (Form childForm in MdiChildren) { childForm.Close(); } backgroundWorker1.CancelAsync(); Application.DoEvents(); Program.CURR_USER = null; frmLogin frm = new frmLogin(); frm.MANAGER = this.kryptonManager1; if (frm.ShowDialog() == DialogResult.OK) { if (frm.LoginSuccess) { //notifyIcon1.BalloonTipIcon = ToolTipIcon.Info; //notifyIcon1.BalloonTipText = string.Format("Welcome {0}\nHave a Nice Day.", Program.CURR_USER.UserFullName); //notifyIcon1.BalloonTipTitle = "Logon Success"; //notifyIcon1.ShowBalloonTip(1000); statusLabelUserName.Text = string.Format("Welcome {0}", Program.CURR_USER.UserFullName); statusLabelFinYear.Text = string.Format("{0}", Program.CURR_USER.FinanicalYearText); TBL_User_Master dbUser = (new ServiceUsers()).GetUserDBModelByEmployeeID(Program.CURR_USER.EmployeeID); if (dbUser != null) { if (dbUser.Theme != null) { Program.CURRENT_THEME = kryptonManager1.GlobalPaletteMode = (PaletteModeManager)dbUser.Theme; } } statusStripFooter.Show(); menuStrip.Show(); if (backgroundWorker1.IsBusy != true) { backgroundWorker1.RunWorkerAsync(); } } } else { Application.Exit(); } }
public bool SetUserTheme(int employeeID, int themeID) { bool result = false; try { TBL_User_Master model = _dbContext.TBL_User_Master.Where(x => x.FK_EmployeeID == employeeID).FirstOrDefault(); if (model != null) { model.Theme = themeID; _dbContext.SaveChanges(); } } catch (Exception ex) { MessageBox.Show(string.Format("{0}\n{1}", ex.Message, ex.InnerException.Message), "", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public TBL_User_Master GetUserDBModelByUserName(string uName) { TBL_User_Master model = null; try { model = _dbContext.TBL_User_Master.Where(x => x.LoginId == uName).FirstOrDefault(); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceUsers::GetUserDBModelByUserName", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(model); }
public TBL_User_Master GetUserDBModelByEmployeeID(int empID) { TBL_User_Master model = null; try { model = _dbContext.TBL_User_Master.Where(x => x.FK_EmployeeID == empID).FirstOrDefault(); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceUser::GetUserDBModelByEmployeeID", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(model); }
public int AddNewUser(TBL_User_Master model) { int newID = 0; try { _dbContext.TBL_User_Master.Add(model); _dbContext.SaveChanges(); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceUser::AddNewUser", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(newID); }
public bool IsVaidUser(string usrName, string Password) { bool result = false; try { string encrPassword = AppCommon.EncryptText(Password); TBL_User_Master user = _dbContext.TBL_User_Master.Where(x => x.LoginId == usrName).Where(xx => xx.LoginPassword == encrPassword).FirstOrDefault(); result = (user == null) ? false : true; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceUser::IsVaidUser", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
private void btnLogin_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { if (this.ValidateChildren() == true) { this.LoginSuccess = (new ServiceUsers()).IsVaidUser(txtUserName.Text.Trim(), txtPassword.Text.Trim()); if (LoginSuccess) { this.Cursor = Cursors.WaitCursor; #region POPULATE USER SPECIFIC INFORMATION Program.CURR_USER = new USER_SESSION(); Program.CURR_USER.UserName = txtUserName.Text; Program.CURR_USER.Password = txtPassword.Text; Program.CURR_USER.FinanicalYearText = cboFinYear.Text; Program.CURR_USER.FinYearID = int.Parse(cboFinYear.SelectedValue.ToString()); Program.CURR_USER.CompanyID = int.Parse(cboCompany.SelectedValue.ToString()); Program.CURR_USER.BranchID = int.Parse(cboBranch.SelectedValue.ToString()); TBL_MP_Master_Employee emp = (new ServiceUsers()).GetEmployeeDBModelByUserName(txtUserName.Text); if (emp == null) { MessageBox.Show("Unable to locate Employee Info. for the user", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Program.CURR_USER.UserFullName = emp.EmployeeName; Program.CURR_USER.EmployeeID = emp.PK_EmployeeId; Program.CURR_USER.EmailAddress = emp.EmailAddress; if (emp.FK_DepartmentId != null) { Program.CURR_USER.DepartmentID = (int)emp.FK_DepartmentId; List <SelectListItem> lstDept = (new ServiceMASTERS()).GetAllDepartments(); if (lstDept != null) { Program.CURR_USER.DepartmentName = lstDept.Where(x => x.ID == (int)Program.CURR_USER.DepartmentID).FirstOrDefault().Description; } } TBL_User_Master dbUser = (new ServiceUsers()).GetUserDBModelByUserName(txtUserName.Text); if (dbUser != null) { Program.CURR_USER.UserID = dbUser.PK_UserID; if (dbUser.FK_RoleId != null) { Program.CURR_USER.RoleID = (int)dbUser.FK_RoleId; ServiceRoles roleService = new ServiceRoles(); TBL_MP_Master_Role dbRole = roleService.GetRoleDBRecordByID(Program.CURR_USER.RoleID); if (dbRole != null) { Program.CURR_USER.RoleName = dbRole.RoleName.ToUpper(); } Program.CONTROL_ACCESS.UpdateControlAccessListForRole(Program.CURR_USER.RoleID, Program.CURR_USER.EmployeeID); } if (dbUser.Theme != null) { Program.CURRENT_THEME = MANAGER.GlobalPaletteMode = (PaletteModeManager)dbUser.Theme; Program.ColorSelected = MANAGER.GlobalPalette.ColorTable.ButtonSelectedHighlight; } } #endregion this.Cursor = Cursors.Default; this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("Invalid User Name or Password!!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "frmLogin::btnLogin_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Default; }
public BindingList <UserAccessPermissionsModel> GetRoleWiseAccessPermissionForUser(int userID) { BindingList <UserAccessPermissionsModel> list = new BindingList <UserAccessPermissionsModel>(); try { TBL_User_Master user = this.GetUserDBModelByUserID(userID); if (user != null) { int roleID = (int)user.FK_RoleId; List <TBL_MP_Master_RoleForm> lstRoleForms = _dbContext.TBL_MP_Master_RoleForm.Where(x => x.FK_RoleID == roleID).ToList(); foreach (TBL_MP_Master_RoleForm roleForm in lstRoleForms) { UserAccessPermissionsModel listItem = new UserAccessPermissionsModel() { ID = roleForm.PK_RoleFormID, FormID = roleForm.FK_FormId, FormName = roleForm.Tbl_MP_Master_Module_Forms.DisplayName, ModuleID = (int)roleForm.FK_ModuleId, ModuleName = roleForm.Tbl_MP_Master_Module.DisplayName, RoleID = roleForm.FK_RoleID, RoleName = roleForm.TBL_MP_Master_Role.RoleName }; string strDescription = string.Empty; if (roleForm.CanAddNew) { strDescription += "ADD "; } if (roleForm.CanApprove) { strDescription += "APPROVE "; } if (roleForm.CanAuthorize) { strDescription += "AUTHORIZE "; } if (roleForm.CanCheck) { strDescription += "CHECK "; } if (roleForm.CanDelete) { strDescription += "DELETE "; } if (roleForm.CanModify) { strDescription += "MODIFY "; } if (roleForm.CanPrepare) { strDescription += "PREPARE "; } if (roleForm.CanPrint) { strDescription += "PRINT "; } if (roleForm.CanView) { strDescription += "VIEW "; } listItem.Permissions = strDescription; list.Add(listItem); } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceUsers::GetRoleWiseAccessPermissionForUser", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(list); }