Example #1
0
    private void UpdatePrice(SKUInfo product, decimal price, DataRow additinalData)
    {
        // Ensures that grid will display inserted price
        product.SKUPrice = price;

        if (DocumentListingDisplayed)
        {
            // Document list is used to display products -> document has to be updated to ensure correct sku mapping
            int documentId = ValidationHelper.GetInteger(additinalData["DocumentID"], 0);

            // Create an instance of the Tree provider and select edited document with coupled data
            var document = new TreeProvider(MembershipContext.AuthenticatedUser)
                           .SelectSingleDocument(documentId);

            if (document != null)
            {
                document.SetValue("SKUPrice", price);
                document.Update();

                forceReloadData = true;
            }
        }
        else
        {
            // Stand-alone product -> only product has to be updated
            product.MakeComplete(true);
            product.Update();

            gridData.ReloadData();
        }
    }
    private object grid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerInvariant())
        {
        case "skuprice":
            var optionRow      = parameter as DataRowView;
            var option         = new SKUInfo(optionRow.Row);
            var currency       = CurrencyInfoProvider.GetMainCurrency(option.SKUSiteID);
            var formattedValue = CurrencyInfoProvider.GetFormattedValue(option.SKUPrice, currency);

            if (sender == null)
            {
                return(formattedValue);
            }

            var inlineSkuPrice = new InlineEditingTextBox
            {
                Text          = formattedValue,
                FormattedText = CurrencyInfoProvider.GetRelativelyFormattedPrice(option.SKUPrice, currency)
            };

            inlineSkuPrice.Update += (s, e) =>
            {
                CheckModifyPermission();

                // Update price if new value is valid
                if (ValidationHelper.IsDecimal(inlineSkuPrice.Text))
                {
                    var price = ValidationHelper.GetDecimal(inlineSkuPrice.Text, option.SKUPrice);

                    var validationMessage = ValidatePrice(price, currency, option);
                    if (string.IsNullOrEmpty(validationMessage))
                    {
                        // Round the price to according to the currency configuration
                        option.SKUPrice = Service.Resolve <IRoundingServiceFactory>()
                                          .GetRoundingService(SiteContext.CurrentSiteID)
                                          .Round(price, currency);

                        option.MakeComplete(true);
                        option.Update();

                        ugOptions.ReloadData();
                    }
                    else
                    {
                        inlineSkuPrice.ErrorText = validationMessage;
                    }
                }
                else
                {
                    inlineSkuPrice.ErrorText = String.Format(GetString("com.productedit.priceinvalid"), currency.CurrencyCode, currency.CurrencyRoundTo);
                }
            };

            return(inlineSkuPrice);

        case "skuavailableitems":
            var row         = parameter as DataRowView;
            var optionStock = new SKUInfo(row.Row);

            int availableItems = optionStock.SKUAvailableItems;

            // Inventory tracking disabled
            if (optionStock.SKUTrackInventory == TrackInventoryTypeEnum.Disabled)
            {
                return(GetString("com.inventory.nottracked"));
            }

            // Ensure correct values for unigrid export
            if (sender == null)
            {
                return(availableItems);
            }

            var inlineSkuAvailableItems = new InlineEditingTextBox
            {
                Text         = availableItems.ToString(),
                EnableEncode = false
            };

            inlineSkuAvailableItems.Formatting += (s, e) =>
            {
                var reorderAt = optionStock.SKUReorderAt;

                // Emphasize the number when product needs to be reordered
                if (availableItems <= reorderAt)
                {
                    // Format message informing about insufficient stock level
                    string reorderMsg = string.Format(GetString("com.sku.reorderatTooltip"), reorderAt);
                    string message    = string.Format("<span class=\"alert-status-error\" onclick=\"UnTip()\" onmouseout=\"UnTip()\" onmouseover=\"Tip('{1}')\">{0}</span>", availableItems, reorderMsg);
                    inlineSkuAvailableItems.FormattedText = message;
                }
            };

            inlineSkuAvailableItems.Update += (s, e) =>
            {
                CheckModifyPermission();

                var newNumberOfItems = ValidationHelper.GetInteger(inlineSkuAvailableItems.Text, availableItems);

                // Update available items if new value is valid
                if (ValidationHelper.IsInteger(inlineSkuAvailableItems.Text) && (-1000000000 <= newNumberOfItems) && (newNumberOfItems <= 1000000000))
                {
                    optionStock.SKUAvailableItems = ValidationHelper.GetInteger(inlineSkuAvailableItems.Text, availableItems);
                    optionStock.MakeComplete(true);
                    optionStock.Update();

                    ugOptions.ReloadData();
                }
                else
                {
                    inlineSkuAvailableItems.ErrorText = GetString("com.productedit.availableitemsinvalid");
                }
            };

            return(inlineSkuAvailableItems);

        case "delete":
        case "move":
        {
            var button = sender as CMSGridActionButton;
            if (button != null)
            {
                // Hide actions when not allowed
                button.Visible = allowActions;
            }
        }
        break;
        }

        return(parameter);
    }
    private object grid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
            case "skuprice":
                var optionRow = parameter as DataRowView;
                var option = new SKUInfo(optionRow.Row);

                if (sender == null)
                {
                    return option.SKUPrice;
                }

                var inlineSkuPrice = new InlineEditingTextBox();
                inlineSkuPrice.Text = option.SKUPrice.ToString();

                inlineSkuPrice.Formatting += (s, e) =>
                {
                    // Format price
                    inlineSkuPrice.FormattedText = CurrencyInfoProvider.GetRelativelyFormattedPrice(option.SKUPrice, option.SKUSiteID);
                };

                inlineSkuPrice.Update += (s, e) =>
                {
                    CheckModifyPermission();

                    CheckDepartmentPermission(option.SKUDepartmentID);

                    var valid = false;
                    var price = option.SKUPrice;
                    // Update price if new value is valid
                    if (ValidationHelper.IsDouble(inlineSkuPrice.Text))
                    {
                        price = ValidationHelper.GetDouble(inlineSkuPrice.Text, option.SKUPrice);
                        // Accessory price can not be negative
                        if (!option.IsAccessoryProduct || !(price < 0.0))
                        {
                            valid = true;
                        }
                    }

                    if (valid)
                    {
                        option.SKUPrice = price;
                        option.MakeComplete(true);
                        option.Update();

                        ugOptions.ReloadData();
                    }
                    else
                    {
                        inlineSkuPrice.ErrorText = GetString("com.productedit.priceinvalid");
                    }
                };

                return inlineSkuPrice;

            case "skuavailableitems":
                var row = parameter as DataRowView;
                var optionStock = new SKUInfo(row.Row);

                int availableItems = optionStock.SKUAvailableItems;

                // Inventory tracking disabled
                if (optionStock.SKUTrackInventory == TrackInventoryTypeEnum.Disabled)
                {
                    return GetString("com.inventory.nottracked");
                }

                // Ensure correct values for unigrid export
                if (sender == null)
                {
                    return availableItems;
                }

                var inlineSkuAvailableItems = new InlineEditingTextBox();
                inlineSkuAvailableItems.Text = availableItems.ToString();
                inlineSkuAvailableItems.EnableEncode = false;

                inlineSkuAvailableItems.Formatting += (s, e) =>
                {
                    var reorderAt = optionStock.SKUReorderAt;

                    // Emphasize the number when product needs to be reordered
                    if (availableItems <= reorderAt)
                    {
                        // Format message informing about insufficient stock level
                        string reorderMsg = string.Format(GetString("com.sku.reorderatTooltip"), reorderAt);
                        string message = string.Format("<span class=\"alert-status-error\" onclick=\"UnTip()\" onmouseout=\"UnTip()\" onmouseover=\"Tip('{1}')\">{0}</span>", availableItems, reorderMsg);
                        inlineSkuAvailableItems.FormattedText = message;
                    }
                };

                inlineSkuAvailableItems.Update += (s, e) =>
                {
                    CheckModifyPermission();

                    CheckDepartmentPermission(optionStock.SKUDepartmentID);

                    var newNumberOfItems = ValidationHelper.GetInteger(inlineSkuAvailableItems.Text, availableItems);

                    // Update available items if new value is valid
                    if (ValidationHelper.IsInteger(inlineSkuAvailableItems.Text) && (-1000000000 <= newNumberOfItems) && (newNumberOfItems <= 1000000000))
                    {
                        optionStock.SKUAvailableItems = ValidationHelper.GetInteger(inlineSkuAvailableItems.Text, availableItems);
                        optionStock.MakeComplete(true);
                        optionStock.Update();

                        ugOptions.ReloadData();
                    }
                    else
                    {
                        inlineSkuAvailableItems.ErrorText = GetString("com.productedit.availableitemsinvalid");
                    }
                };

                return inlineSkuAvailableItems;

            case "delete":
            case "moveup":
            case "movedown":
                {
                    CMSGridActionButton button = sender as CMSGridActionButton;
                    if (button != null)
                    {
                        // Hide actions when not allowed
                        button.Visible = allowActions;
                    }
                }
                break;
        }

        return parameter;
    }
    private object gridData_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView row = parameter as DataRowView;

        if (DocumentListingDisplayed)
        {
            switch (sourceName.ToLowerCSafe())
            {
                case "skunumber":
                case "skuavailableitems":
                case "publicstatusid":
                case "allowforsale":
                case "skusiteid":
                case "typename":
                case "skuprice":

                    if (ShowSections && (row["NodeSKUID"] == DBNull.Value))
                    {
                        return NO_DATA_CELL_VALUE;
                    }

                    break;

                case "edititem":
                    row = ((GridViewRow)parameter).DataItem as DataRowView;

                    if ((row != null) && ((row["NodeSKUID"] == DBNull.Value) || showProductsInTree))
                    {
                        CMSGridActionButton btn = sender as CMSGridActionButton;
                        if (btn != null)
                        {
                            int currentNodeId = ValidationHelper.GetInteger(row["NodeID"], 0);
                            int nodeParentId = ValidationHelper.GetInteger(row["NodeParentID"], 0);

                            if (row["NodeSKUID"] == DBNull.Value)
                            {
                                btn.IconCssClass = "icon-eye";
                                btn.IconStyle = GridIconStyle.Allow;
                                btn.ToolTip = GetString("com.sku.viewproducts");
                            }

                            // Go to the selected document
                            btn.OnClientClick = "EditItem(" + currentNodeId + ", " + nodeParentId + "); return false;";
                        }
                    }

                    break;
            }
        }

        switch (sourceName.ToLowerCSafe())
        {
            case "skunumber":
                string skuNumber = ValidationHelper.GetString(row["SKUNumber"], null);
                return HTMLHelper.HTMLEncode(ResHelper.LocalizeString(skuNumber) ?? "");

            case "skuavailableitems":
                var sku = new SKUInfo(row.Row);
                int availableItems = sku.SKUAvailableItems;

                // Inventory tracked by variants
                if (sku.SKUTrackInventory == TrackInventoryTypeEnum.ByVariants)
                {
                    return GetString("com.inventory.trackedbyvariants");
                }

                // Inventory tracking disabled
                if (sku.SKUTrackInventory == TrackInventoryTypeEnum.Disabled)
                {
                    return GetString("com.inventory.nottracked");
                }

                // Ensure correct values for unigrid export
                if (sender == null)
                {
                    return availableItems;
                }

                // Tracking by products
                InlineEditingTextBox inlineAvailableItems = new InlineEditingTextBox();
                inlineAvailableItems.Text = availableItems.ToString();
                inlineAvailableItems.DelayedReload = DocumentListingDisplayed;
                inlineAvailableItems.EnableEncode = false;

                inlineAvailableItems.Formatting += (s, e) =>
                {
                    var reorderAt = sku.SKUReorderAt;

                    // Emphasize the number when product needs to be reordered
                    if (availableItems <= reorderAt)
                    {
                        // Format message informing about insufficient stock level
                        string reorderMsg = string.Format(GetString("com.sku.reorderatTooltip"), reorderAt);
                        string message = string.Format("<span class=\"alert-status-error\" onclick=\"UnTip()\" onmouseout=\"UnTip()\" onmouseover=\"Tip('{1}')\">{0}</span>", availableItems, reorderMsg);
                        inlineAvailableItems.FormattedText = message;
                    }
                };

                // Unigrid with delayed reload in combination with inline edit control requires additional postback to sort data.
                // Update data only if external data bound is called for the first time.
                if (!forceReloadData)
                {
                    inlineAvailableItems.Update += (s, e) =>
                    {
                        var newNumberOfItems = ValidationHelper.GetInteger(inlineAvailableItems.Text, availableItems);

                        if (ValidationHelper.IsInteger(inlineAvailableItems.Text) && (-1000000000 <= newNumberOfItems) && (newNumberOfItems <= 1000000000))
                        {
                            CheckModifyPermission(sku);

                            // Ensures that grid will display inserted value
                            sku.SKUAvailableItems = newNumberOfItems;

                            // Document list is used to display products -> document has to be updated to ensure correct sku mapping
                            if (DocumentListingDisplayed)
                            {
                                int documentId = ValidationHelper.GetInteger(row.Row["DocumentID"], 0);

                                // Create an instance of the Tree provider and select edited document with coupled data
                                TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
                                TreeNode document = tree.SelectSingleDocument(documentId);

                                if (document == null)
                                {
                                    return;
                                }

                                document.SetValue("SKUAvailableItems", newNumberOfItems);
                                document.Update();

                                forceReloadData = true;
                            }
                            // Stand-alone product -> only product has to be updated
                            else
                            {
                                sku.MakeComplete(true);
                                sku.Update();

                                gridData.ReloadData();
                            }
                        }
                        else
                        {
                            inlineAvailableItems.ErrorText = GetString("com.productedit.availableitemsinvalid");
                        }
                    };
                }

                return inlineAvailableItems;

            case "skuprice":

                SKUInfo product = new SKUInfo(row.Row);

                // Ensure correct values for unigrid export
                if (sender == null)
                {
                    return product.SKUPrice;
                }

                InlineEditingTextBox inlineSkuPrice = new InlineEditingTextBox();
                inlineSkuPrice.Text = product.SKUPrice.ToString();
                inlineSkuPrice.DelayedReload = DocumentListingDisplayed;

                inlineSkuPrice.Formatting += (s, e) =>
                {
                    // Format price
                    inlineSkuPrice.FormattedText = CurrencyInfoProvider.GetFormattedPrice(product.SKUPrice, product.SKUSiteID);
                };

                // Unigrid with delayed reload in combination with inline edit control requires additional postback to sort data.
                // Update data only if external data bound is called for the first time.
                if (!forceReloadData)
                {
                    inlineSkuPrice.Update += (s, e) =>
                    {
                        CheckModifyPermission(product);

                        // Price must be a double number
                        double price = ValidationHelper.GetDouble(inlineSkuPrice.Text, -1);

                        if (ValidationHelper.IsDouble(inlineSkuPrice.Text) && (price >= 0))
                        {
                            // Ensures that grid will display inserted price
                            product.SKUPrice = price;

                            // Document list is used to display products -> document has to be updated to ensure correct sku mapping
                            if (DocumentListingDisplayed)
                            {
                                int documentId = ValidationHelper.GetInteger(row.Row["DocumentID"], 0);

                                // Create an instance of the Tree provider and select edited document with coupled data
                                TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
                                TreeNode document = tree.SelectSingleDocument(documentId);

                                if (document != null)
                                {
                                    document.SetValue("SKUPrice", price);
                                    document.Update();

                                    forceReloadData = true;
                                }
                            }
                            // Stand-alone product -> only product has to be updated
                            else
                            {
                                product.MakeComplete(true);
                                product.Update();

                                gridData.ReloadData();
                            }
                        }
                        else
                        {
                            inlineSkuPrice.ErrorText = GetString("com.productedit.priceinvalid");
                        }
                    };
                }

                return inlineSkuPrice;

            case "publicstatusid":
                int id = ValidationHelper.GetInteger(row["SKUPublicStatusID"], 0);
                PublicStatusInfo publicStatus = PublicStatusInfoProvider.GetPublicStatusInfo(id);
                if (publicStatus != null)
                {
                    // Localize and encode
                    return HTMLHelper.HTMLEncode(ResHelper.LocalizeString(publicStatus.PublicStatusDisplayName));
                }

                return string.Empty;

            case "allowforsale":
                // Get "on sale" flag
                return UniGridFunctions.ColoredSpanYesNo(ValidationHelper.GetBoolean(row["SKUEnabled"], false));

            case "typename":
                string docTypeName = ValidationHelper.GetString(row["ClassDisplayName"], null);

                // Localize class display name
                if (!string.IsNullOrEmpty(docTypeName))
                {
                    return HTMLHelper.HTMLEncode(ResHelper.LocalizeString(docTypeName));
                }

                return string.Empty;
        }

        return parameter;
    }
Example #5
0
    private object gridData_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView row = parameter as DataRowView;

        if (DocumentListingDisplayed)
        {
            switch (sourceName.ToLowerInvariant())
            {
            case "skunumber":
            case "skuavailableitems":
            case "publicstatusid":
            case "allowforsale":
            case "skusiteid":
            case "typename":
            case "skuprice":

                if (ShowSections && (row["NodeSKUID"] == DBNull.Value))
                {
                    return(NO_DATA_CELL_VALUE);
                }

                break;

            case "edititem":
                row = ((GridViewRow)parameter).DataItem as DataRowView;

                if ((row != null) && ((row["NodeSKUID"] == DBNull.Value) || showProductsInTree))
                {
                    CMSGridActionButton btn = sender as CMSGridActionButton;
                    if (btn != null)
                    {
                        int currentNodeId = ValidationHelper.GetInteger(row["NodeID"], 0);
                        int nodeParentId  = ValidationHelper.GetInteger(row["NodeParentID"], 0);

                        if (row["NodeSKUID"] == DBNull.Value)
                        {
                            btn.IconCssClass = "icon-eye";
                            btn.IconStyle    = GridIconStyle.Allow;
                            btn.ToolTip      = GetString("com.sku.viewproducts");
                        }

                        // Go to the selected document
                        btn.OnClientClick = "EditItem(" + currentNodeId + ", " + nodeParentId + "); return false;";
                    }
                }

                break;
            }
        }

        switch (sourceName.ToLowerInvariant())
        {
        case "skunumber":
            string skuNumber = ValidationHelper.GetString(row["SKUNumber"], null);
            return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(skuNumber) ?? ""));

        case "skuavailableitems":
            var sku            = new SKUInfo(row.Row);
            int availableItems = sku.SKUAvailableItems;

            // Inventory tracked by variants
            if (sku.SKUTrackInventory == TrackInventoryTypeEnum.ByVariants)
            {
                return(GetString("com.inventory.trackedbyvariants"));
            }

            // Inventory tracking disabled
            if (sku.SKUTrackInventory == TrackInventoryTypeEnum.Disabled)
            {
                return(GetString("com.inventory.nottracked"));
            }

            // Ensure correct values for unigrid export
            if (sender == null)
            {
                return(availableItems);
            }

            // Tracking by products
            var inlineAvailableItems = new InlineEditingTextBox
            {
                Text          = availableItems.ToString(),
                DelayedReload = DocumentListingDisplayed,
                EnableEncode  = false
            };

            inlineAvailableItems.Formatting += (s, e) =>
            {
                var reorderAt = sku.SKUReorderAt;

                // Emphasize the number when product needs to be reordered
                if (availableItems <= reorderAt)
                {
                    // Format message informing about insufficient stock level
                    string reorderMsg = string.Format(GetString("com.sku.reorderatTooltip"), reorderAt);
                    string message    = string.Format("<span class=\"alert-status-error\" onclick=\"UnTip()\" onmouseout=\"UnTip()\" onmouseover=\"Tip('{1}')\">{0}</span>", availableItems, reorderMsg);
                    inlineAvailableItems.FormattedText = message;
                }
            };

            // Unigrid with delayed reload in combination with inline edit control requires additional postback to sort data.
            // Update data only if external data bound is called for the first time.
            if (!forceReloadData)
            {
                inlineAvailableItems.Update += (s, e) =>
                {
                    var newNumberOfItems = ValidationHelper.GetInteger(inlineAvailableItems.Text, availableItems);

                    if (ValidationHelper.IsInteger(inlineAvailableItems.Text) && (-1000000000 <= newNumberOfItems) && (newNumberOfItems <= 1000000000))
                    {
                        CheckModifyPermission(sku);

                        // Ensures that grid will display inserted value
                        sku.SKUAvailableItems = newNumberOfItems;

                        // Document list is used to display products -> document has to be updated to ensure correct sku mapping
                        if (DocumentListingDisplayed)
                        {
                            int documentId = ValidationHelper.GetInteger(row.Row["DocumentID"], 0);

                            // Create an instance of the Tree provider and select edited document with coupled data
                            var tree     = new TreeProvider(MembershipContext.AuthenticatedUser);
                            var document = tree.SelectSingleDocument(documentId);
                            if (document == null)
                            {
                                return;
                            }

                            document.SetValue("SKUAvailableItems", newNumberOfItems);
                            document.Update();

                            forceReloadData = true;
                        }
                        // Stand-alone product -> only product has to be updated
                        else
                        {
                            sku.MakeComplete(true);
                            sku.Update();

                            gridData.ReloadData();
                        }
                    }
                    else
                    {
                        inlineAvailableItems.ErrorText = GetString("com.productedit.availableitemsinvalid");
                    }
                };
            }

            return(inlineAvailableItems);

        case "skuprice":

            var product        = new SKUInfo(row.Row);
            var currency       = CurrencyInfoProvider.GetMainCurrency(product.SKUSiteID);
            var formattedValue = CurrencyInfoProvider.GetFormattedValue(product.SKUPrice, currency);

            // Ensure correct values for unigrid export
            if (sender == null)
            {
                return(formattedValue);
            }

            var inlineSkuPrice = new InlineEditingTextBox
            {
                Text          = formattedValue,
                FormattedText = CurrencyInfoProvider.GetFormattedPrice(product.SKUPrice, currency),
                DelayedReload = DocumentListingDisplayed
            };

            // Unigrid with delayed reload in combination with inline edit control requires additional postback to sort data.
            // Update data only if external data bound is called for the first time.
            if (!forceReloadData)
            {
                inlineSkuPrice.Update += (s, e) =>
                {
                    CheckModifyPermission(product);

                    var price = ValidationHelper.GetDecimal(inlineSkuPrice.Text, -1);
                    var error = ValidatePrice(price, currency, product);
                    if (String.IsNullOrEmpty(error))
                    {
                        UpdatePrice(product, price, row.Row);
                    }
                    else
                    {
                        inlineSkuPrice.ErrorText = error;
                    }
                };
            }

            return(inlineSkuPrice);

        case "publicstatusid":
            int id = ValidationHelper.GetInteger(row["SKUPublicStatusID"], 0);
            PublicStatusInfo publicStatus = PublicStatusInfoProvider.GetPublicStatusInfo(id);
            if (publicStatus != null)
            {
                // Localize and encode
                return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(publicStatus.PublicStatusDisplayName)));
            }

            return(string.Empty);

        case "allowforsale":
            // Get "on sale" flag
            return(UniGridFunctions.ColoredSpanYesNo(ValidationHelper.GetBoolean(row["SKUEnabled"], false)));

        case "typename":
            string docTypeName = ValidationHelper.GetString(row["ClassDisplayName"], null);

            // Localize class display name
            if (!string.IsNullOrEmpty(docTypeName))
            {
                return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(docTypeName)));
            }

            return(string.Empty);
        }

        return(parameter);
    }
Example #6
0
    private object grid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "skuprice":
            var optionRow = parameter as DataRowView;
            var option    = new SKUInfo(optionRow.Row);

            if (sender == null)
            {
                return(option.SKUPrice);
            }

            var inlineSkuPrice = new InlineEditingTextBox();
            inlineSkuPrice.Text = option.SKUPrice.ToString();

            inlineSkuPrice.Formatting += (s, e) =>
            {
                // Format price
                inlineSkuPrice.FormattedText = CurrencyInfoProvider.GetRelativelyFormattedPrice(option.SKUPrice, option.SKUSiteID);
            };

            inlineSkuPrice.Update += (s, e) =>
            {
                CheckModifyPermission();

                CheckDepartmentPermission(option.SKUDepartmentID);

                var valid = false;
                var price = option.SKUPrice;
                // Update price if new value is valid
                if (ValidationHelper.IsDouble(inlineSkuPrice.Text))
                {
                    price = ValidationHelper.GetDouble(inlineSkuPrice.Text, option.SKUPrice);
                    // Accessory price can not be negative
                    if (!option.IsAccessoryProduct || !(price < 0.0))
                    {
                        valid = true;
                    }
                }

                if (valid)
                {
                    option.SKUPrice = price;
                    option.MakeComplete(true);
                    option.Update();

                    ugOptions.ReloadData();
                }
                else
                {
                    inlineSkuPrice.ErrorText = GetString("com.productedit.priceinvalid");
                }
            };

            return(inlineSkuPrice);

        case "skuavailableitems":
            var row         = parameter as DataRowView;
            var optionStock = new SKUInfo(row.Row);

            int availableItems = optionStock.SKUAvailableItems;

            // Inventory tracking disabled
            if (optionStock.SKUTrackInventory == TrackInventoryTypeEnum.Disabled)
            {
                return(GetString("com.inventory.nottracked"));
            }

            // Ensure correct values for unigrid export
            if (sender == null)
            {
                return(availableItems);
            }

            var inlineSkuAvailableItems = new InlineEditingTextBox();
            inlineSkuAvailableItems.Text         = availableItems.ToString();
            inlineSkuAvailableItems.EnableEncode = false;

            inlineSkuAvailableItems.Formatting += (s, e) =>
            {
                var reorderAt = optionStock.SKUReorderAt;

                // Emphasize the number when product needs to be reordered
                if (availableItems <= reorderAt)
                {
                    // Format message informing about insufficient stock level
                    string reorderMsg = string.Format(GetString("com.sku.reorderatTooltip"), reorderAt);
                    string message    = string.Format("<span class=\"alert-status-error\" onclick=\"UnTip()\" onmouseout=\"UnTip()\" onmouseover=\"Tip('{1}')\">{0}</span>", availableItems, reorderMsg);
                    inlineSkuAvailableItems.FormattedText = message;
                }
            };

            inlineSkuAvailableItems.Update += (s, e) =>
            {
                CheckModifyPermission();

                CheckDepartmentPermission(optionStock.SKUDepartmentID);

                var newNumberOfItems = ValidationHelper.GetInteger(inlineSkuAvailableItems.Text, availableItems);

                // Update available items if new value is valid
                if (ValidationHelper.IsInteger(inlineSkuAvailableItems.Text) && (-1000000000 <= newNumberOfItems) && (newNumberOfItems <= 1000000000))
                {
                    optionStock.SKUAvailableItems = ValidationHelper.GetInteger(inlineSkuAvailableItems.Text, availableItems);
                    optionStock.MakeComplete(true);
                    optionStock.Update();

                    ugOptions.ReloadData();
                }
                else
                {
                    inlineSkuAvailableItems.ErrorText = GetString("com.productedit.availableitemsinvalid");
                }
            };

            return(inlineSkuAvailableItems);

        case "delete":
        case "moveup":
        case "movedown":
        {
            CMSGridActionButton button = sender as CMSGridActionButton;
            if (button != null)
            {
                // Hide actions when not allowed
                button.Visible = allowActions;
            }
        }
        break;
        }

        return(parameter);
    }