Exemplo n.º 1
0
        string RenderHTML()
        {
            List <ProductBrand> brands = ProductBrands.GetProductBrands();

            string nav = GlobalSettings.RelativeWebRoot + "pages/view.aspx?product-brand";

            if (brands == null || brands.Count == 0)
            {
                return("<div><span>没有显示的品牌信息!</span></div>");
            }
            List <string> brandGroup = ProductBrands.GetBrandGroup();
            int           curCount   = brandGroup.Count;

            brandGroup = brandGroup.GetRange(0, Math.Min(_Max, curCount));
            List <ProductBrand> pb = null;
            StringBuilder       sb = new StringBuilder();

            sb.AppendLine("<table cellpadding=\"0\" cellspacing=\"0\" class=\"" + _CssClass + "\">");
            string bId = string.Empty;

            for (int i = 0; i < brandGroup.Count; i++)
            {
                if (i % _Columns == 0)
                {
                    sb.AppendLine("<tr>");
                }

                sb.AppendLine("<td>");
                sb.AppendLine("<div><div><a href=\"javascript:void(0)\">" + brandGroup[i] + "</a></div></div>");
                pb = GetSubBrand(brandGroup[i], brands);
                ProductBrand _pb = null;
                for (int j = 0; j < pb.Count; j++)
                {
                    _pb = pb[j];
                    bId = GlobalSettings.Encrypt(_pb.BrandID.ToString());
                    sb.AppendLine("<a href=\"" + nav + "&ID=" + bId + "\" target=\"_blank\">" + _pb.BrandName + "</a>");
                    if (j != pb.Count - 1)
                    {
                        sb.Append("&nbsp;|&nbsp;");
                    }
                }
                sb.AppendLine("</td>");

                if (i % _Columns == _Columns - 1)
                {
                    sb.AppendLine("</tr>");
                }
            }
            sb.AppendLine("</table>");

            if (curCount > _Max)
            {
                sb.Append("<div class=\"list-more\"><a href=\"" + GlobalSettings.RelativeWebRoot + "pages/view.aspx?product-brand\" title=\"查看全部。。。\"></a></div>");
            }
            return(sb.ToString());
        }
Exemplo n.º 2
0
    void BindBrands()
    {
        List <ProductBrand> brands = ProductBrands.GetProductBrands();

        ddlBrands.DataSource     = brands;
        ddlBrands.DataTextField  = "BrandName";
        ddlBrands.DataValueField = "BrandID";
        ddlBrands.DataBind();
        ddlBrands.Items.Insert(0, new ListItem("-无-", "None"));
    }
Exemplo n.º 3
0
        string RenderHTML()
        {
            if (_Cache.ContainsKey(_BrandID))
            {
                return(_Cache[_BrandID]);
            }
            if (_BrandID == 0)
            {
                return("<div class=\"" + _CssClass + "\"><span>暂无相关品牌信息!</span></div>");
            }
            else
            {
                List <ProductBrand> brands = ProductBrands.GetProductBrands();
                StringBuilder       sb     = new StringBuilder();
                ProductBrand        pb     = ProductBrands.GetProductBrand(_BrandID);

                List <ProductBrand> bs = GetSubBrand(pb.BrandGroup, brands);
                if (bs == null || bs.Count == 0 || (bs.Count == 1 && bs[0].BrandID == _BrandID))
                {
                    return("<div class=\"" + _CssClass + "\"><span>暂无相关品牌信息!</span></div>");
                }
                sb.Append("<div class=\"" + _CssClass + "\">");
                ProductQuery            query;
                int                     count = 0;
                PagingDataSet <Product> __ps  = null;
                foreach (ProductBrand b in bs)
                {
                    if (b.BrandID != _BrandID)
                    {
                        count         = 0;
                        query         = new ProductQuery();
                        query.BrandID = b.BrandID;
                        __ps          = Products.GetProducts(query);
                        if (__ps != null && __ps.Records != null)
                        {
                            count = Products.GetProducts(query).Records.Count;
                        }
                        sb.AppendFormat(_href, GlobalSettings.Encrypt(b.BrandID.ToString()), b.BrandName + "(" + count + ")");
                    }
                }
                sb.Append("</div>");
                if (!_Cache.ContainsKey(_BrandID))
                {
                    lock (_lock)
                        if (!_Cache.ContainsKey(_BrandID))
                        {
                            _Cache.Add(_BrandID, sb.ToString());
                        }
                }
                return(sb.ToString());
            }
        }
        string GenerateBrand(ref bool result)
        {
            List <ProductBrand> pbs = ProductBrands.GetProductBrands();
            SiteMapBuilder      smb = new SiteMapBuilder();

            foreach (ProductBrand pb in pbs)
            {
                smb.AddLocalUrl("pages/view.aspx?product-brand&ID=" + GlobalSettings.Encrypt(pb.BrandID.ToString()), DateTime.Now);
            }
            smb.Save(GlobalSettings.MapPath("~/sitemap/brands.xml"));
            result = true;
            return("成功生成/更新【产品行业】地图!");
        }
    private void BindBand()
    {
        List <ProductBrand> brands = ProductBrands.GetProductBrands();

        ddlProductBrand.DataSource     = brands;
        ddlProductBrand.DataTextField  = "BrandName";
        ddlProductBrand.DataValueField = "BrandID";
        ddlProductBrand.DataBind();
        ddlProductBrand.Items.Insert(0, new ListItem("   ", "0"));
        if (productID > 0)
        {
            Product  product = Products.GetProduct(productID);
            ListItem item    = ddlProductBrand.Items.FindByValue(product.BrandID.ToString());
            if (item != null)
            {
                item.Selected = true;
            }
        }
    }
        HtmlGenericControl BindVarietyList()
        {
            List <ProductBrand> brandsTemp = ProductBrands.GetProductBrands();

            if (brandsTemp == null || brandsTemp.Count == 0)
            {
                HtmlGenericControl p = new HtmlGenericControl("P");
                p.InnerText = "没有品牌信息!";
                return(p);
            }
            List <ProductBrand> brands = brandsTemp.GetRange(0, Math.Min(_Num, brandsTemp.Count));

            if (brands == null || brands.Count == 0)
            {
                HtmlGenericControl p = new HtmlGenericControl("P");
                p.InnerText = "没有品牌信息!";
                return(p);
            }

            HtmlGenericControl ul = new HtmlGenericControl("ul");

            ul.ID = "ulVarietyList";

            HtmlGenericControl li     = null;
            HtmlAnchor         anchor = null;

            foreach (var b in brands)
            {
                li               = new HtmlGenericControl("LI");
                anchor           = new HtmlAnchor();
                anchor.HRef      = GlobalSettings.RelativeWebRoot + "pages/view.aspx?product-brand&ID=" + GlobalSettings.Encrypt(b.BrandID.ToString());
                anchor.InnerText = b.BrandName;
                anchor.Title     = b.BrandTitle;
                anchor.Target    = "_blank";
                li.Controls.Add(anchor);

                ul.Controls.Add(li);
            }
            return(ul);
        }
        string RenderHTML()
        {
            if (_Cache.ContainsKey(_BrandID))
            {
                return(_Cache[_BrandID]);
            }
            List <ProductBrand> brands = ProductBrands.GetProductBrands();
            StringBuilder       sb     = new StringBuilder();

            if (_BrandID == 0)
            {
                sb.Append("您的位置:<b>所有品牌</b>");
            }
            else
            {
                ProductBrand pb = ProductBrands.GetProductBrand(_BrandID);
                sb.Append("<b>" + pb.BrandName + "</b>");

                string _bId            = string.Empty;
                List <ProductBrand> bs = GetSubBrand(pb.BrandName, brands);
                foreach (ProductBrand b in bs)
                {
                    _bId = GlobalSettings.Encrypt(b.BrandID.ToString());
                    sb.Insert(0, string.Format(_href, "&ID=" + _bId, b.BrandName) + ">>");
                }
                sb.Insert(0, "您的位置:" + string.Format(_href, "", "所有品牌") + ">>");
                if (!_Cache.ContainsKey(_BrandID))
                {
                    lock (_lock)
                        if (!_Cache.ContainsKey(_BrandID))
                        {
                            _Cache.Add(_BrandID, sb.ToString());
                        }
                }
            }
            return(sb.ToString());
        }
Exemplo n.º 8
0
    private void InitialDataBind()
    {
        SiteSettings ss = HHContext.Current.SiteSettings;

        ltCopyRight.Text = ss.Copyright;

        StringBuilder       sbItems = new StringBuilder();
        List <ProductBrand> brands  = ProductBrands.GetProductBrands();

        foreach (ProductBrand item in brands)
        {
            sbItems.AppendFormat("<li><a href=\"http://www.ehuaho.com/pages/view.aspx?product-brand&ID={0}\" target=\"_blank\" title=\"{2}\">{1}</a></li>",
                                 GlobalSettings.Encrypt(item.BrandID.ToString()),
                                 GlobalSettings.SubString(item.BrandName, 10),
                                 item.BrandName);
        }
        ltBrand.Text = sbItems.ToString();

        List <ProductIndustry> inds = ProductIndustries.GetProductIndustries();

        sbItems.Remove(0, sbItems.Length);
        foreach (ProductIndustry item in inds)
        {
            sbItems.AppendFormat("<li><a href=\"http://www.ehuaho.com/pages/view.aspx?product-industry&ID={0}\" target=\"_blank\" title=\"{2}\">{1}</a></li>",
                                 GlobalSettings.Encrypt(item.IndustryID.ToString()),
                                 GlobalSettings.SubString(item.IndustryName, 10),
                                 item.IndustryName);
        }
        ltIndustry.Text = sbItems.ToString();

        ProductQuery q = new ProductQuery();

        q.PageIndex    = 0;
        q.PageSize     = int.MaxValue;
        q.HasPublished = true;
        List <Product> ps = Products.GetProductList(q);

        sbItems.Remove(0, sbItems.Length);
        foreach (Product item in ps)
        {
            sbItems.AppendFormat("<li><a href=\"http://www.ehuaho.com/pages/view.aspx?product-product&ID={0}\" target=\"_blank\" title=\"{2}\">{1}</a></li>",
                                 GlobalSettings.Encrypt(item.ProductID.ToString()),
                                 GlobalSettings.SubString(item.ProductName, 17),
                                 item.ProductName);
        }
        ltProduct.Text = sbItems.ToString();

        List <ProductCategory> cats = ProductCategories.GetCategories();

        sbItems.Remove(0, sbItems.Length);
        foreach (ProductCategory item in cats)
        {
            sbItems.AppendFormat("<li><a href=\"http://www.ehuaho.com/pages/view.aspx?product-category&ID={0}\" target=\"_blank\" title=\"{2}\">{1}</a></li>",
                                 GlobalSettings.Encrypt(item.CategoryID.ToString()),
                                 GlobalSettings.SubString(item.CategoryName, 10),
                                 item.CategoryName);
        }
        ltCategory.Text = sbItems.ToString();


        List <Article> ars = ArticleManager.GetAllArticles();

        sbItems.Remove(0, sbItems.Length);
        foreach (Article item in ars)
        {
            sbItems.AppendFormat("<li><a href=\"http://www.ehuaho.com/pages/view.aspx?news-newsdetail&ID={0}\" target=\"_blank\" title=\"{2}\">{1}</a></li>",
                                 GlobalSettings.Encrypt(item.ID.ToString()),
                                 GlobalSettings.SubString(item.Title, 10),
                                 item.Title);
        }
        ltNews.Text = sbItems.ToString();
        //ltCategory; ltIndustry; ltNews; ltProduct;
    }
    private void BindData()
    {
        ProductQuery query = ProductQuery.GetQueryFromQueryString(Request.QueryString);

        query.CompanyID = Profile.AccountInfo.CompanyID;

        lnkAll.CssClass = "active";
        lblTip.Text     = "“全部”";

        if (query.HasPictures.HasValue)
        {
            if (query.HasPictures.Value)
            {
                lnkAll.CssClass     = "";
                lnkPicture.CssClass = "active";
                lblTip.Text         = "“有图”";
            }
            else
            {
                lnkAll.CssClass       = "";
                lnkNoPicture.CssClass = "active";
                lblTip.Text           = "“无图”";
            }
        }

        if (query.HasPrice.HasValue)
        {
            if (query.HasPrice.Value)
            {
                lnkAll.CssClass    = "";
                lnkPriced.CssClass = "active";
                lblTip.Text        = "“已报价”";
            }
            else
            {
                lnkAll.CssClass      = "";
                lnkNoPriced.CssClass = "active";
                lblTip.Text          = "“未报价”";
            }
        }

        if (query.HasPublished.HasValue)
        {
            if (query.HasPublished.Value)
            {
                lnkAll.CssClass       = "";
                lnkPublished.CssClass = "active";
                lblTip.Text           = "“已发布”";
            }
            else
            {
                lnkAll.CssClass          = "";
                lnkUnPublishied.CssClass = "active";
                lblTip.Text = "“未发布”";
            }
        }

        bool flag = false;

        if (!GlobalSettings.IsNullOrEmpty(query.ProductNameFilter))
        {
            txtProductName.Text = query.ProductNameFilter;
            lblTip.Text         = "名称中包含“" + query.ProductNameFilter + "”";
            flag = true;
        }

        //BrandID
        ddlBrands.DataSource     = ProductBrands.GetProductBrands();
        ddlBrands.DataTextField  = "BrandName";
        ddlBrands.DataValueField = "BrandID";
        ddlBrands.DataBind();
        ddlBrands.Items.Insert(0, new ListItem("=所有品牌=", "0"));

        if (query.BrandID.HasValue && query.BrandID.Value != 0)
        {
            ListItem item = ddlBrands.Items.FindByValue(query.BrandID.Value.ToString());
            if (item != null)
            {
                item.Selected = true;
                if (flag)
                {
                    lblTip.Text = lblTip.Text + ",品牌为“" + ProductBrands.GetProductBrand(query.BrandID.Value).BrandName + "”";
                }
                else
                {
                    lblTip.Text = "品牌为“" + ProductBrands.GetProductBrand(query.BrandID.Value).BrandName + "”";
                    flag        = true;
                }
            }
        }

        //CategoryID
        ddlCategory.DataSource     = ProductCategories.GetValueRange();
        ddlCategory.DataTextField  = "Text";
        ddlCategory.DataValueField = "Name";
        ddlCategory.DataBind();
        ddlCategory.Items.Insert(0, new ListItem("=所有分类=", "0"));

        if (query.CategoryID.HasValue && query.CategoryID.Value != 0)
        {
            ListItem item = ddlCategory.Items.FindByValue(query.CategoryID.Value.ToString());
            if (item != null)
            {
                item.Selected = true;
                if (flag)
                {
                    lblTip.Text = lblTip.Text + ",分类为“" + ProductCategories.GetCategory(query.CategoryID.Value).CategoryName + "”";
                }
                else
                {
                    lblTip.Text = "分类为“" + ProductCategories.GetCategory(query.CategoryID.Value).CategoryName + "”";
                    flag        = true;
                }
            }
        }

        //IndustryID
        ddlIndustry.DataSource     = ProductIndustries.GetHierarchyIndustries();
        ddlIndustry.DataTextField  = "IndustryName";
        ddlIndustry.DataValueField = "IndustryID";
        ddlIndustry.DataBind();
        ddlIndustry.Items.Insert(0, new ListItem("=所有行业=", "0"));

        if (query.IndustryID.HasValue && query.IndustryID.Value != 0)
        {
            ListItem item = ddlIndustry.Items.FindByValue(query.IndustryID.Value.ToString());
            if (item != null)
            {
                item.Selected = true;
                if (flag)
                {
                    lblTip.Text = lblTip.Text + ",行业为“" + ProductIndustries.GetProductIndustry(query.IndustryID.Value).IndustryName + "”";
                }
                else
                {
                    lblTip.Text = "行业为“" + ProductIndustries.GetProductIndustry(query.IndustryID.Value).IndustryName + "”";
                    flag        = true;
                }
            }
        }

        query.PageSize       = egvProducts.PageSize;
        query.PageIndex      = egvProducts.PageIndex;
        query.ProductOrderBy = ProductOrderBy.DataCreated;
        query.SortOrder      = SortOrder.Descending;

        List <Product> products = Products.GetProductList(query);

        egvProducts.DataSource = products;
        egvProducts.DataBind();
    }
Exemplo n.º 10
0
 void BindData()
 {
     this.egvBrands.DataSource = ProductBrands.GetProductBrands();
     this.egvBrands.DataBind();
 }