private void BindSeason() { bool flag = true; if (SelectTourMaterial.PriceType == TERMS.Common.TourPriceType.AirLand) flag = false; TourProfile tourProfile = (TourProfile)((TourMaterial)SelectTourMaterial).Profile; List<Decimal> priceList = new List<decimal>(); Hashtable seasonHash = new Hashtable(); Decimal defaultPrice = decimal.Zero; for (int i = 0; i < tourProfile.Seasons.Count; i++) { defaultPrice = decimal.Zero; for (int ii = 0; ii < tourProfile.RoomTypes.Count; ii++) { decimal roomePrice = (Decimal)tourProfile.GetPrice(tourProfile.Seasons[i], tourProfile.RoomTypes[ii] , flag, false).GetAmount(TERMS.Common.PassengerType.Adult) + (Decimal)tourProfile.GetPrice(tourProfile.Seasons[i], tourProfile.RoomTypes[ii], flag, false).GetMarkup(TERMS.Common.PassengerType.Adult); if (defaultPrice == decimal.Zero) defaultPrice = roomePrice; else { if (roomePrice < defaultPrice) defaultPrice = roomePrice; } } priceList.Add(defaultPrice); seasonHash.Add((TERMS.Common.Season)tourProfile.Seasons[i], defaultPrice); } priceList.Sort(); List<PriceDate> myPriceDateList = new List<PriceDate>(); PriceDate priceDate = null; decimal LowFare = 0M; List<DateTime> dtList = null; foreach (TERMS.Common.Season season in seasonHash.Keys) { LowFare = (Decimal)seasonHash[season]; priceDate = new PriceDate(); dtList = new List<DateTime>(); for (int j = 0; j < season.Periods.Count; j++) { dtList.AddRange(GetDateList(season.Periods[j].PeriodFrom, season.Periods[j].PeriodTo)); } priceDate.LowFare = (Decimal)seasonHash[season]; dtList.Sort(); priceDate.DateElementList = (List<DateTime>)dtList; if (!IsExeists(myPriceDateList, priceDate.LowFare)) { if (priceDate.DateElementList.Count > 0) myPriceDateList.Add(priceDate); } else { foreach (PriceDate pd in myPriceDateList) { if (pd.LowFare == priceDate.LowFare) { if (priceDate.DateElementList.Count > 0) { foreach (DateTime dt in priceDate.DateElementList) { pd.DateElementList.Add(dt); } } } } } } SeasonFareList seasonFareList = new SeasonFareList(); seasonFareList.Items = myPriceDateList; seasonFareList.SortByPrice(); //����������� List<PriceDate> priceDates = new List<PriceDate>(); List<DateTime> tempDates = null; PriceDate tempPriceDate = null; decimal tempPrice = 0M; foreach (PriceDate pd in seasonFareList.Items) { if (tempPrice != pd.LowFare) { tempPrice = pd.LowFare; tempDates = new List<DateTime>(); tempPriceDate = new PriceDate(); foreach (DateTime date in pd.DateElementList) { tempDates.Add(date); } tempDates.Sort(); tempPriceDate.LowFare = tempPrice; tempPriceDate.DateElementList = (List<DateTime>)tempDates; if (tempPriceDate != null && tempPriceDate.DateElementList.Count > 0) priceDates.Add(tempPriceDate); } else { foreach (DateTime date in pd.DateElementList) { tempDates.Add(date); } tempDates.Sort(); tempPriceDate.DateElementList = (List<DateTime>)tempDates; if (!IsExeists(priceDates, tempPriceDate.LowFare)) { if (tempPriceDate.DateElementList.Count > 0) myPriceDateList.Add(tempPriceDate); } } } priceDates.Sort(delegate(PriceDate c1, PriceDate c2) { return (c1.DateElementList[0].CompareTo(c2.DateElementList[0])); }); PriceDateList = priceDates; }
private void BindSeason() { TourProfile tourProfile = (TourProfile)((TourMaterial)tourMerchandise.DefaultTourMaterial).Profile; List<Decimal> priceList = new List<decimal>(); Hashtable seasonHash = new Hashtable(); for (int i = 0; i < tourProfile.Seasons.Count; i++) { Decimal defaultPrice = (Decimal)tourProfile.GetPrice(tourProfile.Seasons[i], ((Terms.Product.Business.MVTourProfile)tourProfile).DefaultFareKey, ((TourSearchCondition)Transaction.CurrentSearchConditions).IsLandOnly, false).GetAmount(TERMS.Common.PassengerType.Adult); priceList.Add(defaultPrice); seasonHash.Add((TERMS.Common.Season)tourProfile.Seasons[i], defaultPrice); } priceList.Sort(); List<PriceDate> myPriceDateList = new List<PriceDate>(); PriceDate priceDate = null; decimal LowFare = 0M; List<DateTime> dtList = null; foreach (TERMS.Common.Season season in seasonHash.Keys) { LowFare = (Decimal)seasonHash[season]; priceDate = new PriceDate(); dtList = new List<DateTime>(); for (int j = 0; j < season.Periods.Count; j++) { dtList.AddRange(GetDateList(season.Periods[j].PeriodFrom, season.Periods[j].PeriodTo)); } priceDate.LowFare = (Decimal)seasonHash[season]; dtList.Sort(); priceDate.DateElementList = (List<DateTime>)dtList; if (!IsExeists(myPriceDateList, priceDate.LowFare)) { if (priceDate.DateElementList.Count > 0) myPriceDateList.Add(priceDate); } else { foreach (PriceDate pd in myPriceDateList) { if (pd.LowFare == priceDate.LowFare) { if (priceDate.DateElementList.Count > 0) { foreach (DateTime dt in priceDate.DateElementList) { pd.DateElementList.Add(dt); } } } } } } SeasonFareList seasonFareList = new SeasonFareList(); seasonFareList.Items = myPriceDateList; seasonFareList.SortByPrice(); //����������� List<PriceDate> priceDates = new List<PriceDate>(); List<DateTime> tempDates = null; PriceDate tempPriceDate = null; decimal tempPrice = 0M; foreach (PriceDate pd in seasonFareList.Items) { if (tempPrice != pd.LowFare) { tempPrice = pd.LowFare; tempDates = new List<DateTime>(); tempPriceDate = new PriceDate(); foreach (DateTime date in pd.DateElementList) { tempDates.Add(date); } tempDates.Sort(); tempPriceDate.LowFare = tempPrice; tempPriceDate.DateElementList = (List<DateTime>)tempDates; if (tempPriceDate != null && tempPriceDate.DateElementList.Count > 0) priceDates.Add(tempPriceDate); } else { foreach (DateTime date in pd.DateElementList) { tempDates.Add(date); } tempDates.Sort(); tempPriceDate.DateElementList = (List<DateTime>)tempDates; if (!IsExeists(priceDates, tempPriceDate.LowFare)) { if (tempPriceDate.DateElementList.Count > 0) myPriceDateList.Add(tempPriceDate); } } } priceDates.Sort(delegate(PriceDate c1, PriceDate c2) { return (c1.DateElementList[0].CompareTo(c2.DateElementList[0])); }); PriceDateList = priceDates;// seasonFareList.Items; }