コード例 #1
0
    public string GetShoppingFilter()
    {
        AspxCommonInfo aspxCommonObj = new AspxCommonInfo();

        aspxCommonObj.StoreID     = StoreID;
        aspxCommonObj.PortalID    = PortalID;
        aspxCommonObj.UserName    = UserName;
        aspxCommonObj.CultureName = CultureName;
        bool               isByCategory           = false;
        string             aspxTemplateFolderPath = ResolveUrl("~/") + "Templates/" + TemplateName;
        List <Filter>      lstFilter      = AspxFilterController.GetShoppingFilter(aspxCommonObj, Categorykey, isByCategory);
        string             pId            = "";
        List <string>      attrID         = new List <string>();
        List <string>      attrValue      = new List <string>();
        string             attrName       = "";
        StringBuilder      elem           = new StringBuilder();
        StringBuilder      scriptExecute  = new StringBuilder();
        List <int>         catIdsArr      = new List <int>();
        StoreSettingConfig ssc            = new StoreSettingConfig();
        float              additionalCCVR = float.Parse(ssc.GetStoreSettingsByKey(StoreSetting.AdditionalCVR, StoreID, PortalID, CultureName));
        string             MainCurrency   = ssc.GetStoreSettingsByKey(StoreSetting.MainCurrency, StoreID, PortalID, CultureName);

        if (HttpContext.Current.Session["CurrencyRate"] != null)
        {
            if (Session["CurrencyCode"].ToString() != MainCurrency)
            {
                float rate1 = float.Parse(Session["CurrencyRate"].ToString());
                rate = (rate1 + (rate1 * additionalCCVR / 100));
            }
            else
            {
                rate = float.Parse(Session["CurrencyRate"].ToString());
            }
        }

        if (lstFilter != null && lstFilter.Count > 0)
        {
            int currentAttributeID = 0;
            scriptExecute.Append("$('#divShopFilter').show();$('.divRange').show();");

            foreach (Filter value in lstFilter)
            {
                if (catIdsArr.IndexOf(value.ItemID) == -1)
                {
                    catIdsArr.Add(value.ItemID);
                    catIds += value.ItemID + ",";
                }
                if (Int32.Parse(value.AttributeID) != 8 && Int32.Parse(value.AttributeID) > 40)
                {
                    if (attrID.IndexOf(value.AttributeID) == -1)
                    {
                        attrID.Add(value.AttributeID);
                        if (attrID.IndexOf(value.AttributeID) != -1)
                        {
                            if (Int32.Parse(value.AttributeID) != currentAttributeID && currentAttributeID > 0)
                            {
                                elem.Append("</ul></div></div></div></div></div>");
                            }
                            currentAttributeID = Int32.Parse(value.AttributeID);
                        }
                        elem.Append("<div value=" + value.AttributeID + " class=\"cssClasscategorgy\"><div class=\"divTitle\"><b><label style=\"color:#006699\">" + value.AttributeName + "</label></b><img align=\"right\" src=\"" + aspxTemplateFolderPath + "/images/arrow_up.png\"/></div> <div id=\"scrollbar3\" class=\"cssClassScroll\"> <div class=\"scrollbar\"> <div class=\"track\"><div class=\"thumb\" style=\"display:none\"> <div class=\"end\">  </div> </div>  </div>  </div><div class=\"viewport\"><div class=\"overview\"><div class=" + "divContent" + value.AttributeID + "><ul>");
                        attrValue = new List <string>();

                        //$(".filter").append(elem);
                        elem.Append("<li><label><input class= \"chkFilter\" type=\"checkbox\" name=\"" + value.AttributeValue + "\" ids=\"" + value.ItemID + "\" value=\"" + value.AttributeID + "\"/> " + value.AttributeValue + "<span id=\"count\"></span></label></li>");
                        //elem.Append("</ul></div></div></div></div></div>");
                        attrValue.Add(value.AttributeValue);
                    }
                    else
                    {
                        if (attrID.IndexOf(value.AttributeID) != -1)
                        {
                            if (Int32.Parse(value.AttributeID) != currentAttributeID && currentAttributeID > 0)
                            {
                                elem.Append("</ul></div></div></div></div></div>");
                            }
                            currentAttributeID = Int32.Parse(value.AttributeID);
                        }
                        if (attrValue.IndexOf(value.AttributeValue) == -1)
                        {
                            //elem = '';
                            elem.Append("<li><label><input class=\"chkFilter\" type=\"checkbox\" name=\"" + value.AttributeValue + "\" ids=\"" + value.ItemID + "\" value=\"" + value.AttributeID + "\"/> " + value.AttributeValue + "<span id=\"count\"></span></label></li>");
                            //$(".filter").find('div[value=' + value.AttributeID + ']').find('ul').append(elem);
                            attrValue.Add(value.AttributeValue);
                        }
                        else
                        {
                            scriptExecute.Append("var ids = $('.filter').find('input[type=checkbox][value=" + value.AttributeID + "][name=" + value.AttributeValue + "]').attr('ids');");
                            scriptExecute.Append("ids += ',' +" + value.ItemID + ";");
                            scriptExecute.Append("$('.filter').find('input[type=checkbox][value=" + value.AttributeID + "][name=" + value.AttributeValue + "]').attr('ids', ids);");
                        }
                    }


                    // elem.Append("</ul></div></div></div></div></div>");
                }

                else if (Int32.Parse(value.AttributeID) == 8)
                {
                    arrPrice.Add(value);
                    Page.ClientScript.RegisterArrayDeclaration("arrPrice", JSONHelper.Serialize(value.AttributeValue + "@" + value.ItemID));
                    if (float.Parse(value.AttributeValue) > maxPrice)
                    {
                        maxPrice = float.Parse(value.AttributeValue);
                    }
                    if (float.Parse(value.AttributeValue) < minPrice || minPrice == 0)
                    {
                        minPrice = float.Parse(value.AttributeValue);
                    }
                }
            }
            if (attrID.Count > 0)
            {
                elem.Append("</ul></div></div></div></div></div>");
            }
            float interval = (maxPrice - minPrice) / 4;
            elem.Append("<div value=\"8\" class=\"cssClassbrowseprice\">");
            elem.Append("<div class=\"divTitle\"><b><label style=\"color:#006699\">" + getLocale("Price") + "</label></b><img align=\"right\" src=\"" + aspxTemplateFolderPath + "/images/arrow_up.png\"/></div><div class=\"divContent8\"><ul>");
            if (arrPrice.Count > 1)
            {
                elem.Append("<li><a id=\"f1\" href=\"#\" ids=\"\"  minprice=" + GetPriceData(minPrice, 0, interval) + " maxprice=" + GetPriceData(minPrice, 1, interval) + ">" + "<span class=\"cssClassFormatCurrency\">" + minPrice * rate + "</span>" + " - " + "<span class=\"cssClassFormatCurrency\">" + GetPriceData(minPrice, 1, interval) * rate + "</span>" + "<span id=\"count\"></span></a></li>");
                elem.Append("<li><a id=\"f2\" href=\"#\" ids=\"\" minprice=" + GetPriceData(minPrice + float.Parse("0.01"), 1, interval) + " maxprice=" + GetPriceData(minPrice, 2, interval) + ">" + "<span class=\"cssClassFormatCurrency\">" + GetPriceData(minPrice * rate + float.Parse("0.01"), 1, interval * rate) + "</span>" + " - " + "<span class=\"cssClassFormatCurrency\">" + GetPriceData(minPrice, 2, interval) * rate + "</span>" + "<span id=\"count\"></span></a></li>");
                elem.Append("<li><a id=\"f3\" href=\"#\" ids=\"\" minprice=" + GetPriceData(minPrice + float.Parse("0.01"), 2, interval) + " maxprice=" + GetPriceData(minPrice, 3, interval) + ">" + "<span class=\"cssClassFormatCurrency\">" + GetPriceData(minPrice * rate + float.Parse("0.01"), 2, interval * rate) + "</span>" + " - " + "<span class=\"cssClassFormatCurrency\">" + GetPriceData(minPrice, 3, interval) * rate + "</span>" + "<span id=\"count\"></span></a></li>");
                elem.Append("<li><a id=\"f4\" href=\"#\" ids=\"\" minprice=" + GetPriceData(minPrice + float.Parse("0.01"), 3, interval) + " maxprice=" + maxPrice + ">" + "<span class=\"cssClassFormatCurrency\">" + GetPriceData(minPrice * rate + float.Parse("0.01"), 3, interval * rate) + "</span>" + " - " + "<span class=\"cssClassFormatCurrency\">" + maxPrice * rate + "</span>" + "<span id=\"count\"></span></a></li>");
            }
            if (arrPrice.Count == 1)
            {
                elem.Append("<li><a id=\"f1\" href=\"#\" ids=\",\"  minprice=" + GetPriceData(minPrice, 0, interval) + " maxprice=" + GetPriceData(minPrice, 1, interval) + ">" + "<span class=\"cssClassFormatCurrency\">" + minPrice * rate + "</span>" + "<span id=\"count\"></span></a></li>");
                minPrice = 0;
            }

            elem.Append("</ul></div>");
            elem.Append("<div class=\"divRange\"><div id=\"slider-range\"></div></div></div>");
            foreach (Filter value in arrPrice)
            {
                idsByPrice += value.ItemID + ",";
                if (float.Parse(value.AttributeValue) >= GetPriceData(minPrice, 0, interval) && float.Parse(value.AttributeValue) <= GetPriceData(minPrice, 1, interval))
                {
                    scriptExecute.Append("var ids = $('.filter').find('div[value=" + value.AttributeID + "]').find('#f1').attr('ids');");
                    scriptExecute.Append("ids += ','+" + value.ItemID + ";");
                    scriptExecute.Append("$('.filter').find('div[value=" + value.AttributeID + "]').find('#f1').attr('ids', ids);");
                }
                else if (float.Parse(value.AttributeValue) >= GetPriceData(minPrice + float.Parse("0.01"), 1, interval) && float.Parse(value.AttributeValue) <= GetPriceData(minPrice, 2, interval))
                {
                    scriptExecute.Append("var ids = $('.filter').find('div[value=" + value.AttributeID + "]').find('#f2').attr('ids');");
                    scriptExecute.Append("ids += ','+" + value.ItemID + ";");
                    scriptExecute.Append("$('.filter').find('div[value=" + value.AttributeID + "]').find('#f2').attr('ids', ids);");
                }
                else if (float.Parse(value.AttributeValue) >= GetPriceData(minPrice + float.Parse("0.01"), 2, interval) && float.Parse(value.AttributeValue) <= GetPriceData(minPrice, 3, interval))
                {
                    scriptExecute.Append("var ids = $('.filter').find('div[value=" + value.AttributeID + "]').find('#f3').attr('ids');");
                    scriptExecute.Append("ids += ','+" + value.ItemID + ";");
                    scriptExecute.Append("$('.filter').find('div[value=" + value.AttributeID + "]').find('#f3').attr('ids', ids);");
                }
                else if (float.Parse(value.AttributeValue) >= GetPriceData(minPrice + float.Parse("0.01"), 3, interval) && float.Parse(value.AttributeValue) <= maxPrice)
                {
                    scriptExecute.Append("var ids = $('.filter').find('div[value=" + value.AttributeID + "]').find('#f4').attr('ids');");
                    scriptExecute.Append("ids += ','+" + value.ItemID + ";");
                    scriptExecute.Append("$('.filter').find('div[value=" + value.AttributeID + "]').find('#f4').attr('ids', ids);");
                }
            }


            scriptExecute.Append(" $('.chkFilter').each(function() { var itemArray = []; itemArray = $(this).attr('ids').split(','); $(this).parents('li').find('#count').text(' (' + itemArray.length + ')'); }); $('.filter').find('div[value=8]').find('ul').find('li').each(function() { var itemArray = []; if ($(this).find('a').attr('ids').indexOf(',') != -1) { var anchorItem = $(this).find('a').attr('ids').substring(1, $(this).find('a').attr('ids').length); itemArray = anchorItem.split(','); } $(this).find('#count').text(' (' + itemArray.length + ')'); }); ");
            scriptExecute.Append(
                "$('#amount').html('<span class=\"cssClassFormatCurrency\">" + minPrice * rate + "</span>' +' - ' + '<span class=\"cssClassFormatCurrency\">" + maxPrice * rate + "</span>');");
            scriptExecute.Append(
                "$('.cssClassFormatCurrency').formatCurrency({ colorize: true, region: '' + region + '' });");

            string script = GetStringScript(scriptExecute.ToString());
            elem.Append(script);
            return(elem.ToString());
        }
        return("");
    }
コード例 #2
0
    public string GetShoppingFilter(AspxCommonInfo aspxCommonObj)
    {
        bool          isByCategory           = false;
        string        aspxTemplateFolderPath = ResolveUrl("~/") + "Templates/" + TemplateName;
        List <Filter> lstFilter = AspxFilterController.GetShoppingFilter(aspxCommonObj, Categorykey, isByCategory);
        List <string> attrID    = new List <string>();
        List <string> attrValue = new List <string>();
        StringBuilder elem      = new StringBuilder();

        //StringBuilder scriptExecute = new StringBuilder();

        if (lstFilter != null && lstFilter.Count > 0)
        {
            int currentAttributeID = 0;
            //scriptExecute.Append("$('#divShopFilter').show();$('.divRange').show();");
            foreach (Filter value in lstFilter)
            {
                IsCategoryHasItems = 1;
                if (Int32.Parse(value.AttributeID) != 8 && Int32.Parse(value.AttributeID) > 48)
                {
                    if (attrID.IndexOf(value.AttributeID) == -1)
                    {
                        attrID.Add(value.AttributeID);
                        if (attrID.IndexOf(value.AttributeID) != -1)
                        {
                            if (Int32.Parse(value.AttributeID) != currentAttributeID && currentAttributeID > 0)
                            {
                                elem.Append("</ul></div></div></div></div></div>");
                            }
                            currentAttributeID = Int32.Parse(value.AttributeID);
                        }
                        elem.Append("<div value=");
                        elem.Append(value.AttributeID);
                        elem.Append(" class=\"cssClasscategorgy\"><div class=\"divTitle\"><b><label style=\"color:#006699\">");
                        elem.Append(value.AttributeName);
                        elem.Append("</label></b><img align=\"right\" src=\"");
                        elem.Append(aspxTemplateFolderPath);
                        elem.Append("/images/arrow_up.png\"/></div> <div id=\"scrollbar3\" class=\"cssClassScroll\"><div class=\"viewport\"><div class=\"overview\"><div class=");
                        elem.Append("divContent");
                        elem.Append(value.AttributeID);
                        elem.Append("><ul>");
                        attrValue = new List <string>();
                        elem.Append("<li><label><input class= \"chkFilter\" type=\"checkbox\" name=\"");
                        elem.Append(value.AttributeValue);
                        elem.Append("\" inputTypeID=\"");
                        elem.Append(value.InputTypeID);
                        elem.Append("\"  value=\"");
                        elem.Append(value.AttributeID);
                        elem.Append("\"/> ");
                        elem.Append(value.AttributeValue);
                        elem.Append("<span id=\"count\"> (");
                        elem.Append(value.ItemCount);
                        elem.Append(")</span></label></li>");
                        attrValue.Add(value.AttributeValue);
                    }
                    else
                    {
                        if (attrID.IndexOf(value.AttributeID) != -1)
                        {
                            if (Int32.Parse(value.AttributeID) != currentAttributeID && currentAttributeID > 0)
                            {
                                elem.Append("</ul></div></div></div></div></div>");
                            }
                            currentAttributeID = Int32.Parse(value.AttributeID);
                        }

                        if (attrValue.IndexOf(value.AttributeValue) == -1)
                        {
                            elem.Append("<li><label><input class=\"chkFilter\" type=\"checkbox\" name=\"");
                            elem.Append(value.AttributeValue);
                            elem.Append("\" inputTypeID=\"");
                            elem.Append(value.InputTypeID);
                            elem.Append("\"  value=\"");
                            elem.Append(value.AttributeID);
                            elem.Append("\"/> ");
                            elem.Append(value.AttributeValue);
                            elem.Append("<span id=\"count\"> (");
                            elem.Append(value.ItemCount);
                            elem.Append(")</span></label></li>");
                            attrValue.Add(value.AttributeValue);
                        }
                    }
                }

                else if (Int32.Parse(value.AttributeID) == 8)
                {
                    arrPrice.Add(value);
                    if (decimal.Parse(value.AttributeValue) > maxPrice)
                    {
                        maxPrice = decimal.Parse(value.AttributeValue);
                    }
                }
            }
            if (attrID.Count > 0)
            {
                elem.Append("</ul></div></div></div></div></div>");
            }
            decimal interval = (maxPrice - minPrice) / 4;
            elem.Append("<div value=\"8\" class=\"cssClassbrowseprice\">");
            elem.Append("<div class=\"divTitle\"><b><label style=\"color:#006699\">");
            elem.Append(getLocale("Price"));
            elem.Append("</label></b><img align=\"right\" src=\"");
            elem.Append(aspxTemplateFolderPath);
            elem.Append("/images/arrow_up.png\"/></div><div class=\"divContent8\"><ul>");
            if (arrPrice.Count > 1)
            {
                elem.Append(GetPriceData(minPrice, 1, interval) != minPrice.ToString("N2") ? "<li><a id=\"f1\" href=\"#\"  minprice=" + GetPriceData(minPrice, 0, interval) + " maxprice=" + GetPriceData(minPrice, 1, interval) + ">" + "<span class=\"cssClassFormatCurrency\">" + minPrice.ToString("N2") + "</span>" + " - " + "<span class=\"cssClassFormatCurrency\">" + GetPriceDataFloat(minPrice, 1, interval) + "</span>" + "</a></li>" : "");
                elem.Append(GetPriceData(minPrice, 0, interval) != GetPriceData(minPrice + decimal.Parse("0.01"), 1, interval) && GetPriceData(minPrice, 2, interval) != GetPriceData(minPrice, 1, interval) ? "<li><a id=\"f2\" href=\"#\"  minprice=" + GetPriceData(minPrice + decimal.Parse("0.01"), 1, interval) + " maxprice=" + GetPriceData(minPrice, 2, interval) + ">" + "<span class=\"cssClassFormatCurrency\">" + GetPriceDataFloat(minPrice + decimal.Parse("0.01"), 1, interval) + "</span>" + " - " + "<span class=\"cssClassFormatCurrency\">" + GetPriceDataFloat(minPrice, 2, interval) + "</span>" + "</a></li>" : "");
                elem.Append(GetPriceData(minPrice + decimal.Parse("0.01"), 1, interval) != GetPriceData(minPrice + decimal.Parse("0.01"), 2, interval) && GetPriceData(minPrice, 2, interval) != GetPriceData(minPrice, 3, interval) ? "<li><a id=\"f3\" href=\"#\"  minprice=" + GetPriceData(minPrice + decimal.Parse("0.01"), 2, interval) + " maxprice=" + GetPriceData(minPrice, 3, interval) + ">" + "<span class=\"cssClassFormatCurrency\">" + GetPriceDataFloat(minPrice + decimal.Parse("0.01"), 2, interval) + "</span>" + " - " + "<span class=\"cssClassFormatCurrency\">" + GetPriceDataFloat(minPrice, 3, interval) + "</span>" + "</a></li>" : "");
                elem.Append(GetPriceData(minPrice, 3, interval) != maxPrice.ToString("N2") ? "<li><a id=\"f4\" href=\"#\"  minprice=" + GetPriceData(minPrice + decimal.Parse("0.01"), 3, interval) + " maxprice=" + maxPrice + ">" + "<span class=\"cssClassFormatCurrency\">" + GetPriceDataFloat(minPrice + decimal.Parse("0.01"), 3, interval) + "</span>" + " - " + "<span class=\"cssClassFormatCurrency\">" + maxPrice.ToString("N2") + "</span>" + "</a></li>" : "");
            }
            if (arrPrice.Count == 1)
            {
                elem.Append("<li><a id=\"f1\" href=\"#\"   minprice=");
                elem.Append(GetPriceData(minPrice, 0, interval));
                elem.Append(" maxprice=");
                elem.Append(GetPriceData(minPrice, 1, interval));
                elem.Append(">");
                elem.Append("<span class=\"cssClassFormatCurrency\">");
                elem.Append(minPrice.ToString("N2"));
                elem.Append("</span>");
                elem.Append("</a></li>");
                minPrice = 0;
            }

            elem.Append("</ul></div>");
            elem.Append("<div class=\"divRange\"><div id=\"slider-range\"></div>");
            elem.Append("<p><b style=\"color: #006699\">");
            elem.Append(getLocale("Range: "));
            elem.Append("<span id=\"amount\">");
            elem.Append("<span class=\"cssClassFormatCurrency\">");
            elem.Append(minPrice.ToString("N2"));
            elem.Append("</span>");
            elem.Append(" - ");
            elem.Append("<span class=\"cssClassFormatCurrency\">");
            elem.Append(maxPrice.ToString("N2"));
            elem.Append("</span>");
            elem.Append("</span></b></p>");
            elem.Append("</div></div>");
            //string script = GetStringScript(scriptExecute.ToString());
            //elem.Append(script);
            return(elem.ToString());
        }
        return(string.Empty);
    }