예제 #1
0
        public static DiscountCard GetDiscount(string codebar)
        {
            var discountCard = RepositoryDiscountCard.GetOneByNumber(codebar);

            if (discountCard != null && discountCard.IsActive)
            {
                Client.Barcode = codebar;
                Client.Points  = discountCard.Points;
                Client.InfoClientsCustomerId = discountCard.InfoClientsCustomerId;
                Client.Procent     = 0;
                Client.LastDateUpd = discountCard.DateTimeLastAddProduct;
            }

            return(discountCard);
        }
예제 #2
0
        public static void SetDiscountPoint(string codebar, int points, bool isSet)
        {
            var discountCard = RepositoryDiscountCard.GetOneByNumber(codebar);

            if (discountCard != null)
            {
                if (points >= Client.MaxPoints)
                {
                    points = Client.MaxPoints;
                }
                discountCard.Points = isSet ? points : discountCard.Points;

                if (isSet)
                {
                    RepositoryDiscountCard.Update(discountCard);
                }
            }
        }
예제 #3
0
        public static void Sync()
        {
            if (SyncData.IsConnect)
            {
                SetFromDb();
                SaveFile();
            }
            else
            {
                LoadFile();
            }

            if (RepositoryDiscountCard.DiscountCards.Count == 0)
            {
                RepositoryDiscountCard.Sync();
            }

            foreach (var info in ClientInfos)
            {
                var cards = RepositoryDiscountCard.DiscountCards.FindAll(dc => dc.InfoClientsCustomerId == info.CustomerId);
                info.DiscountCards.AddRange(cards);
            }
        }