예제 #1
0
        void UCGiftCardUsageDetail_Loaded(object sender, RoutedEventArgs e)
        {
            Loaded -= new RoutedEventHandler(UCGiftCardUsageDetail_Loaded);
            facade  = new GiftCardFacade(CPApplication.Current.CurrentPage);

            comGiftCardStatus.ItemsSource   = EnumConverter.GetKeyValuePairs <ECCentral.BizEntity.IM.GiftCardStatus>();
            comGiftCardCategory.ItemsSource = EnumConverter.GetKeyValuePairs <ECCentral.BizEntity.IM.GiftCardType>();
            customerInfo = new BizEntity.Customer.CustomerInfo();

            this.btnSave.Visibility = System.Windows.Visibility.Collapsed;
            this.btnVoid.Visibility = System.Windows.Visibility.Collapsed;

            if (VM != null)
            {
                VM.ChannelID         = "1";
                oldEndDate           = VM.EndDate;
                BaseInfo.DataContext = VM;

                customerInfo.BasicInfo.CustomerID    = VM.CustomerID;
                customerInfo.BasicInfo.CustomerSysNo = int.Parse(string.IsNullOrEmpty(VM.CustomerSysNo)?"0":VM.CustomerSysNo);
                facade.GetGiftCardOperateLogByCode(VM.CardCode, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }

                    List <ECCentral.BizEntity.IM.GiftCardOperateLog> logs = args.Result;
                    if (logs != null && logs.Count > 0)
                    {
                        StringBuilder str = new StringBuilder();
                        logs = logs.OrderByDescending(p => p.InDate).ToList();
                        foreach (ECCentral.BizEntity.IM.GiftCardOperateLog log in logs)
                        {
                            str.AppendFormat("{0} {1} by {2} {3}", log.InDate.Value.ToString("yyyy-MM-dd HH:mm"), log.ActionType.ToDescription(), log.InUser, log.Memo);
                            str.AppendLine();
                        }
                        tbLog.Text = str.ToString().TrimEnd();
                    }
                });
                facade.GetGiftCardRedeemLogJoinSOMaster(VM.CardCode, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    DataGrid.ItemsSource = args.Result;
                });

                if ((VM.Status == GiftCardStatus.Valid || VM.Status == GiftCardStatus.ManualActive) && VM.AvailAmount.HasValue && VM.AvailAmount > 0)
                {
                    this.btnSave.Visibility = System.Windows.Visibility.Visible;
                    //this.btnVoid.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    this.dpEndDate.IsEnabled = false;
                }
            }
        }