private void retailCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Parameter == null)
            {
                return;
            }
            switch (e.Parameter.ToString())
            {
            case "Cash":
                OPResult result = _dataContext.ValidateWhenCash();
                if (!result.IsSucceed)
                {
                    MessageBox.Show(result.Message);
                    return;
                }
                _dataContext.SetRetailData();
                BindingExpression be = txtRemark.GetBindingExpression(TextBox.TextProperty);
                be.UpdateTarget();    //备注可能更改,更新UI
                CashWin wincash = new CashWin(_dataContext);
                wincash.Owner            = View.Extension.UIHelper.GetAncestor <Window>(this);
                wincash.CashScceedEvent += delegate
                {
                    _dataContext.Init();
                    be.UpdateTarget();
                };
                wincash.ShowDialog();
                break;

            case "CashCoupon":
                List <int> brandIDs = new List <int>();
                SysProcessView.UIHelper.TraverseGridViewData <DistributionProductShow>(gvDatas, p => { brandIDs.Add(p.BrandID); });
                CashCouponWin couponwin = new CashCouponWin(brandIDs.Distinct().Select(o => VMGlobal.PoweredBrands.Find(b => b.ID == o)),
                                                            _dataContext.BeforeDiscountCoupon, _dataContext.AfterDiscountCoupon, _dataContext.CouponBrandIDs);
                couponwin.Owner           = View.Extension.UIHelper.GetAncestor <Window>(this);
                couponwin.CouponObtained += new Action <int, int, IEnumerable <int> >(win_CouponObtained);
                couponwin.ShowDialog();
                break;

            case "VIP":
                break;

            case "Back":
                RetailCodeInputWin win = new RetailCodeInputWin(_dataContext);
                win.Owner             = View.Extension.UIHelper.GetAncestor <Window>(this);
                win.SetRetailVMEvent += () =>
                {
                    foreach (var d in _dataContext.GridDataItems)
                    {
                        d.Quantity *= (-1);
                        d.CutMoney *= (-1);
                    }
                    _dataContext.Master.ReceiveTicket = 0;
                    _dataContext.Master.TicketKind    = null;
                    _dataContext.Master.TicketMoney   = 0;
                    //this.DataContext = _dataContext = vm;
                };
                win.ShowDialog();
                break;
            }
        }
Ejemplo n.º 2
0
        private void retailCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Parameter == null)
            {
                return;
            }
            switch (e.Parameter.ToString())
            {
            case "Cash":
                OPResult result = _dataContext.ValidateWhenCash();
                if (!result.IsSucceed)
                {
                    MessageBox.Show(result.Message);
                    return;
                }
                result = _dataContext.ValidateVIPBirthdayConsumption();
                if (!result.IsSucceed)
                {
                    var diaResult = MessageBox.Show(result.Message + "\n确认继续吗?\n(注意:点击确认将以正常VIP折扣消费,取消可返回修改单据明细.)", "提示", MessageBoxButton.OKCancel);
                    if (diaResult == MessageBoxResult.OK)
                    {
                        _dataContext.ClearVIPBirthdayDiscount();
                    }
                    else
                    {
                        return;
                    }
                }
                _dataContext.SetRetailData();
                BindingExpression be = txtRemark.GetBindingExpression(TextBox.TextProperty);
                be.UpdateTarget();    //备注可能更改,更新UI
                CashWin wincash = new CashWin(_dataContext);
                wincash.Owner            = View.Extension.UIHelper.GetAncestor <Window>(this);
                wincash.CashScceedEvent += delegate
                {
                    _dataContext.Init();
                    be.UpdateTarget();
                };
                wincash.ShowDialog();
                break;

            case "CashCoupon":
                List <int> brandIDs = new List <int>();
                SysProcessView.UIHelper.TraverseGridViewData <DistributionProductShow>(gvDatas, p => { brandIDs.Add(p.BrandID); });
                CashCouponWin couponwin = new CashCouponWin(brandIDs.Distinct().Select(o => VMGlobal.PoweredBrands.Find(b => b.ID == o)),
                                                            _dataContext.BeforeDiscountCoupon, _dataContext.AfterDiscountCoupon, _dataContext.CouponBrandIDs);
                couponwin.Owner           = View.Extension.UIHelper.GetAncestor <Window>(this);
                couponwin.CouponObtained += new Action <int, int, IEnumerable <int> >(win_CouponObtained);
                couponwin.ShowDialog();
                break;

            case "VIP":
                this.SetVIPInfo();
                break;

            case "Hold":
                if (_holdRetails == null)
                {
                    _holdRetails = new ObservableCollection <HoldRetailEntity>();
                }
                _holdRetails.Add(new HoldRetailEntity {
                    CreateTime = DateTime.Now, HoldRetail = _dataContext, Code = this.GenerateHoldRetailCode()
                });
                this.DataContext = _dataContext = new BillRetailVM();
                break;

            case "Fetch":
                if (_holdRetails == null || _holdRetails.Count == 0)
                {
                    MessageBox.Show("没有挂单.");
                    return;
                }
                FetchRetailBillWin winFetch = new FetchRetailBillWin();
                winFetch.DataContext       = _holdRetails;
                winFetch.Owner             = View.Extension.UIHelper.GetAncestor <Window>(this);
                winFetch.FetchRetailEvent += hr => { this.DataContext = _dataContext = (BillRetailVM)hr.HoldRetail; };
                winFetch.ShowDialog();
                break;

            case "Back":
                RetailCodeInputWin win = new RetailCodeInputWin();
                win.Owner             = View.Extension.UIHelper.GetAncestor <Window>(this);
                win.GetRetailVMEvent += vm =>
                {
                    foreach (var d in vm.GridDataItems)
                    {
                        d.Quantity *= (-1);
                        d.CutMoney *= (-1);
                    }
                    vm.Master.ReceiveTicket = 0;
                    vm.Master.TicketKind    = null;
                    vm.Master.TicketMoney   = 0;
                    this.DataContext        = _dataContext = vm;
                };
                win.ShowDialog();
                break;
            }
        }