protected void uxAddItemButton_Click(object sender, EventArgs e)
    {
        string errMeg = String.Empty;

        try
        {
            ProductKitGroup productKitGroup = DataAccessContext.ProductKitGroupRepository.GetOne(CurrentCulture, ProductKitGroupID);

            ProductKitItem productKitItem = new ProductKitItem();
            productKitItem.ProductID             = uxProductKitProductDetails.ProductID;
            productKitItem.ProductKitGroupID     = ProductKitGroupID;
            productKitItem.Quantity              = uxProductKitProductDetails.Quantity;
            productKitItem.IsDefault             = uxProductKitProductDetails.IsDefault;
            productKitItem.IsUserDefinedQuantity = uxProductKitProductDetails.IsUserDefinedQuantity;

            if (!IsDuplicateItems(productKitGroup.ProductKitItems, productKitItem))
            {
                productKitGroup.ProductKitItems.Add(productKitItem);
                productKitGroup.ProductKitItems = UpdateItemDefault(productKitGroup.ProductKitItems, productKitItem);
                DataAccessContext.ProductKitGroupRepository.Save(productKitGroup);
                uxMessage.DisplayMessage(Resources.ProductKitGroupItemMessages.ItemAddSuccess);
                OnBubbleEvent(e);
                uxProductKitProductDetails.ClearCheckBox();
            }
            else
            {
                uxMessage.DisplayError("Product already exist in this Group");
            }
        }
        catch (Exception ex)
        {
            MessageControl.DisplayError(ex.ToString());
        }
    }
Exemple #2
0
    public bool IsValidStock(int mainProductQuantity)
    {
        if ((!ProductKitGroup.IsRequired) && (uxKitItemDrop.SelectedValue == ""))
        {
            return(true);
        }
        int  productQty;
        bool isNum = int.TryParse(Quantity, out productQty);

        if (isNum == false)
        {
            uxMessageLabel.Text = GetLanguageText("ProductKitInputInvalid");
            return(false);
        }
        int purchaseQuantity = productQty * mainProductQuantity;

        if (purchaseQuantity <= 0)
        {
            return(true);
        }
        ProductKitItem kitItem      = GetSelectedProductKitItem();
        Product        product      = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, kitItem.ProductID, new StoreRetriever().GetCurrentStoreID());
        int            currentStock = product.GetPurchasableStock(
            StoreContext.ShoppingCart.GetNumberOfItems(kitItem.ProductID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, kitItem.ProductID));

        if (product.IsOutOfStock(
                purchaseQuantity,
                StoreContext.ShoppingCart.GetNumberOfItems(kitItem.ProductID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, kitItem.ProductID)))
        {
            uxMessageDiv.Visible = true;
            uxMessageLabel.Text  = String.Format(GetLanguageText("CheckStockMessage"));
            return(false);
        }
        return(true);
    }
    protected void uxKitItemRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
    {
        ProductKitItem kitItem = GetSelectedProductKitItem();

        if (!kitItem.IsNull)
        {
            SetDisplayIsUserDefinedQTY(kitItem);
            Quantity = kitItem.Quantity.ToString();
        }
    }
 private bool IsDuplicateItems(IList <ProductKitItem> productKitItems, ProductKitItem newKitItem)
 {
     foreach (ProductKitItem productKitItem in productKitItems)
     {
         if (productKitItem.ProductID == newKitItem.ProductID)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #5
0
    public void CreateProductKitItems(ArrayList selectedList)
    {
        ProductKitItem kitItem = GetSelectedProductKitItem();

        if (!kitItem.IsNull)
        {
            int  qty;
            bool isNum = int.TryParse(uxQuantityText.Text, out qty);
            ProductKitItemValue value = new ProductKitItemValue(kitItem, ProductKitGroup.ProductKitGroupType.DropDown, uxKitItemDrop.SelectedItem.Text, qty);
            selectedList.Add(value);
        }
    }
Exemple #6
0
 private void SetDisplayIsUserDefinedQTY(ProductKitItem kitItem)
 {
     if ((kitItem.IsUserDefinedQuantity))
     {
         uxQuantityText.Visible  = true;
         uxQuantityLabel.Visible = false;
     }
     else
     {
         uxQuantityText.Visible  = false;
         uxQuantityLabel.Visible = true;
     }
 }
Exemple #7
0
    private void PopulateControls()
    {
        ProductKitItem kitItem = GetSelectedProductKitItem();

        if (kitItem.IsDefault)
        {
            Quantity = kitItem.Quantity.ToString();
        }
        else
        {
            Quantity = "";
        }

        SetDisplayIsUserDefinedQTY(kitItem);
    }
Exemple #8
0
    protected void uxKitItemDrop_SelectedIndexChanged(object sender, EventArgs e)
    {
        ProductKitItem kitItem = GetSelectedProductKitItem();

        if (!kitItem.IsNull)
        {
            SetDisplayIsUserDefinedQTY(kitItem);
            Quantity = kitItem.Quantity.ToString();
        }
        else
        {
            uxQuantityText.Visible  = false;
            uxQuantityLabel.Visible = true;
            Quantity = "";
        }
    }
    private ProductKitItemValueCollection GenerateProductKitItemValueCollection(Product product, OrderItem orderItem, ArrayList productKit, ArrayList productKitCount, ArrayList productKitGroupID)
    {
        ProductKitItemValueCollection kitCollection = new ProductKitItemValueCollection();

        for (int i = 0; i < productKit.Count; i++)
        {
            Product        subProduct = (Product)productKit[i];
            ProductKitItem item       = new ProductKitItem();
            item.IsUserDefinedQuantity = true;
            item.ProductKitGroupID     = (string)productKitGroupID[i];
            item.ProductID             = subProduct.ProductID;
            ProductKitItemValue value = new ProductKitItemValue(item, ProductKitGroup.ProductKitGroupType.Unknown, "",
                                                                (int)productKitCount[i]);
            kitCollection.Add(value);
        }
        return(kitCollection);
    }
    private IList <ProductKitItem> UpdateItemDefault(IList <ProductKitItem> productKitItems, ProductKitItem newKitItem)
    {
        IList <ProductKitItem> newList = new List <ProductKitItem>();

        if (newKitItem.IsDefault)
        {
            foreach (ProductKitItem productKitItem in productKitItems)
            {
                if (productKitItem.ProductID != newKitItem.ProductID)
                {
                    productKitItem.IsDefault = false;
                }
                newList.Add(productKitItem);
            }
        }
        else
        {
            newList = productKitItems;
        }

        return(newList);
    }