Example #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!IsPostBack)
            {
                var tenants = GetPossibleTenants();
                CurrentTenantField.SetBusinessObjectList(tenants);
                var currentTenant = SecurityManagerPrincipal.Current.Tenant;

                CurrentTenantField.LoadUnboundValue(currentTenant, false);

                bool isCurrentTenantTheOnlyTenantInTheCollection = tenants.Length == 1 && currentTenant != null && tenants[0].ID.Equals(currentTenant.ID);
                bool isCurrentTenantTheOnlyTenant = tenants.Length == 0 && currentTenant != null;
                bool hasExactlyOneTenant          = isCurrentTenantTheOnlyTenantInTheCollection || isCurrentTenantTheOnlyTenant;
                IsTenantSelectionEnabled = !hasExactlyOneTenant;

                var substitutions = GetPossibleSubstitutions();
                CurrentSubstitutionField.SetBusinessObjectList(substitutions);
                var currentSubstitution = SecurityManagerPrincipal.Current.Substitution;

                CurrentSubstitutionField.LoadUnboundValue(currentSubstitution, false);
                IsSubstitutionSelectionEnabled = substitutions.Length > 0;
            }

            if (!IsTenantSelectionEnabled)
            {
                CurrentTenantField.Command.Type = CommandType.None;
            }

            if (!IsSubstitutionSelectionEnabled)
            {
                CurrentSubstitutionField.Command.Type = CommandType.None;
            }
        }
Example #2
0
 protected void CurrentSubstitutionField_CommandClick(object sender, BocCommandClickEventArgs e)
 {
     _isCurrentSubstitutionFieldReadOnly = false;
     CurrentSubstitutionField.SetBusinessObjectList(GetPossibleSubstitutions());
     CurrentSubstitutionField.LoadUnboundValue(SecurityManagerPrincipal.Current.Substitution, false);
 }