void categoryGrid_OnAction(string actionName, object actionArgument) { int categoryId = ValidationHelper.GetInteger(actionArgument, 0); switch (actionName.ToLowerCSafe()) { case "up": case "down": // In case Up or Down action was performed permissions are checked RaiseOnCheckPermissions(PERMISSION_MODIFY, this); SKUOptionCategoryInfo selectedItem = SKUOptionCategoryInfoProvider.GetSKUOptionCategoryInfo(categoryId, ProductID); if (actionName.ToLowerCSafe() == "up") { // Move SKU Category Up SKUOptionCategoryInfoProvider.MoveSKUCategoryOrderUp(selectedItem); } else { // Move SKU Category Down SKUOptionCategoryInfoProvider.MoveSKUCategoryOrderDown(selectedItem); } // Clear selected rows categoryGrid.ResetSelection(); // Reload uniGrid & uniSelector categoryGrid.ReloadData(); break; } }
protected void Page_Load(object sender, EventArgs e) { // SKU option category info to select options from optionSKUCategoryInfo = SKUOptionCategoryInfoProvider.GetSKUOptionCategoryInfo(CategoryID, ProductID); // Redirect user if edited option category for this product does not exist if (optionSKUCategoryInfo == null) { EditedObject = null; } else { // Set title and help var optionCategoryInfo = OptionCategoryInfoProvider.GetOptionCategoryInfo(optionSKUCategoryInfo.CategoryID); var categoryFullName = optionCategoryInfo.CategoryFullName; string titleText = string.Format(GetString("com.optioncategory.select"), HTMLHelper.HTMLEncode(categoryFullName)); SetTitle(titleText); } // Register event handlers rbAllowAllOption.SelectedIndexChanged += rbAllowAllOption_SelectedIndexChanged; ugOptions.OnExternalDataBound += ugOptions_OnExternalDataBound; ugOptions.OnBeforeDataReload += ugOptions_OnBeforeDataReload; Save += btnOk_Click; // Initialize value of controls if (!RequestHelper.IsPostBack()) { rbAllowAllOption.SelectedValue = optionSKUCategoryInfo.AllowAllOptions ? ALLOW_ALL : SELECTED_ONLY; ugOptions.SelectedItems = SelectedOptionsIds; } // Hide selection if all options are allowed ugOptions.GridOptions.ShowSelection = rbAllowAllOption.SelectedValue != ALLOW_ALL; // Display only options for particular category ugOptions.WhereCondition = "SKUOptionCategoryID=" + CategoryID; // Navigate user if there is nothing to select from ugOptions.ZeroRowsText = GetString("com.selectableoptions.nodata"); }
/// <summary> /// Saves selected item. Permission checks are performed. /// </summary> public void SaveItems() { // Check permissions RaiseOnCheckPermissions(PERMISSION_MODIFY, this); // Remove old items string newValues = ValidationHelper.GetString(uniSelector.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // Add all new items to user foreach (string item in newItems) { int categoryId = ValidationHelper.GetInteger(item, 0); SKUOptionCategoryInfoProvider.RemoveOptionCategoryFromSKU(categoryId, ProductID); } } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // Add all new items to user foreach (string item in newItems) { int categoryId = ValidationHelper.GetInteger(item, 0); SKUOptionCategoryInfoProvider.AddOptionCategoryToSKU(categoryId, ProductID); } } // Show message & reload uniGrid ShowChangesSaved(); categoryGrid.ClearSelectedItems(); categoryGrid.ReloadData(); }
/// <summary> /// Saves selected item. Permission checks are performed. /// </summary> public void SaveItems() { // Check permissions RaiseOnCheckPermissions(PERMISSION_MODIFY, this); // Remove old items string newValues = ValidationHelper.GetString(uniSelector.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); var displayChangesSaved = true; if (!String.IsNullOrEmpty(items)) { var categoryIds = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(Int32.Parse).ToList(); // Display Save info message only if some binding was removed displayChangesSaved = RemoveSKUCategoryBindings(categoryIds); } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { displayChangesSaved = true; string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string item in newItems) { int categoryId = ValidationHelper.GetInteger(item, 0); SKUOptionCategoryInfoProvider.AddOptionCategoryToSKU(categoryId, ProductID); } } // Show message & reload uniGrid if (displayChangesSaved) { ShowChangesSaved(); } ReloadGrid(); }
/// <summary> /// Saves selected item. No permission checks are performed. /// </summary> public void SaveItems() { // Remove old items string newValues = ValidationHelper.GetString(uniSelector.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to user foreach (string item in newItems) { int categoryId = ValidationHelper.GetInteger(item, 0); SKUOptionCategoryInfoProvider.RemoveOptionCategoryFromSKU(categoryId, ProductID); } } } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to user foreach (string item in newItems) { int categoryId = ValidationHelper.GetInteger(item, 0); SKUOptionCategoryInfoProvider.AddOptionCategoryToSKU(categoryId, ProductID); } } } lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); }
protected void uniSelector_OnSelectionChanged(object sender, EventArgs e) { var cu = MembershipContext.AuthenticatedUser; // Check permissions if ((cu == null) || (!cu.IsAuthorizedPerResource(ModuleName.ECOMMERCE, EcommercePermissions.ECOMMERCE_MODIFY) && !cu.IsAuthorizedPerResource(ModuleName.ECOMMERCE, EcommercePermissions.PRODUCTS_MODIFY))) { RedirectToAccessDenied(ModuleName.ECOMMERCE, "EcommerceModify OR ModifyProducts"); } else { string newValues = ValidationHelper.GetString(uniSelector.Value, null); string addItems = DataHelper.GetNewItemsInList(UniSelectorData, newValues); string removeItems = DataHelper.GetNewItemsInList(newValues, UniSelectorData); // Add SKU to Option Category if (!String.IsNullOrEmpty(addItems)) { string[] newItems = addItems.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string item in newItems) { SKUOptionCategoryInfoProvider.AddOptionCategoryToSKU(categoryId, ValidationHelper.GetInteger(item, 0)); } // Show message ShowChangesSaved(); } // Remove SKU from Option Category if (!String.IsNullOrEmpty(removeItems)) { string[] productIds = removeItems.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); bool displayWarning = false; StringBuilder ids = new StringBuilder(); // Check if category is not used in variants of product foreach (string skuID in productIds) { int productId = ValidationHelper.GetInteger(skuID, 0); // Inform user that removing of product is not possible if (VariantHelper.AreCategoriesUsedInVariants(productId, new int[] { categoryId })) { displayWarning = true; ids.Append(";" + skuID); } else { ProductHelper.RemoveOptionCategory(productId, categoryId); } } if (displayWarning) { // Display items which cannot be removed in the selector uniSelector.Value += ids.ToString(); ShowWarning(GetString("com.optioncategory.removeproduct")); } else { ShowChangesSaved(); } } } PreloadUniSelector(true); }
protected void editOptionCategory_OnAfterSave(object sender, EventArgs e) { if (EditedCategory == null) { EditedObject = null; return; } // New option category if (!Editing) { // For new TEXT option category create text option if (SelectedCategoryType == OptionCategoryTypeEnum.Text) { CreateTextOption(); } // Assign option category to product if (ParentProduct != null) { SKUOptionCategoryInfoProvider.AddOptionCategoryToSKU(EditedCategory.CategoryID, ParentProduct.SKUID); } // Redirect from new form dialog to option category edit. string query = QueryHelper.BuildQuery("saved", "1", "productid", ProductID.ToString(), "siteid", CategorySiteID.ToString()); if (ParentProduct == null) { URLHelper.Redirect(UIContextHelper.GetElementUrl(ModuleName.ECOMMERCE, "EditOptionCategory", false, EditedCategory.CategoryID, query)); } else { URLHelper.Redirect(ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "EditProductOptionCategory", EditedCategory.CategoryID, query)); } } if (Editing) { // Refresh breadcrumbs var append = EditedCategory.IsGlobal ? " " + GetString("general.global") : ""; ScriptHelper.RefreshTabHeader(Page, EditedCategory.CategoryDisplayName + append); // Category options DataSet options = SKUInfoProvider.GetSKUOptions(EditedCategory.CategoryID, false); // Option category type may be changed during editing and additional action is required switch (SelectedAdditionalAction) { case AdditionalActionEnum.DeleteOptionsAndCreateTextOption: DestroyOptions(options); CreateTextOption(); break; case AdditionalActionEnum.DeleteTextOption: DestroyOptions(options); CategoryHasOptions = false; break; case AdditionalActionEnum.ConvertAttributeToProduct: ChangeAttributeToProduct(options); break; case AdditionalActionEnum.ConvertProductToAttribute: ChangeProductToAttribute(options); break; case AdditionalActionEnum.None: break; } editOptionCategory.SubmitButton.OnClientClick = ""; } }