/** * Set Region * @param region */ public void SetRegion(MRegion region) { _region = region; if (region == null) { base.SetC_Region_ID(0); } else { base.SetC_Region_ID(_region.GetC_Region_ID()); if (_region.GetC_Country_ID() != GetC_Country_ID()) { log.Info("Region(" + region + ") C_Country_ID=" + region.GetC_Country_ID() + " - From C_Country_ID=" + GetC_Country_ID()); SetC_Country_ID(region.GetC_Country_ID()); } } }
/// <summary> /// Standard Constructor /// </summary> /// <param name="ctx">context</param> /// <param name="C_Location_ID">id</param> /// <param name="trxName">transaction</param> public MLocation(Ctx ctx, int C_Location_ID, Trx trxName) : base(ctx, C_Location_ID, trxName) { if (C_Location_ID == 0) { MCountry defaultCountry = MCountry.GetDefault(GetCtx()); SetCountry(defaultCountry); MRegion defaultRegion = MRegion.GetDefault(GetCtx()); if (defaultRegion != null && defaultRegion.GetC_Country_ID() == defaultCountry.GetC_Country_ID()) { SetRegion(defaultRegion); } } }
/** * Return Array of Regions of Country * @param ctx context * @param C_Country_ID country * @return MRegion Array */ //@SuppressWarnings("unchecked") public static MRegion[] GetRegions(Ctx ctx, int C_Country_ID) { if (s_regions == null || s_regions.Count == 0) { LoadAllRegions(ctx); } List <MRegion> list = new List <MRegion>(); //iterator it = s_regions.Values.iterator(); IEnumerator it = s_regions.Values.GetEnumerator(); while (it.MoveNext()) { MRegion r = (MRegion)it.Current; if (r.GetC_Country_ID() == C_Country_ID) { list.Add(r); } } // Sort it MRegion[] retValue = new MRegion[list.Count]; retValue = list.ToArray(); Array.Sort(retValue, new MRegion(ctx, 0, null)); return(retValue); }