Example #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();
                        }
                    }
                }
            }
        }
Example #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;
                }
            }
        }
Example #3
0
        private void addVisibleDiscount(VisibleDiscount v)
        {
            //SqlConnection connection = Connector.getInstance().getSQLConnection();
            int    id          = v.getId();
            string type        = "Visible";
            string reliantType = "-1";
            string visibleType;
            int    productId;
            int    storeId = v.getStoreId();

            if (v.getProduct() == null)
            {
                visibleType = "StoreVisibleDiscount";
                productId   = -1;
            }
            else
            {
                visibleType = "ProductVisibleDiscount";
                productId   = v.getProduct().getProductID();
            }
            //not reliantdiscount
            int    numOfProducts = -1;
            int    totalAmount   = -1;
            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
            });
        }