Пример #1
0
        private void GetLimitsDataForSelectedUserInStore()
        {
            selectedUserLimits = new List <LimitsVO>();

            //Get the limits of the selected user
            selectedUserLimits = SecurityProfileProcedures.GetListOfLimits(_UserVO, _ShopID);

            //check if all the resources which belong to the selected user has
            //associated limit and if yes check if its there in selecteduserlimits
            //and if not get the limit from the business rule
            List <ServiceOffering> serviceOfferings = GlobalDataAccessor.Instance.DesktopSession.ServiceOfferings;

            foreach (ResourceVO rVo in _UserVO.UserResources)
            {
                ResourceVO vo = rVo;
                if (vo.Assigned == "N")
                {
                    continue;
                }
                var sOffering = (from servOffering in serviceOfferings
                                 where servOffering.ServiceOfferingID == vo.ResourceID
                                 select servOffering).FirstOrDefault();
                if (sOffering.ServiceOfferingID != null)
                {
                    //Check if that limit is there in selecteduserlimits
                    var limitData = (from limit in loggedinUserLimits
                                     where limit.ServiceOffering == sOffering.ServiceOfferingID
                                     select limit).FirstOrDefault();
                    if (limitData == null)
                    {
                        LimitsVO newLimit = new LimitsVO();
                        newLimit.ServiceOffering = sOffering.ServiceOfferingID;
                        newLimit.ProdOfferingId  = sOffering.ProdOffering;
                        newLimit.ResourceName    = vo.ResourceName;
                        newLimit.RoleLimitId     = 0;
                        newLimit.StoreID         = string.Empty;

                        if (vo.ResourceName == Commons.GetResourceName("NEWPAWNLOAN"))
                        {
                            //Get the limit from business rule
                            decimal maxLoanLimit = 0.0m;
                            if (new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetMaxLoanLimit(GlobalDataAccessor.Instance.CurrentSiteId, out maxLoanLimit))
                            {
                                newLimit.Limit = maxLoanLimit;
                            }
                        }
                        if (vo.ResourceName == Commons.GetResourceName("CUSTOMERBUY"))
                        {
                            //Set the limit to the max
                            newLimit.Limit = 99999;
                        }
                        selectedUserLimits.Add(newLimit);
                    }
                }
            }

            this.gvLimits.AutoGenerateColumns = false;
            foreach (LimitsVO limitData in selectedUserLimits)
            {
                if (limitData.StoreNumber == string.Empty)
                {
                    //If the limit being shown is the default limit
                    //Make sure the corresponding resource is still part
                    //of the user's resources list
                    var resName = (from resource in selectedUserResources
                                   where resource == limitData.ResourceName
                                   select resource).FirstOrDefault();
                    if (resName == null)
                    {
                        continue;
                    }
                }
                DataGridViewRow         dgvr  = new DataGridViewRow();
                DataGridViewTextBoxCell cell1 = new DataGridViewTextBoxCell();
                cell1.Value = limitData.ProdOfferingId.ToString();
                dgvr.Cells.Insert(0, cell1);
                DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell();
                cell2.Value = limitData.ResourceName.ToString();
                dgvr.Cells.Insert(1, cell2);
                DataGridViewTextBoxCell cell3 = new DataGridViewTextBoxCell();
                cell3.Value = limitData.Limit;
                dgvr.Cells.Insert(2, cell3);
                DataGridViewTextBoxCell cell4 = new DataGridViewTextBoxCell();
                cell4.Value = limitData.RoleLimitId;
                dgvr.Cells.Insert(3, cell4);
                gvLimits.Rows.Add(dgvr);
            }

            //Set the format for the limit field to currency
            //TO DO - when limit type attribute is added the format will change accordingly
            gvLimits.Columns[2].DefaultCellStyle.Format = "C";
            populateLimitsDataGrid();
        }
Пример #2
0
        private void SecurityProfile_Load(object sender, EventArgs e)
        {
            try
            {
                this.NavControlBox.Owner = this;
                limitsErrorLabel.Text    = "";
                resourcesErrorLabel.Text = "";
                addedResource            = new List <string>();
                removedResource          = new List <string>();
                errorMessages            = new StringBuilder();
                isFormValid = true;

                _UserVO = GlobalDataAccessor.Instance.DesktopSession.SelectedUserProfile;

                employeeNumberLabel.Text = !string.IsNullOrEmpty(_UserVO.EmployeeNumber) ? _UserVO.EmployeeNumber : "";
                employeeRoleLabel.Text   = _UserVO.UserFirstName
                                           + " "
                                           + _UserVO.UserLastName
                                           + " "
                                           + _UserVO.UserRole.RoleName;
                homeShopIDLabel.Text   = _UserVO.FacNumber ?? "";
                limitsLastUpdated.Text = _UserVO.LastUpdatedDate.ToShortDateString();

                _userStores = _UserVO.ProfileStores;
                _ShopID     = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;
                if (_userStores.Count > 0 && _userStores[0] != null)
                {
                    foreach (string s in _userStores)
                    {
                        shopIDComboBox.Items.Add(s);
                    }
                }
                //TODO: Fix THIS!!!! Should be a static method call!!!!!!!!!
                new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetMaxLoanLimit(CashlinxDesktopSession.Instance.CurrentSiteId, out maxLoanStateLimit);

                loggedInUser       = GlobalDataAccessor.Instance.DesktopSession.LoggedInUserSecurityProfile;
                loggedinUserLimits = new List <LimitsVO>();
                //Populate the limits list
                //Get the limits of the logged in user
                loggedinUserLimits = SecurityProfileProcedures.GetListOfLimits(loggedInUser, _ShopID);
                List <ServiceOffering> serviceOfferings = GlobalDataAccessor.Instance.DesktopSession.ServiceOfferings;
                foreach (ResourceVO rVo in loggedInUser.UserResources)
                {
                    ResourceVO vo        = rVo;
                    var        sOffering = (from servOffering in serviceOfferings
                                            where servOffering.ServiceOfferingID == vo.ResourceID
                                            select servOffering).FirstOrDefault();
                    if (sOffering.ServiceOfferingID != null)
                    {
                        //Check if that limit is there in loggedinuserlimits
                        var limitData = (from limit in loggedinUserLimits
                                         where limit.ServiceOffering == sOffering.ServiceOfferingID
                                         select limit).FirstOrDefault();
                        if (limitData == null)
                        {
                            LimitsVO newLimit = new LimitsVO();
                            newLimit.ServiceOffering = sOffering.ServiceOfferingID;
                            newLimit.ProdOfferingId  = sOffering.ProdOffering;
                            newLimit.ResourceName    = vo.ResourceName;
                            newLimit.RoleLimitId     = 0;
                            newLimit.StoreID         = string.Empty;

                            if (vo.ResourceName == Commons.GetResourceName("NEWPAWNLOAN"))
                            {
                                //Get the limit from business rule
                                decimal maxLoanLimit = 0.0m;
                                if (new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetMaxLoanLimit(GlobalDataAccessor.Instance.CurrentSiteId, out maxLoanLimit))
                                {
                                    newLimit.Limit = maxLoanLimit;
                                }
                            }
                            if (vo.ResourceName == Commons.GetResourceName("CUSTOMERBUY"))
                            {
                                //Set the limit to the max
                                newLimit.Limit = 99999;
                            }
                            loggedinUserLimits.Add(newLimit);
                        }
                    }
                }

                shopIDComboBox.SelectedIndex = _userStores.IndexOf(_ShopID);
            }
            catch (Exception ex)
            {
                FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Cannot load security profile");
                BasicExceptionHandler.Instance.AddException("Security profile could not be loaded " + ex.Message, new ApplicationException(ex.ToString()));
            }
        }