Пример #1
0
        private void removeChildren(DiscountComposite d)
        {
            foreach (DiscountComponent child in d.getChildren())
            {
                if (child is DiscountComposite)
                {
                    removeChildren((DiscountComposite)child);
                }
                else
                {
                    if (child is ReliantDiscount)
                    {
                        ReliantDiscount r = (ReliantDiscount)child;

                        if (r.getProduct() != null)
                        {
                            r.getProduct().removeReliantDiscount();
                        }
                    }
                    if (child is VisibleDiscount)
                    {
                        VisibleDiscount v = (VisibleDiscount)child;

                        if (v.getProduct() != null)
                        {
                            v.getProduct().removeDiscount();
                        }
                    }
                }
            }
        }
Пример #2
0
        public void removeDiscount(int discountID)
        {
            foreach (DiscountComponent d in discountList)
            {
                if (d.getId() == discountID)
                {
                    //
                    discountList.Remove(d);
                    if (d is ReliantDiscount)
                    {
                        ReliantDiscount r = (ReliantDiscount)d;

                        if (r.getProduct() != null)
                        {
                            r.getProduct().removeReliantDiscount();
                        }
                    }
                    if (d is VisibleDiscount)
                    {
                        VisibleDiscount v = (VisibleDiscount)d;

                        if (v.getProduct() != null)
                        {
                            v.getProduct().removeDiscount();
                        }
                    }
                    if (d is DiscountComposite)
                    {
                        removeChildren((DiscountComposite)d);
                    }
                    break;
                }
            }
        }
Пример #3
0
        private void addReliantDiscount(ReliantDiscount r)
        {
            //SqlConnection connection = Connector.getInstance().getSQLConnection();
            int    id              = r.getId();
            string type            = "Reliant";
            bool   isPartOfComplex = r.getIsPartOfComplex();
            string reliantType;
            string visibleType = "-1";
            int    productId;
            int    storeId = r.getStoreId();
            int    numOfProducts;
            int    totalAmount;

            if (r.getProduct() == null)
            {
                reliantType   = "totalAmount";
                productId     = -1;
                totalAmount   = r.getTotalAmount();
                numOfProducts = -1;
            }
            else
            {
                reliantType   = "sameProduct";
                productId     = r.getProduct().getProductID();
                totalAmount   = -1;
                numOfProducts = r.getMinNumOfProducts();
            }
            string sql = "INSERT INTO [dbo].[Discount] (id, type, reliantType, visibleType, productId, storeId, numOfProducts, totalAmount)" +
                         " VALUES (@id, @type, @reliantType, @visibleType, @productId, @storeId, @numOfProducts, @totalAmount)";

            connection.Execute(sql, new
            {
                id,
                type,
                reliantType,
                visibleType,
                productId,
                storeId,
                numOfProducts,
                totalAmount
            });
        }