Exemple #1
0
        private bool _physicalStateMatchesUnitType(string PhysicalState, CswEnumNbtUnitTypes UnitType, bool ExcludeEach = false)
        {
            //Case 29589 - add Each units to all Size qty options, unless explicitly stated otherwise (dispensing)
            bool matchFound = UnitType == CswEnumNbtUnitTypes.Each && false == ExcludeEach;

            if (false == matchFound)
            {
                switch (PhysicalState)
                {
                case CswNbtPropertySetMaterial.CswEnumPhysicalState.NA:
                    matchFound = UnitType == CswEnumNbtUnitTypes.Each;
                    break;

                case CswNbtPropertySetMaterial.CswEnumPhysicalState.Solid:
                    matchFound = UnitType == CswEnumNbtUnitTypes.Weight;
                    break;

                case CswNbtPropertySetMaterial.CswEnumPhysicalState.Liquid:
                case CswNbtPropertySetMaterial.CswEnumPhysicalState.Gas:
                    matchFound = UnitType == CswEnumNbtUnitTypes.Weight ||
                                 UnitType == CswEnumNbtUnitTypes.Volume;
                    break;
                }
            }
            return(matchFound);
        }
Exemple #2
0
        private void _populateUnitViewRelationships(CswNbtView UnitView, string PhysicalState, bool ExcludeEach)
        {
            CswNbtMetaDataObjectClass UnitOfMeasureOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.UnitOfMeasureClass);
            CswNbtMetaDataNodeType    EachNT          = null;

            foreach (CswNbtMetaDataNodeType UnitOfMeasureNodeType in UnitOfMeasureOC.getNodeTypes())
            {
                CswNbtMetaDataNodeTypeProp UnitTypeProp = UnitOfMeasureNodeType.getNodeTypePropByObjectClassProp(CswNbtObjClassUnitOfMeasure.PropertyName.UnitType);
                if (UnitTypeProp.HasDefaultValue())
                {
                    CswEnumNbtUnitTypes UnitType = (CswEnumNbtUnitTypes)UnitTypeProp.getDefaultValue(false).AsList.Value;
                    if (_physicalStateMatchesUnitType(PhysicalState, UnitType, ExcludeEach))
                    {
                        if (UnitType == CswEnumNbtUnitTypes.Each)
                        {
                            EachNT = UnitOfMeasureNodeType;
                        }
                        else
                        {
                            UnitView.AddViewRelationship(UnitOfMeasureNodeType, true);
                        }
                    }
                }
            }
            if (null != EachNT) //Case 29933 - Each units always go at the end of the list
            {
                UnitView.AddViewRelationship(EachNT, true);
            }
        }
 public void setOldUnitProps(CswNbtObjClassUnitOfMeasure OldUnitNode)
 {
     if (OldUnitNode != null)
     {
         _OldConversionFactor = OldUnitNode.ConversionFactor.RealValue;
         _OldUnitType         = (CswEnumNbtUnitTypes)OldUnitNode.UnitType.Value;
     }
 }
 public void setNewUnitProps(CswNbtObjClassUnitOfMeasure NewUnitNode)
 {
     if (NewUnitNode != null)
     {
         _NewConversionFactor = NewUnitNode.ConversionFactor.RealValue;
         _NewUnitType         = (CswEnumNbtUnitTypes)NewUnitNode.UnitType.Value;
     }
 }
        /// <summary>
        /// Identifies the UnitType relationship between two UnitTypes.
        /// </summary>
        private CswEnumNbtUnitTypeRelationship _getUnitTypeRelationship(CswEnumNbtUnitTypes OldUnitType, CswEnumNbtUnitTypes NewUnitType)
        {
            CswEnumNbtUnitTypeRelationship UnitRelationship;

            if (OldUnitType.ToString() == NewUnitType.ToString())
            {
                UnitRelationship = CswEnumNbtUnitTypeRelationship.Same;
            }
            else if (OldUnitType == CswEnumNbtUnitTypes.Weight && NewUnitType == CswEnumNbtUnitTypes.Volume)
            {
                UnitRelationship = CswEnumNbtUnitTypeRelationship.WeightToVolume;
            }
            else if (OldUnitType == CswEnumNbtUnitTypes.Volume && NewUnitType == CswEnumNbtUnitTypes.Weight)
            {
                UnitRelationship = CswEnumNbtUnitTypeRelationship.VolumeToWeight;
            }
            else
            {
                UnitRelationship = CswEnumNbtUnitTypeRelationship.NotSupported;
            }

            return(UnitRelationship);
        }