コード例 #1
0
    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();
    }
コード例 #2
0
 void BindData()
 {
     this.egvIndustries.DataSource = ProductIndustries.GetHierarchyIndustries();
     this.egvIndustries.DataBind();
 }