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()
internal CswNbtNode createMaterialNode(string NodeTypeName = "Chemical", string State = "Liquid", double SpecificGravity = 1.0, string PPE = "", string Hazards = "", string SpecialFlags = "", string CASNo = "12-34-0", CswEnumTristate IsTierII = null, Collection <CswNbtNode> Constituents = null, int ConstPercentage = 10) { IsTierII = IsTierII ?? CswEnumTristate.True; CswNbtNode ret = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(_getNodeTypeId(NodeTypeName), delegate(CswNbtNode NewNode) { CswNbtObjClassChemical MaterialNode = NewNode; if (CswTools.IsDouble(SpecificGravity)) { MaterialNode.SpecificGravity.Value = SpecificGravity; } MaterialNode.PhysicalState.Value = State; MaterialNode.TradeName.Text = "Fake Chemical " + Sequence; MaterialNode.PartNumber.Text = "ABC00" + Sequence; if (NodeTypeName == "Chemical") { if (false == String.IsNullOrEmpty(PPE)) { _setMultiListValue(MaterialNode.Node, PPE, "PPE"); } if (false == String.IsNullOrEmpty(Hazards)) { _setMultiListValue(MaterialNode.Node, Hazards, "Hazard Classes"); } MaterialNode.postChanges(true); _setMultiListValue(MaterialNode.Node, SpecialFlags, "Special Flags"); MaterialNode.CasNo.Text = CASNo; MaterialNode.IsTierII.Checked = IsTierII; if (null != Constituents) { foreach (CswNbtNode Constituent in Constituents) { _CswNbtResources.Nodes.makeNodeFromNodeTypeId(_getNodeTypeId("Material Component"), delegate(CswNbtNode Node) { CswNbtObjClassMaterialComponent MaterialComponentNode = Node; MaterialComponentNode.Mixture.RelatedNodeId = MaterialNode.NodeId; MaterialComponentNode.Constituent.RelatedNodeId = Constituent.NodeId; //MaterialComponentNode.LowPercentageValue.Value = ConstPercentage; //MaterialComponentNode.TargetPercentageValue.Value = ConstPercentage; //MaterialComponentNode.HighPercentageValue.Value = ConstPercentage; //MaterialComponentNode.Percentage.Value = ConstPercentage; MaterialComponentNode.PercentageRange.Lower = ConstPercentage; MaterialComponentNode.PercentageRange.Target = ConstPercentage; MaterialComponentNode.PercentageRange.Upper = ConstPercentage; }); } } } }, OverrideUniqueValidation: true); _finalize(); return(ret); }
protected override void afterDeleteNodeLogic() { // case 28303 - add list to Chemical's Suppressed list if (false == SetByChemical && CswTools.IsPrimaryKey(Chemical.RelatedNodeId)) { CswNbtObjClassChemical ChemicalNode = _CswNbtResources.Nodes[Chemical.RelatedNodeId]; if (null != ChemicalNode) { ChemicalNode.addSuppressedRegulatoryList(RegulatoryList.RelatedNodeId); ChemicalNode.postChanges(false); } } }//afterDeleteNode()