protected void Page_Load(object sender, EventArgs e) { mTaxClassId = QueryHelper.GetInteger("objectid", 0); if (mTaxClassId > 0) { mTaxClassInfoObj = TaxClassInfoProvider.GetTaxClassInfo(mTaxClassId); EditedObject = mTaxClassInfoObj; if (mTaxClassInfoObj != null) { int editedSiteId = mTaxClassInfoObj.TaxClassSiteID; // Check object's site id CheckEditedObjectSiteID(editedSiteId); // Offer global products when allowed bool offerGlobalProducts; if (editedSiteId != 0) { offerGlobalProducts = ECommerceSettings.AllowGlobalProducts(editedSiteId); } // Configuring global products else { offerGlobalProducts = ECommerceSettings.AllowGlobalProducts(CurrentSiteName); } PreloadUniSelector(offerGlobalProducts); uniSelector.WhereCondition = GetSelectorWhereCondition(offerGlobalProducts); } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); filteredControl = FilteredControl as CMSUserControl; // Hide filter button, this filter has its own UniGrid grid = filteredControl as UniGrid; if (grid != null) { grid.HideFilterButton = true; } allowGlobalProducts = ECommerceSettings.AllowGlobalProducts(SiteContext.CurrentSiteName); // Display Global and site option if global products are allowed siteElem.ShowSiteAndGlobal = allowGlobalProducts; // Initialize controls if (!URLHelper.IsPostback()) { FillThreeStateDDL(ddlNeedsShipping); FillThreeStateDDL(ddlAllowForSale); FillDocumentTypesDDL(); ResetFilter(); } }
/// <summary> /// Indicates if exchange rate from global main currency is needed. /// </summary> protected bool IsFromGlobalRateNeeded() { string siteName = SiteInfoProvider.GetSiteName(ConfiguredSiteID); if ((ConfiguredSiteID == 0) || (ECommerceSettings.UseGlobalCurrencies(siteName))) { return(false); } string globalMainCode = CurrencyInfoProvider.GetMainCurrencyCode(0); string siteMainCode = CurrencyInfoProvider.GetMainCurrencyCode(ConfiguredSiteID); // Check whether main currencies are defined if (string.IsNullOrEmpty(siteMainCode) || string.IsNullOrEmpty(globalMainCode)) { return(false); } // Check whether global and site main currency are the same if (globalMainCode.ToLowerCSafe() == siteMainCode.ToLowerCSafe()) { return(false); } return(ECommerceSettings.AllowGlobalDiscountCoupons(siteName) || ECommerceSettings.AllowGlobalProductOptions(siteName) || ECommerceSettings.AllowGlobalProducts(siteName) || ECommerceSettings.AllowGlobalShippingOptions(siteName) || ECommerceSettings.UseGlobalCredit(siteName) || ECommerceSettings.UseGlobalTaxClasses(siteName)); }
/// <summary> /// Indicates if exchange rate from global main currency is needed. /// </summary> protected bool IsFromGlobalRateNeeded() { var siteId = ConfiguredSiteID; if ((siteId == 0) || (ECommerceSettings.UseGlobalCurrencies(siteId))) { return(false); } string globalMainCode = CurrencyInfoProvider.GetMainCurrencyCode(0); string siteMainCode = CurrencyInfoProvider.GetMainCurrencyCode(siteId); // Check whether main currencies are defined if (string.IsNullOrEmpty(siteMainCode) || string.IsNullOrEmpty(globalMainCode)) { return(false); } // Check whether global and site main currency are the same if (string.Equals(globalMainCode, siteMainCode, StringComparison.InvariantCultureIgnoreCase)) { return(false); } // Check if site has currency with same code as global main -> no need for global rate if (CurrencyInfoProvider.GetCurrenciesByCode(siteId).ContainsKey(globalMainCode)) { return(false); } return(ECommerceSettings.AllowGlobalProductOptions(siteId) || ECommerceSettings.AllowGlobalProducts(siteId) || ECommerceSettings.UseGlobalCredit(siteId) || ECommerceSettings.UseGlobalTaxClasses(siteId)); }
private string GetItemsWhereCondition() { // Exclude product options string where = "SKUOptionCategoryID IS NULL"; // Exclude bundle products where = SqlHelper.AddWhereCondition(where, String.Format("SKUProductType <> '{0}'", SKUProductTypeEnum.Bundle.ToStringRepresentation())); // Exclude donation products where = SqlHelper.AddWhereCondition(where, String.Format("SKUProductType <> '{0}'", SKUProductTypeEnum.Donation.ToStringRepresentation())); // Exclude edited product itself where = SqlHelper.AddWhereCondition(where, "SKUID <> " + SKUID); // Exclude variant parents where = SqlHelper.AddWhereCondition(where, "SKUID NOT IN (SELECT SKUParentSKUID FROM COM_SKU WHERE SKUParentSKUID IS NOT NULL)"); // If bundle is global if (SiteID == 0) { // Include global products where = SqlHelper.AddWhereCondition(where, "SKUSiteID IS NULL"); } else { // If global products are allowed on this site if (ECommerceSettings.AllowGlobalProducts(SiteID)) { // Include global and site products where = SqlHelper.AddWhereCondition(where, String.Format("(SKUSiteID IS NULL) OR (SKUSiteID = {0})", SiteID)); } else { // Include site products where = SqlHelper.AddWhereCondition(where, "SKUSiteID = " + SiteID); } } // Include only enabled products where = SqlHelper.AddWhereCondition(where, "SKUEnabled = 1"); // Include currently selected items if (!string.IsNullOrEmpty(Items)) { // Perform validation of items IDs separated by ';' string[] idsAsString = Items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); int[] idsAsInt = ValidationHelper.GetIntegers(idsAsString, 0); // Separates IDs with ',' for use in SQL query string idsQuery = TextHelper.Join(",", idsAsInt); where = SqlHelper.AddWhereCondition(where, String.Format("SKUID IN ({0})", idsQuery), "OR"); } return(where); }
protected override void OnPreInit(EventArgs e) { // Get customer ID CustomerID = QueryHelper.GetInteger("customerid", 0); // Check whether global products are allowed allowGlobalProducts = ECommerceSettings.AllowGlobalProducts(CMSContext.CurrentSiteName); base.OnPreInit(e); }
private string GetItemsWhereCondition() { string where = null; // Exclude product options where = SqlHelperClass.AddWhereCondition(where, "SKUOptionCategoryID IS NULL"); // Exclude bundle products where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUProductType <> '{0}'", SKUInfoProvider.GetSKUProductTypeString(SKUProductTypeEnum.Bundle))); // Exclude donation products where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUProductType <> '{0}'", SKUInfoProvider.GetSKUProductTypeString(SKUProductTypeEnum.Donation))); // Exclude edited product itself where = SqlHelperClass.AddWhereCondition(where, "SKUID <> " + SKUID); // If bundle is global if (SiteID == 0) { // Inlcude global products where = SqlHelperClass.AddWhereCondition(where, "SKUSiteID IS NULL"); } else { // If global products are allowed on this site if (ECommerceSettings.AllowGlobalProducts(SiteInfoProvider.GetSiteName(SiteID))) { // Include global and site products where = SqlHelperClass.AddWhereCondition(where, String.Format("(SKUSiteID IS NULL) OR (SKUSiteID = {0})", SiteID)); } else { // Include site products where = SqlHelperClass.AddWhereCondition(where, "SKUSiteID = " + SiteID); } } // Include only enabled products where = SqlHelperClass.AddWhereCondition(where, "SKUEnabled = 1"); // Include only products from user's departments if (!ECommerceContext.IsUserAuthorizedForPermission("AccessAllDepartments")) { where = SqlHelperClass.AddWhereCondition(where, String.Format("(SKUDepartmentID IN (SELECT DepartmentID FROM COM_UserDepartment WHERE UserID = {0}) OR (SKUDepartmentID IS NULL))", CMSContext.CurrentUser.UserID)); } // Include currently selected items if (!string.IsNullOrEmpty(Items)) { where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUID IN ({0})", Items.Replace(';', ',')), "OR"); } return(where); }
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; } } }
/// <summary> /// Creates where condition for product selector. /// </summary> protected string GetWhereCondition() { // Select nothing string where = "(1=0)"; if (mDiscountCouponInfoObj != null) { string siteName = SiteInfoProvider.GetSiteName(mDiscountCouponInfoObj.DiscountCouponSiteID); // Offer global products for global coupons or in case they are allowed if (mDiscountCouponInfoObj.IsGlobal || ECommerceSettings.AllowGlobalProducts(siteName)) { where = SqlHelperClass.AddWhereCondition(where, "SKUSiteID IS NULL", "OR"); } // Offer site product only for site coupons if (!mDiscountCouponInfoObj.IsGlobal) { where = SqlHelperClass.AddWhereCondition(where, "SKUSiteID = " + mDiscountCouponInfoObj.DiscountCouponSiteID, "OR"); } } where = SqlHelperClass.AddWhereCondition(where, "(SKUEnabled = 1) AND (SKUProductType != 'DONATION')"); // Include only products from user's departments if (!ECommerceContext.IsUserAuthorizedForPermission("AccessAllDepartments")) { where = SqlHelperClass.AddWhereCondition(where, String.Format("(SKUDepartmentID IN (SELECT DepartmentID FROM COM_UserDepartment WHERE UserID = {0}) OR (SKUDepartmentID IS NULL))", CMSContext.CurrentUser.UserID)); } // Include selected values if (!string.IsNullOrEmpty(mCurrentValues)) { string[] skuIds = mCurrentValues.Split(';'); int[] intSkuIds = ValidationHelper.GetIntegers(skuIds, 0); where = SqlHelperClass.AddWhereCondition(where, SqlHelperClass.GetWhereCondition("SKUID", intSkuIds), "OR"); } // Select only products - not product options where = SqlHelperClass.AddWhereCondition(where, "SKUOptionCategoryID IS NULL"); return(where); }
/// <summary> /// Creates where condition for product selector. /// </summary> protected string GetWhereCondition() { // Select nothing string where = "(1=0)"; if (mDiscountCouponInfoObj != null) { // Offer global products for global coupons or in case they are allowed if (mDiscountCouponInfoObj.IsGlobal || ECommerceSettings.AllowGlobalProducts(mDiscountCouponInfoObj.DiscountCouponSiteID)) { where = SqlHelper.AddWhereCondition(where, "SKUSiteID IS NULL", "OR"); } // Offer site product only for site coupons if (!mDiscountCouponInfoObj.IsGlobal) { where = SqlHelper.AddWhereCondition(where, "SKUSiteID = " + mDiscountCouponInfoObj.DiscountCouponSiteID, "OR"); } } where = SqlHelper.AddWhereCondition(where, "(SKUEnabled = 1) AND (SKUProductType != 'DONATION')"); // Include selected values if (!string.IsNullOrEmpty(mCurrentValues)) { string[] skuIds = mCurrentValues.Split(';'); int[] intSkuIds = ValidationHelper.GetIntegers(skuIds, 0); where = SqlHelper.AddWhereCondition(where, SqlHelper.GetWhereCondition("SKUID", intSkuIds.AsEnumerable()), "OR"); } // Select only products - not product options where = SqlHelper.AddWhereCondition(where, "SKUOptionCategoryID IS NULL"); return(where); }
protected override void OnInit(EventArgs e) { base.OnInit(e); SKUInfo sku = null; if (Node != null) { sku = SKUInfoProvider.GetSKUInfo(Node.NodeSKUID); } if ((sku != null) && (sku.SKUSiteID != CMSContext.CurrentSiteID) && ((sku.SKUSiteID != 0) || !ECommerceSettings.AllowGlobalProducts(CMSContext.CurrentSiteName))) { EditedObject = null; } productEditElem.ProductSaved += productEditElem_ProductSaved; }
/// <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> /// Displays or hides columns based on VisibleColumns property. /// </summary> private void DisplayColumns() { string[] visibleColumns = VisibleColumns.Split('|'); // Hide all first foreach (var item in gridElem.NamedColumns.Values) { item.Visible = false; } // Show columns that should be visible foreach (var item in visibleColumns) { string key = null; switch (item) { case COLUMN_NUMBER: key = "Number"; break; case COLUMN_PRICE: key = "Price"; break; case COLUMN_DEPARTMENT: key = "Department"; break; case COLUMN_MANUFACTURER: key = "Manufacturer"; break; case COLUMN_SUPPLIER: key = "Supplier"; break; case COLUMN_PUBLIC_STATUS: key = "PublicStatus"; break; case COLUMN_INTERNAL_STATUS: key = "InternalStatus"; break; case COLUMN_REORDER_AT: key = "ReorderAt"; break; case COLUMN_AVAILABLE_ITEMS: key = "AvailableItems"; break; case COLUMN_ITEMS_TO_BE_REORDERED: key = "ItemsToBeReordered"; break; case COLUMN_ALLOW_FOR_SALE: key = "AllowForSale"; break; } // Show column if (key != null) { gridElem.NamedColumns[key].Visible = true; } } // Show option category column if not only product listed if (ProductType != PRODUCT_TYPE_PRODUCTS) { gridElem.NamedColumns["OptionCategory"].Visible = true; } // If global products are allowed, display column if (ECommerceSettings.AllowGlobalProducts(CMSContext.CurrentSiteName)) { gridElem.NamedColumns["Global"].Visible = true; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { currentUser = MembershipContext.AuthenticatedUser; if (AuthenticationHelper.IsAuthenticated()) { // Control initialization lblTitle.Text = GetString("Ecommerce.Wishlist.Title"); btnContinue.Text = GetString("Ecommerce.Wishlist.btnContinue"); mSKUId = QueryHelper.GetInteger("productID", 0); currentSite = SiteContext.CurrentSite; // Set repeater transformation repeater.TransformationName = TransformationName; repeater.ItemSeparator = ItemSeparator; if ((currentUser != null) && (currentSite != null)) { if ((!RequestHelper.IsPostBack()) && (mSKUId > 0)) { int addSKUId = mSKUId; // Get added SKU info object from database SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(addSKUId); if (skuObj != null) { // Can not add option as a product if (skuObj.SKUOptionCategoryID > 0) { addSKUId = 0; } else if (!skuObj.IsGlobal) { // Site specific product must belong to the current site if (skuObj.SKUSiteID != currentSite.SiteID) { addSKUId = 0; } } else { // Global products must be allowed when adding global product if (!ECommerceSettings.AllowGlobalProducts(currentSite.SiteName)) { addSKUId = 0; } } } if (addSKUId > 0) { // Add specified product to the user's wishlist WishlistItemInfoProvider.AddSKUToWishlist(currentUser.UserID, addSKUId, currentSite.SiteID); LogProductAddedToWLActivity(addSKUId, ResHelper.LocalizeString(skuObj.SKUName)); } } if (mSKUId > 0) { // Remove product parameter from URL to avoid adding it next time string newUrl = URLHelper.RemoveParameterFromUrl(RequestContext.CurrentURL, "productID"); URLHelper.Redirect(newUrl); } } } else { // Hide control if current user is not authenticated Visible = false; } } }
/// <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); }
/// <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); }
private string GetItemsWhereCondition() { string where = null; // Exclude product options where = SqlHelperClass.AddWhereCondition(where, "SKUOptionCategoryID IS NULL"); // Exclude bundle products where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUProductType <> '{0}'", SKUInfoProvider.GetSKUProductTypeString(SKUProductTypeEnum.Bundle))); // Exclude donation products where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUProductType <> '{0}'", SKUInfoProvider.GetSKUProductTypeString(SKUProductTypeEnum.Donation))); // Exclude edited product itself where = SqlHelperClass.AddWhereCondition(where, "SKUID <> " + SKUID); // If bundle is global if (SiteID == 0) { // Inlcude global products where = SqlHelperClass.AddWhereCondition(where, "SKUSiteID IS NULL"); } else { // If global products are allowed on this site if (ECommerceSettings.AllowGlobalProducts(SiteInfoProvider.GetSiteName(SiteID))) { // Include global and site products where = SqlHelperClass.AddWhereCondition(where, String.Format("(SKUSiteID IS NULL) OR (SKUSiteID = {0})", SiteID)); } else { // Include site products where = SqlHelperClass.AddWhereCondition(where, "SKUSiteID = " + SiteID); } } // Include only enabled products where = SqlHelperClass.AddWhereCondition(where, "SKUEnabled = 1"); // Include only products from user's departments if (!ECommerceContext.IsUserAuthorizedForPermission("AccessAllDepartments")) { where = SqlHelperClass.AddWhereCondition(where, String.Format("(SKUDepartmentID IN (SELECT DepartmentID FROM COM_UserDepartment WHERE UserID = {0}) OR (SKUDepartmentID IS NULL))", CMSContext.CurrentUser.UserID)); } // Include currently selected items if (!string.IsNullOrEmpty(Items)) { // Perform validation of items IDs separated by ';' string[] idsAsString = Items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); int[] idsAsInt = ValidationHelper.GetIntegers(idsAsString, 0); // Separates IDs with ',' for use in SQL query string idsQuery = TextHelper.Join(",", idsAsInt); where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUID IN ({0})", idsQuery), "OR"); } return(where); }
protected override void OnInit(EventArgs e) { base.OnInit(e); CMSContentPage.CheckSecurity(); // Check module permissions if (!ECommerceContext.IsUserAuthorizedForPermission("ReadProducts")) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceRead OR ReadProducts"); } SKUInfo sku = null; if (Node != null) { sku = SKUInfoProvider.GetSKUInfo(Node.NodeSKUID); } if ((sku != null) && (sku.SKUSiteID != SiteContext.CurrentSiteID) && ((sku.SKUSiteID != 0) || !ECommerceSettings.AllowGlobalProducts(SiteContext.CurrentSiteName))) { EditedObject = null; } productEditElem.ProductSaved += productEditElem_ProductSaved; string action = QueryHelper.GetString("action", string.Empty).ToLowerCSafe(); if (action == "newculture") { // Ensure breadcrumb for new culture version of product EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: GetString("content.newcultureversiontitle")); } }
protected void Page_Load(object sender, EventArgs e) { // If bundle ID set if (this.BundleID != 0) { // Get selected products from database DataSet selectedProductsDataSet = BundleInfoProvider.GetBundles("BundleID = " + this.BundleID, "SKUID"); if (!DataHelper.DataSourceIsEmpty(selectedProductsDataSet)) { this.selectedProducts = TextHelper.Join(";", SqlHelperClass.GetStringValues(selectedProductsDataSet.Tables[0], "SKUID")); } } // If reload required if (this.ReloadRequired) { // Set selected products to selector this.productsUniSelector.Value = this.selectedProducts; } string where = null; // Exclude product options where = SqlHelperClass.AddWhereCondition(where, "SKUOptionCategoryID IS NULL"); // Exclude bundle products where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUProductType <> '{0}'", SKUInfoProvider.GetSKUProductTypeString(SKUProductTypeEnum.Bundle))); // Exclude donation products where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUProductType <> '{0}'", SKUInfoProvider.GetSKUProductTypeString(SKUProductTypeEnum.Donation))); // Exclude edited product itself where = SqlHelperClass.AddWhereCondition(where, "SKUID <> " + this.BundleID); // If bundle is global if (this.SiteID == 0) { // Inlcude global products where = SqlHelperClass.AddWhereCondition(where, "SKUSiteID IS NULL"); } else { // If global products are allowed on this site if (ECommerceSettings.AllowGlobalProducts(SiteInfoProvider.GetSiteName(this.SiteID))) { // Include global and site products where = SqlHelperClass.AddWhereCondition(where, String.Format("(SKUSiteID IS NULL) OR (SKUSiteID = {0})", this.SiteID)); } else { // Include site products where = SqlHelperClass.AddWhereCondition(where, "SKUSiteID = " + this.SiteID); } } // Include only enabled products where = SqlHelperClass.AddWhereCondition(where, "SKUEnabled = 1"); // Include only products from user's departments if (!ECommerceContext.IsUserAuthorizedForPermission("AccessAllDepartments")) { where = SqlHelperClass.AddWhereCondition(where, String.Format("(SKUDepartmentID IN (SELECT DepartmentID FROM COM_UserDepartment WHERE UserID = {0}) OR (SKUDepartmentID IS NULL))", CMSContext.CurrentUser.UserID)); } // Include currently selected products if (!string.IsNullOrEmpty(this.selectedProducts)) { where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUID IN ({0})", this.selectedProducts.Replace(';', ',')), "OR"); } this.productsUniSelector.WhereCondition = where; this.productsUniSelector.SelectionMode = SelectionModeEnum.Multiple; this.productsUniSelector.OnSelectionChanged += new EventHandler(productsUniSelector_OnSelectionChanged); this.productsUniSelector.StopProcessing = this.StopProcessing; }