示例#1
0
        protected void BindDescriptors()
        {
            CheckBoxList DescriptorsObj = (CheckBoxList)formView.FindControl("Descriptors");
            IEnumerable <KeyValuePair <int, string> > DescriptorsForScope = LookupBLL.GetDescriptorsForScope(ViewData.Scope);

            if (ViewData.IsUserStateScope)
            {
                bool RemoveShipDirectorDescriptor = true;
                if (ViewData.IsAdmin)
                {
                    //If a Ship Director does not exist for the State, the Ship Director Descriptor can be shown
                    if (!LookupBLL.GetShipDirectorForState(ViewData.StateFIPS).HasValue)
                    {
                        RemoveShipDirectorDescriptor = false;
                    }
                }

                //Ship Director already exists for the State. Need not show it for State Level Admins
                if (RemoveShipDirectorDescriptor)
                {
                    DescriptorsObj.DataSource = (from scope in DescriptorsForScope where scope.Key != Descriptor.ShipDirector.EnumValue <int>() select scope);
                }
            }
            else
            {
                DescriptorsObj.DataSource = DescriptorsForScope;
            }

            DescriptorsObj.DataTextField  = "Value";
            DescriptorsObj.DataValueField = "Key";
            DescriptorsObj.DataBind();

            foreach (ListItem item in DescriptorsObj.Items)
            {
                if (item.Attributes["CustomValue"] == null)
                {
                    item.Attributes.Add("CustomValue", item.Value);
                }
                else
                {
                    item.Attributes["CustomValue"] = item.Value;
                }

                if (item.Attributes["onClick"] == null)
                {
                    item.Attributes.Add("onClick", string.Format("HandleDescriptorlist('{0}', {1})", DescriptorsObj.ClientID, item.Value));
                }
                else
                {
                    item.Attributes["onClick"] = string.Format("HandleDescriptorlist('{0}', {1})", DescriptorsObj.ClientID, item.Value);
                }
            }
        }
示例#2
0
 private IEnumerable <KeyValuePair <int, string> > GetDescriptors()
 {
     if (this.AccountInfo.IsCMSLevel && this.AccountInfo.IsAdmin)
     {
         return(LookupBLL.GetDescriptorsForScope(Scope.State));
     }
     else
     {
         var DescriptorsList = LookupBLL.GetDescriptorsForScope(Scope.State);
         return(DescriptorsList.Where(p => p.Key != Descriptor.ShipDirector.EnumValue <int>()));
     }
 }