Пример #1
0
        public MeasureUnitCollection GetConvertUnits()
        {
            MeasureUnitCollection units = new MeasureUnitCollection();

            units.Add(this);
            this.FillRelatedUnits(ref units);
            units.Remove(this);
            //units.SortByLevel();
            return(units);
        }
Пример #2
0
        public static MeasureUnitCollection GetUnitsByUnitType(string unitType)
        {
            Guid orgId = Micajah.Common.Security.UserContext.Current.OrganizationId;

            if (orgId.Equals(Guid.Empty))
            {
                return(new MeasureUnitCollection());
            }
            else
            {
                return(MeasureUnitCollection.GetUnitsByUnitType(orgId, unitType));
            }
        }
Пример #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);
        }
Пример #4
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);
        }
Пример #5
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);
            }
        }