Esempio n. 1
0
        protected void GoButton_Click(object sender, EventArgs e)
        {
            bool selectAll = AlwaysConvert.ToBool(SelectAll.Value, false);
            bool link      = AlwaysConvert.ToBool(GridActions.SelectedValue, false);

            if (selectAll)
            {
                BitFieldState   featured = (BitFieldState)Enum.Parse(typeof(BitFieldState), FeaturedFilter.SelectedValue);
                IList <Product> products = ProductDataSource.FindProducts(Name.Text.Trim(), SearchDescriptions.Checked, Sku.Text.Trim(), AlwaysConvert.ToInt(CategoriesList.SelectedValue), AlwaysConvert.ToInt(ManufacturerList.SelectedValue), AlwaysConvert.ToInt(VendorList.SelectedValue), featured, AlwaysConvert.ToInt(TaxCodeList.SelectedValue), AlwaysConvert.ToDecimal(FromPrice.Text), AlwaysConvert.ToDecimal(ToPrice.Text), OnlyDigitalGoods.Checked, OnlyGiftCertificates.Checked, OnlyKits.Checked, OnlySubscriptions.Checked, AlwaysConvert.ToInt(ProductGroups.SelectedValue));
                foreach (var product in products)
                {
                    SetFeatured(product.Id, link);
                }
            }
            else
            {
                int indexPeg = PG.PageSize * PG.PageIndex;

                foreach (GridViewRow row in PG.Rows)
                {
                    CheckBox selected = (CheckBox)PageHelper.RecursiveFindControl(row, "PID");
                    if ((selected != null) && selected.Checked)
                    {
                        int productId = (int)PG.DataKeys[row.DataItemIndex - indexPeg].Values[0];
                        SetFeatured(productId, link);
                    }
                }
            }

            PG.DataBind();
        }
        protected void ProductsDS_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            BitFieldState featured = OnlyFeatured.Checked ? BitFieldState.True : BitFieldState.Any;

            e.InputParameters["featured"] = featured;
            if (_DisplayCategorySearch)
            {
                e.InputParameters["categoryId"] = AlwaysConvert.ToInt(HiddenSelectedCategoryId.Value);
            }
            PG.Columns[1].Visible = ShowProductThumbnails.Checked;
        }
        protected void GoButton_Click(object sender, EventArgs e)
        {
            bool selectAll = AlwaysConvert.ToBool(SelectAll.Value, false);
            bool link      = AlwaysConvert.ToBool(GridActions.SelectedValue, false);

            if (selectAll)
            {
                BitFieldState featured = OnlyFeatured.Checked ? BitFieldState.True : BitFieldState.Any;
                BitFieldState status   = (BitFieldState)Enum.Parse(typeof(BitFieldState), ProductAssignment.SelectedValue);

                int categoryId = 0;
                if (!_DisplayCategorySearch)
                {
                    categoryId = AlwaysConvert.ToInt(CategoriesList.SelectedValue);
                }
                else
                {
                    categoryId = AlwaysConvert.ToInt(HiddenSelectedCategoryId.Value);
                }

                IList <Product> products = ProductDataSource.FindProducts(Name.Text.Trim(), SearchDescriptions.Checked, Sku.Text.Trim(), categoryId, AlwaysConvert.ToInt(ManufacturerList.SelectedValue), AlwaysConvert.ToInt(VendorList.SelectedValue), featured, AlwaysConvert.ToInt(TaxCodeList.SelectedValue), AlwaysConvert.ToDecimal(FromPrice.Text), AlwaysConvert.ToDecimal(ToPrice.Text), OnlyDigitalGoods.Checked, OnlyGiftCertificates.Checked, OnlyKits.Checked, OnlySubscriptions.Checked, AlwaysConvert.ToInt(ProductGroups.SelectedValue), AssignmentTable, AssignmentValue, status);
                foreach (var product in products)
                {
                    if (OnAssignProduct != null)
                    {
                        OnAssignProduct(this, new FindAssignProductEventArgs(product.Id, link));
                    }
                }
            }
            else
            {
                int indexPeg = PG.PageSize * PG.PageIndex;

                foreach (GridViewRow row in PG.Rows)
                {
                    CheckBox selected = (CheckBox)PageHelper.RecursiveFindControl(row, "PID");
                    if ((selected != null) && selected.Checked)
                    {
                        int productId = (int)PG.DataKeys[row.DataItemIndex - indexPeg].Values[0];
                        if (OnAssignProduct != null)
                        {
                            OnAssignProduct(this, new FindAssignProductEventArgs(productId, link));
                        }
                    }
                }
            }

            PG.DataBind();
        }
        protected void ProductsDS_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            BitFieldState featured = OnlyFeatured.Checked ? BitFieldState.True : BitFieldState.Any;
            BitFieldState status   = (BitFieldState)Enum.Parse(typeof(BitFieldState), ProductAssignment.SelectedValue);

            e.InputParameters["featured"]         = featured;
            e.InputParameters["assignmentTable"]  = this.AssignmentTable;
            e.InputParameters["assignmentValue"]  = this.AssignmentValue;
            e.InputParameters["assignmentStatus"] = status;
            if (_DisplayCategorySearch)
            {
                e.InputParameters["categoryId"] = AlwaysConvert.ToInt(HiddenSelectedCategoryId.Value);
            }
            PG.Columns[1].Visible = ShowProductThumbnails.Checked;
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the index of the specified scriptlet in this collection
        /// </summary>
        /// <param name="identifier">Identifier of the scriptlet to find index of</param>
        /// <param name="scriptletType">Type of the scriptlet to find index of</param>
        /// <param name="isCustom">Indicates whether this a custom scriptlet or default scriptlet or any of the two</param>
        /// <returns>Index of the specified scriptlet in this collection</returns>
        public int IndexOf(string identifier, ScriptletType scriptletType, BitFieldState isCustom)
        {
            bool custom = (isCustom == BitFieldState.True);

            for (int i = 0; i < this.Count; i++)
            {
                Scriptlet s = this[i];
                if ((identifier == s.Identifier) && (scriptletType == s.ScriptletType))
                {
                    if ((isCustom == BitFieldState.Any) || (custom == s.IsCustom))
                    {
                        return(i);
                    }
                }
            }
            return(-1);
        }
        public IList <Product> GetSelectedProducts()
        {
            bool            selectAll = AlwaysConvert.ToBool(SelectAll.Value, false);
            bool            link      = AlwaysConvert.ToBool(GridActions.SelectedValue, false);
            IList <Product> products  = new List <Product>();

            if (selectAll)
            {
                BitFieldState featured   = OnlyFeatured.Checked ? BitFieldState.True : BitFieldState.Any;
                BitFieldState status     = (BitFieldState)Enum.Parse(typeof(BitFieldState), ProductAssignment.SelectedValue);
                int           categoryId = 0;
                if (!_DisplayCategorySearch)
                {
                    categoryId = AlwaysConvert.ToInt(CategoriesList.SelectedValue);
                }
                else
                {
                    categoryId = AlwaysConvert.ToInt(HiddenSelectedCategoryId.Value);
                }
                products = ProductDataSource.FindProducts(Name.Text.Trim(), SearchDescriptions.Checked, Sku.Text.Trim(), categoryId, AlwaysConvert.ToInt(ManufacturerList.SelectedValue), AlwaysConvert.ToInt(VendorList.SelectedValue), featured, AlwaysConvert.ToInt(TaxCodeList.SelectedValue), AlwaysConvert.ToDecimal(FromPrice.Text), AlwaysConvert.ToDecimal(ToPrice.Text), OnlyDigitalGoods.Checked, OnlyGiftCertificates.Checked, OnlyKits.Checked, OnlySubscriptions.Checked, AlwaysConvert.ToInt(ProductGroups.SelectedValue), AssignmentTable, AssignmentValue, status);
            }
            else
            {
                int indexPeg = PG.PageSize * PG.PageIndex;

                foreach (GridViewRow row in PG.Rows)
                {
                    CheckBox selected = (CheckBox)PageHelper.RecursiveFindControl(row, "PID");
                    if ((selected != null) && selected.Checked)
                    {
                        int dataItemIndex = row.DataItemIndex;
                        dataItemIndex = (dataItemIndex - (PG.PageSize * PG.PageIndex));
                        int productId = (int)PG.DataKeys[dataItemIndex].Value;
                        products.Add(ProductDataSource.Load(productId));
                    }
                }
            }

            return(products);
        }
Esempio n. 7
0
        /// <summary>
        /// Loads this scriptlet object for given scriptlet identifier and scriptlet type
        /// </summary>
        /// <param name="themeId">Name/Identifier of the theme</param>
        /// <param name="identifier">criptlet identifier</param>
        /// <param name="scriptletType">The scriptlet type</param>
        /// <param name="custom">Is it a custom scriptlet, default script or any of the two</param>
        /// <returns></returns>
        public bool Load(string themeId, string identifier, ScriptletType scriptletType, BitFieldState custom)
        {
            //VALIDATE INPUT PARAMETERS
            if (string.IsNullOrEmpty(identifier))
            {
                throw new ArgumentNullException("Identifier must be specified.", "identifier");
            }
            identifier = identifierRegex.Replace(identifier, string.Empty);
            if (scriptletType == ScriptletType.Unspecified)
            {
                throw new ArgumentOutOfRangeException("Scriptlet type must be specified.", "scriptletType");
            }
            //DETERMINE THE FILE PATH TO LOAD
            string baseDir = _BaseDir;
            string filePath;
            bool   isCustom = false;

            switch (custom)
            {
            case BitFieldState.Any:
                filePath = GetFilePath(themeId, identifier, scriptletType, true);
                if (File.Exists(Path.Combine(baseDir, filePath)))
                {
                    isCustom = true;
                }
                else
                {
                    filePath = GetFilePath(identifier, scriptletType, false);
                }
                break;

            case BitFieldState.True:
                filePath = GetFilePath(themeId, identifier, scriptletType, true);
                isCustom = true;
                break;

            default:
                filePath = GetFilePath(themeId, identifier, scriptletType, false);
                break;
            }
            //LOAD THE FILE
            FileInfo fi = new FileInfo(Path.Combine(baseDir, filePath));

            if (fi.Exists)
            {
                this.ThemeId         = themeId;
                this.Identifier      = identifier;
                _LoadedIdentifier    = identifier;
                this.ScriptletType   = scriptletType;
                _LoadedScriptletType = scriptletType;
                this.IsCustom        = isCustom;
                _LoadedIsCustom      = isCustom;
                try
                {
                    bool parsed = this.ParseScriptletFile(File.ReadAllText(fi.FullName));
                    if (parsed)
                    {
                        this.IsDirty = false;
                        return(true);
                    }
                    return(false);
                }
                catch (Exception ex)
                {
                    Logger.Warn("Could not read scriptlet file '" + filePath + "'.", ex);
                }
            }
            return(false);
        }
        protected int CountSubscriptions(object dataItem, BitFieldState active)
        {
            SubscriptionPlan subscriptionPlan = (SubscriptionPlan)dataItem;

            return(SubscriptionDataSource.SearchCount(subscriptionPlan.Product.Id, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, DateTime.MinValue, DateTime.MaxValue, active));
        }
        /// <summary>
        /// Loads a Scriptlet object with given identifier and type from the database
        /// </summary>
        /// <param name="themeId">Name/Identifier of the theme</param>
        /// <param name="identifier">Identifier of Scriptlet to load</param>
        /// <param name="scriptletType">Type of of Scriptlet to load</param>
        /// <param name="custom">Is the Scriptlet to be loaded a custom scriptlet?</param>
        /// <param name="useCache">If <b>true</b> tries to load the object from cache first</param>
        /// <returns>The Scriptlet object loaded</returns>
        public static Scriptlet Load(string themeId, string identifier, ScriptletType scriptletType, BitFieldState custom, bool useCache)
        {
            if (useCache)
            {
                ScriptletCollection scriptlets = CacheLoad(themeId);
                int index = scriptlets.IndexOf(identifier, scriptletType, custom);
                if (index > -1)
                {
                    return(scriptlets[index]);
                }
                return(null);
            }
            //(DO NOT USE CACHE, LOAD FOR THE NAME)
            Scriptlet s = new Scriptlet();

            if (s.Load(themeId, identifier, scriptletType, custom))
            {
                return(s);
            }
            return(null);
        }