/// <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) { EditedObject = Product; if (ProductID > 0) { DataSet ds = TaxClassInfoProvider.GetSKUTaxClasses(ProductID); if (!DataHelper.DataSourceIsEmpty(ds)) { currentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "TaxClassID")); } uniSelector.WhereCondition = GetWhereCondition(); if (!RequestHelper.IsPostBack()) { uniSelector.Value = currentValues; } headTitle.Text = GetString("product_edit_tax.taxtitle"); } // Get category of product OptionCategoryInfo category = OptionCategoryInfoProvider.GetOptionCategoryInfo(Product.SKUOptionCategoryID); // Ensure correct info label for Attribute and Text product option if (category != null) { if (category.CategoryType != OptionCategoryTypeEnum.Products) { headTitle.Text = GetString("product_edit_tax.taxtitleforoption"); } } }
/// <summary> /// Handle display price selection made. /// </summary> protected void chkCategoryDisplayPrice_CheckedChanged(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(); } }
/// <summary> /// Creates breadcrumbs. /// </summary> private void CreateBreadcrumbs() { if (IsProductOption) { OptionCategoryInfo categoryInfo = OptionCategoryInfoProvider.GetOptionCategoryInfo(OptionCategoryID); if (categoryInfo != null) { string productListText = GetString("Prodect_Edit_Header.ProductOptionsLink"); string productListUrl = "~/CMSModules/Ecommerce/Pages/Tools/ProductOptions/OptionCategory_Edit_Options.aspx"; productListUrl = URLHelper.AddParameterToUrl(productListUrl, "categoryId", OptionCategoryID.ToString()); productListUrl = URLHelper.AddParameterToUrl(productListUrl, "siteId", SiteID.ToString()); productListUrl = URLHelper.AddParameterToUrl(productListUrl, "productId", ParentProductID.ToString()); productListUrl = URLHelper.AddParameterToUrl(productListUrl, "dialog", QueryHelper.GetString("dialog", "0")); // Set breadcrumb PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem { Text = productListText, Target = (categoryInfo.CategoryType == OptionCategoryTypeEnum.Products) ? "_parent" : null, RedirectUrl = ResolveUrl(productListUrl) }); PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem { Text = FormatBreadcrumbObjectName(SKU.SKUName, SiteID) }); } } else { // Ensure correct suffix UIHelper.SetBreadcrumbsSuffix(GetString("objecttype.com_sku")); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); // Get option category ID from url optionCategoryId = QueryHelper.GetInteger("categoryid", 0); newObjSiteId = ConfiguredSiteID; // Creating new product option if (optionCategoryId > 0) { GlobalObjectsKeyName = ECommerceSettings.ALLOW_GLOBAL_PRODUCT_OPTIONS; OptionCategoryInfo oci = OptionCategoryInfoProvider.GetOptionCategoryInfo(optionCategoryId); // Check edited object EditedObject = oci; // New product option wil be bound to same site as option category if (oci != null) { // Check edited site id CheckEditedObjectSiteID(oci.CategorySiteID); newObjSiteId = oci.CategorySiteID; } } // Creating new product else { GlobalObjectsKeyName = ECommerceSettings.ALLOW_GLOBAL_PRODUCTS; } }
protected void Page_Load(object sender, EventArgs e) { // Setup help object options = new { helpName = "lnkProductEditHelp", helpUrl = UIContextHelper.GetDocumentationTopicUrl(HELP_TOPIC_LINK) }; ScriptHelper.RegisterModule(this, "CMS/DialogContextHelpChange", options); //No need to check changes DocumentManager.RegisterSaveChangesScript = false; // Check UI personalization for product / product option separately if (OptionCategoryID > 0) { // Check elements in product options categories subtree CheckUIElementAccessHierarchical("CMS.Ecommerce", "ProductOptions.Options.TaxClasses"); } else { CheckUIElementAccessHierarchical("CMS.Ecommerce", "Products.TaxClasses"); } if (ProductID > 0) { sku = SKUInfoProvider.GetSKUInfo(ProductID); EditedObject = sku; if (sku != null) { // Check products site id CheckEditedObjectSiteID(sku.SKUSiteID); taxForm.ProductID = ProductID; taxForm.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged; if (sku.IsProductOption) { var categoryInfo = OptionCategoryInfoProvider.GetOptionCategoryInfo(sku.SKUOptionCategoryID); if (categoryInfo != null) { CreateBreadcrumbs(sku); if (categoryInfo.CategoryType != OptionCategoryTypeEnum.Products) { ShowError(GetString("com.taxesNotSupportedForOptionType")); taxForm.Visible = false; } } } } } }
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(ModuleName.ECOMMERCE, "ProductOptions.Products"); } else { // UIElement from product edit CheckUIElementAccessHierarchical(ModuleName.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; } } }
protected void Page_Load(object sender, EventArgs e) { bool hideBreadcrumbs = QueryHelper.GetBoolean("hidebreadcrumbs", false); // Get option category ID from querystring categoryId = QueryHelper.GetInteger("categoryID", 0); CMSMasterPage master = (CMSMasterPage)this.CurrentMaster; // Get localized option category name string categName = ""; OptionCategoryInfo categObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId); if (categObj != null) { categName = ResHelper.LocalizeString(categObj.CategoryDisplayName); editedSiteId = categObj.CategorySiteID; // Check if edited object belongs to configured site CheckEditedObjectSiteID(editedSiteId); } if (!hideBreadcrumbs) { // Initializes page title control string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("optioncategory_edit.itemlistlink"); breadcrumbs[0, 1] = "~/CMSModules/Ecommerce/Pages/Tools/ProductOptions/OptionCategory_List.aspx?siteId=" + SiteID; breadcrumbs[0, 2] = "ecommerceContent"; breadcrumbs[1, 0] = FormatBreadcrumbObjectName(categName, editedSiteId); breadcrumbs[1, 1] = ""; breadcrumbs[1, 2] = ""; this.CurrentMaster.Title.Breadcrumbs = breadcrumbs; } master.Title.HelpTopicName = "edit_option_category___general"; master.Title.HelpName = "helpTopic"; master.Tabs.ModuleName = "CMS.Ecommerce"; master.Tabs.ElementName = "ProductOptions"; master.Tabs.UrlTarget = "OptionCategoryEdit"; master.Tabs.OnTabCreated += new UITabs.TabCreatedEventHandler(Tabs_OnTabCreated); master.Tabs.OpenTabContentAfterLoad = false; // Set master title master.Title.TitleText = GetString("com.optioncategory.edit"); master.Title.TitleImage = GetImageUrl("Objects/Ecommerce_OptionCategory/object.png"); }
protected object productsUniGridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { var row = (DataRowView)parameter; switch (sourceName.ToLowerInvariant()) { case "skuprice": // Get information needed to format SKU price var value = ValidationHelper.GetDecimal(row["SKUPrice"], 0); int siteId = ValidationHelper.GetInteger(row["SKUSiteID"], 0); // Return formatted SKU price return(CurrencyInfoProvider.GetFormattedPrice(value, siteId)); case "skuvalidity": // Get information needed to format SKU validity ValidityEnum validity = DateTimeHelper.GetValidityEnum(ValidationHelper.GetString(row["SKUValidity"], null)); int validFor = ValidationHelper.GetInteger(row["SKUValidFor"], 0); DateTime validUntil = ValidationHelper.GetDateTime(row["SKUValidUntil"], DateTimeHelper.ZERO_TIME); // Return formatted SKU validity return(DateTimeHelper.GetFormattedValidity(validity, validFor, validUntil)); case "skuisproductoption": var skuInfo = SKUInfoProvider.GetSKUInfo(ValidationHelper.GetInteger(row["SKUID"], 0)); if (skuInfo != null && skuInfo.IsProductOption) { return(ResHelper.GetString("general.yes")); } return(ResHelper.GetString("general.no")); case "skuproductoptioncategoryname": var resultCategoryName = ""; var optionCategoryID = ValidationHelper.GetInteger(row["SKUOptionCategoryID"], 0); var optionCategory = OptionCategoryInfoProvider.GetOptionCategoryInfo(optionCategoryID); if (optionCategory != null) { resultCategoryName = optionCategory.CategoryDisplayName; } return(resultCategoryName); } return(null); }
/// <summary> /// Redirects to the edit page of the saved product. /// </summary> private void RedirectToSavedProduct(BaseInfo product) { string url = ProductUIHelper.GetProductEditUrl(); // Creating product options of type other than products is redirected directly to form if (OptionCategoryID > 0) { var categoryInfo = OptionCategoryInfoProvider.GetOptionCategoryInfo(OptionCategoryID); if (categoryInfo != null) { url = "Product_Edit_General.aspx"; if (categoryInfo.CategoryType == OptionCategoryTypeEnum.Products) { url = UIContextHelper.GetElementUrl("cms.ecommerce", "ProductOptions.Options.Edit", false); } } } url = URLHelper.AddParameterToUrl(url, "siteId", SiteID.ToString()); url = URLHelper.AddParameterToUrl(url, "categoryId", OptionCategoryID.ToString()); url = URLHelper.AddParameterToUrl(url, "objectid", OptionCategoryID.ToString()); if (product is TreeNode) { int nodeId = product.GetIntegerValue("NodeID", 0); url = URLHelper.AddParameterToUrl(url, "nodeId", nodeId.ToString()); } else if (product is SKUInfo) { int skuId = product.GetIntegerValue("SKUID", 0); url = URLHelper.AddParameterToUrl(url, "productId", skuId.ToString()); // Select general tab if stan-alone SKU is saved if (OptionCategoryID == 0) { url = URLHelper.AddParameterToUrl(url, "tabName", "Products.General"); } } url = URLHelper.AddParameterToUrl(url, "saved", "1"); URLHelper.Redirect(url); }
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> /// Redirects to the edit page of the saved product. /// </summary> private void RedirectToSavedProduct(BaseInfo product) { string url = ProductUIHelper.GetProductEditUrl(); if (OptionCategoryID > 0) { var categoryInfo = OptionCategoryInfoProvider.GetOptionCategoryInfo(OptionCategoryID); if (categoryInfo != null) { url = UIContextHelper.GetElementUrl(ModuleName.ECOMMERCE, "ProductOptions.Options.General", false); } } var categoryID = OptionCategoryID.ToString(); url = URLHelper.AddParameterToUrl(url, "siteId", SiteID.ToString()); url = URLHelper.AddParameterToUrl(url, "categoryId", categoryID); url = URLHelper.AddParameterToUrl(url, "parentobjectid", categoryID); if (product is TreeNode) { int nodeId = product.GetIntegerValue("NodeID", 0); url = URLHelper.AddParameterToUrl(url, "nodeId", nodeId.ToString()); } else if (product is SKUInfo) { var skuId = product.GetIntegerValue("SKUID", 0).ToString(); url = URLHelper.AddParameterToUrl(url, "productId", skuId); url = URLHelper.AddParameterToUrl(url, "objectid", skuId); // Select general tab if stan-alone SKU is saved if (OptionCategoryID == 0) { url = URLHelper.AddParameterToUrl(url, "tabName", "Products.General"); } } url = URLHelper.AddParameterToUrl(url, "saved", "1"); URLHelper.Redirect(UrlResolver.ResolveUrl(url)); }
/// <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); // Set actions if (actionName == "edit") { URLHelper.Redirect("OptionCategory_Edit.aspx?CategoryID=" + categoryId + "&siteId=" + SelectSite.SiteID); } else if (actionName == "delete") { OptionCategoryInfo categoryObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId); if (!ECommerceContext.IsUserAuthorizedToModifyOptionCategory(categoryObj)) { // Check module permissions if (categoryObj.CategoryIsGlobal) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify"); } else { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyProducts"); } } // Check dependencies if (OptionCategoryInfoProvider.CheckDependencies(categoryId)) { // Show error message ShowError(GetString("Ecommerce.DeleteDisabled")); return; } // Delete option category from database OptionCategoryInfoProvider.DeleteOptionCategoryInfo(categoryObj); } }
protected void Page_Load(object sender, EventArgs e) { bool hideBreadcrumbs = QueryHelper.GetBoolean("hidebreadcrumbs", false); // Get option category ID from querystring categoryId = QueryHelper.GetInteger("categoryID", 0); CMSMasterPage master = (CMSMasterPage)CurrentMaster; // Get localized option category name string categName = ""; OptionCategoryInfo categObj = OptionCategoryInfoProvider.GetOptionCategoryInfo(categoryId); if (categObj != null) { categName = ResHelper.LocalizeString(categObj.CategoryDisplayName); editedSiteId = categObj.CategorySiteID; // Check if edited object belongs to configured site CheckEditedObjectSiteID(editedSiteId); } if (!hideBreadcrumbs) { // Initializes page title control string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("optioncategory_edit.itemlistlink"); breadcrumbs[0, 1] = "~/CMSModules/Ecommerce/Pages/Tools/ProductOptions/OptionCategory_List.aspx?siteId=" + SiteID; breadcrumbs[0, 2] = "ecommerceContent"; breadcrumbs[1, 0] = FormatBreadcrumbObjectName(categName, editedSiteId); breadcrumbs[1, 1] = ""; breadcrumbs[1, 2] = ""; CurrentMaster.Title.Breadcrumbs = breadcrumbs; } master.Tabs.OnTabCreated += Tabs_OnTabCreated; master.Tabs.OpenTabContentAfterLoad = false; }
/// <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 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; } }
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; } }
/// <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; } }
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); }
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); }
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"); } } }
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> /// 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; } }
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); }