Exemple #1
0
        /// <summary>
        /// Function to to check if the user is authorized to override
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        private bool checkRole(string userName)
        {
            string errorCode;
            string errorMesg;

            //Get the security profile of the user whose credentials were entered in the override form
            if (SecurityProfileProcedures.GetUserSecurityProfile(userName, GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, null, "N", GlobalDataAccessor.Instance.DesktopSession, out managerUserProfile, out errorCode, out errorMesg))
            {
                //check if the manager whose credentials were entered
                //has modify access on the override resource
                //return true if yes and false if not
                if (SecurityProfileProcedures.CanUserModifyResource("OVERRIDE", managerUserProfile, GlobalDataAccessor.Instance.DesktopSession))
                {
                    //If the override type is for new pawn loan override
                    //check that the overriding user's limits allow override
                    var managerLimit = 0.0m;
                    if (ManagerOverrideTypes[0] == ManagerOverrideType.NLO)
                    {
                        if (!(SecurityProfileProcedures.CanUserOverridePawnLoanLimit(managerUserProfile, _OverrideAmount[0], GlobalDataAccessor.Instance.DesktopSession, new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession), out managerLimit)))
                        {
                            MessageBox.Show(@"The amount to override exceeds the amount you can override. Your override limit is " + managerLimit);
                            return(false);
                        }
                    }
                    if (ManagerOverrideTypes[0] == ManagerOverrideType.PURO)
                    {
                        if (!(SecurityProfileProcedures.CanUserOverrideBuyLimit(managerUserProfile, _OverrideAmount[0], out managerLimit)))
                        {
                            MessageBox.Show(@"The amount to override exceeds the amount you can override. Your override limit is " + managerLimit);
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }