Beispiel #1
0
    private void gridData_OnAction(string actionName, object actionArgument)
    {
        if (string.IsNullOrEmpty(actionName))
        {
            return;
        }

        var argument = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerInvariant())
        {
        case "edit":
        {
            string url   = ProductUIHelper.GetProductEditUrl();
            string query = DocumentListingDisplayed ? "?sectionId=" + NodeID + "&nodeId=" + argument + "&culture=" + CultureCode : "?productid=" + argument;

            url = URLHelper.AppendQuery(url, query);

            URLHelper.Redirect(UrlResolver.ResolveUrl(url));
        }
        break;

        case "delete":
            if (DocumentListingDisplayed)
            {
                var url = "Product_Section.aspx?action=delete&nodeId=" + argument;
                URLHelper.Redirect(UrlResolver.ResolveUrl(URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url))));
            }
            else
            {
                SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(argument);

                // Check module permissions
                CheckModifyPermission(skuObj);

                // Check dependencies
                if (SKUInfoProvider.CheckDependencies(argument))
                {
                    // Show error message
                    ShowError(EcommerceUIHelper.GetDependencyMessage(skuObj));

                    return;
                }

                SKUInfoProvider.DeleteSKUInfo(skuObj);
            }

            break;
        }
    }
    /// <summary>
    /// Checks and processes the dependencies of the meta file and related SKU file that is being deleted.
    /// Returns true if the related SKU file object that is being deleted has no existing dependencies and it can be deleted, otherwise returns false.
    /// </summary>
    private bool ProcessDeleteForExistingEproduct()
    {
        MetaFileInfo metaFile = fileListElem.CurrentlyHandledMetaFile;

        DataSet skuFiles = SKUFileInfoProvider.GetSKUFiles().WhereEquals("FileMetaFileGUID", metaFile.MetaFileGUID);

        if (!DataHelper.DataSourceIsEmpty(skuFiles))
        {
            SKUFileInfo skuFile = new SKUFileInfo(skuFiles.Tables[0].Rows[0]);
            if (skuFile.Generalized.CheckDependencies())
            {
                ErrorMessage = EcommerceUIHelper.GetDependencyMessage(skuFile);
                return(false);
            }

            SKUFileInfoProvider.DeleteSKUFileInfo(skuFile);
        }

        return(true);
    }
Beispiel #3
0
    /// <summary>
    /// Handles the UniGrid'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 gridElem_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            URLHelper.Redirect(UrlResolver.ResolveUrl("Currency_Edit.aspx?currencyid=" + Convert.ToString(actionArgument) + "&siteId=" + SiteID));
        }
        else if (actionName == "delete")
        {
            // Check permissions
            CheckConfigurationModification();

            int currencyId = ValidationHelper.GetInteger(actionArgument, 0);
            var currency   = CurrencyInfoProvider.GetCurrencyInfo(currencyId);

            if (currency != null)
            {
                if (currency.Generalized.CheckDependencies())
                {
                    // Show error message
                    ShowError(EcommerceUIHelper.GetDependencyMessage(currency));

                    return;
                }

                // An attempt to delete main currency
                if (currency.CurrencyIsMain)
                {
                    // Show error message
                    ShowError(string.Format(GetString("com.deletemaincurrencyerror"), HTMLHelper.HTMLEncode(currency.CurrencyDisplayName)));

                    return;
                }

                // Delete CurrencyInfo object from database
                CurrencyInfoProvider.DeleteCurrencyInfo(currency);
            }
        }
    }
    private void grid_OnAction(string actionName, object actionArgument)
    {
        if (string.IsNullOrEmpty(actionName))
        {
            return;
        }

        int skuId = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerInvariant())
        {
        case "edit":
            // Show product tabs for type Products, otherwise show only general tab
        {
            var url = UIContextHelper.GetElementUrl(ModuleName.ECOMMERCE, "ProductOptions.Options.General");
            url = URLHelper.AddParameterToUrl(url, "displaytitle", "false");
            url = URLHelper.AddParameterToUrl(url, "productId", skuId.ToString());
            url = URLHelper.AddParameterToUrl(url, "categoryid", categoryId.ToString());
            url = URLHelper.AddParameterToUrl(url, "siteId", categoryObj.CategorySiteID.ToString());
            url = URLHelper.AddParameterToUrl(url, "objectid", skuId.ToString());
            // To be able to hide tax class tab for attribute and text option
            url = URLHelper.AddParameterToUrl(url, "parentobjectid", categoryId.ToString());

            // Add parent product id
            if (parentProductId > 0)
            {
                url += "&parentProductId=" + parentProductId;
            }

            if (QueryHelper.GetBoolean("isindialog", false))
            {
                url = URLHelper.AddParameterToUrl(url, "isindialog", "1");
                url = ApplicationUrlHelper.AppendDialogHash(url);
            }

            URLHelper.Redirect(url);
        }
        break;

        case "delete":
            // Check permissions
            CheckModifyPermission();

            // Check dependencies
            if (SKUInfoProvider.CheckDependencies(skuId))
            {
                // Show error message
                ShowError(EcommerceUIHelper.GetDependencyMessage(SKUInfoProvider.GetSKUInfo(skuId)));

                return;
            }

            // Check if same variant is defined by this option
            DataSet variants = VariantOptionInfoProvider.GetVariantOptions()
                               .TopN(1)
                               .Columns("VariantSKUID")
                               .WhereEquals("OptionSKUID", skuId);

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

                return;
            }

            SKUInfoProvider.DeleteSKUInfo(skuId);
            ugOptions.ReloadData();

            break;
        }
    }
    /// <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;
        }
    }