示例#1
0
        /// <summary>
        /// 更新顯示面板
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public string UpdateSellDetail(EventArgs e)
        {
            SellInformationEventArgs args = e as SellInformationEventArgs;

            return(String.Format("一張{0} 原價{1} 特價{2} 共{3}張 小計:{4} {5}" + System.Environment.NewLine,
                                 args.TicketName, args.TicketPrice.ToString(), args.TicketOffPrice.ToString(), args.TicketNumber.ToString(), args.TicketOffPrice * args.TicketNumber
                                 , args.BenefitCount > 0 ? "本次紅利積點 " + args.BenefitCount.ToString() : ""));
        }
示例#2
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("");
        }