示例#1
0
        private void OnLinkDiscountCardCommandExecuted()
        {
            var firstDiscount = _dc.CumulativeDiscounts
                                .OrderBy(x => x.Percent)
                                .FirstOrDefault();

            if (firstDiscount != null)
            {
                _discountCard = new Models.DiscountCard()
                {
                    Code               = Models.DiscountCard.GenerateCode(),
                    DiscountPercent    = firstDiscount.Percent,
                    MaxDiscount        = firstDiscount.MaxDiscount,
                    MinDiscount        = firstDiscount.MinDiscount,
                    DiscountTypeID     = (int)Enums.DiscountType.Cumulative,
                    TotalPurchaseValue = 0
                };
                _customer.DiscountCard = _discountCard;
                DiscountCardEnabled    = true;
                _dc.SaveChanges();
                RaisePropertiesChanged(BindGroupAttribute.GetPropertiesOfGroup(this.GetType(), "DiscountCard").Select(x => x.Name).ToArray());
            }
            else
            {
                MessageService.Show("Нельзя выполнить данную операцию, т.к. не заполнен справочник скидок!\nЗаполните справочник скидок и повторите попытку.", "Отсутствуют данные в справочнике", MessageBoxButton.OK, MessageBoxImage.Error);
            };
        }
示例#2
0
        private void refreshData(int customerID)
        {
            _dc.Dispose();
            _dc       = new Models.CRMContext();
            _customer = _dc.Customers
                        .Where(x => x.ID == customerID)
                        .Include(x => x.DiscountCard)
                        .Include(x => x.Appointments)
                        .Include(x => x.FinancialTransactions)
                        .First();

            _discountCard       = _customer.DiscountCard;
            DiscountCardEnabled = _discountCard != null;

            VisitHistory          = _customer.Appointments;
            FinancialTransactions = _customer.FinancialTransactions;

            refreshProperties();
        }
示例#3
0
        private void OnUnlinkDiscountCardCommandExecuted()
        {
            DiscountCardEnabled = false;
            var cardID   = _discountCard.ID;
            var cardCode = _discountCard.Code;

            _discountCard          = null;
            _customer.DiscountCard = null;

            RaisePropertiesChanged(BindGroupAttribute.GetPropertiesOfGroup(this.GetType(), "DiscountCard").Select(x => x.Name).ToArray());
            _dc.SaveChanges();

            if (!_dc.Customers.Any(x => x.DiscountCardID == cardID) &&
                MessageService.Show(String.Format("Карта с кодом \"{0}\" не принадлежит ни одному клиенту, удалить карту из системы?", cardCode), "Подтвердите удаление картф", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                var card = _dc.DiscountCards.Single(x => x.ID == cardID);
                _dc.DiscountCards.Remove(card);
                _dc.SaveChanges();
            }
        }