}//afterPopulateProps()

        public override void archiveMatchingDocs()
        {
            //Archives existing Documents related to the same Owner.
            //Existing SDS Documents are only archived if both Language and Format matches.
            if( Archived.Checked != CswEnumTristate.True &&
                false == String.IsNullOrEmpty( Language.Value ) &&
                false == String.IsNullOrEmpty( Format.Value ) )
            {
                CswNbtNode OwnerNode = _CswNbtResources.Nodes.GetNode( Owner.RelatedNodeId );
                if( null != OwnerNode )
                {
                    CswNbtView ExistingDocsView = new CswNbtView( _CswNbtResources );
                    CswNbtViewRelationship DocumentVr = ExistingDocsView.AddViewRelationship( NodeType, false );
                    ExistingDocsView.AddViewPropertyAndFilter( DocumentVr, Owner.NodeTypeProp, OwnerNode.NodeId.PrimaryKey.ToString(), CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID );
                    ExistingDocsView.AddViewPropertyAndFilter( DocumentVr, Archived.NodeTypeProp, CswEnumTristate.True.ToString(), FilterMode : CswEnumNbtFilterMode.NotEquals );
                    ExistingDocsView.AddViewPropertyAndFilter( DocumentVr, Format.NodeTypeProp, Format.Value );
                    ExistingDocsView.AddViewPropertyAndFilter( DocumentVr, Language.NodeTypeProp, Language.Value );

                    ICswNbtTree Tree = _CswNbtResources.Trees.getTreeFromView( ExistingDocsView, true, false, false );
                    Int32 DocCount = Tree.getChildNodeCount();
                    if( DocCount > 0 )
                    {
                        for( Int32 I = 0; I < DocCount; I += 1 )
                        {
                            Tree.goToNthChild( I );
                            CswNbtNode DocNode = Tree.getNodeForCurrentPosition();
                            if( DocNode.NodeId != NodeId )
                            {
                                CswNbtObjClassSDSDocument DocNodeAsDocument = DocNode;
                                DocNodeAsDocument.Archived.Checked = CswEnumTristate.True;
                                DocNode.postChanges( true );
                            }
                            Tree.goToParentNode();
                        }
                    }

                }
            }
        }
        protected override bool onButtonClick( NbtButtonData ButtonData )
        {
            bool HasPermission = true;
            if( null != ButtonData.NodeTypeProp )
            {
                HasPermission = false;
                string OCPPropName = ButtonData.NodeTypeProp.getObjectClassPropName();
                switch( OCPPropName )
                {
                    case PropertyName.OpenFile:
                        HasPermission = true;
                        string url = "";
                        if( FileType.Value.Equals( CswEnumDocumentFileTypes.File ) )
                        {
                            url = File.Href;
                        }
                        else if( FileType.Value.Equals( CswEnumDocumentFileTypes.Link ) )
                        {
                            url = Link.GetFullURL();
                        }
                        else if( FileType.Value.Equals( CswNbtObjClassSDSDocument.CswEnumDocumentFileTypes.ChemWatch ) )
                        {
                            if( CswEnumNbtObjectClass.SDSDocumentClass == Node.ObjClass.ObjectClass.ObjectClass )
                            {
                                CswNbtObjClassSDSDocument SDSDocNode = Node;
                                if( null != SDSDocNode.ChemWatch && false == string.IsNullOrEmpty( SDSDocNode.ChemWatch.Text ) )
                                {
                                    url = "Services/ChemWatch/GetSDSDocument?filename=" + SDSDocNode.ChemWatch.Text;
                                }
                            }
                        }

                        ButtonData.Data["url"] = url;
                        ButtonData.Action = CswEnumNbtButtonAction.popup;
                        break;
                }
            }
            return HasPermission;
        }
 /// <summary>
 /// Cast a the Object Class as a PropertySet
 /// </summary>
 public static CswNbtPropertySetDocument toPropertySet( CswNbtObjClassSDSDocument ObjClass )
 {
     return ObjClass;
 }
        /// <summary>
        /// Create an ObjClass instance for given ObjectClass and Node
        /// </summary>
        public static CswNbtObjClass makeObjClass(CswNbtResources CswNbtResources, CswNbtMetaDataObjectClass ObjectClass, CswNbtNode Node = null)
        {
            CswNbtObjClass ReturnVal = null;

            switch (ObjectClass.ObjectClass)
            {
            case CswEnumNbtObjectClass.BalanceClass:
                ReturnVal = new CswNbtObjClassBalance(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.BalanceConfigurationClass:
                ReturnVal = new CswNbtObjClassBalanceConfiguration(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.BatchOpClass:
                ReturnVal = new CswNbtObjClassBatchOp(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.BiologicalClass:
                ReturnVal = new CswNbtObjClassBiological(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CertDefCharacteristicLimitClass:
                ReturnVal = new CswNbtObjClassCertDefCharacteristicLimit(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CertDefSpecClass:
                ReturnVal = new CswNbtObjClassCertDefSpec(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CertificateDefinitionClass:
                ReturnVal = new CswNbtObjClassCertificateDefinition(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CertDefConditionClass:
                ReturnVal = new CswNbtObjClassCertDefCondition(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CertDefSpecLevelClass:
                ReturnVal = new CswNbtObjClassCertDefSpecLevel(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CofADocumentClass:
                ReturnVal = new CswNbtObjClassCofADocument(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CofAMethodClass:
                ReturnVal = new CswNbtObjClassCofAMethod(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CofAMethodTemplateClass:
                ReturnVal = new CswNbtObjClassCofAMethodTemplate(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ContainerClass:
                ReturnVal = new CswNbtObjClassContainer(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ContainerDispenseTransactionClass:
                ReturnVal = new CswNbtObjClassContainerDispenseTransaction(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ContainerGroupClass:
                ReturnVal = new CswNbtObjClassContainerGroup(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ContainerLocationClass:
                ReturnVal = new CswNbtObjClassContainerLocation(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ControlZoneClass:
                ReturnVal = new CswNbtObjClassControlZone(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CustomerClass:
                ReturnVal = new CswNbtObjClassCustomer(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DepartmentClass:
                ReturnVal = new CswNbtObjClassDepartment(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DesignNodeTypeClass:
                ReturnVal = new CswNbtObjClassDesignNodeType(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DesignNodeTypePropClass:
                ReturnVal = new CswNbtObjClassDesignNodeTypeProp(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DesignNodeTypeTabClass:
                ReturnVal = new CswNbtObjClassDesignNodeTypeTab(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DesignSequenceClass:
                ReturnVal = new CswNbtObjClassDesignSequence(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DocumentClass:
                ReturnVal = new CswNbtObjClassDocument(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DSDPhraseClass:
                ReturnVal = new CswNbtObjClassDSDPhrase(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.EnterprisePartClass:
                ReturnVal = new CswNbtObjClassEnterprisePart(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.EquipmentAssemblyClass:
                ReturnVal = new CswNbtObjClassEquipmentAssembly(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.EquipmentClass:
                ReturnVal = new CswNbtObjClassEquipment(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.EquipmentTypeClass:
                ReturnVal = new CswNbtObjClassEquipmentType(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.FeedbackClass:
                ReturnVal = new CswNbtObjClassFeedback(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.FireClassExemptAmountClass:
                ReturnVal = new CswNbtObjClassFireClassExemptAmount(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.FireClassExemptAmountSetClass:
                ReturnVal = new CswNbtObjClassFireClassExemptAmountSet(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GenericClass:
                ReturnVal = new CswNbtObjClassGeneric(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GHSClass:
                ReturnVal = new CswNbtObjClassGHS(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GHSClassificationClass:
                ReturnVal = new CswNbtObjClassGHSClassification(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GHSPhraseClass:
                ReturnVal = new CswNbtObjClassGHSPhrase(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GHSSignalWordClass:
                ReturnVal = new CswNbtObjClassGHSSignalWord(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InspectionDesignClass:
                ReturnVal = new CswNbtObjClassInspectionDesign(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InspectionRouteClass:
                ReturnVal = new CswNbtObjClassInspectionRoute(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InspectionTargetClass:
                ReturnVal = new CswNbtObjClassInspectionTarget(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InspectionTargetGroupClass:
                ReturnVal = new CswNbtObjClassInspectionTargetGroup(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InventoryGroupClass:
                ReturnVal = new CswNbtObjClassInventoryGroup(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InventoryGroupPermissionClass:
                ReturnVal = new CswNbtObjClassInventoryGroupPermission(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InventoryLevelClass:
                ReturnVal = new CswNbtObjClassInventoryLevel(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.JurisdictionClass:
                ReturnVal = new CswNbtObjClassJurisdiction(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.Level:
                ReturnVal = new CswNbtObjClassLevel(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.LocationClass:
                ReturnVal = new CswNbtObjClassLocation(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.LQNoClass:
                ReturnVal = new CswNbtObjClassLQNo(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ManufacturerClass:
                ReturnVal = new CswNbtObjClassManufacturer(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ManufacturerEquivalentPartClass:
                ReturnVal = new CswNbtObjClassManufacturerEquivalentPart(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ChemicalClass:
                ReturnVal = new CswNbtObjClassChemical(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MaterialComponentClass:
                ReturnVal = new CswNbtObjClassMaterialComponent(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MaterialSynonymClass:
                ReturnVal = new CswNbtObjClassMaterialSynonym(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MailReportClass:
                ReturnVal = new CswNbtObjClassMailReport(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MailReportGroupClass:
                ReturnVal = new CswNbtObjClassMailReportGroup(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MailReportGroupPermissionClass:
                ReturnVal = new CswNbtObjClassMailReportGroupPermission(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MethodClass:
                ReturnVal = new CswNbtObjClassMethod(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MethodCharacteristicClass:
                ReturnVal = new CswNbtObjClassMethodCharacteristic(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MethodConditionClass:
                ReturnVal = new CswNbtObjClassMethodCondition(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.NonChemicalClass:
                ReturnVal = new CswNbtObjClassNonChemical(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.PrinterClass:
                ReturnVal = new CswNbtObjClassPrinter(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.PrintJobClass:
                ReturnVal = new CswNbtObjClassPrintJob(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.PrintLabelClass:
                ReturnVal = new CswNbtObjClassPrintLabel(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ProblemClass:
                ReturnVal = new CswNbtObjClassProblem(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ReceiptLotClass:
                ReturnVal = new CswNbtObjClassReceiptLot(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RegulatoryListClass:
                ReturnVal = new CswNbtObjClassRegulatoryList(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RegulatoryListCasNoClass:
                ReturnVal = new CswNbtObjClassRegulatoryListCasNo(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RegulatoryListMemberClass:
                ReturnVal = new CswNbtObjClassRegulatoryListMember(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RegulatoryListListCodeClass:
                ReturnVal = new CswNbtObjClassRegulatoryListListCode(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ReportClass:
                ReturnVal = new CswNbtObjClassReport(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ReportGroupClass:
                ReturnVal = new CswNbtObjClassReportGroup(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ReportGroupPermissionClass:
                ReturnVal = new CswNbtObjClassReportGroupPermission(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RequestClass:
                ReturnVal = new CswNbtObjClassRequest(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RequestItemClass:
                ReturnVal = new CswNbtObjClassRequestItem(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RoleClass:
                ReturnVal = new CswNbtObjClassRole(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.SDSDocumentClass:
                ReturnVal = new CswNbtObjClassSDSDocument(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.TestingLabClass:
                ReturnVal = new CswNbtObjClassTestingLab(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GeneratorClass:
                ReturnVal = new CswNbtObjClassGenerator(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.SizeClass:
                ReturnVal = new CswNbtObjClassSize(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.TaskClass:
                ReturnVal = new CswNbtObjClassTask(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.TestingLabUserAssignmentClass:
                ReturnVal = new CswNbtObjClassTestingLabUserAssignment(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.TestingLabMethodAssignmentClass:
                ReturnVal = new CswNbtObjClassTestingLabMethodAssignment(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.UnitOfMeasureClass:
                ReturnVal = new CswNbtObjClassUnitOfMeasure(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.UserClass:
                ReturnVal = new CswNbtObjClassUser(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.VendorClass:
                ReturnVal = new CswNbtObjClassVendor(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.WorkUnitClass:
                ReturnVal = new CswNbtObjClassWorkUnit(CswNbtResources, Node);
                break;

            default:
                //ReturnVal = new CswNbtObjClassDefault( CswNbtResources, _CswNbtNode );
                throw (new CswDniException("There is no NbtObjClass derivative for object class " + ObjectClass.ObjectClass.ToString()));
            }//switch


            return(ReturnVal);
        } //makeObjClass()