protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "ProductOptions.Options"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "ProductOptions.Options");
        }

        // Get category ID and department ID from url
        categoryId = QueryHelper.GetInteger("categoryid", 0);
        categoryObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId);

        EditedObject = categoryObj;

        if (categoryObj != null)
        {
            editedSiteId = categoryObj.CategorySiteID;

            // Check edited objects site id
            CheckEditedObjectSiteID(editedSiteId);

            // Allow actions only for non-text categories
            allowActions = (categoryObj.CategorySelectionType != OptionCategorySelectionTypeEnum.TextBox) && (categoryObj.CategorySelectionType != OptionCategorySelectionTypeEnum.TextArea);

            if (allowActions)
            {
                string[,] actions = new string[2, 7];

                // New item link
                actions[0, 0] = HeaderActions.TYPE_HYPERLINK;
                actions[0, 1] = GetString("ProductOptions.NewItemCaption");
                actions[0, 2] = null;
                actions[0, 3] = ResolveUrl("~/CMSModules/Ecommerce/Pages/Tools/Products/Product_New.aspx?categoryid=" + categoryId + "&siteId=" + SiteID);
                actions[0, 4] = null;
                actions[0, 5] = GetImageUrl("Objects/Ecommerce_SKU/add.png");

                // Sort link & img
                actions[1, 0] = HeaderActions.TYPE_LINKBUTTON;
                actions[1, 1] = GetString("ProductOptions.SortAlphabetically");
                actions[1, 2] = null;
                actions[1, 3] = null;
                actions[1, 4] = null;
                actions[1, 5] = GetImageUrl("CMSModules/CMS_Ecommerce/optionssort.png");
                actions[1, 6] = "lnkSort_Click";

                this.CurrentMaster.HeaderActions.Actions = actions;
                this.CurrentMaster.HeaderActions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed);
            }

            // Unigrid
            grid.OnAction += new OnActionEventHandler(grid_OnAction);
            grid.OnExternalDataBound += new OnExternalDataBoundEventHandler(grid_OnExternalDataBound);
            grid.WhereCondition = "SKUOptionCategoryID = " + categoryId;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get category ID and department ID from URL
        categoryId = QueryHelper.GetInteger("categoryid", 0);
        categoryObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId);

        EditedObject = categoryObj;

        if (categoryObj != null)
        {
            editedSiteId = categoryObj.CategorySiteID;

            // Check edited objects site id
            CheckEditedObjectSiteID(editedSiteId);

            // Allow actions only for non-text categories
            allowActions = (categoryObj.CategorySelectionType != OptionCategorySelectionTypeEnum.TextBox) && (categoryObj.CategorySelectionType != OptionCategorySelectionTypeEnum.TextArea);

            grid.ShowObjectMenu = allowActions;

            if (allowActions)
            {
                HeaderActions hdrActions = CurrentMaster.HeaderActions;

                // New option action
                hdrActions.ActionsList.Add(new HeaderAction()
                {
                    ControlType = HeaderActionTypeEnum.Hyperlink,
                    Text = GetString("ProductOptions.NewItemCaption"),
                    RedirectUrl = ResolveUrl("~/CMSModules/Ecommerce/Pages/Tools/Products/Product_New.aspx?categoryid=" + categoryId + "&siteId=" + SiteID),
                    ImageUrl = GetImageUrl("Objects/Ecommerce_SKU/add.png")
                });

                // Sort action
                hdrActions.ActionsList.Add(new HeaderAction()
                {
                    ControlType = HeaderActionTypeEnum.LinkButton,
                    Text = GetString("ProductOptions.SortAlphabetically"),
                    ImageUrl = GetImageUrl("CMSModules/CMS_Ecommerce/optionssort.png"),
                    CommandName = "lnkSort_Click"
                });

                hdrActions.ActionPerformed += HeaderActions_ActionPerformed;
            }

            // Unigrid
            grid.OnAction += grid_OnAction;
            grid.OnExternalDataBound += grid_OnExternalDataBound;
            grid.WhereCondition = "SKUOptionCategoryID = " + categoryId;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get parent product from url
        int parentProductId = QueryHelper.GetInteger("productId", 0);

        // Check UI permissions
        if (parentProductId <= 0)
        {
            // UIElement from option category list
            CheckUIElementAccessHierarchical("CMS.Ecommerce", "ProductOptions.Products");
        }
        else
        {
            // UIElement from product edit
            CheckUIElementAccessHierarchical("CMS.Ecommerce", "Products.ProductOptions.Products");
        }

        categoryId = QueryHelper.GetInteger("categoryId", 0);
        categoryObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId);

        EditedObject = categoryObj;
        if (categoryObj != null)
        {
            editedSiteId = categoryObj.CategorySiteID;

            // Check edited objects site id
            CheckEditedObjectSiteID(editedSiteId);

            // Offer global products when allowed
            if (editedSiteId != 0)
            {
                offerGlobalProducts = ECommerceSettings.AllowGlobalProducts(editedSiteId);
            }
            // Configuring global products
            else
            {
                offerGlobalProducts = ECommerceSettings.AllowGlobalProducts(CurrentSiteName);
            }

            PreloadUniSelector(false);
            uniSelector.WhereCondition = GetWhereCondition();

            // If option category is disabled, hide ADD button
            if (categoryObj.CategoryEnabled == false)
            {
                uniSelector.ButtonAddItems.Visible = false;
            }
        }
    }
    /// <summary>
    /// Loads the data of the edited product option category.
    /// </summary>
    /// <param name="category">Option category info</param>
    protected void LoadData(OptionCategoryInfo category)
    {
        // Load data to controls
        txtDisplayName.Text  = category.CategoryDisplayName;
        txtCategoryName.Text = category.CategoryName;

        // Add text types only to text category or to category without options
        if ((category.CategorySelectionType == OptionCategorySelectionTypeEnum.TextBox) ||
            (category.CategorySelectionType == OptionCategorySelectionTypeEnum.TextArea))
        {
            plcDefaultRecordText.Visible = false;

            // Add text types
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.textbox"), OptionCategorySelectionTypeEnum.TextBox.ToString()));
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.textarea"), OptionCategorySelectionTypeEnum.TextArea.ToString()));
        }
        else
        {
            plcTextMaxLength.Visible = false;

            // Add standard types
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.dropdownlist"), OptionCategorySelectionTypeEnum.Dropdownlist.ToString()));
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.radiobuttonsvertical"), OptionCategorySelectionTypeEnum.RadioButtonsVertical.ToString()));
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.radiobuttonshorizontal"), OptionCategorySelectionTypeEnum.RadioButtonsHorizontal.ToString()));
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.checkboxesvertical"), OptionCategorySelectionTypeEnum.CheckBoxesVertical.ToString()));
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.checkboxeshorizontal"), OptionCategorySelectionTypeEnum.CheckBoxesHorizontal.ToString()));
        }

        drpCategorySelectionType.SelectedValue = category.CategorySelectionType.ToString();
        chkCategoryDisplayPrice.Checked        = category.CategoryDisplayPrice;

        txtCategoryDecription.Text = category.CategoryDescription;
        txtDefaultRecord.Text      = category.CategoryDefaultRecord;
        txtTextMaxLength.Text      = (category.CategoryTextMaxLength > 0) ? category.CategoryTextMaxLength.ToString() : "";
        chkCategoryEnabled.Checked = category.CategoryEnabled;
    }
Esempio n. 5
0
        public void SetUpOptionCategories()
        {
            // Create categories
            categorySize  = Factory.NewOptionCategory("Size").With(c => c.Insert());
            categoryColor = Factory.NewOptionCategory("Color").With(c => c.Insert());

            // Create parent product
            skuWithVariants = Factory.NewSKU("Hammer");
            skuWithVariants.SKUImagePath = PATH_TO_PRODUCT_IMAGE;
            skuWithVariants.Insert();

            // Create product without variants
            skuWithoutVariants = Factory.NewSKU("Hammer without nails").With(s => s.Insert());

            // Assign categories to product
            new SKUOptionCategoryInfo
            {
                AllowAllOptions = true,
                SKUID           = skuWithVariants.SKUID,
                CategoryID      = categorySize.CategoryID,
            }.Insert();

            new SKUOptionCategoryInfo
            {
                AllowAllOptions = true,
                SKUID           = skuWithVariants.SKUID,
                CategoryID      = categoryColor.CategoryID,
            }.Insert();

            new SKUOptionCategoryInfo
            {
                AllowAllOptions = true,
                SKUID           = skuWithoutVariants.SKUID,
                CategoryID      = categoryColor.CategoryID,
            }.Insert();
        }
    /// <summary>
    /// Ensures the options text to display.
    /// </summary>
    protected virtual void EnsureOptionString()
    {
        if (ShoppingCartItemInfoObject != null)
        {
            List <string> optionNames = new List <string>();

            foreach (ShoppingCartItemInfo optionItem in ShoppingCartItemInfoObject.ProductOptions)
            {
                // Ignore bundle items
                if (optionItem.IsBundleItem)
                {
                    continue;
                }

                string itemText = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(optionItem.CartItemText));

                if (!string.IsNullOrEmpty(itemText))
                {
                    itemText = String.Format(" '{0}'", itemText);
                }
                else
                {
                    OptionCategoryInfo category = OptionCategoryInfoProvider.GetOptionCategoryInfo(optionItem.SKU.SKUOptionCategoryID);
                    // Exclude Text options without specified text
                    if ((category != null) && (category.CategoryType == OptionCategoryTypeEnum.Text))
                    {
                        continue;
                    }
                }

                optionNames.Add(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(optionItem.SKU.SKUName)) + itemText);
            }

            lblOptions.Text = TextHelper.Join(TextSeparator, optionNames) ?? String.Empty;
        }
    }
    protected object OptionCategoryGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
            // Convert selection type to text
            case "categoryselectiontype":
                switch (ValidationHelper.GetString(parameter, "").ToLowerCSafe())
                {
                    case "dropdown":
                        return GetString("OptionCategory_List.DropDownList");

                    case "checkboxhorizontal":
                        return GetString("OptionCategory_List.checkboxhorizontal");

                    case "checkboxvertical":
                        return GetString("OptionCategory_List.checkboxvertical");

                    case "radiobuttonhorizontal":
                        return GetString("OptionCategory_List.radiobuttonhorizontal");

                    case "radiobuttonvertical":
                        return GetString("OptionCategory_List.radiobuttonvertical");

                    case "textbox":
                        return GetString("optioncategory_selectiontype.textbox");

                    case "textarea":
                        return GetString("optioncategory_selectiontype.textarea");
                }
                break;

            case "categorytype":
                return ValidationHelper.GetString(parameter, "").ToEnum<OptionCategoryTypeEnum>().ToLocalizedString("com.optioncategorytype");

            case "categorydisplayname":
                OptionCategoryInfo category = new OptionCategoryInfo(((DataRowView)parameter).Row);

                return HTMLHelper.HTMLEncode(category.CategoryFullName);
        }

        return parameter;
    }
    /// <summary>
    /// Load data of editing optionCategory.
    /// </summary>
    /// <param name="optionCategoryObj">OptionCategory object</param>
    protected void LoadData(OptionCategoryInfo optionCategoryObj)
    {
        // Load data to controls
        txtDisplayName.Text = optionCategoryObj.CategoryDisplayName;
        txtCategoryName.Text = optionCategoryObj.CategoryName;

        // Add text types only to text category or to category without options
        if ((optionCategoryObj.CategorySelectionType == OptionCategorySelectionTypeEnum.TextBox) ||
            (optionCategoryObj.CategorySelectionType == OptionCategorySelectionTypeEnum.TextArea))
        {
            plcDefaultRecordText.Visible = false;

            // Add text types
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.textbox"), OptionCategorySelectionTypeEnum.TextBox.ToString()));
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.textarea"), OptionCategorySelectionTypeEnum.TextArea.ToString()));
        }
        else
        {
            plcTextMaxLength.Visible = false;

            // Add standard types
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.dropdownlist"), OptionCategorySelectionTypeEnum.Dropdownlist.ToString()));
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.radiobuttonsvertical"), OptionCategorySelectionTypeEnum.RadioButtonsVertical.ToString()));
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.radiobuttonshorizontal"), OptionCategorySelectionTypeEnum.RadioButtonsHorizontal.ToString()));
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.checkboxesvertical"), OptionCategorySelectionTypeEnum.CheckBoxesVertical.ToString()));
            drpCategorySelectionType.Items.Add(new ListItem(GetString("optioncategory_selectiontype.checkboxeshorizontal"), OptionCategorySelectionTypeEnum.CheckBoxesHorizontal.ToString()));
        }

        drpCategorySelectionType.SelectedValue = optionCategoryObj.CategorySelectionType.ToString();
        chkCategoryDisplayPrice.Checked = optionCategoryObj.CategoryDisplayPrice;

        txtCategoryDecription.Text = optionCategoryObj.CategoryDescription;
        txtDefaultRecord.Text = optionCategoryObj.CategoryDefaultRecord;
        txtTextMaxLength.Text = (optionCategoryObj.CategoryTextMaxLength > 0) ? optionCategoryObj.CategoryTextMaxLength.ToString() : "";
        chkCategoryEnabled.Checked = optionCategoryObj.CategoryEnabled;
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check module permissions
        bool global = (editedSiteId <= 0);

        if (!ECommerceContext.IsUserAuthorizedToModifyOptionCategory(global))
        {
            // Check module permissions
            if (global)
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify");
            }
            else
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyProducts");
            }
        }

        // Check input value from textboxs
        string errorMessage = new Validator().NotEmpty(txtDisplayName.Text, GetString("general.requiresdisplayname"))
                              .NotEmpty(txtCategoryName.Text, GetString("general.requirescodename"))
                              .IsIdentificator(txtCategoryName.Text, GetString("optioncategory_new.errorNotIdentificator")).Result;

        if (errorMessage == "")
        {
            // Category code name must be unique
            OptionCategoryInfo optionCategoryObj = null;
            string             siteWhere         = (ConfiguredSiteID > 0) ? " AND (CategorySiteID = " + ConfiguredSiteID + " OR CategorySiteID IS NULL)" : "";
            DataSet            ds = OptionCategoryInfoProvider.GetOptionCategories("CategoryName = '" + txtCategoryName.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                optionCategoryObj = new OptionCategoryInfo(ds.Tables[0].Rows[0]);
            }

            // If category code name value is unique
            if (optionCategoryObj == null)
            {
                // Create, fill and set OptionCategoryInfo object
                optionCategoryObj = new OptionCategoryInfo();
                optionCategoryObj.CategoryDisplayName    = txtDisplayName.Text.Trim();
                optionCategoryObj.CategoryName           = txtCategoryName.Text.Trim();
                optionCategoryObj.CategorySelectionType  = radSelection.Checked ? OptionCategorySelectionTypeEnum.Dropdownlist : OptionCategorySelectionTypeEnum.TextBox;
                optionCategoryObj.CategoryEnabled        = true;
                optionCategoryObj.CategoryDefaultRecord  = "";
                optionCategoryObj.CategoryDefaultOptions = "";
                optionCategoryObj.CategorySiteID         = ConfiguredSiteID;

                // Create category and option under transaction
                using (CMSTransactionScope tr = new CMSTransactionScope())
                {
                    OptionCategoryInfoProvider.SetOptionCategoryInfo(optionCategoryObj);

                    if (radText.Checked)
                    {
                        // Create text product option
                        SKUInfo option = new SKUInfo()
                        {
                            SKUOptionCategoryID = optionCategoryObj.CategoryID,
                            SKUProductType      = SKUProductTypeEnum.Text,
                            SKUSiteID           = ConfiguredSiteID,
                            SKUName             = optionCategoryObj.CategoryDisplayName,
                            SKUDepartmentID     = 0,
                            SKUPrice            = 0,
                            SKUNeedsShipping    = false,
                            SKUWeight           = 0,
                            SKUEnabled          = true
                        };

                        SKUInfoProvider.SetSKUInfo(option);
                    }

                    // Commit a transaction
                    tr.Commit();
                }

                URLHelper.Redirect("OptionCategory_Edit.aspx?categoryId=" + Convert.ToString(optionCategoryObj.CategoryID) + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("optioncategory_new.errorExistingCodeName");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
    private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView row = parameter as DataRowView;

        switch (sourceName.ToLowerCSafe())
        {
        case "optioncategory":
            int optionCategoryId = ValidationHelper.GetInteger(row["SKUOptionCategoryID"], 0);
            OptionCategoryInfo optionCategory = OptionCategoryInfoProvider.GetOptionCategoryInfo(optionCategoryId);

            // Return option category display name for product option or '-' for product
            if (optionCategory != null)
            {
                return(HTMLHelper.HTMLEncode(optionCategory.CategoryDisplayName ?? ""));
            }
            return("-");

        case "skunumber":
            string skuNumber = ValidationHelper.GetString(row["SKUNumber"], null);
            return(HTMLHelper.HTMLEncode(skuNumber ?? ""));

        case "skuprice":
            double value  = ValidationHelper.GetDouble(row["SKUPrice"], 0);
            int    siteId = ValidationHelper.GetInteger(row["SKUSiteID"], 0);

            // Format price
            return(CurrencyInfoProvider.GetFormattedPrice(value, siteId));

        case "skudepartmentid":
            // Tranform to display name and localize
            int            departmentId = ValidationHelper.GetInteger(row["SKUDepartmentID"], 0);
            DepartmentInfo department   = DepartmentInfoProvider.GetDepartmentInfo(departmentId);

            return((department != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(department.DepartmentDisplayName)) : "");

        case "skumanufacturerid":
            // Tranform to display name and localize
            int manufacturerId            = ValidationHelper.GetInteger(row["SKUManufacturerID"], 0);
            ManufacturerInfo manufacturer = ManufacturerInfoProvider.GetManufacturerInfo(manufacturerId);

            return((manufacturer != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(manufacturer.ManufacturerDisplayName)) : "");

        case "skusupplierid":
            // Tranform to display name and localize
            int          supplierId = ValidationHelper.GetInteger(row["SKUSupplierID"], 0);
            SupplierInfo supplier   = SupplierInfoProvider.GetSupplierInfo(supplierId);

            return((supplier != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(supplier.SupplierDisplayName)) : "");

        case "skuavailableitems":
            int?count     = row["SKUAvailableItems"] as int?;
            int?reorderAt = row["SKUReorderAt"] as int?;

            // Emphasise the number when product needs to be reordered
            if (count.HasValue && ((reorderAt.HasValue && (count <= reorderAt)) || (!reorderAt.HasValue && (count <= 0))))
            {
                // Format message informing about insufficient stock level
                string reorderMsg = string.Format(GetString("com.sku.reorderatTooltip"), reorderAt);
                return(string.Format("<span class=\"OperationFailed\">{0}</span>", count));
            }
            return(count);

        case "itemstobereordered":
            int skuReorderAt      = ValidationHelper.GetInteger(row["SKUReorderAt"], 0);
            int skuAvailableItems = ValidationHelper.GetInteger(row["SKUAvailableItems"], 0);
            int difference        = skuReorderAt - skuAvailableItems;

            // Return difference, or '-'
            return((difference > 0) ? difference.ToString() : "-");

        case "skusiteid":
            return(UniGridFunctions.ColoredSpanYesNo(row["SKUSiteID"] == DBNull.Value));
        }

        return(parameter);
    }
    /// <summary>
    /// Creates option category. Called when the "Create category" button is pressed.
    /// </summary>
    private bool CreateOptionCategory()
    {
        // Create new option category object
        OptionCategoryInfo newCategory = new OptionCategoryInfo();

        // Set the properties
        newCategory.CategoryDisplayName = "My new category";
        newCategory.CategoryName = "MyNewCategory";
        newCategory.CategorySelectionType = OptionCategorySelectionTypeEnum.Dropdownlist;
        newCategory.CategoryDisplayPrice = true;
        newCategory.CategoryEnabled = true;
        newCategory.CategoryDefaultRecord = "";
        newCategory.CategorySiteID = CMSContext.CurrentSiteID;

        // Create the option category
        OptionCategoryInfoProvider.SetOptionCategoryInfo(newCategory);

        return true;
    }
    /// <summary>
    /// Creates variants for product. Called when the "Create product variants" button is pressed.
    /// Expects the CreateProduct method to be run first.
    /// </summary>
    private bool CreateVariants()
    {
        // Get product
        var product = SKUInfoProvider.GetSKUs()
                           .WhereStartsWith("SKUName", "MyNewProduct")
                           .WhereNull("SKUOptionCategoryID")
                           .FirstOrDefault();

        if (product == null)
        {
            return false;
        }

        // List of categories
        List<int> categoryIDs = new List<int>();

        // Create two attribute option categories with options
        for (int i = 1; i <= 2; i++)
        {
            OptionCategoryInfo newCategory = new OptionCategoryInfo
            {
                CategoryDisplayName = "My new attribute category "+ i,
                CategoryName = "MyNewAttributteCategory" + i,
                CategoryType = OptionCategoryTypeEnum.Attribute,
                CategorySelectionType = OptionCategorySelectionTypeEnum.Dropdownlist,
                CategoryDisplayPrice = true,
                CategoryEnabled = true,
                CategoryDefaultRecord = "",
                CategorySiteID = SiteContext.CurrentSiteID
            };

            // Set category and add to product
            OptionCategoryInfoProvider.SetOptionCategoryInfo(newCategory);
            SKUOptionCategoryInfoProvider.AddOptionCategoryToSKU(newCategory.CategoryID, product.SKUID);
            categoryIDs.Add(newCategory.CategoryID);

            // Create two product options for new attribute category
            foreach (var color in new[] { "Black", "White" })
            {
                SKUInfo newOption = new SKUInfo
                {
                    SKUName = "MyNewColorOption" + color,
                    SKUPrice = 0,
                    SKUEnabled = true,
                    SKUOptionCategoryID = newCategory.CategoryID,
                    SKUSiteID = SiteContext.CurrentSiteID,
                    SKUProductType = SKUProductTypeEnum.Product
                };

                // Set option and add to product
                SKUInfoProvider.SetSKUInfo(newOption);
                SKUAllowedOptionInfoProvider.AddOptionToProduct(product.SKUID, newOption.SKUID);
            }
        }

        // Generate variants
        List<ProductVariant> variants = VariantHelper.GetAllPossibleVariants(product.SKUID, categoryIDs);

        // Set variants
        foreach (var variant in variants)
        {
            VariantHelper.SetProductVariant(variant);
        }

        return true;
    }
Esempio n. 13
0
 public ProductOptionCategoryViewModel(int skuID, int selectedOptionID, OptionCategoryInfo category, ISKUInfoProvider skuInfoProvider)
 {
     SelectedOptionId = selectedOptionID;
     Category         = category;
     Options          = GetOptions(skuID, category.CategoryID, skuInfoProvider);
 }
    object categoryGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        OptionCategoryInfo category;

        // Formatting columns
        switch (sourceName.ToLowerCSafe())
        {
            case "categorydisplayname":
                category = OptionCategoryInfoProvider.GetOptionCategoryInfo(ValidationHelper.GetInteger(parameter, 0));
                return HTMLHelper.HTMLEncode(category.CategoryFullName);

            case "categorytype":
                return ValidationHelper.GetString(parameter, "").ToEnum<OptionCategoryTypeEnum>().ToLocalizedString("com.optioncategorytype");

            case "optionscounts":
                category = OptionCategoryInfoProvider.GetOptionCategoryInfo(ValidationHelper.GetInteger(parameter, 0));

                if (category.CategoryType != OptionCategoryTypeEnum.Text)
                {
                    var tr = new ObjectTransformation("OptionsCounts", category.CategoryID)
                    {
                        DataProvider = countsDataProvider,
                        Transformation = "{% if(AllowAllOptions) { GetResourceString(\"general.all\") } else { FormatString(GetResourceString(\"com.ProductOptions.availableXOfY\"), SelectedOptions, AllOptions) } %}",
                        NoDataTransformation = "{$com.productoptions.nooptions$}",
                        EncodeOutput = false
                    };

                    return tr;
                }

                return "";

            case "edititem":
                category = new OptionCategoryInfo(((DataRowView)((GridViewRow)parameter).DataItem).Row);

                CMSGridActionButton btn = sender as CMSGridActionButton;

                // Disable edit button if category is global and global categories are NOT allowed
                if (btn != null)
                {
                    if (!allowedGlobalCat && category.IsGlobal)
                    {
                        btn.Enabled = false;
                    }

                    var query = QueryHelper.BuildQuery("siteId", category.CategorySiteID.ToString(), "productId", ProductID.ToString());
                    string redirectUrl = UIContextHelper.GetElementDialogUrl("CMS.Ecommerce", "EditProductOptionCategory", category.CategoryID, query);
                    btn.OnClientClick = "modalDialog('" + redirectUrl + "','categoryEdit', '1000', '800');";
                }
                break;

            case "selectoptions":
                category = new OptionCategoryInfo(((DataRowView)((GridViewRow)parameter).DataItem).Row);

                CMSGridActionButton btnSelect = sender as CMSGridActionButton;

                if (btnSelect != null)
                {
                    // Disable select button if category is type of Text
                    if (category.CategoryType == OptionCategoryTypeEnum.Text)
                    {
                        btnSelect.Enabled = false;
                    }
                    else
                    {
                        var query = QueryHelper.BuildQuery("productId", ProductID.ToString());
                        // URL of allowed option selector pop-up
                        string urlSelect = UIContextHelper.GetElementDialogUrl("CMS.Ecommerce", "ProductOptions.SelectOptions", category.CategoryID, query);

                        // Open allowed options selection dialog
                        btnSelect.OnClientClick = ScriptHelper.GetModalDialogScript( urlSelect, "selectoptions", 1000, 650);
                    }
                }
                break;
        }

        return parameter;
    }
 public ProductOptionCategoryViewModel(int skuID, int selectedOptionID, OptionCategoryInfo category)
 {
     SelectedOptionId = selectedOptionID;
     Category         = category;
     Options          = GetOptions(skuID, category.CategoryID);
 }
Esempio n. 16
0
    /// <summary>
    /// Generates variants into DataSet and DataTable.
    /// </summary>
    /// <returns>DataSet of generated variants</returns>
    private DataSet GenerateVariants()
    {
        List <ProductVariant> productVariantList;

        // Creating new variants and some has been already generated
        if ((NewCategories.Count > 0) && (ExistingCategories.Count > 0))
        {
            ProductAttributeSet   productAttributeSet = new ProductAttributeSet(CategorySelector.SelectedCategories.Values.Where(x => x > VariantOptionInfo.NewOption));
            List <ProductVariant> oldVariants         = VariantHelper.AddNewCategoriesToVariantsOfProduct(ProductID, productAttributeSet);
            productVariantList = VariantHelper.GetAllPossibleVariants(oldVariants);
        }
        else
        {
            productVariantList = VariantHelper.GetAllPossibleVariants(ProductID, NewCategories.Concat(ExistingCategories));
        }

        DataSet   ds = new DataSet("VariantsDS");
        DataTable dt = new DataTable("VariantsDT");

        // Build DataTable and UniGrid structure
        foreach (int categoryId in ExistingCategories.Union(NewCategories))
        {
            OptionCategoryInfo optionCategoryInfo = mAllCategoriesOptions.Keys.FirstOrDefault(k => (ValidationHelper.GetInteger(k["CategoryId"], 0) == categoryId));

            // Add columns to DataTable
            dt.Columns.Add(new DataColumn(categoryId.ToString(), typeof(String)));

            // Add column with option category live site display name to the grid with variant preview. In case live site display name is not available option category display name is used
            if (optionCategoryInfo != null)
            {
                AddGridColumn(ResHelper.LocalizeString(optionCategoryInfo.CategoryTitle), categoryId.ToString(), "#transform: ecommerce.skuoption.SKUName");
            }
        }

        // Add RowNumber column to DataTable
        dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
        AddGridColumn("RowNumber", "RowNumber", string.Empty, true);

        // Add Exist column to DataTable
        dt.Columns.Add(new DataColumn("Exist", typeof(bool)));

        // Add Variant number column to DataTable and UniGrid
        dt.Columns.Add(new DataColumn("VariantNumber", typeof(string)));
        AddGridColumn(GetString("com.sku.skunumber"), "VariantNumber");

        // Fill DataTable
        int index = 0;

        foreach (ProductVariant productVariant in productVariantList)
        {
            DataRow dr = dt.NewRow();

            int i = 0;
            foreach (int categoryId in productVariant.ProductAttributes.CategoryIDs)
            {
                // Fill values to dynamically added column
                OptionCategoryInfo optionCategoryInfo = mAllCategoriesOptions.Keys.FirstOrDefault(k => (ValidationHelper.GetInteger(k["CategoryId"], 0) == categoryId));

                if (optionCategoryInfo != null)
                {
                    dr[optionCategoryInfo.CategoryID.ToString()] = productVariant.ProductAttributes[i].SKUID;
                    i++;
                }
            }

            dr["RowNumber"]     = index;
            dr["Exist"]         = productVariant.Existing;
            dr["VariantNumber"] = productVariant.Variant.SKUNumber;

            dt.Rows.Add(dr);
            index++;
        }

        ds.Tables.Add(dt);
        return(ds);
    }
Esempio n. 17
0
 public ProductOptionCategoryViewModel(int skuID, int selectedOptionID, OptionCategoryInfo category)
 {
 }
    object categoryGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        OptionCategoryInfo category;

        // Formatting columns
        switch (sourceName.ToLowerCSafe())
        {
        case "categorydisplayname":
            category = OptionCategoryInfo.Provider.Get(ValidationHelper.GetInteger(parameter, 0));
            return(HTMLHelper.HTMLEncode(category.CategoryFullName));

        case "categorytype":
            return(EnumStringRepresentationExtensions.ToEnum <OptionCategoryTypeEnum>(ValidationHelper.GetString(parameter, "")).ToLocalizedString("com.optioncategorytype"));

        case "optionscounts":
            category = OptionCategoryInfo.Provider.Get(ValidationHelper.GetInteger(parameter, 0));

            if (category.CategoryType != OptionCategoryTypeEnum.Text)
            {
                var tr = new ObjectTransformation("OptionsCounts", category.CategoryID)
                {
                    DataProvider         = countsDataProvider,
                    Transformation       = "{% if(AllowAllOptions) { GetResourceString(\"general.all\") } else { FormatString(GetResourceString(\"com.ProductOptions.availableXOfY\"), SelectedOptions, AllOptions) } %}",
                    NoDataTransformation = "{$com.productoptions.nooptions$}",
                    EncodeOutput         = false
                };

                return(tr);
            }

            return("");

        case "edititem":
            category = new OptionCategoryInfo(((DataRowView)((GridViewRow)parameter).DataItem).Row);

            CMSGridActionButton btn = sender as CMSGridActionButton;

            // Disable edit button if category is global and global categories are NOT allowed
            if (btn != null)
            {
                if (!allowedGlobalCat && category.IsGlobal)
                {
                    btn.Enabled = false;
                }

                var    query       = QueryHelper.BuildQuery("siteId", category.CategorySiteID.ToString(), "productId", ProductID.ToString());
                string redirectUrl = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "EditProductOptionCategory", category.CategoryID, query);
                btn.OnClientClick = "modalDialog('" + redirectUrl + "','categoryEdit', '1000', '800');";
            }
            break;

        case "selectoptions":
            category = new OptionCategoryInfo(((DataRowView)((GridViewRow)parameter).DataItem).Row);

            CMSGridActionButton btnSelect = sender as CMSGridActionButton;

            if (btnSelect != null)
            {
                // Disable select button if category is type of Text
                if (category.CategoryType == OptionCategoryTypeEnum.Text)
                {
                    btnSelect.Enabled = false;
                }
                else
                {
                    var query = QueryHelper.BuildQuery("productId", ProductID.ToString());
                    // URL of allowed option selector pop-up
                    string urlSelect = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "ProductOptions.SelectOptions", category.CategoryID, query);

                    // Open allowed options selection dialog
                    btnSelect.OnClientClick = ScriptHelper.GetModalDialogScript(urlSelect, "selectoptions", 1000, 650);
                }
            }
            break;
        }

        return(parameter);
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check module permissions
        bool global = (editedSiteId <= 0);
        if (!ECommerceContext.IsUserAuthorizedToModifyOptionCategory(global))
        {
            // Check module permissions
            if (global)
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify");
            }
            else
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyProducts");
            }
        }

        // Check input value from textboxes
        string errorMessage = new Validator().NotEmpty(txtDisplayName.Text, GetString("general.requiresdisplayname"))
            .NotEmpty(txtCategoryName.Text, GetString("general.requirescodename"))
            .IsIdentifier(txtCategoryName.Text, GetString("optioncategory_new.errorNotIdentifier")).Result;

        if (errorMessage == "")
        {
            // Category code name must be unique
            OptionCategoryInfo optionCategoryObj = null;
            string siteWhere = (ConfiguredSiteID > 0) ? " AND (CategorySiteID = " + ConfiguredSiteID + " OR CategorySiteID IS NULL)" : "";
            DataSet ds = OptionCategoryInfoProvider.GetOptionCategories("CategoryName = '" + txtCategoryName.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                optionCategoryObj = new OptionCategoryInfo(ds.Tables[0].Rows[0]);
            }

            // If category code name value is unique
            if (optionCategoryObj == null)
            {
                // Create, fill and set OptionCategoryInfo object
                optionCategoryObj = new OptionCategoryInfo();
                optionCategoryObj.CategoryDisplayName = txtDisplayName.Text.Trim();
                optionCategoryObj.CategoryName = txtCategoryName.Text.Trim();
                optionCategoryObj.CategorySelectionType = radSelection.Checked ? OptionCategorySelectionTypeEnum.Dropdownlist : OptionCategorySelectionTypeEnum.TextBox;
                optionCategoryObj.CategoryEnabled = true;
                optionCategoryObj.CategoryDefaultRecord = "";
                optionCategoryObj.CategoryDefaultOptions = "";
                optionCategoryObj.CategorySiteID = ConfiguredSiteID;

                // Create category and option under transaction
                using (CMSTransactionScope tr = new CMSTransactionScope())
                {
                    OptionCategoryInfoProvider.SetOptionCategoryInfo(optionCategoryObj);

                    if (radText.Checked)
                    {
                        // Create text product option
                        SKUInfo option = new SKUInfo()
                                             {
                                                 SKUOptionCategoryID = optionCategoryObj.CategoryID,
                                                 SKUProductType = SKUProductTypeEnum.Text,
                                                 SKUSiteID = ConfiguredSiteID,
                                                 SKUName = optionCategoryObj.CategoryDisplayName,
                                                 SKUDepartmentID = 0,
                                                 SKUPrice = 0,
                                                 SKUNeedsShipping = false,
                                                 SKUWeight = 0,
                                                 SKUEnabled = true
                                             };

                        SKUInfoProvider.SetSKUInfo(option);
                    }

                    // Commit a transaction
                    tr.Commit();
                }

                URLHelper.Redirect("OptionCategory_Edit.aspx?categoryId=" + Convert.ToString(optionCategoryObj.CategoryID) + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                // Show error message
                ShowError(GetString("optioncategory_new.errorExistingCodeName"));
            }
        }
        else
        {
            // Show error message
            ShowError(errorMessage);
        }
    }
    /// <summary>
    /// Gets and bulk updates option categories. Called when the "Get and bulk update categories" button is pressed.
    /// Expects the CreateOptionCategory method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateOptionCategories()
    {
        // Prepare the parameters
        string where = "CategoryName LIKE N'MyNewCategory%'";

        // Get the data
        DataSet categories = OptionCategoryInfoProvider.GetOptionCategories(where, null);
        if (!DataHelper.DataSourceIsEmpty(categories))
        {
            // Loop through the individual items
            foreach (DataRow categoryDr in categories.Tables[0].Rows)
            {
                // Create object from DataRow
                OptionCategoryInfo modifyCategory = new OptionCategoryInfo(categoryDr);

                // Update the properties
                modifyCategory.CategoryDisplayName = modifyCategory.CategoryDisplayName.ToUpper();

                // Update the option category
                OptionCategoryInfoProvider.SetOptionCategoryInfo(modifyCategory);
            }

            return true;
        }

        return false;
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check module permissions
        bool global = (editedSiteId <= 0);

        if (!ECommerceContext.IsUserAuthorizedToModifyOptionCategory(global))
        {
            // Check module permissions
            if (global)
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify");
            }
            else
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyProducts");
            }
        }

        // Validate the form
        string errorMessage = ValidateForm();

        if (errorMessage == "")
        {
            // Category code name must be unique
            OptionCategoryInfo optionCategoryObj = null;
            string             siteWhere         = (editedSiteId > 0) ? " AND (CategorySiteID = " + editedSiteId + " OR CategorySiteID IS NULL)" : "";
            DataSet            ds = OptionCategoryInfoProvider.GetOptionCategories("CategoryName = '" + txtCategoryName.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                optionCategoryObj = new OptionCategoryInfo(ds.Tables[0].Rows[0]);
            }

            // If category code name value is unique
            if ((optionCategoryObj == null) || (optionCategoryObj.CategoryID == categoryID))
            {
                // If optionCategory doesn't already exist, create new one
                if (optionCategoryObj == null)
                {
                    optionCategoryObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryID);
                    if (optionCategoryObj == null)
                    {
                        optionCategoryObj = new OptionCategoryInfo();
                        optionCategoryObj.CategorySiteID = editedSiteId;
                    }
                }

                // Set category properties
                optionCategoryObj.CategoryID             = categoryID;
                optionCategoryObj.CategoryDisplayName    = txtDisplayName.Text.Trim();
                optionCategoryObj.CategoryName           = txtCategoryName.Text.Trim();
                optionCategoryObj.CategorySelectionType  = GetOptionCategoryEnum(drpCategorySelectionType.SelectedValue);
                optionCategoryObj.CategoryDefaultOptions = productOptionSelector.GetSelectedSKUOptions();
                optionCategoryObj.CategoryDescription    = txtCategoryDecription.Text.Trim();
                optionCategoryObj.CategoryDefaultRecord  = txtDefaultRecord.Text.Trim();
                optionCategoryObj.CategoryEnabled        = chkCategoryEnabled.Checked;
                optionCategoryObj.CategoryDisplayPrice   = chkCategoryDisplayPrice.Checked;
                optionCategoryObj.CategoryTextMaxLength  = ValidationHelper.GetInteger(txtTextMaxLength.Text.Trim(), 0);

                using (CMSTransactionScope tran = new CMSTransactionScope())
                {
                    // Save changes
                    OptionCategoryInfoProvider.SetOptionCategoryInfo(optionCategoryObj);

                    // Add text option to text category only if it is empty
                    if (((optionCategoryObj.CategorySelectionType == OptionCategorySelectionTypeEnum.TextBox) ||
                         (optionCategoryObj.CategorySelectionType == OptionCategorySelectionTypeEnum.TextArea)) &&
                        (SKUInfoProvider.GetSKUOptionsCount(categoryID) == 0))
                    {
                        // Create default text product option
                        SKUInfo option = new SKUInfo();
                        option.SKUName        = optionCategoryObj.CategoryDisplayName;
                        option.SKUDescription = optionCategoryObj.CategoryDescription;
                        option.SKUSiteID      = optionCategoryObj.CategorySiteID;
                        option.SKUPrice       = 0;
                    }

                    tran.Commit();
                }

                // If hidebreadcrumbs (is in modal window)
                if (QueryHelper.GetBoolean("hidebreadcrumbs", false))
                {
                    // Close window and refresh opener
                    ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CloseAndRefresh", ScriptHelper.GetScript("parent.wopener.Refresh(); parent.window.close();"));
                }
                else
                {
                    // Normal save
                    //URLHelper.Redirect("OptionCategory_Edit_General.aspx?CategoryID=" + Convert.ToString(optionCategoryObj.CategoryID) + "&saved=1&siteId=" + this.SiteID);
                    ScriptHelper.RefreshTabHeader(this, "general");

                    lblInfo.Visible = true;
                    lblInfo.Text    = GetString("General.ChangesSaved");
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("optioncategory_new.errorExistingCodeName");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get parent product from url
        parentProductId = QueryHelper.GetInteger("productId", 0);

        // Check UI permissions
        if (parentProductId <= 0)
        {
            // UIElement from option category list
            CheckUIElementAccessHierarchical("CMS.Ecommerce", "ProductOptions.Options");
        }
        else
        {
            // UIElement from product edit
            CheckUIElementAccessHierarchical("CMS.Ecommerce", "Products.ProductOptions.Options");
        }

        // Hide/rename columns before loading data
        ugOptions.OnBeforeDataReload += grid_OnBeforeDataReload;

        // Get category ID and department ID from URL
        categoryId = QueryHelper.GetInteger("categoryid", 0);
        categoryObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId);

        EditedObject = categoryObj;

        if (categoryObj != null)
        {
            editedSiteId = categoryObj.CategorySiteID;

            // Check edited objects site id
            CheckEditedObjectSiteID(editedSiteId);

            // Allow actions only for non-text categories
            allowActions = (categoryObj.CategorySelectionType != OptionCategorySelectionTypeEnum.TextBox) && (categoryObj.CategorySelectionType != OptionCategorySelectionTypeEnum.TextArea);

            ugOptions.ShowObjectMenu = allowActions;

            if (allowActions)
            {
                var hdrActions = CurrentMaster.HeaderActions;

                string newButtonText;
                if (categoryObj.CategoryType == OptionCategoryTypeEnum.Products)
                {
                    newButtonText = GetString("com.sku.newproduct");
                }
                else
                {
                    newButtonText = GetString("com.productoptions.newoption");
                }

                // New option action
                hdrActions.ActionsList.Add(new HeaderAction
                {
                    Text = newButtonText,
                    RedirectUrl = ResolveUrl("~/CMSModules/Ecommerce/Pages/Tools/Products/Product_New.aspx?categoryid=" + categoryId + "&siteId=" + SiteID + (parentProductId > 0 ? "&parentProductId=" + parentProductId : ""))
                });

                // Sort action
                hdrActions.ActionsList.Add(new HeaderAction
                {
                    Text = GetString("ProductOptions.SortAlphabetically"),
                    OnClientClick = "return confirm(" + ScriptHelper.GetLocalizedString("com.productoptions.sortalphaasc") + ");",
                    CommandName = "lnkSort_Click",
                    ButtonStyle = ButtonStyle.Default
                });

                hdrActions.ActionPerformed += HeaderActions_ActionPerformed;
            }

            // Unigrid
            ugOptions.OnAction += grid_OnAction;
            ugOptions.OnExternalDataBound += grid_OnExternalDataBound;
            ugOptions.WhereCondition = "SKUOptionCategoryID = " + categoryId;
            ugOptions.GridView.AllowSorting = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "ProductOptions.General"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "ProductOptions.General");
        }

        // Field validator error messages initialization
        rfvCategoryName.ErrorMessage = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage  = GetString("general.requiresdisplayname");

        // Control initializations
        lblCategoryName.Text        = GetString("general.codename") + ResHelper.Colon;
        lblCategoryDescription.Text = GetString("general.description") + ResHelper.Colon;
        lblDefaultRecord.Text       = GetString("OptionCategory_Edit.CategoryDefaultRecord");
        lblNoOptions.Text           = GetString("OptionCategory_Edit.NoProductOptions");
        btnOk.Text = GetString("General.OK");

        categoryID   = QueryHelper.GetInteger("categoryID", 0);
        editedSiteId = ConfiguredSiteID;

        // Get option category information
        OptionCategoryInfo categObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryID);

        EditedObject = categObj;

        if (categObj == null)
        {
            // Do not process
            return;
        }

        // Set category type specific labels
        switch (categObj.CategorySelectionType)
        {
        case OptionCategorySelectionTypeEnum.TextArea:
        case OptionCategorySelectionTypeEnum.TextBox:

            lblCategorySelectionType.Text  = GetString("OptionCategory_Edit.CategoryTextTypeLabel");
            lblCategoryDefaultOptions.Text = GetString("optioncategory_edit.categorydefaulttext");
            lblTextMaxLength.Text          = GetString("com.optioncategory.textmaxlength");
            break;

        default:

            lblCategorySelectionType.Text  = GetString("OptionCategory_Edit.CategorySelectionTypeLabel");
            lblCategoryDefaultOptions.Text = GetString("OptionCategory_Edit.CategoryDefaultOptionsLabel");
            break;
        }

        // Use default currency for price formatting
        productOptionSelector.UseDefaultCurrency = true;

        if (SelectionType != "")
        {
            categObj.CategorySelectionType       = GetOptionCategoryEnum(SelectionType);
            productOptionSelector.OptionCategory = categObj;
        }
        else
        {
            productOptionSelector.OptionCategoryId = categoryID;
        }

        editedSiteId = categObj.CategorySiteID;

        // Check edited object site ID
        CheckEditedObjectSiteID(editedSiteId);

        // Fill editing form
        if (!RequestHelper.IsPostBack())
        {
            LoadData(categObj);

            // Show that the optionCategory was created or updated successfully
            if (QueryHelper.GetString("saved", "") == "1")
            {
                lblInfo.Visible = true;
                lblInfo.Text    = GetString("General.ChangesSaved");
            }
        }
    }
    /// <summary>
    /// DrpCategorySelectionType SelectedIndexChanged event handler.
    /// </summary>
    protected void drpCategorySelectionType_SelectedIndexChanged(object sender, EventArgs e)
    {
        OptionCategoryInfo categObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryID);
        if (categObj != null)
        {
            // Clone option category data
            OptionCategoryInfo tempCategObj = new OptionCategoryInfo(categObj, false);

            // Set new selection type from selection control
            tempCategObj.CategorySelectionType = GetOptionCategoryEnum(drpCategorySelectionType.SelectedValue);

            // Set previously selected options
            tempCategObj.CategoryDefaultOptions = productOptionSelector.GetSelectedSKUOptions();

            // Set display price option
            tempCategObj.CategoryDisplayPrice = this.chkCategoryDisplayPrice.Checked;

            // Remember selection type in viewstate
            this.SelectionType = drpCategorySelectionType.SelectedValue;

            // Reload selector
            productOptionSelector.OptionCategory = tempCategObj;
            productOptionSelector.ReloadSelector();
        }
    }
Esempio n. 25
0
    private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView rowView = parameter as DataRowView;

        if (rowView != null)
        {
            SKUInfo sku = new SKUInfo(rowView.Row);
            switch (sourceName.ToLowerCSafe())
            {
            case "skuname":
                string fullName = sku.SKUName;

                // For variant, add name from parent SKU
                if (sku.SKUParentSKUID != 0)
                {
                    SKUInfo parentSku = SKUInfoProvider.GetSKUInfo(sku.SKUParentSKUID);
                    fullName = string.Format("{0}: {1}", parentSku.SKUName, sku.SKUName);
                }
                return(HTMLHelper.HTMLEncode(fullName));

            case "optioncategory":
                OptionCategoryInfo optionCategory = OptionCategoryInfoProvider.GetOptionCategoryInfo(sku.SKUOptionCategoryID);

                // Return option category display name for product option or '-' for product
                if (optionCategory != null)
                {
                    return(HTMLHelper.HTMLEncode(optionCategory.CategoryDisplayName ?? ""));
                }
                return("-");

            case "skunumber":
                return(ResHelper.LocalizeString(sku.SKUNumber, null, true));

            case "skuprice":
                // Format price
                return(CurrencyInfoProvider.GetFormattedPrice(sku.SKUPrice, sku.SKUSiteID));

            case "skudepartmentid":
                // Transform to display name and localize
                DepartmentInfo department = DepartmentInfoProvider.GetDepartmentInfo(sku.SKUDepartmentID);
                return((department != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(department.DepartmentDisplayName)) : "");

            case "skumanufacturerid":
                // Transform to display name and localize
                ManufacturerInfo manufacturer = ManufacturerInfoProvider.GetManufacturerInfo(sku.SKUManufacturerID);
                return((manufacturer != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(manufacturer.ManufacturerDisplayName)) : "");

            case "skusupplierid":
                // Transform to display name and localize
                SupplierInfo supplier = SupplierInfoProvider.GetSupplierInfo(sku.SKUSupplierID);
                return((supplier != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(supplier.SupplierDisplayName)) : "");

            case "skupublicstatusid":
                // Transform to display name and localize
                PublicStatusInfo publicStatus = PublicStatusInfoProvider.GetPublicStatusInfo(sku.SKUPublicStatusID);
                return((publicStatus != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(publicStatus.PublicStatusDisplayName)) : "");

            case "skuinternalstatusid":
                // Transform to display name and localize
                InternalStatusInfo internalStatus = InternalStatusInfoProvider.GetInternalStatusInfo(sku.SKUInternalStatusID);
                return((internalStatus != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(internalStatus.InternalStatusDisplayName)) : "");

            case "skuavailableitems":
                int?count     = sku.SKUAvailableItems as int?;
                int?reorderAt = sku.SKUReorderAt as int?;

                // Emphasize the number when product needs to be reordered
                if (count.HasValue && ((reorderAt.HasValue && (count <= reorderAt)) || (!reorderAt.HasValue && (count <= 0))))
                {
                    // Format message informing about insufficient stock level
                    return(string.Format("<span class=\"OperationFailed\">{0}</span>", count));
                }
                return(count);

            case "itemstobereordered":
                int difference = sku.SKUReorderAt - sku.SKUAvailableItems;

                // Return difference, or '-'
                return((difference > 0) ? difference.ToString() : "-");

            case "skusiteid":
                return(UniGridFunctions.ColoredSpanYesNo(sku.SKUSiteID == 0));
            }
        }

        return(parameter);
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check module permissions
        bool global = (editedSiteId <= 0);
        if (!ECommerceContext.IsUserAuthorizedToModifyOptionCategory(global))
        {
            // Check module permissions
            if (global)
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify");
            }
            else
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyProducts");
            }
        }

        // Validate the form
        string errorMessage = ValidateForm();

        if (errorMessage == "")
        {
            // Category code name must be unique
            OptionCategoryInfo optionCategoryObj = null;
            string siteWhere = (editedSiteId > 0) ? " AND (CategorySiteID = " + editedSiteId + " OR CategorySiteID IS NULL)" : "";
            DataSet ds = OptionCategoryInfoProvider.GetOptionCategories("CategoryName = '" + txtCategoryName.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                optionCategoryObj = new OptionCategoryInfo(ds.Tables[0].Rows[0]);
            }

            // If category code name value is unique
            if ((optionCategoryObj == null) || (optionCategoryObj.CategoryID == categoryID))
            {
                // If optionCategory doesn't already exist, create new one
                if (optionCategoryObj == null)
                {
                    optionCategoryObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryID);
                    if (optionCategoryObj == null)
                    {
                        optionCategoryObj = new OptionCategoryInfo();
                        optionCategoryObj.CategorySiteID = editedSiteId;
                    }
                }

                // Set category properties
                optionCategoryObj.CategoryID = categoryID;
                optionCategoryObj.CategoryDisplayName = txtDisplayName.Text.Trim();
                optionCategoryObj.CategoryName = txtCategoryName.Text.Trim();
                optionCategoryObj.CategorySelectionType = GetOptionCategoryEnum(drpCategorySelectionType.SelectedValue);
                optionCategoryObj.CategoryDefaultOptions = productOptionSelector.GetSelectedSKUOptions();
                optionCategoryObj.CategoryDescription = txtCategoryDecription.Text.Trim();
                optionCategoryObj.CategoryDefaultRecord = txtDefaultRecord.Text.Trim();
                optionCategoryObj.CategoryEnabled = chkCategoryEnabled.Checked;
                optionCategoryObj.CategoryDisplayPrice = chkCategoryDisplayPrice.Checked;
                optionCategoryObj.CategoryTextMaxLength = ValidationHelper.GetInteger(txtTextMaxLength.Text.Trim(),0);

                using (CMSTransactionScope tran = new CMSTransactionScope())
                {
                    // Save changes
                    OptionCategoryInfoProvider.SetOptionCategoryInfo(optionCategoryObj);

                    // Add text option to text category only if it is empty
                    if (((optionCategoryObj.CategorySelectionType == OptionCategorySelectionTypeEnum.TextBox) ||
                        (optionCategoryObj.CategorySelectionType == OptionCategorySelectionTypeEnum.TextArea)) &&
                        (SKUInfoProvider.GetSKUOptionsCount(categoryID) == 0))
                    {
                        // Create default text product option
                        SKUInfo option = new SKUInfo();
                        option.SKUName = optionCategoryObj.CategoryDisplayName;
                        option.SKUDescription = optionCategoryObj.CategoryDescription;
                        option.SKUSiteID =  optionCategoryObj.CategorySiteID;
                        option.SKUPrice = 0;
                    }

                    tran.Commit();
                }

                // If hidebreadcrumbs (is in modal window)
                if (QueryHelper.GetBoolean("hidebreadcrumbs", false))
                {
                    // Close window and refresh opener
                    ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CloseAndRefresh", ScriptHelper.GetScript("parent.wopener.Refresh(); parent.window.close();"));
                }
                else
                {
                    // Normal save
                    //URLHelper.Redirect("OptionCategory_Edit_General.aspx?CategoryID=" + Convert.ToString(optionCategoryObj.CategoryID) + "&saved=1&siteId=" + this.SiteID);
                    ScriptHelper.RefreshTabHeader(this, "general");

                    lblInfo.Visible = true;
                    lblInfo.Text = GetString("General.ChangesSaved");
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = GetString("optioncategory_new.errorExistingCodeName");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text = errorMessage;
        }
    }
    /// <summary>
    /// Loads control.
    /// </summary>
    private void LoadControl()
    {
        // Get all product categories with options which are already in variants
        if (VariantCategoriesOptions.Count == 0)
        {
            DataSet variantCategoriesDS = VariantHelper.GetProductVariantsCategories(ProductID);
            FillCategoriesOptionsDictionary(VariantCategoriesOptions, variantCategoriesDS);
        }

        // Get all product attribute categories with options
        if (AllCategoriesOptions.Count == 0)
        {
            DataSet allCategoriesDS = OptionCategoryInfoProvider.GetProductOptionCategories(ProductID, true, OptionCategoryTypeEnum.Attribute);
            FillCategoriesOptionsDictionary(AllCategoriesOptions, allCategoriesDS);
        }

        foreach (KeyValuePair <OptionCategoryInfo, List <SKUInfo> > keyValuePair in AllCategoriesOptions)
        {
            if (keyValuePair.Value.Count > 0)
            {
                OptionCategoryInfo optionCategory = keyValuePair.Key;

                // Create new instance of CheckBoxWithDropDown control and prefill all necessary values
                CheckBoxWithDropDown checkBoxWithDropDown = new CheckBoxWithDropDown();
                checkBoxWithDropDown.ID    = ValidationHelper.GetString(optionCategory.CategoryID, string.Empty);
                checkBoxWithDropDown.Value = optionCategory.CategoryID;
                // Use live site display name instead of category display name in case it is available
                checkBoxWithDropDown.CheckboxText = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(optionCategory.CategoryTitle));

                // Attach listeners
                checkBoxWithDropDown.OnCheckBoxSelectionChanged += checkBoxWithDropDown_OnCheckBoxSelectionChanged;
                checkBoxWithDropDown.OnDropDownSelectionChanged += checkBoxWithDropDown_OnDropDownSelectionChanged;

                // Option category is in variants too
                if (VariantCategoriesOptions.Keys.Any(c => ValidationHelper.GetInteger(c["categoryId"], 0) == optionCategory.CategoryID))
                {
                    // Check and disable checkbox
                    checkBoxWithDropDown.CheckboxChecked = true;
                    checkBoxWithDropDown.Enabled         = false;

                    // Already existing variants add to selected categories too
                    if (!SelectedCategories.ContainsKey(optionCategory.CategoryID))
                    {
                        SelectedCategories.Add(optionCategory.CategoryID, VariantOptionInfo.ExistingSelectedOption);
                    }
                }
                // Option category is not in variant, but some categories in variants already exists
                else if (VariantCategoriesOptions.Count > 0)
                {
                    // Set prompt message and visibility
                    checkBoxWithDropDown.DropDownPrompt  = GetString("general.pleaseselect");
                    checkBoxWithDropDown.DropDownLabel   = GetString("com.variants.dropdownlabel");
                    checkBoxWithDropDown.DropDownVisible = true;

                    // Get all product options and bind them to dropdownlist
                    var options       = SKUInfoProvider.GetSKUOptionsForProduct(ProductID, optionCategory.CategoryID, true).OrderBy("SKUOrder");
                    var dropDownItems = new ListItemCollection();

                    foreach (var option in options)
                    {
                        dropDownItems.Add(new ListItem(option.SKUName, option.SKUID.ToString()));
                    }

                    checkBoxWithDropDown.DropDownItems = dropDownItems;
                }

                // Finally bind this control to parent
                chboxPanel.Controls.Add(checkBoxWithDropDown);
            }
        }
    }
Esempio n. 28
0
 /// <summary>
 /// Creates a new instance of the <see cref="ProductOptionCategory"/> class.
 /// </summary>
 /// <param name="category"><see cref="OptionCategoryInfo"/> object representing an original Kentico option category info object from which the model is created.</param>
 /// <param name="options">Collection of selectable product options.</param>
 public ProductOptionCategory(OptionCategoryInfo category, IEnumerable <SKUInfo> options)
 {
     OriginalCategory = category;
     CategoryOptions  = options;
 }
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Field validator error messages initialization
        rfvCategoryName.ErrorMessage = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage  = GetString("general.requiresdisplayname");

        // Control initializations
        lblCategoryName.Text        = GetString("general.codename") + ResHelper.Colon;
        lblCategoryDescription.Text = GetString("general.description") + ResHelper.Colon;
        lblDefaultRecord.Text       = GetString("OptionCategory_Edit.CategoryDefaultRecord");
        lblNoOptions.Text           = GetString("OptionCategory_Edit.NoProductOptions");

        categoryId   = QueryHelper.GetInteger("categoryId", 0);
        editedSiteId = ConfiguredSiteID;

        // Get option category information
        OptionCategoryInfo category = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId);

        EditedObject = category;

        if (category == null)
        {
            // Do not process
            return;
        }

        // Set category type specific labels
        switch (category.CategorySelectionType)
        {
        case OptionCategorySelectionTypeEnum.TextArea:
        case OptionCategorySelectionTypeEnum.TextBox:

            lblCategorySelectionType.Text  = GetString("OptionCategory_Edit.CategoryTextTypeLabel");
            lblCategoryDefaultOptions.Text = GetString("optioncategory_edit.categorydefaulttext");
            lblTextMaxLength.Text          = GetString("com.optioncategory.textmaxlength");
            break;

        default:

            lblCategorySelectionType.Text  = GetString("OptionCategory_Edit.CategorySelectionTypeLabel");
            lblCategoryDefaultOptions.Text = GetString("OptionCategory_Edit.CategoryDefaultOptionsLabel");
            break;
        }

        // Use default currency for price formatting
        productOptionSelector.UseDefaultCurrency = true;

        if (SelectionType != "")
        {
            category.CategorySelectionType       = GetOptionCategoryEnum(SelectionType);
            productOptionSelector.OptionCategory = category;
        }
        else
        {
            productOptionSelector.OptionCategoryId = categoryId;
        }

        editedSiteId = category.CategorySiteID;

        // Check edited object site ID
        CheckEditedObjectSiteID(editedSiteId);

        // Fill editing form
        if (!RequestHelper.IsPostBack())
        {
            LoadData(category);

            // Show that the optionCategory was created or updated successfully
            if (QueryHelper.GetString("saved", "") == "1")
            {
                // Show message
                ShowChangesSaved();
            }
        }
    }
    /// <summary>
    /// Handles the OptionCategoryGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void OptionCategoryGrid_OnAction(string actionName, object actionArgument)
    {
        int categoryId = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerCSafe())
        {
        case "edit":
            URLHelper.Redirect(UIContextHelper.GetElementUrl(ModuleName.ECOMMERCE, "EditOptionCategory", false, categoryId));

            break;

        case "delete":

            OptionCategoryInfo categoryObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId);

            if (categoryObj == null)
            {
                break;
            }

            // Check permissions
            if (!ECommerceContext.IsUserAuthorizedToModifyOptionCategory(categoryObj))
            {
                // Check module permissions
                if (categoryObj.CategoryIsGlobal)
                {
                    RedirectToAccessDenied(ModuleName.ECOMMERCE, EcommercePermissions.ECOMMERCE_MODIFYGLOBAL);
                }
                else
                {
                    RedirectToAccessDenied(ModuleName.ECOMMERCE, "EcommerceModify OR ModifyProducts");
                }
            }

            // Check category dependencies
            if (categoryObj.Generalized.CheckDependencies())
            {
                // Show error message
                ShowError(EcommerceUIHelper.GetDependencyMessage(categoryObj));
                return;
            }

            DataSet options = SKUInfoProvider.GetSKUOptions(categoryId, false);

            // Check option category options dependencies
            if (!DataHelper.DataSourceIsEmpty(options))
            {
                // Check if some attribute option is not used in variant
                if (categoryObj.CategoryType == OptionCategoryTypeEnum.Attribute)
                {
                    var optionIds = DataHelper.GetIntegerValues(options.Tables[0], "SKUID");

                    // Check if some variant is defined by this option
                    DataSet variants = VariantOptionInfoProvider.GetVariantOptions()
                                       .TopN(1)
                                       .Column("VariantSKUID")
                                       .WhereIn("OptionSKUID", optionIds);

                    if (!DataHelper.DataSourceIsEmpty(variants))
                    {
                        // Option is used in some variant
                        ShowError(GetString("com.option.categoryoptiosusedinvariant"));

                        return;
                    }
                }

                // Check other dependencies (shopping cart, order)
                foreach (DataRow option in options.Tables[0].Rows)
                {
                    var skuid = ValidationHelper.GetInteger(option["SKUID"], 0);
                    var sku   = SKUInfoProvider.GetSKUInfo(skuid);

                    if (SKUInfoProvider.CheckDependencies(skuid))
                    {
                        // Show error message
                        ShowError(EcommerceUIHelper.GetDependencyMessage(sku));

                        return;
                    }
                }
            }

            // Delete option category from database
            OptionCategoryInfoProvider.DeleteOptionCategoryInfo(categoryObj);

            break;
        }
    }
    /// <summary>
    /// Reload default option selector.
    /// </summary>
    protected void ReloadDefaultOptionSelector()
    {
        OptionCategoryInfo categObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId);
        if (categObj != null)
        {
            // Clone option category data
            OptionCategoryInfo tempCategObj = new OptionCategoryInfo(categObj, false);

            // Set new selection type from selection control
            tempCategObj.CategorySelectionType = GetOptionCategoryEnum(drpCategorySelectionType.SelectedValue);

            // Set previously selected options
            tempCategObj.CategoryDefaultOptions = productOptionSelector.GetSelectedSKUOptions();

            // Set display price option
            tempCategObj.CategoryDisplayPrice = chkCategoryDisplayPrice.Checked;

            // Remember selection type in viewstate
            SelectionType = drpCategorySelectionType.SelectedValue;

            tempCategObj.CategoryFormControlName = null;

            // Reload selector
            productOptionSelector.OptionCategory = tempCategObj;
            productOptionSelector.ReloadSelector();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get parent product from url
        parentProductId = QueryHelper.GetInteger("productId", 0);

        // Check UI permissions
        var elementName = parentProductId <= 0 ? "ProductOptions.Options" : "Products.ProductOptions.Options";

        CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, elementName);

        // Hide/rename columns before loading data
        ugOptions.OnBeforeDataReload += grid_OnBeforeDataReload;

        // Get category ID and department ID from URL
        categoryId  = QueryHelper.GetInteger("categoryid", 0);
        categoryObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId);

        EditedObject = categoryObj;

        if (categoryObj != null)
        {
            editedSiteId = categoryObj.CategorySiteID;

            // Check edited objects site id
            CheckEditedObjectSiteID(editedSiteId);

            // Allow actions only for non-text categories
            allowActions = (categoryObj.CategorySelectionType != OptionCategorySelectionTypeEnum.TextBox) && (categoryObj.CategorySelectionType != OptionCategorySelectionTypeEnum.TextArea);

            ugOptions.ShowObjectMenu = allowActions;

            if (allowActions)
            {
                var hdrActions    = CurrentMaster.HeaderActions;
                var stringName    = categoryObj.CategoryType == OptionCategoryTypeEnum.Products ? "com.sku.newproduct" : "com.productoptions.newoption";
                var newButtonText = GetString(stringName);

                // New option action
                hdrActions.ActionsList.Add(new HeaderAction
                {
                    Text        = newButtonText,
                    RedirectUrl = ResolveUrl("~/CMSModules/Ecommerce/Pages/Tools/Products/Product_New.aspx?categoryid=" + categoryId + "&siteId=" + SiteID + (parentProductId > 0 ? "&parentProductId=" + parentProductId : ""))
                });

                // Sort action
                hdrActions.ActionsList.Add(new HeaderAction
                {
                    Text          = GetString("ProductOptions.SortAlphabetically"),
                    OnClientClick = "return confirm(" + ScriptHelper.GetLocalizedString("com.productoptions.sortalphaasc") + ");",
                    CommandName   = "lnkSort_Click",
                    ButtonStyle   = ButtonStyle.Default
                });

                hdrActions.ActionPerformed += HeaderActions_ActionPerformed;
            }

            // Unigrid
            ugOptions.OnAction             += grid_OnAction;
            ugOptions.OnExternalDataBound  += grid_OnExternalDataBound;
            ugOptions.WhereCondition        = "SKUOptionCategoryID = " + categoryId;
            ugOptions.GridView.AllowSorting = false;
        }
    }
Esempio n. 33
0
    protected void Page_Load(object sender, EventArgs e)
    {
        editedSiteId = ProductSiteID;

        manufacturerElem.SiteID    = editedSiteId;
        departmentElem.SiteID      = editedSiteId;
        supplierElem.SiteID        = editedSiteId;
        publicStatusElem.SiteID    = editedSiteId;
        internalStatusElem.SiteID  = editedSiteId;
        txtSKUPrice.CurrencySiteID = editedSiteId;

        htmlTemplateBody.AutoDetectLanguage = false;
        htmlTemplateBody.DefaultLanguage    = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
        htmlTemplateBody.EditorAreaCSS      = FormHelper.GetHtmlEditorAreaCss(CMSContext.CurrentSiteName);
        htmlTemplateBody.ToolbarSet         = "Basic";

        // Set form groups texts
        this.pnlGeneral.GroupingText    = this.GetString("com.productedit.general");
        this.pnlMembership.GroupingText = this.GetString("com.producttype.membership");
        this.pnlEProduct.GroupingText   = this.GetString("com.producttype.eproduct");
        this.pnlDonation.GroupingText   = this.GetString("com.producttype.donation");
        this.pnlBundle.GroupingText     = this.GetString("com.producttype.bundle");
        this.pnlStatus.GroupingText     = this.GetString("com.productedit.status");
        this.pnlShipping.GroupingText   = this.GetString("com.productedit.shipping");
        this.pnlInventory.GroupingText  = this.GetString("com.productedit.inventory");

        // Set validation messages
        this.txtSKUPrice.ValidationErrorMessage = this.GetString("com.productedit.priceinvalid");
        this.txtSKUPrice.EmptyErrorMessage      = this.GetString("com.productedit.priceinvalid");
        this.txtSKUPrice.ValidatorOnNewLine     = true;
        this.rfvSKUName.ErrorMessage            = this.GetString("com.productedit.nameinvalid");
        this.rvSKUDepth.ErrorMessage            = this.GetString("com.productedit.packagedepthinvalid");
        this.rvSKUHeight.ErrorMessage           = this.GetString("com.productedit.packageheightinvalid");
        this.rvSKUWeight.ErrorMessage           = this.GetString("com.productedit.packageweightinvalid");
        this.rvSKUWidth.ErrorMessage            = this.GetString("com.productedit.packagewidthinvalid");
        this.rvSKUAvailableItems.ErrorMessage   = this.GetString("com.productedit.availableitemsinvalid");
        this.rvSKUAvailableInDays.ErrorMessage  = this.GetString("com.productedit.availabilityinvalid");
        this.rvMaxOrderItems.ErrorMessage       = this.GetString("com.productedit.maxorderitemsinvalid");
        this.pnlConversion.GroupingText         = this.GetString("conversion.conversion.list");

        // Conversion's logging avaible only for site objects
        if (ProductSiteID == 0)
        {
            this.pnlConversion.Visible = false;
        }

        // Get current product info
        SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(mProductId);

        // If product exists
        if (skuObj != null)
        {
            this.editedSiteId = skuObj.SKUSiteID;
            string imagePath = skuObj.SKUImagePath;

            if (String.IsNullOrEmpty(imagePath) || imagePath.ToLower().StartsWith("~/getmetafile/"))
            {
                this.hasAttachmentImagePath = false;
            }

            if (this.OptionCategoryID == 0)
            {
                this.OptionCategoryID = skuObj.SKUOptionCategoryID;
            }

            if (this.OptionCategoryID > 0)
            {
                OptionCategoryInfo optionCat = OptionCategoryInfoProvider.GetOptionCategoryInfo(this.OptionCategoryID);
                if ((optionCat != null) &&
                    ((optionCat.CategorySelectionType == OptionCategorySelectionTypeEnum.TextBox) ||
                     (optionCat.CategorySelectionType == OptionCategorySelectionTypeEnum.TextArea)))
                {
                    this.selectProductTypeElem.AllowBundle          = false;
                    this.selectProductTypeElem.AllowDonation        = false;
                    this.selectProductTypeElem.AllowEproduct        = false;
                    this.selectProductTypeElem.AllowMembership      = false;
                    this.selectProductTypeElem.AllowStandardProduct = false;

                    this.selectProductTypeElem.AllowText = true;
                }
            }

            // Set site IDs
            this.membershipElem.SiteID = skuObj.SKUSiteID;
            this.eProductElem.SiteID   = skuObj.SKUSiteID;
            this.eProductElem.SKUID    = skuObj.SKUID;
            this.donationElem.SiteID   = skuObj.SKUSiteID;
            this.bundleElem.SiteID     = skuObj.SKUSiteID;
            this.bundleElem.BundleID   = skuObj.SKUID;

            if (!RequestHelper.IsPostBack())
            {
                this.LoadData(skuObj);
            }
        }
        else
        {
            if (!RequestHelper.IsPostBack())
            {
                // If creating a product option
                if (this.OptionCategoryID > 0)
                {
                    // Disable specific product type options
                    this.selectProductTypeElem.AllowBundle   = false;
                    this.selectProductTypeElem.AllowDonation = false;
                    this.selectProductTypeElem.Initialize();
                }
            }

            this.hasAttachmentImagePath = false;

            this.membershipElem.SiteID = this.ProductSiteID;
            this.eProductElem.SiteID   = this.ProductSiteID;
            this.eProductElem.SKUID    = this.ProductID;
            this.donationElem.SiteID   = this.ProductSiteID;
            this.bundleElem.SiteID     = this.ProductSiteID;
            this.bundleElem.BundleID   = this.ProductID;
        }

        // Get currently selected product type
        SKUProductTypeEnum selectedProductType = SKUInfoProvider.GetSKUProductTypeEnum((string)this.selectProductTypeElem.Value);

        // Stop processing of e-product properties element if selected product type is not e-product
        this.eProductElem.StopProcessing = (selectedProductType != SKUProductTypeEnum.EProduct);

        // Stop processing of bundle properties element if selected product type is not bundle
        this.bundleElem.StopProcessing = (selectedProductType != SKUProductTypeEnum.Bundle);

        // Enable uploaders if sufficient SKU modify permissions
        if (ECommerceContext.IsUserAuthorizedToModifySKU(editedSiteId == 0))
        {
            this.imgSelect.Enabled  = this.FormEnabled;
            this.ucMetaFile.Enabled = this.FormEnabled;
        }

        CurrentUserInfo cui = CMSContext.CurrentUser;

        if ((cui != null) && (!cui.IsGlobalAdministrator))
        {
            departmentElem.UserID = cui.UserID;
        }

        if (ECommerceSettings.UseMetaFileForProductImage && !hasAttachmentImagePath)
        {
            // Display image uploader for existing product
            this.plcExistingProductImage.Visible = true;
            this.ucMetaFile.ObjectID             = mProductId;
            this.ucMetaFile.ObjectType           = ECommerceObjectType.SKU;
            this.ucMetaFile.Category             = MetaFileInfoProvider.OBJECT_CATEGORY_IMAGE;
            this.ucMetaFile.SiteID         = editedSiteId;
            this.ucMetaFile.OnAfterDelete += new EventHandler(ucMetaFile_OnAfterDelete);
        }
        else
        {
            // Display image uploader for new product
            this.plcNewProductImage.Visible = true;
        }

        // Check presence of main currency
        if (CurrencyInfoProvider.GetMainCurrency(editedSiteId) == null)
        {
            bool usingGlobal = ECommerceSettings.UseGlobalCurrencies(SiteInfoProvider.GetSiteName(editedSiteId));

            if (usingGlobal)
            {
                lblError.Text = GetString("com.noglobalmaincurrency");
            }
            else
            {
                lblError.Text = GetString("com.nomaincurrency");
            }

            lblError.Visible = true;
        }
    }