/// <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) { int id = actionArgument.ToInteger(0); if (actionName == "edit") { URLHelper.Redirect("InternalStatus_Edit.aspx?statusid=" + id + "&siteId=" + SiteID); } else if (actionName == "delete") { CheckConfigurationModification(); var status = InternalStatusInfoProvider.GetInternalStatusInfo(id); if (status != null) { if (status.Generalized.CheckDependencies()) { // Show error message ShowError(ECommerceHelper.GetDependencyMessage(status)); return; } // delete InternalStatusInfo object from database InternalStatusInfoProvider.DeleteInternalStatusInfo(status); } } }
/// <summary> /// Gets object from the specified column of the internal status with specific ID. /// </summary> /// <param name="Id">Internal status ID</param> /// <param name="column">Column name</param> public static object GetInternalStatus(object Id, string column) { int id = ValidationHelper.GetInteger(Id, 0); if ((id > 0) && !DataHelper.IsEmpty(column)) { // Get internal status InternalStatusInfo isi = InternalStatusInfoProvider.GetInternalStatusInfo(id); if (isi != null) { // Return datarow value if specified column exists if (isi.ContainsColumn(column)) { return(isi.GetValue(column)); } else { return(""); } } } return(""); }
protected void Page_Load(object sender, EventArgs e) { rfvCodeName.ErrorMessage = GetString("InternalStatus_Edit.errorCodeName"); rfvDisplayName.ErrorMessage = GetString("InternalStatus_Edit.errorDisplayName"); // control initializations lblInternalStatusName.Text = GetString("InternalStatus_Edit.InternalStatusNameLabel"); lblInternalStatusDisplayName.Text = GetString("InternalStatus_Edit.InternalStatusDisplayNameLabel"); btnOk.Text = GetString("General.OK"); string currentInternalStatus = GetString("InternalStatus_Edit.NewItemCaption"); // get internalStatus id from querystring mStatusid = QueryHelper.GetInteger("statusid", 0); if (mStatusid > 0) { InternalStatusInfo internalStatusObj = InternalStatusInfoProvider.GetInternalStatusInfo(mStatusid); EditedObject = internalStatusObj; if (internalStatusObj != null) { CheckEditedObjectSiteID(internalStatusObj.InternalStatusSiteID); currentInternalStatus = internalStatusObj.InternalStatusDisplayName; // fill editing form if (!RequestHelper.IsPostBack()) { LoadData(internalStatusObj); // show that the internalStatus was created or updated successfully if (QueryHelper.GetString("saved", "") == "1") { lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } } } this.CurrentMaster.Title.TitleText = GetString("InternalStatus_Edit.HeaderCaption"); this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_InternalStatus/object.png"); } else { this.CurrentMaster.Title.TitleText = GetString("InternalStatus_New.HeaderCaption"); this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_InternalStatus/new.png"); } this.CurrentMaster.Title.HelpTopicName = "newedit_internal_status"; this.CurrentMaster.Title.HelpName = "helpTopic"; // Initializes page title breadcrumbs control string[,] pageTitleTabs = new string[2, 3]; pageTitleTabs[0, 0] = GetString("InternalStatus_Edit.ItemListLink"); pageTitleTabs[0, 1] = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/InternalStatus/InternalStatus_List.aspx?siteId=" + SiteID; pageTitleTabs[0, 2] = ""; pageTitleTabs[1, 0] = currentInternalStatus; pageTitleTabs[1, 1] = ""; pageTitleTabs[1, 2] = ""; this.CurrentMaster.Title.Breadcrumbs = pageTitleTabs; }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { CheckConfigurationModification(); string errorMessage = new Validator() .NotEmpty(txtInternalStatusDisplayName.Text.Trim(), GetString("InternalStatus_Edit.errorDisplayName")) .NotEmpty(txtInternalStatusName.Text.Trim(), GetString("InternalStatus_Edit.errorCodeName")).Result; if (!ValidationHelper.IsCodeName(txtInternalStatusName.Text.Trim())) { errorMessage = GetString("General.ErrorCodeNameInIdentifierFormat"); } if (errorMessage == "") { // Check unique name for configured site DataSet ds = InternalStatusInfoProvider.GetInternalStatuses("InternalStatusName = '" + txtInternalStatusName.Text.Trim().Replace("'", "''") + "' AND ISNULL(InternalStatusSiteID, 0) = " + ConfiguredSiteID, null); InternalStatusInfo internalStatusObj = null; if (!DataHelper.DataSourceIsEmpty(ds)) { internalStatusObj = new InternalStatusInfo(ds.Tables[0].Rows[0]); } // if internalStatusName value is unique if ((internalStatusObj == null) || (internalStatusObj.InternalStatusID == mStatusId)) { // if internalStatusName value is unique -> determine whether it is update or insert if ((internalStatusObj == null)) { // get InternalStatusInfo object by primary key internalStatusObj = InternalStatusInfoProvider.GetInternalStatusInfo(mStatusId); if (internalStatusObj == null) { // create new item -> insert internalStatusObj = new InternalStatusInfo(); internalStatusObj.InternalStatusSiteID = ConfiguredSiteID; } } internalStatusObj.InternalStatusEnabled = chkInternalStatusEnabled.Checked; internalStatusObj.InternalStatusName = txtInternalStatusName.Text.Trim(); internalStatusObj.InternalStatusDisplayName = txtInternalStatusDisplayName.Text.Trim(); InternalStatusInfoProvider.SetInternalStatusInfo(internalStatusObj); URLHelper.Redirect("InternalStatus_Edit.aspx?statusid=" + Convert.ToString(internalStatusObj.InternalStatusID) + "&saved=1&siteId=" + SiteID); } else { // Show error message ShowError(GetString("InternalStatus_Edit.InternalStatusNameExists")); } } else { // Show error message ShowError(errorMessage); } }
protected void Page_Load(object sender, EventArgs e) { // Init header actions HeaderActions actions = CurrentMaster.HeaderActions; actions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed); // New item action actions.ActionsList.Add(new HeaderAction() { Text = GetString("InternalStatus_List.NewItemCaption"), RedirectUrl = ResolveUrl("InternalStatus_Edit.aspx?siteId=" + SiteID), ImageUrl = GetImageUrl("Objects/Ecommerce_InternalStatus/add.png"), ControlType = HeaderActionTypeEnum.Hyperlink }); // Show copy from global link when not configuring global statuses. if (ConfiguredSiteID != 0) { // Show "Copy from global" link only if there is at least one global status DataSet ds = InternalStatusInfoProvider.GetInternalStatuses("InternalStatusSiteID IS NULL", null, 1, "InternalStatusSiteID"); if (!DataHelper.DataSourceIsEmpty(ds)) { actions.ActionsList.Add(new HeaderAction() { Text = GetString("general.copyfromglobal"), OnClientClick = "return ConfirmCopyFromGlobal();", ImageUrl = GetImageUrl("Objects/Ecommerce_InternalStatus/fromglobal.png"), CommandName = "copyFromGlobal", ControlType = HeaderActionTypeEnum.LinkButton }); // Register javascript to confirm generate string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmInternalStatusFromGlobal")) + ");}"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script)); } } gridElem.OnAction += new OnActionEventHandler(gridElem_OnAction); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); gridElem.ZeroRowsText = GetString("general.nodatafound"); // Configuring global records from specific site if ((ConfiguredSiteID == 0) && (SiteID != 0)) { ShowInformation(GetString("com.UsingGlobalSettings")); } // Filter records by site gridElem.WhereCondition = "ISNULL(InternalStatusSiteID, 0) = " + ConfiguredSiteID; }
/// <summary> /// Gets object from the specified column of the internal status with specific ID. /// </summary> /// <param name="Id">Internal status ID</param> /// <param name="column">Column name</param> public static object GetInternalStatus(object Id, string column) { int id = ValidationHelper.GetInteger(Id, 0); if ((id > 0) && !DataHelper.IsEmpty(column)) { // Get internal status InternalStatusInfo status = InternalStatusInfoProvider.GetInternalStatusInfo(id); return(GetColumnValue(status, column)); } return(""); }
protected void Page_Load(object sender, EventArgs e) { // Init header actions HeaderActions actions = CurrentMaster.HeaderActions; actions.ActionPerformed += HeaderActions_ActionPerformed; // New item action actions.ActionsList.Add(new HeaderAction { Text = GetString("InternalStatus_List.NewItemCaption"), RedirectUrl = ResolveUrl("InternalStatus_Edit.aspx?siteId=" + SiteID) }); // Show copy from global link when not configuring global statuses. if (ConfiguredSiteID != 0) { // Show "Copy from global" link only if there is at least one global status DataSet ds = InternalStatusInfoProvider.GetInternalStatuses(0).TopN(1); if (!DataHelper.DataSourceIsEmpty(ds)) { actions.ActionsList.Add(new HeaderAction { Text = GetString("general.copyfromglobal"), OnClientClick = "return ConfirmCopyFromGlobal();", CommandName = "copyFromGlobal", ButtonStyle = ButtonStyle.Default }); // Register javascript to confirm generate string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmInternalStatusFromGlobal")) + ");}"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script)); } } gridElem.OnAction += gridElem_OnAction; // Show information about usage of global objects when used on site HandleGlobalObjectInformation(gridElem.ObjectType); // Filter records by site gridElem.WhereCondition = "ISNULL(InternalStatusSiteID, 0) = " + ConfiguredSiteID; }
/// <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("InternalStatus_Edit.aspx?statusid=" + Convert.ToString(actionArgument) + "&siteId=" + SiteID); } else if (actionName == "delete") { CheckConfigurationModification(); if (InternalStatusInfoProvider.CheckDependencies(ValidationHelper.GetInteger(actionArgument, 0))) { lblError.Visible = true; lblError.Text = GetString("Ecommerce.DeleteDisabled"); return; } // delete InternalStatusInfo object from database InternalStatusInfoProvider.DeleteInternalStatusInfo(ValidationHelper.GetInteger(actionArgument, 0)); } }
/// <summary> /// Returns where condition based on webpart fields. /// </summary> private string GetWhereCondition() { string where = null; // Show products only from current site or global too, based on setting if (ECommerceSettings.AllowGlobalProducts(CMSContext.CurrentSiteName)) { where = "(SKUSiteID = " + CMSContext.CurrentSiteID + ") OR (SKUSiteID IS NULL)"; } else { where = "SKUSiteID = " + CMSContext.CurrentSiteID; } // Product type filter if (!string.IsNullOrEmpty(ProductType) && (ProductType != FILTER_ALL)) { if (ProductType == PRODUCT_TYPE_PRODUCTS) { where = SqlHelperClass.AddWhereCondition(where, "SKUOptionCategoryID IS NULL"); } else if (ProductType == PRODUCT_TYPE_PRODUCT_OPTIONS) { where = SqlHelperClass.AddWhereCondition(where, "SKUOptionCategoryID IS NOT NULL"); } } // Representing filter if (!string.IsNullOrEmpty(Representing) && (Representing != FILTER_ALL)) { SKUProductTypeEnum productTypeEnum = SKUInfoProvider.GetSKUProductTypeEnum(Representing); string productTypeString = SKUInfoProvider.GetSKUProductTypeString(productTypeEnum); where = SqlHelperClass.AddWhereCondition(where, "SKUProductType = N'" + productTypeString + "'"); } // Product number filter if (!string.IsNullOrEmpty(ProductNumber)) { string safeProductNumber = SqlHelperClass.GetSafeQueryString(ProductNumber, true); where = SqlHelperClass.AddWhereCondition(where, "SKUNumber LIKE N'%" + safeProductNumber + "%'"); } // Department filter DepartmentInfo di = DepartmentInfoProvider.GetDepartmentInfo(Department, CurrentSiteName); if (di != null) { where = SqlHelperClass.AddWhereCondition(where, "SKUDepartmentID = " + di.DepartmentID); } // Manufacturer filter ManufacturerInfo mi = ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, CurrentSiteName); if (mi != null) { where = SqlHelperClass.AddWhereCondition(where, "SKUManufacturerID = " + mi.ManufacturerID); } // Supplier filter SupplierInfo si = SupplierInfoProvider.GetSupplierInfo(Supplier, CurrentSiteName); if (si != null) { where = SqlHelperClass.AddWhereCondition(where, "SKUSupplierID = " + si.SupplierID); } // Needs shipping filter if (!string.IsNullOrEmpty(NeedsShipping) && (NeedsShipping != FILTER_ALL)) { if (NeedsShipping == NEEDS_SHIPPING_YES) { where = SqlHelperClass.AddWhereCondition(where, "SKUNeedsShipping = 1"); } else if (NeedsShipping == NEEDS_SHIPPING_NO) { where = SqlHelperClass.AddWhereCondition(where, "(SKUNeedsShipping = 0) OR (SKUNeedsShipping IS NULL)"); } } // Price from filter if (PriceFrom > 0) { where = SqlHelperClass.AddWhereCondition(where, "SKUPrice >= " + PriceFrom); } // Price to filter if (PriceTo > 0) { where = SqlHelperClass.AddWhereCondition(where, "SKUPrice <= " + PriceTo); } // Public status filter PublicStatusInfo psi = PublicStatusInfoProvider.GetPublicStatusInfo(PublicStatus, CurrentSiteName); if (psi != null) { where = SqlHelperClass.AddWhereCondition(where, "SKUPublicStatusID = " + psi.PublicStatusID); } // Internal status filter InternalStatusInfo isi = InternalStatusInfoProvider.GetInternalStatusInfo(InternalStatus, CurrentSiteName); if (isi != null) { where = SqlHelperClass.AddWhereCondition(where, "SKUInternalStatusID = " + isi.InternalStatusID); } // Allow for sale filter if (!string.IsNullOrEmpty(AllowForSale) && (AllowForSale != FILTER_ALL)) { if (AllowForSale == ALLOW_FOR_SALE_YES) { where = SqlHelperClass.AddWhereCondition(where, "SKUEnabled = 1"); } else if (AllowForSale == ALLOW_FOR_SALE_NO) { where = SqlHelperClass.AddWhereCondition(where, "(SKUEnabled = 0) OR (SKUEnabled IS NULL)"); } } // Available items filter if (!string.IsNullOrEmpty(AvailableItems)) { int value = ValidationHelper.GetInteger(AvailableItems, int.MaxValue); where = SqlHelperClass.AddWhereCondition(where, "SKUAvailableItems <= " + value); } // Needs to be reordered filter if (NeedsToBeReordered) { where = SqlHelperClass.AddWhereCondition(where, "((SKUReorderAt IS NULL) AND (SKUAvailableItems <= 0)) OR ((SKUReorderAt IS NOT NULL) AND (SKUAvailableItems <= SKUReorderAt))"); } return(where); }
/// <summary> /// Convert given status name to its ID for specified site. /// </summary> /// <param name="name">Code name of the internal status to be converted.</param> /// <param name="siteName">Name of the site to translate code name for.</param> protected override int GetID(string name, string siteName) { InternalStatusInfo status = InternalStatusInfoProvider.GetInternalStatusInfo(name, siteName); return((status != null) ? status.InternalStatusID : 0); }
/// <summary> /// Copies site-specific status options from global status list. /// </summary> protected void CopyFromGlobal() { CheckConfigurationModification(); InternalStatusInfoProvider.CopyFromGlobal(ConfiguredSiteID); }
/// <summary> /// Returns where condition based on webpart fields. /// </summary> private WhereCondition GetWhereCondition() { var where = new WhereCondition().WhereEquals("SKUSiteID", SiteContext.CurrentSiteID); // Show products only from current site or global too, based on setting if (ECommerceSettings.AllowGlobalProducts(SiteContext.CurrentSiteName)) { where.Where(w => w.WhereEquals("SKUSiteID", SiteContext.CurrentSiteID).Or().WhereNull("SKUSiteID")); } // Show/hide product variants - it is based on type of inventory tracking for parent product string trackByVariants = TrackInventoryTypeEnum.ByVariants.ToStringRepresentation(); where.Where(v => v.Where(w => w.WhereNull("SKUParentSKUID").And().WhereNotEquals("SKUTrackInventory", trackByVariants)) .Or() .Where(GetParentProductWhereCondition(new WhereCondition().WhereEquals("SKUTrackInventory", trackByVariants)))); // Product type filter if (!string.IsNullOrEmpty(ProductType) && (ProductType != FILTER_ALL)) { if (ProductType == PRODUCT_TYPE_PRODUCTS) { where.WhereNull("SKUOptionCategoryID"); } else if (ProductType == PRODUCT_TYPE_PRODUCT_OPTIONS) { where.WhereNotNull("SKUOptionCategoryID"); } } // Representing filter if (!string.IsNullOrEmpty(Representing) && (Representing != FILTER_ALL)) { SKUProductTypeEnum productTypeEnum = Representing.ToEnum <SKUProductTypeEnum>(); string productTypeString = productTypeEnum.ToStringRepresentation(); where.WhereEquals("SKUProductType", productTypeString); } // Product number filter if (!string.IsNullOrEmpty(ProductNumber)) { where.WhereContains("SKUNumber", ProductNumber); } // Department filter DepartmentInfo di = DepartmentInfoProvider.GetDepartmentInfo(Department, CurrentSiteName); di = di ?? DepartmentInfoProvider.GetDepartmentInfo(Department, null); if (di != null) { where.Where(GetColumnWhereCondition("SKUDepartmentID", new WhereCondition().WhereEquals("SKUDepartmentID", di.DepartmentID))); } // Manufacturer filter ManufacturerInfo mi = ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, CurrentSiteName); mi = mi ?? ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, null); if (mi != null) { where.Where(GetColumnWhereCondition("SKUManufacturerID", new WhereCondition().WhereEquals("SKUManufacturerID", mi.ManufacturerID))); } // Supplier filter SupplierInfo si = SupplierInfoProvider.GetSupplierInfo(Supplier, CurrentSiteName); si = si ?? SupplierInfoProvider.GetSupplierInfo(Supplier, null); if (si != null) { where.Where(GetColumnWhereCondition("SKUSupplierID", new WhereCondition().WhereEquals("SKUSupplierID", si.SupplierID))); } // Needs shipping filter if (!string.IsNullOrEmpty(NeedsShipping) && (NeedsShipping != FILTER_ALL)) { if (NeedsShipping == NEEDS_SHIPPING_YES) { where.Where(GetColumnWhereCondition("SKUNeedsShipping", new WhereCondition().WhereTrue("SKUNeedsShipping"))); } else if (NeedsShipping == NEEDS_SHIPPING_NO) { where.Where(GetColumnWhereCondition("SKUNeedsShipping", new WhereCondition().WhereFalse("SKUNeedsShipping").Or().WhereNull("SKUNeedsShipping"))); } } // Price from filter if (PriceFrom > 0) { where.WhereGreaterOrEquals("SKUPrice", PriceFrom); } // Price to filter if (PriceTo > 0) { where.WhereLessOrEquals("SKUPrice", PriceTo); } // Public status filter PublicStatusInfo psi = PublicStatusInfoProvider.GetPublicStatusInfo(PublicStatus, CurrentSiteName); if (psi != null) { where.Where(GetColumnWhereCondition("SKUPublicStatusID", new WhereCondition().WhereEquals("SKUPublicStatusID", psi.PublicStatusID))); } // Internal status filter InternalStatusInfo isi = InternalStatusInfoProvider.GetInternalStatusInfo(InternalStatus, CurrentSiteName); if (isi != null) { where.Where(GetColumnWhereCondition("SKUInternalStatusID", new WhereCondition().WhereEquals("SKUInternalStatusID", isi.InternalStatusID))); } // Allow for sale filter if (!string.IsNullOrEmpty(AllowForSale) && (AllowForSale != FILTER_ALL)) { if (AllowForSale == ALLOW_FOR_SALE_YES) { where.WhereTrue("SKUEnabled"); } else if (AllowForSale == ALLOW_FOR_SALE_NO) { where.WhereEqualsOrNull("SKUEnabled", false); } } // Available items filter if (!string.IsNullOrEmpty(AvailableItems)) { int value = ValidationHelper.GetInteger(AvailableItems, int.MaxValue); where.WhereLessOrEquals("SKUAvailableItems", value); } // Needs to be reordered filter if (NeedsToBeReordered) { where.Where(w => w.Where(v => v.WhereNull("SKUReorderAt").And().WhereLessOrEquals("SKUAvailableItems", 0)) .Or() .Where(z => z.WhereNotNull("SKUReorderAt").And().WhereLessOrEquals("SKUAvailableItems".AsColumn(), "SKUReorderAt".AsColumn()))); } return(where); }
private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView rowView = parameter as DataRowView; if (rowView != null) { SKUInfo sku = new SKUInfo(rowView.Row); switch (sourceName.ToLowerCSafe()) { case "skuname": string fullName = sku.SKUName; // For variant, add name from parent SKU if (sku.SKUParentSKUID != 0) { SKUInfo parentSku = SKUInfoProvider.GetSKUInfo(sku.SKUParentSKUID); fullName = string.Format("{0}: {1}", parentSku.SKUName, sku.SKUName); } return(HTMLHelper.HTMLEncode(fullName)); case "optioncategory": OptionCategoryInfo optionCategory = OptionCategoryInfoProvider.GetOptionCategoryInfo(sku.SKUOptionCategoryID); // Return option category display name for product option or '-' for product if (optionCategory != null) { return(HTMLHelper.HTMLEncode(optionCategory.CategoryDisplayName ?? "")); } return("-"); case "skunumber": return(ResHelper.LocalizeString(sku.SKUNumber, null, true)); case "skuprice": // Format price return(CurrencyInfoProvider.GetFormattedPrice(sku.SKUPrice, sku.SKUSiteID)); case "skudepartmentid": // Transform to display name and localize DepartmentInfo department = DepartmentInfoProvider.GetDepartmentInfo(sku.SKUDepartmentID); return((department != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(department.DepartmentDisplayName)) : ""); case "skumanufacturerid": // Transform to display name and localize ManufacturerInfo manufacturer = ManufacturerInfoProvider.GetManufacturerInfo(sku.SKUManufacturerID); return((manufacturer != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(manufacturer.ManufacturerDisplayName)) : ""); case "skusupplierid": // Transform to display name and localize SupplierInfo supplier = SupplierInfoProvider.GetSupplierInfo(sku.SKUSupplierID); return((supplier != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(supplier.SupplierDisplayName)) : ""); case "skupublicstatusid": // Transform to display name and localize PublicStatusInfo publicStatus = PublicStatusInfoProvider.GetPublicStatusInfo(sku.SKUPublicStatusID); return((publicStatus != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(publicStatus.PublicStatusDisplayName)) : ""); case "skuinternalstatusid": // Transform to display name and localize InternalStatusInfo internalStatus = InternalStatusInfoProvider.GetInternalStatusInfo(sku.SKUInternalStatusID); return((internalStatus != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(internalStatus.InternalStatusDisplayName)) : ""); case "skuavailableitems": int?count = sku.SKUAvailableItems as int?; int?reorderAt = sku.SKUReorderAt as int?; // Emphasize the number when product needs to be reordered if (count.HasValue && ((reorderAt.HasValue && (count <= reorderAt)) || (!reorderAt.HasValue && (count <= 0)))) { // Format message informing about insufficient stock level return(string.Format("<span class=\"OperationFailed\">{0}</span>", count)); } return(count); case "itemstobereordered": int difference = sku.SKUReorderAt - sku.SKUAvailableItems; // Return difference, or '-' return((difference > 0) ? difference.ToString() : "-"); case "skusiteid": return(UniGridFunctions.ColoredSpanYesNo(sku.SKUSiteID == 0)); } } return(parameter); }
/// <summary> /// Returns where condition based on webpart fields. /// </summary> private string GetWhereCondition() { string where = "SKUSiteID = " + SiteContext.CurrentSiteID; // Show products only from current site or global too, based on setting if (ECommerceSettings.AllowGlobalProducts(SiteContext.CurrentSiteName)) { where = "(SKUSiteID = " + SiteContext.CurrentSiteID + ") OR (SKUSiteID IS NULL)"; } // Show/hide product variants - it is based on type of inventory tracking for parent product string trackByVariants = TrackInventoryTypeEnum.ByVariants.ToStringRepresentation(); string parentSkuWhere = "(SKUParentSKUID IS NULL) AND (SKUTrackInventory != '" + trackByVariants + "')"; string variantWhere = GetParentProductWhereCondition("SKUTrackInventory = '" + trackByVariants + "'"); where = SqlHelper.AddWhereCondition(where, string.Format("({0}) OR ({1})", parentSkuWhere, variantWhere)); // Product type filter if (!string.IsNullOrEmpty(ProductType) && (ProductType != FILTER_ALL)) { if (ProductType == PRODUCT_TYPE_PRODUCTS) { where = SqlHelper.AddWhereCondition(where, "SKUOptionCategoryID IS NULL"); } else if (ProductType == PRODUCT_TYPE_PRODUCT_OPTIONS) { where = SqlHelper.AddWhereCondition(where, "SKUOptionCategoryID IS NOT NULL"); } } // Representing filter if (!string.IsNullOrEmpty(Representing) && (Representing != FILTER_ALL)) { SKUProductTypeEnum productTypeEnum = Representing.ToEnum <SKUProductTypeEnum>(); string productTypeString = productTypeEnum.ToStringRepresentation(); where = SqlHelper.AddWhereCondition(where, "SKUProductType = N'" + productTypeString + "'"); } // Product number filter if (!string.IsNullOrEmpty(ProductNumber)) { string safeProductNumber = SqlHelper.GetSafeQueryString(ProductNumber, true); where = SqlHelper.AddWhereCondition(where, "SKUNumber LIKE N'%" + safeProductNumber + "%'"); } // Department filter DepartmentInfo di = DepartmentInfoProvider.GetDepartmentInfo(Department, CurrentSiteName); di = di ?? DepartmentInfoProvider.GetDepartmentInfo(Department, null); if (di != null) { where = SqlHelper.AddWhereCondition(where, GetColumnWhereCondition("SKUDepartmentID", "SKUDepartmentID = " + di.DepartmentID)); } // Manufacturer filter ManufacturerInfo mi = ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, CurrentSiteName); mi = mi ?? ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, null); if (mi != null) { where = SqlHelper.AddWhereCondition(where, GetColumnWhereCondition("SKUManufacturerID", "SKUManufacturerID = " + mi.ManufacturerID)); } // Supplier filter SupplierInfo si = SupplierInfoProvider.GetSupplierInfo(Supplier, CurrentSiteName); si = si ?? SupplierInfoProvider.GetSupplierInfo(Supplier, null); if (si != null) { where = SqlHelper.AddWhereCondition(where, GetColumnWhereCondition("SKUSupplierID", "SKUSupplierID = " + si.SupplierID)); } // Needs shipping filter if (!string.IsNullOrEmpty(NeedsShipping) && (NeedsShipping != FILTER_ALL)) { if (NeedsShipping == NEEDS_SHIPPING_YES) { where = SqlHelper.AddWhereCondition(where, GetColumnWhereCondition("SKUNeedsShipping", "SKUNeedsShipping = 1")); } else if (NeedsShipping == NEEDS_SHIPPING_NO) { where = SqlHelper.AddWhereCondition(where, GetColumnWhereCondition("SKUNeedsShipping", "(SKUNeedsShipping = 0) OR (SKUNeedsShipping IS NULL)")); } } // Price from filter if (PriceFrom > 0) { where = SqlHelper.AddWhereCondition(where, "SKUPrice >= " + PriceFrom); } // Price to filter if (PriceTo > 0) { where = SqlHelper.AddWhereCondition(where, "SKUPrice <= " + PriceTo); } // Public status filter PublicStatusInfo psi = PublicStatusInfoProvider.GetPublicStatusInfo(PublicStatus, CurrentSiteName); if (psi != null) { where = SqlHelper.AddWhereCondition(where, GetColumnWhereCondition("SKUPublicStatusID", "SKUPublicStatusID = " + psi.PublicStatusID)); } // Internal status filter InternalStatusInfo isi = InternalStatusInfoProvider.GetInternalStatusInfo(InternalStatus, CurrentSiteName); if (isi != null) { where = SqlHelper.AddWhereCondition(where, GetColumnWhereCondition("SKUInternalStatusID", "SKUInternalStatusID = " + isi.InternalStatusID)); } // Allow for sale filter if (!string.IsNullOrEmpty(AllowForSale) && (AllowForSale != FILTER_ALL)) { if (AllowForSale == ALLOW_FOR_SALE_YES) { where = SqlHelper.AddWhereCondition(where, "SKUEnabled = 1"); } else if (AllowForSale == ALLOW_FOR_SALE_NO) { where = SqlHelper.AddWhereCondition(where, "(SKUEnabled = 0) OR (SKUEnabled IS NULL)"); } } // Available items filter if (!string.IsNullOrEmpty(AvailableItems)) { int value = ValidationHelper.GetInteger(AvailableItems, int.MaxValue); where = SqlHelper.AddWhereCondition(where, "SKUAvailableItems <= " + value); } // Needs to be reordered filter if (NeedsToBeReordered) { where = SqlHelper.AddWhereCondition(where, "((SKUReorderAt IS NULL) AND (SKUAvailableItems <= 0)) OR ((SKUReorderAt IS NOT NULL) AND (SKUAvailableItems <= SKUReorderAt))"); } return(where); }
protected void Page_Load(object sender, EventArgs e) { // Pagetitle this.CurrentMaster.Title.TitleText = GetString("InternalStatus_List.HeaderCaption"); this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_InternalStatus/object.png"); this.CurrentMaster.Title.HelpTopicName = "internal_status_list"; this.CurrentMaster.Title.HelpName = "helpTopic"; // New item link string[,] actions = new string[2, 9]; actions[0, 0] = HeaderActions.TYPE_HYPERLINK; actions[0, 1] = GetString("InternalStatus_List.NewItemCaption"); actions[0, 2] = null; actions[0, 3] = ResolveUrl("InternalStatus_Edit.aspx?siteId=" + SiteID); actions[0, 4] = null; actions[0, 5] = GetImageUrl("Objects/Ecommerce_InternalStatus/add.png"); // Show copy from global link when not configuring global statuses. if (ConfiguredSiteID != 0) { // Show "Copy from global" link only if there is at least one global status DataSet ds = InternalStatusInfoProvider.GetInternalStatuses("InternalStatusSiteID IS NULL", null, 1, "InternalStatusSiteID"); if (!DataHelper.DataSourceIsEmpty(ds)) { actions[1, 0] = HeaderActions.TYPE_SAVEBUTTON; actions[1, 1] = GetString("general.copyfromglobal"); actions[1, 2] = "return ConfirmCopyFromGlobal();"; actions[1, 3] = null; actions[1, 4] = null; actions[1, 5] = GetImageUrl("Objects/Ecommerce_InternalStatus/fromglobal.png"); actions[1, 6] = "copyFromGlobal"; actions[1, 7] = String.Empty; actions[1, 8] = true.ToString(); // Register javascript to confirm generate string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmInternalStatusFromGlobal")) + ");}"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script)); } } this.CurrentMaster.HeaderActions.Actions = actions; this.CurrentMaster.HeaderActions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed); gridElem.OnAction += new OnActionEventHandler(gridElem_OnAction); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); gridElem.ZeroRowsText = GetString("general.nodatafound"); // Configuring global records if (ConfiguredSiteID == 0) { // Select only global records gridElem.WhereCondition = "InternalStatusSiteID IS NULL"; // Show "using global settings" info message only if showing global store settings if (SiteID != 0) { lblGlobalInfo.Visible = true; lblGlobalInfo.Text = GetString("com.UsingGlobalSettings"); } } else { // Select only site-specific records gridElem.WhereCondition = "InternalStatusSiteID = " + ConfiguredSiteID; } }