Esempio n. 1
0
        public static MeasureUnitCollection GetUnits(Guid organizationId)
        {
            MeasureUnitCollection list = new MeasureUnitCollection();

            foreach (MasterDataSet.UnitsOfMeasureRow row in MeasureUnitsProvider.GetBuiltInMeasureUnits())
            {
                list.Add(MeasureUnit.Create(row));
            }

            foreach (MasterDataSet.UnitsOfMeasureRow row in MeasureUnitsProvider.GetMeasureUnits(organizationId))
            {
                list.Add(MeasureUnit.Create(row));
            }

            return(list);
        }
Esempio n. 2
0
        public MeasureUnitCollection GetConvertUnits()
        {
            MeasureUnitCollection units = new MeasureUnitCollection();

            units.Add(this);
            this.FillRelatedUnits(ref units);
            units.Remove(this);
            //units.SortByLevel();
            return(units);
        }
Esempio n. 3
0
        public static MeasureUnitCollection GetUnitsByUnitType(Guid organizationId, string unitType)
        {
            MeasureUnitCollection list = new MeasureUnitCollection();

            MasterDataSet.UnitsOfMeasureDataTable table = MeasureUnitsProvider.GetMeasureUnits(organizationId);
            foreach (MasterDataSet.UnitsOfMeasureRow row in table)
            {
                if (row.LocalName.Equals(unitType))
                {
                    list.Add(MeasureUnit.Create(row));
                }
            }
            return(list);
        }
Esempio n. 4
0
        private void FillRelatedUnits(ref MeasureUnitCollection units)
        {
            if (this.Level > 10)
            {
                return;
            }
            MeasureUnitCollection tmp = new MeasureUnitCollection();

            foreach (MeasureUnit unit in this.RelatedUnits)
            {
                if (!units.Contains(unit))
                {
                    unit.SetLevel(this.Level + 1);
                    unit.SetConversionFactor(unit.ConversionFactor * this.ConversionFactor);
                    units.Add(unit);
                    tmp.Add(unit);
                }
            }
            foreach (MeasureUnit unit in tmp)
            {
                unit.FillRelatedUnits(ref units);
            }
        }