예제 #1
0
        protected void btnNewProductVariantAttributeCombination_Click(object sender, EventArgs e)
        {
            try
            {
                ProductVariant productVariant = ProductManager.GetProductVariantById(this.ProductVariantId);
                if (productVariant != null)
                {
                    string attributes            = ctrlSelectProductAttributes.SelectedAttributes;
                    int    stockQuantity         = txtStockQuantity.Value;
                    bool   allowOutOfStockOrders = cbAllowOutOfStockOrders.Checked;

                    List <string> warnings = ShoppingCartManager.GetShoppingCartItemAttributeWarnings(ShoppingCartTypeEnum.ShoppingCart,
                                                                                                      productVariant.ProductVariantId, attributes, 1, false);
                    if (warnings.Count > 0)
                    {
                        StringBuilder warningsSb = new StringBuilder();
                        for (int i = 0; i < warnings.Count; i++)
                        {
                            warningsSb.Append(Server.HtmlEncode(warnings[i]));
                            if (i != warnings.Count - 1)
                            {
                                warningsSb.Append("<br />");
                            }
                        }

                        pnlCombinationWarningsr.Visible = true;
                        lCombinationWarnings.Text       = warningsSb.ToString();
                    }
                    else
                    {
                        var combination = ProductAttributeManager.InsertProductVariantAttributeCombination(productVariant.ProductVariantId,
                                                                                                           attributes,
                                                                                                           stockQuantity,
                                                                                                           allowOutOfStockOrders);
                    }
                    BindCombinations();
                }
            }
            catch (Exception exc)
            {
                processAjaxError(exc);
            }
        }