Beispiel #1
0
        /// <summary>
        /// 執行計算折扣 然後傳回顯示此次購買明細
        /// </summary>
        /// <param name="e"></param>
        public string OnAddListExchanged(EventArgs e)
        {
            if (e != null)
            {
                //銷售資訊
                SellInformationEventArgs sellInfo = e as SellInformationEventArgs;
                //要丟去計算的錢
                MoneyEventArgs moneyEventArgs = new MoneyEventArgs() { TicketPrice = sellInfo.TicketPrice };

                //看有幾種折價方法 ex 學生八折 勾選花旗卡 又五折 分別計算
                foreach (string discount in sellInfo.TicketOff)
                {
                    if (!string.IsNullOrWhiteSpace(discount))
                    {
                        Type type = Assembly.Load("StrategyPatternHW_Discount").GetType(discount);
                        //依折數計算後結果 更新錢參數
                        moneyEventArgs = (Activator.CreateInstance(type) as IDiscount).Calculate(moneyEventArgs);
                    }
                }

                //更新銷售資訊的折扣後價格
                sellInfo.TicketOffPrice = moneyEventArgs.TicketPrice;

                //把總價丟去計算紅利
                moneyEventArgs = new MoneyEventArgs() { TicketPrice = sellInfo.TicketOffPrice * sellInfo.TicketNumber };
                if (sellInfo.IsVIP)
                {
                    sellInfo.BenefitCount = benefit.BenefitCount(moneyEventArgs);
                }

                //銷售資訊組成顯示字串
                return UpdateSellDetail(sellInfo);
            }

            return "";
        }
Beispiel #2
0
 public MoneyEventArgs Calculate(MoneyEventArgs price)
 {
     price.TicketPrice = Convert.ToInt32(Math.Floor(price.TicketPrice * 0.5));
     return price;
 }
Beispiel #3
0
 public MoneyEventArgs Calculate(MoneyEventArgs price)
 {
     price.TicketPrice = Convert.ToInt32(Math.Floor(price.TicketPrice * 0.8));
     return(price);
 }
Beispiel #4
0
 //100元換一點
 public int BenefitCount(MoneyEventArgs price)
 {
     return(price.TicketPrice / 100);
 }
Beispiel #5
0
 //100元換一點
 public int BenefitCount(MoneyEventArgs price)
 {
     return price.TicketPrice / 100;
 }