public Boolean IsPricesOk(UInt32 a_PriceExpiryDays) { DateTime limitTime = PriceDate.AddDays(a_PriceExpiryDays); if (limitTime < DateTime.UtcNow) { return(false); } return(true); }
//购气 购气用cardnew控件 public void CSellGas() { if (PriceDate != null) { PriceDate = PriceDate.Substring(0, 10); PriceDate = PriceDate.Replace("-", ""); } if (SellDate != null) { SellDate = SellDate.Substring(0, 10); SellDate = SellDate.Replace("-", ""); } //购气次数加1 BuyTimes++; var openRen = GetSellEvent("Open").Open(0); if (openRen != 0) { GetSellEvent("Close").Close(); Error = "打开串口失败!"; MessageBox.Show(Error); return; } var pricenow = PriceNow * 100; var pricenew = PriceNew * 100; var money = Money * 100; var pricemodify = 1; //如果是无线表,需要先设置数据 if (FactoryId == 13 || FactoryId == 14 || FactoryId == 15 || FactoryId == 16) { var r = GetSellEvent("SaveWxPara").SaveWxPara(money, pricenow, pricemodify, pricenew, PriceDate); } //售气成功返回true,失败false; var sellRen = GetSellEvent("SellGas").SellGas(Gas, BuyTimes, SellDate); GetSellEvent("Close").Close(); if (sellRen) { State = State.End; OnCompleted(null); } else { State = State.Error; Error = "售气不成功!"; MessageBox.Show(Error); } }
//发卡 /* 民用发卡 * cardid:卡号 * alarm:告警气量 * constant:表常数 * amount:气量 * metertype:表型 * user_type:用户类型 * money:金额 * pricenow:当前单价 */ public bool MYInitCard(string cardid, int alarm, int constant, int amount, int metertype, int user_type, double money, double pricenow, int pricemodify, double pricenew, string pricedate, string selldate) { //日期转换格式:yyyymmdd if (PriceDate != null) { PriceDate = PriceDate.Substring(0, 10); PriceDate = PriceDate.Replace("-", ""); } if (SellDate != null) { SellDate = SellDate.Substring(0, 10); SellDate = SellDate.Replace("-", ""); } //打开串口,检查卡 var openRen = GetEvent("Open").Open(0); if (openRen != 0) { GetEvent("Close").Close(); OpenErrorTip(openRen); } //发卡,如果是无线表,需要先设置参数 if (metertype == 13 || metertype == 14 || metertype == 15 || metertype == 16) { GetEvent("SaveWxPara").SaveWxPara(money, pricenow, pricemodify, pricenew, pricedate); } //发卡 var initRen = GetEvent("Init").Init(cardid, alarm, metertype, constant, amount, user_type); GetEvent("Close").Close(); if (initRen) { State = State.End; return(true); } else { State = State.Error; Error = "发卡不成功!'"; return(false); } }
//补卡 card_id, meter_type, times, metre_con, warn_gas, pricenow, pricemodify, pricenew, pricedate, selldate public void MakeUp() { //如果是化解,不允许补购气卡 if (FactoryId == 1 || FactoryId == 2 || FactoryId == 11 || FactoryId == 12) { Error = "华捷不允许补购气卡!"; MessageBox.Show(Error); return; } var cpuselldate = SellDate; var cpupricedate = PriceDate; if (PriceDate != null) { PriceDate = PriceDate.Substring(0, 10); PriceDate = PriceDate.Replace("-", ""); } if (SellDate != null) { SellDate = SellDate.Substring(0, 10); SellDate = SellDate.Replace("-", ""); } // alert("card_id:" + card_id + ",meter_type:" + meter_type + ",times:" + times +",metre_con:" + metre_con + ",warn_gas:" + warn_gas + ",pricenow" + pricenow // + ",pricemodify:" + pricemodify + ",pricenew:" + pricenew + ",pricedate:" + pricedate); var gas = 0; var cus_type = 0; var money = 0; var openRen = GetEvent("Open").Open(0); if (openRen == 0) { GetEvent("Close").Close(); GetSellEvent("Open").Open(0); bool cardren; if (FactoryId == 13 || FactoryId == 14 || FactoryId == 15 || FactoryId == 16) { GetSellEvent("SaveWxPara").SaveWxPara(money, PriceNow, PriceModify, PriceNew, PriceDate); } if (FactoryId == 14 || FactoryId == 16) { var firstCard = CardId.Substring(0, 2); CardId = CardId.Substring(2, 10); cardren = GetSellEvent("SaveOldCard").SaveOldCard(CardId, FactoryId, gas, BuyTimes, cus_type, firstCard, Alarm, firstCard, 0, 0); } else { cardren = GetSellEvent("SaveOldCard").SaveOldCard(CardId, FactoryId, gas, BuyTimes, cus_type, MetreCon, Alarm, MetreCon, 0, 0); } GetSellEvent("Close").Close(); if (cardren) { State = State.End; OnCompleted(null); } else { State = State.Error; Error = "补卡不成功!'"; MessageBox.Show(Error); } } else if (openRen == 1) { GetEvent("Close").Close(); Error = "卡没有插入!"; MessageBox.Show(Error); } else if (openRen == 2) { GetEvent("Close").Close(); Error = "硬件连接错误:线没连接或读卡器有问题或计算机串口坏!"; MessageBox.Show(Error); } else if (openRen == 3) { GetEvent("Close").Close(); Error = "密码错误!"; MessageBox.Show(Error); } //补cpu卡 else if (openRen == 4) { var NewRemnant = 1000; var FirstAlarmV = 1000; var SecondAlamV = 2000; var xs = 1; var consumerlevel = 11; GetEvent("Close").Close(); //MakeUpCpu(card_id, FirstAlarmV, SecondAlamV, NewRemnant, consumerlevel, cus_type, pricedate, xs, cpupricedate, times, money, cpuselldate); } }
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; }
protected static int CompareByPrice(PriceDate priceX, PriceDate priceY) { if (priceX.LowFare == 0M) { if (priceY.LowFare == 0M) { return 0; } else { return -1; } } else { if (priceY.LowFare == 0M) { return 1; } else { if (priceX.LowFare > priceY.LowFare) { return 1; } else if (priceX.LowFare == priceY.LowFare) { return 0; } else { return -1; } } } }
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; }