示例#1
0
        protected void gvTierPrices_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UpdateTierPrice")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = gvTierPrices.Rows[index];

                HiddenField    hfTierPriceID = row.FindControl("hfTierPriceID") as HiddenField;
                NumericTextBox txtQuantity   = row.FindControl("txtQuantity") as NumericTextBox;
                DecimalTextBox txtPrice      = row.FindControl("txtPrice") as DecimalTextBox;

                int     tierPriceID = int.Parse(hfTierPriceID.Value);
                decimal price       = txtPrice.Value;
                int     quantity    = txtQuantity.Value;

                TierPrice tierPrice = ProductManager.GetTierPriceByID(tierPriceID);

                if (tierPrice != null)
                {
                    ProductManager.UpdateTierPrice(tierPrice.TierPriceID,
                                                   tierPrice.ProductVariantID, quantity, price);
                }

                BindData();
            }
        }
示例#2
0
        protected void gvProductVariantAttributeValues_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UpdateProductVariantAttributeValue")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = gvProductVariantAttributeValues.Rows[index];

                HiddenField    hfProductVariantAttributeValueID = row.FindControl("hfProductVariantAttributeValueID") as HiddenField;
                SimpleTextBox  txtName             = row.FindControl("txtName") as SimpleTextBox;
                DecimalTextBox txtPriceAdjustment  = row.FindControl("txtPriceAdjustment") as DecimalTextBox;
                DecimalTextBox txtWeightAdjustment = row.FindControl("txtWeightAdjustment") as DecimalTextBox;
                CheckBox       cbIsPreSelected     = row.FindControl("cbIsPreSelected") as CheckBox;
                NumericTextBox txtDisplayOrder     = row.FindControl("txtDisplayOrder") as NumericTextBox;

                int     productVariantAttributeValueID = int.Parse(hfProductVariantAttributeValueID.Value);
                string  name             = txtName.Text;
                decimal priceAdjustment  = txtPriceAdjustment.Value;
                decimal weightAdjustment = txtWeightAdjustment.Value;
                bool    isPreSelected    = cbIsPreSelected.Checked;
                int     displayOrder     = txtDisplayOrder.Value;

                ProductVariantAttributeValue productVariantAttributeValue = ProductAttributeManager.GetProductVariantAttributeValueByID(productVariantAttributeValueID);

                if (productVariantAttributeValue != null)
                {
                    ProductAttributeManager.UpdateProductVariantAttributeValue(productVariantAttributeValue.ProductVariantAttributeValueID,
                                                                               productVariantAttributeValue.ProductVariantAttributeID, name,
                                                                               priceAdjustment, weightAdjustment, isPreSelected, displayOrder);
                }

                BindData();
            }
        }
        protected void gvValues_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UpdateCheckoutAttributeValue")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = gvValues.Rows[index];

                HiddenField    hfCheckoutAttributeValueId = row.FindControl("hfCheckoutAttributeValueId") as HiddenField;
                SimpleTextBox  txtName             = row.FindControl("txtName") as SimpleTextBox;
                DecimalTextBox txtPriceAdjustment  = row.FindControl("txtPriceAdjustment") as DecimalTextBox;
                DecimalTextBox txtWeightAdjustment = row.FindControl("txtWeightAdjustment") as DecimalTextBox;
                CheckBox       cbIsPreSelected     = row.FindControl("cbIsPreSelected") as CheckBox;
                NumericTextBox txtDisplayOrder     = row.FindControl("txtDisplayOrder") as NumericTextBox;

                int     cavId            = int.Parse(hfCheckoutAttributeValueId.Value);
                string  name             = txtName.Text;
                decimal priceAdjustment  = txtPriceAdjustment.Value;
                decimal weightAdjustment = txtWeightAdjustment.Value;
                bool    isPreSelected    = cbIsPreSelected.Checked;
                int     displayOrder     = txtDisplayOrder.Value;

                var cav = CheckoutAttributeManager.GetCheckoutAttributeValueById(cavId, 0);

                if (cav != null)
                {
                    cav = CheckoutAttributeManager.UpdateCheckoutAttributeValue(cav.CheckoutAttributeValueId,
                                                                                cav.CheckoutAttributeId, name,
                                                                                priceAdjustment, weightAdjustment, isPreSelected, displayOrder);

                    SaveLocalizableContentGrid(cav);
                }
                BindData();
            }
        }
示例#4
0
        protected void gvProductVariants_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ProductVariant productVariant = (ProductVariant)e.Row.DataItem;

                DropDownList   ddlPriceAdjustmentType      = e.Row.FindControl("ddlPriceAdjustmentType") as DropDownList;
                CheckBox       chkSelected                 = e.Row.FindControl("chkSelected") as CheckBox;
                DecimalTextBox txtPriceAdjustment          = e.Row.FindControl("txtPriceAdjustment") as DecimalTextBox;
                HiddenField    hfProductVariantPricelistId = e.Row.FindControl("hfProductVariantPricelistId") as HiddenField;

                if (chkSelected != null && ddlPriceAdjustmentType != null && txtPriceAdjustment != null && hfProductVariantPricelistId != null)
                {
                    CommonHelper.FillDropDownWithEnum(ddlPriceAdjustmentType, typeof(PriceAdjustmentTypeEnum));

                    ProductVariantPricelist productVariantPricelist = ProductManager.GetProductVariantPricelist(
                        productVariant.ProductVariantId, this.PricelistId);

                    if (productVariantPricelist != null)
                    {
                        chkSelected.Checked = true;
                        CommonHelper.SelectListItem(ddlPriceAdjustmentType, productVariantPricelist.PriceAdjustmentTypeId);
                        txtPriceAdjustment.Value          = productVariantPricelist.PriceAdjustment;
                        hfProductVariantPricelistId.Value = productVariantPricelist.ProductVariantPricelistId.ToString();
                    }
                }
            }
        }
        protected void gvLiveRates_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ApplyLiveRate")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = gvLiveRates.Rows[index];

                Label          lblCurrencyCode = row.FindControl("lblCurrencyCode") as Label;
                DecimalTextBox txtRate         = row.FindControl("txtRate") as DecimalTextBox;

                Currency           currency   = null;
                CurrencyCollection currencies = CurrencyManager.GetAllCurrencies();
                foreach (Currency currency2 in currencies)
                {
                    if (currency2.CurrencyCode.ToLower() == lblCurrencyCode.Text.ToLower())
                    {
                        currency = currency2;
                    }
                }
                if (currency != null)
                {
                    CurrencyManager.UpdateCurrency(currency.CurrencyId, currency.Name, currency.CurrencyCode,
                                                   txtRate.Value, currency.DisplayLocale, currency.CustomFormatting, currency.Published, currency.DisplayOrder,
                                                   currency.CreatedOn, DateTime.Now);
                    BindCurrencyGrid();
                }
            }
        }
        protected void gvTierPrices_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UpdateTierPrice")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = gvTierPrices.Rows[index];

                HiddenField    hfTierPriceId = row.FindControl("hfTierPriceId") as HiddenField;
                NumericTextBox txtQuantity   = row.FindControl("txtQuantity") as NumericTextBox;
                DecimalTextBox txtPrice      = row.FindControl("txtPrice") as DecimalTextBox;

                int     tierPriceId = int.Parse(hfTierPriceId.Value);
                decimal price       = txtPrice.Value;
                int     quantity    = txtQuantity.Value;

                TierPrice tierPrice = this.ProductService.GetTierPriceById(tierPriceId);

                if (tierPrice != null)
                {
                    tierPrice.Quantity = quantity;
                    tierPrice.Price    = price;
                    this.ProductService.UpdateTierPrice(tierPrice);
                }

                BindData();
            }
        }
        protected void SavePricelistChanges(int priceListId)
        {
            foreach (GridViewRow objRow in gvProductVariants.Rows)
            {
                if (objRow.RowType == DataControlRowType.DataRow)
                {
                    CheckBox       chkSelected                 = objRow.FindControl("chkSelected") as CheckBox;
                    DropDownList   ddlPriceAdjustmentType      = objRow.FindControl("ddlPriceAdjustmentType") as DropDownList;
                    DecimalTextBox txtPriceAdjustment          = objRow.FindControl("txtPriceAdjustment") as DecimalTextBox;
                    HiddenField    hfProductVariantPricelistId = objRow.FindControl("hfProductVariantPricelistId") as HiddenField;
                    HiddenField    hfProductVariantId          = objRow.FindControl("hfProductVariantId") as HiddenField;

                    int productVariantPricelistId = 0;
                    int.TryParse(hfProductVariantPricelistId.Value, out productVariantPricelistId);

                    ProductVariantPricelist productVariantPricelist = this.ProductService.GetProductVariantPricelistById(productVariantPricelistId);
                    if (chkSelected.Checked)
                    {
                        int productVariantId = 0;
                        int.TryParse(hfProductVariantId.Value, out productVariantId);

                        PriceAdjustmentTypeEnum priceAdjustmentType = (PriceAdjustmentTypeEnum)Enum.ToObject(typeof(PriceAdjustmentTypeEnum), int.Parse(ddlPriceAdjustmentType.SelectedItem.Value));
                        decimal priceAdjustment = txtPriceAdjustment.Value;

                        if (productVariantPricelist != null)
                        {
                            productVariantPricelist.ProductVariantId      = productVariantId;
                            productVariantPricelist.PricelistId           = priceListId;
                            productVariantPricelist.PriceAdjustmentTypeId = (int)priceAdjustmentType;
                            productVariantPricelist.PriceAdjustment       = priceAdjustment;
                            productVariantPricelist.UpdatedOn             = DateTime.UtcNow;
                            this.ProductService.UpdateProductVariantPricelist(productVariantPricelist);
                        }
                        else
                        {
                            productVariantPricelist = new ProductVariantPricelist();
                            productVariantPricelist.ProductVariantId      = productVariantId;
                            productVariantPricelist.PricelistId           = priceListId;
                            productVariantPricelist.PriceAdjustmentTypeId = (int)priceAdjustmentType;
                            productVariantPricelist.PriceAdjustment       = priceAdjustment;
                            productVariantPricelist.UpdatedOn             = DateTime.UtcNow;
                            this.ProductService.InsertProductVariantPricelist(productVariantPricelist);
                        }
                    }
                    else
                    {
                        if (productVariantPricelist != null)
                        {
                            this.ProductService.DeleteProductVariantPricelist(productVariantPricelistId);
                        }
                    }
                }
            }
        }
        protected void SavePricelistChanges(int priceListID)
        {
            foreach (GridViewRow objRow in gvProductVariants.Rows)
            {
                if (objRow.RowType == DataControlRowType.DataRow)
                {
                    CheckBox       chkSelected                 = objRow.FindControl("chkSelected") as CheckBox;
                    DropDownList   ddlPriceAdjustmentType      = objRow.FindControl("ddlPriceAdjustmentType") as DropDownList;
                    DecimalTextBox txtPriceAdjustment          = objRow.FindControl("txtPriceAdjustment") as DecimalTextBox;
                    HiddenField    hfProductVariantPricelistID = objRow.FindControl("hfProductVariantPricelistID") as HiddenField;
                    HiddenField    hfProductVariantID          = objRow.FindControl("hfProductVariantID") as HiddenField;

                    int productVariantPricelistID = 0;
                    int.TryParse(hfProductVariantPricelistID.Value, out productVariantPricelistID);

                    ProductVariantPricelist productVariantPricelist = ProductManager.GetProductVariantPricelistByID(productVariantPricelistID);
                    if (chkSelected.Checked)
                    {
                        int productVariantID = 0;
                        int.TryParse(hfProductVariantID.Value, out productVariantID);

                        PriceAdjustmentTypeEnum priceAdjustmentType = (PriceAdjustmentTypeEnum)Enum.ToObject(typeof(PriceAdjustmentTypeEnum), int.Parse(ddlPriceAdjustmentType.SelectedItem.Value));
                        decimal priceAdjustment = txtPriceAdjustment.Value;

                        if (productVariantPricelist != null)
                        {
                            productVariantPricelist = ProductManager.UpdateProductVariantPricelist(productVariantPricelistID, productVariantPricelist.ProductVariantID,
                                                                                                   productVariantPricelist.PricelistID, priceAdjustmentType, priceAdjustment, DateTime.Now);
                        }
                        else
                        {
                            productVariantPricelist = ProductManager.InsertProductVariantPricelist(productVariantID,
                                                                                                   priceListID, priceAdjustmentType, priceAdjustment, DateTime.Now);
                        }
                    }
                    else
                    {
                        if (productVariantPricelist != null)
                        {
                            ProductManager.DeleteProductVariantPricelist(productVariantPricelistID);
                        }
                    }
                }
            }
        }
示例#9
0
        protected void gvLiveRates_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ApplyLiveRate")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = gvLiveRates.Rows[index];

                Label          lblCurrencyCode = row.FindControl("lblCurrencyCode") as Label;
                DecimalTextBox txtRate         = row.FindControl("txtRate") as DecimalTextBox;

                Currency currency = this.CurrencyService.GetCurrencyByCode(lblCurrencyCode.Text);
                if (currency != null)
                {
                    currency.Rate      = txtRate.Value;
                    currency.UpdatedOn = DateTime.UtcNow;

                    this.CurrencyService.UpdateCurrency(currency);
                    BindCurrencyGrid();
                }
            }
        }
        protected void gvPrices_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UpdateCustomerRolePrice")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = gvPrices.Rows[index];

                HiddenField    hfCustomerRoleProductPriceId = row.FindControl("hfCustomerRoleProductPriceId") as HiddenField;
                DecimalTextBox txtPrice = row.FindControl("txtPrice") as DecimalTextBox;

                int     crppId = int.Parse(hfCustomerRoleProductPriceId.Value);
                decimal price  = txtPrice.Value;

                var crpp = this.ProductService.GetCustomerRoleProductPriceById(crppId);
                if (crpp != null)
                {
                    crpp.Price = price;
                    this.ProductService.UpdateCustomerRoleProductPrice(crpp);
                }

                BindData();
            }
        }
        protected void gvProductVariantAttributeValues_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UpdateProductVariantAttributeValue")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = gvProductVariantAttributeValues.Rows[index];

                HiddenField    hfProductVariantAttributeValueId = row.FindControl("hfProductVariantAttributeValueId") as HiddenField;
                SimpleTextBox  txtName             = row.FindControl("txtName") as SimpleTextBox;
                DecimalTextBox txtPriceAdjustment  = row.FindControl("txtPriceAdjustment") as DecimalTextBox;
                DecimalTextBox txtWeightAdjustment = row.FindControl("txtWeightAdjustment") as DecimalTextBox;
                CheckBox       cbIsPreSelected     = row.FindControl("cbIsPreSelected") as CheckBox;
                NumericTextBox txtDisplayOrder     = row.FindControl("txtDisplayOrder") as NumericTextBox;

                int     productVariantAttributeValueId = int.Parse(hfProductVariantAttributeValueId.Value);
                string  name             = txtName.Text;
                decimal priceAdjustment  = txtPriceAdjustment.Value;
                decimal weightAdjustment = txtWeightAdjustment.Value;
                bool    isPreSelected    = cbIsPreSelected.Checked;
                int     displayOrder     = txtDisplayOrder.Value;

                ProductVariantAttributeValue productVariantAttributeValue = this.ProductAttributeService.GetProductVariantAttributeValueById(productVariantAttributeValueId);

                if (productVariantAttributeValue != null)
                {
                    productVariantAttributeValue.Name             = name;
                    productVariantAttributeValue.PriceAdjustment  = priceAdjustment;
                    productVariantAttributeValue.WeightAdjustment = weightAdjustment;
                    productVariantAttributeValue.IsPreSelected    = isPreSelected;
                    productVariantAttributeValue.DisplayOrder     = displayOrder;
                    this.ProductAttributeService.UpdateProductVariantAttributeValue(productVariantAttributeValue);

                    SaveLocalizableContentGrid(productVariantAttributeValue);
                }
                BindData();
            }
        }