Ejemplo n.º 1
0
        public BalanceFrom(SaleOrderForm saleOrderFormWindow, IUnitOfWork unitOfWork,
                           DataModel.Model.SaleOrder saleOrder)
        {
            InitializeComponent();

            _unitOfWork          = unitOfWork;
            _saleOrderRepository = _unitOfWork.GetRepository <SaleOrderRepository>();
            _soProduceRepository = _unitOfWork.GetRepository <SOProduceRepository>();
            _produceRepository   = _unitOfWork.GetRepository <ProduceRepository>();
            _userRepository      = _unitOfWork.GetRepository <UserRepository>();

            _saleOrderFormWindow = saleOrderFormWindow;

            _saleOrder          = saleOrder;
            _balanceDomainModel = new BalanceDomainModel
            {
                TotalPrice    = saleOrder.TotalCost ?? 0,
                DiscountPrice = 0.0f,
                CashTotal     = _user.CashTotal,
            };

            DataContext = new
            {
                BalanceDomainModel = _balanceDomainModel,
                ResourcesHelper.CurrentUserRolePermission,
            };

            RadBanlanceModeCard.Click += (s, e) =>
            {
                TabItemCard.IsSelected = true;
            };
            RadBanlanceModeCash.Click += (s, e) =>
            {
                TabItemCash.IsSelected = true;
            };
        }
Ejemplo n.º 2
0
        public SaleOrderForm(SaleOrder saleOrderWindow, DataModel.Model.SaleOrder saleOrder)
        {
            InitializeComponent();

            TxtUserNoOrPhone.Focus();

            _unitOfWork           = UnityInit.UnitOfWork;
            _saleOrderRepository  = _unitOfWork.GetRepository <SaleOrderRepository>();
            _soProduceRepository  = _unitOfWork.GetRepository <SOProduceRepository>();
            _produceRepository    = _unitOfWork.GetRepository <ProduceRepository>();
            _userRepository       = _unitOfWork.GetRepository <UserRepository>();
            _memberCardRepository = _unitOfWork.GetRepository <IMemberCardRepository>();

            SaleOrderWindow = saleOrderWindow;

            if (saleOrder.SaleOrderId > 0)
            {
                _saleOrder = _saleOrderRepository.Query()
                             .Single(x => x.SaleOrderId == saleOrder.SaleOrderId);
                _saleOrder.SOProduces.ForEach(x => _soProduceDomainModels.Add(new SOProduceDomainModel
                {
                    SOProduce      = x,
                    CostPerUnit    = x.CostPerUnit,
                    SOProduceTotal = (x.CostPerUnit ?? 0) * x.Quantity ?? 0
                }));

                if (_saleOrder.PurchaseOrderUserId.HasValue)
                {
                    _user       = _userRepository.GetByUserId(_saleOrder.PurchaseOrderUserId.Value);
                    _memberCard =
                        _memberCardRepository.Query()
                        .FirstOrDefault(x => x.IsEnable && x.RelateUserId == _saleOrder.PurchaseOrderUserId);
                    if (_memberCard == null)
                    {
                        _memberCard = new DataModel.Model.MemberCard();
                    }
                }
            }
            else
            {
                _saleOrder = saleOrder;
            }

            if (_saleOrder.SaleOrderStatus == (byte)DataType.SaleOrderStatus.Balanced)
            {
                ButSave.IsEnabled    = false;
                ButBalance.IsEnabled = false;
            }

            if (_saleOrder.HowBalance == (sbyte)DataType.SaleOrderBalancedMode.Cash)
            {
                TabItemCash.IsSelected        = true;
                RadBanlanceModeCash.IsChecked = true;
            }
            else if (_saleOrder.HowBalance == (sbyte)DataType.SaleOrderBalancedMode.MemberCard)
            {
                RadBanlanceModeCard.IsChecked = true;
                TabItemCard.IsSelected        = true;
            }
            else
            {
                RadBanlanceModeUnionPay.IsChecked = true;
                TabItemUnionPay.IsSelected        = true;
            }

            _balanceDomainModel = new BalanceDomainModel
            {
                TotalPrice    = saleOrder.TotalCost ?? 0,
                DiscountPrice = saleOrder.FavorableCost ?? 0,
                CashTotal     = _user.CashTotal,
                RealPrice     = saleOrder.UserRealPrice ?? 0,
                ReturnedPrice = saleOrder.UserReturnedPrice ?? 0
            };

            DataContext = new
            {
                SaleOrder = _saleOrder,
                SOProduceDomainModels,
                ResourcesHelper.CurrentUserRolePermission,
                BalanceDomainModel = _balanceDomainModel,
            };

            TxtDiscount.Text  = _balanceDomainModel.DiscountPrice.ToString();
            TxtRealPrice.Text = _balanceDomainModel.RealPrice.ToString();

            _soProduceDomainModels.CollectionChanged += (sender, e) => SetTotalNameberText();

            SetTotalNameberText();
            SetUserInfo();

            RadBanlanceModeCard.Click += (s, e) =>
            {
                TabItemCard.IsSelected = true;
            };
            RadBanlanceModeCash.Click += (s, e) =>
            {
                TabItemCash.IsSelected = true;
            };
            RadBanlanceModeUnionPay.Click += (s, e) =>
            {
                TabItemUnionPay.IsSelected = true;
            };
        }