コード例 #1
0
        public void _RegulatoryList_OnChange(CswNbtNodeProp Prop, bool Creating)
        {
            if (null != RegulatoryList.RelatedNodeId &&
                RegulatoryList.RelatedNodeId.PrimaryKey != CswConvert.ToInt32(RegulatoryList.GetOriginalPropRowValue(CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID)))
            {
                // case 28303 - set ByUser to current user when regulatory list is modified
                if (false == SetByChemical && false == _CswNbtResources.CurrentNbtUser is CswNbtSystemUser)
                {
                    ByUser.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId;

                    // case 28303 - remove list from Chemical's Suppressed list
                    if (CswTools.IsPrimaryKey(Chemical.RelatedNodeId))
                    {
                        CswNbtObjClassChemical ChemicalNode = _CswNbtResources.Nodes[Chemical.RelatedNodeId];
                        if (null != ChemicalNode)
                        {
                            if (ChemicalNode.isRegulatoryListSuppressed(RegulatoryList.RelatedNodeId))    // important to prevent an infinite loop
                            {
                                ChemicalNode.removeSuppressedRegulatoryList(RegulatoryList.RelatedNodeId);
                                ChemicalNode.postChanges(false);
                            }
                        }
                    }
                }
            }
        } // _RegulatoryList_OnChange()
コード例 #2
0
 private void onRolePropChange(CswNbtNodeProp NodeProp, bool Creating)
 {
     if (null != _CswNbtResources.CurrentNbtUser &&
         CswTools.IsPrimaryKey(Role.RelatedNodeId) &&
         Role.RelatedNodeId.PrimaryKey != CswConvert.ToInt32(Role.GetOriginalPropRowValue(CswEnumNbtPropColumn.Field1_FK)))
     {
         if (false == _CswNbtResources.CurrentNbtUser.IsAdministrator())
         {
             throw new CswDniException(CswEnumErrorType.Warning, "Only Administrators can change user roles",
                                       "Current user (" + _CswNbtResources.CurrentUser.Username +
                                       ") attempted to edit a user role.");
         }
         if (this.Username != ChemSWAdminUsername &&
             ((CswNbtObjClassRole)_CswNbtResources.Nodes[Role.RelatedNodeId]).Name.Text ==
             CswNbtObjClassRole.ChemSWAdminRoleName)
         {
             throw new CswDniException(CswEnumErrorType.Warning,
                                       "New users may not be assigned to the '" +
                                       CswNbtObjClassRole.ChemSWAdminRoleName + "' role",
                                       "Current user (" + _CswNbtResources.CurrentUser.Username +
                                       ") attempted to assign a new user to the '" +
                                       CswNbtObjClassRole.ChemSWAdminRoleName + "' role.");
         }
     }
 }