public MeasureUnitCollection GetConvertUnits() { MeasureUnitCollection units = new MeasureUnitCollection(); units.Add(this); this.FillRelatedUnits(ref units); units.Remove(this); //units.SortByLevel(); return(units); }
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)); } }
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); }
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); }
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); } }