void BindData() { ProductProperty property = ProductProperties.GetProperty(id); ProductCategory category = null; if (property != null) { btnPost.Text = "修改"; this.txtPropertyDesc.Text = property.PropertyDesc; this.txtPropertyName.Text = property.PropertyName; this.txtDisplayOrder.Text = property.DisplayOrder.ToString(); this.scHidden.SelectedValue = property.SubCategoryHidden; category = ProductCategories.GetCategory(property.CategoryID); } if (category == null) { category = ProductCategories.GetCategory(categoryID); } if (category != null) { ltParCategory.Text = category.CategoryName; ltParCategoryDesc.Text = category.CategoryDesc; } else { parentName.Visible = false; parentDesc.Visible = false; } }
protected void btnPost_Click(object sender, EventArgs e) { ProductCategory category = null; if (action == OperateType.Add) { category = new ProductCategory(); category.ParentID = parentID; category.PropertyID = propertyID; } else { category = ProductCategories.GetCategory(id); } category.CategoryName = txtCategoryName.Text; category.CategoryDesc = txtCategoryDesc.Text; category.DisplayOrder = Convert.ToInt32(txtDisplayOrder.Text); if (action == OperateType.Add) { DataActionStatus status = ProductCategories.Create(category); switch (status) { case DataActionStatus.DuplicateName: mbMsg.ShowMsg("新增产品分类失败,存在同名产品分类!"); break; case DataActionStatus.UnknownFailure: mbMsg.ShowMsg("新增产品分类失败,请联系管理员!"); break; case DataActionStatus.Success: default: base.ExecuteJs("msg('操作成功,已成功增加一个新的产品分类!',true);", false); break; } } else { DataActionStatus status = ProductCategories.Update(category); switch (status) { case DataActionStatus.DuplicateName: mbMsg.ShowMsg("修改产品分类失败,存在同名产品分类!"); break; case DataActionStatus.UnknownFailure: mbMsg.ShowMsg("修改产品分类失败,请联系管理员!"); break; case DataActionStatus.Success: default: base.ExecuteJs("msg('操作成功,已成功修改产品分类信息!',true);", false); break; } } }
string GetNavigations(int pId) { List <ProductCategory> pcs = new List <ProductCategory>(); if (pId != 0) { ProductCategory pc = ProductCategories.GetCategory(pId); pcs.Add(pc); while (pc.ParentID != 0) { pc = ProductCategories.GetCategory(pc.ParentID); pcs.Add(pc); } } return(Newtonsoft.Json.JavaScriptConvert.SerializeObject(pcs)); }
string RenderHTML() { if (_Cache.ContainsKey(_CategoryID)) { return(_Cache[_CategoryID]); } StringBuilder sb = new StringBuilder(); if (_CategoryID == 0) { sb.Append("您的位置:<b>所有类别</b>"); } else { ProductCategory curCat = ProductCategories.GetCategory(_CategoryID); sb.Append("<b>" + curCat.CategoryName + "</b>"); int parId = curCat.ParentID; string _catId = string.Empty; while (parId != 0) { _catId = GlobalSettings.Encrypt(parId.ToString()); curCat = ProductCategories.GetCategory(parId); if (curCat == null) { break; } sb.Insert(0, string.Format(_href, "&ID=" + _catId, curCat.CategoryName) + ">>"); parId = curCat.ParentID; } sb.Insert(0, "您的位置:" + string.Format(_href, "", "所有类别") + ">>"); if (!_Cache.ContainsKey(_CategoryID)) { lock (_lock) { if (!_Cache.ContainsKey(_CategoryID)) { _Cache.Add(_CategoryID, sb.ToString()); } } } } return(sb.ToString()); }
void BindData() { ProductCategory category = ProductCategories.GetCategory(id); ProductCategory parent = null; ProductProperty property = null; if (category != null) { btnPost.Text = "修改"; txtCategoryName.Text = category.CategoryName; txtCategoryDesc.Text = category.CategoryDesc; txtDisplayOrder.Text = category.DisplayOrder.ToString(); parent = ProductCategories.GetCategory(category.ParentID); property = ProductProperties.GetProperty(category.PropertyID); } if (parent == null) { parent = ProductCategories.GetCategory(parentID); } if (parent != null) { ltParCategory.Text = parent.CategoryName; ltParCategoryDesc.Text = parent.CategoryDesc; } else { parentName.Visible = false; parentDesc.Visible = false; } if (property == null) { property = ProductProperties.GetProperty(propertyID); } if (property != null) { ltPropertyName.Text = property.PropertyName; } else { propertyName.Visible = false; } }
public override void OnPageLoaded() { string catName = string.Empty, catRelated = string.Empty; StringBuilder sbRelated = new StringBuilder(); string id = Request.QueryString["ID"]; ProductCategory pc = null; if (!string.IsNullOrEmpty(id)) { int catId = int.Parse(GlobalSettings.Decrypt(id)); pc = ProductCategories.GetCategory(catId); if (pc != null) { catName = pc.CategoryName; } } if (!string.IsNullOrEmpty(catName)) { //获取子分类 List <ProductCategory> childCategories = ProductCategories.GetChidCategories(pc.CategoryID); if (null == childCategories || 0 == childCategories.Count) { } else { foreach (ProductCategory pcChild in childCategories) { sbRelated.AppendFormat("{0},", pcChild.CategoryName); } } //获取相关分类 List <ProductCategory> relateCategories = ProductCategories.GetChidCategories(pc.ParentID); if (null == relateCategories || 0 == relateCategories.Count) { } else { foreach (ProductCategory pcRelate in relateCategories) { sbRelated.AppendFormat("{0},", pcRelate.CategoryName); } } catRelated = sbRelated.ToString().TrimEnd(','); } else { List <ProductCategory> relateCategories = ProductCategories.GetCategories(); if (null == relateCategories || 0 == relateCategories.Count) { } else { foreach (ProductCategory pcRelate in relateCategories) { if (pcRelate.ParentID > 0) { continue; } sbRelated.AppendFormat("{0},", pcRelate.CategoryName); } } catRelated = sbRelated.ToString().TrimEnd(','); } if (string.IsNullOrEmpty(catName)) { catName = "所有分类"; this.AddKeywords(catName + "," + catRelated); this.AddDescription("显示所有一级和二级产品分类,选择产品分类导航到对应分类的产品列表。" + string.Format(" 关键字: {0},{1}", catName, catRelated)); this.ShortTitle = catName; } else { this.AddKeywords(string.Format("{0},{1}", catName, catRelated)); this.AddDescription(string.Format("显示{0}分类的产品列表。{1}", catName, string.Format(" 关键字: {0},{1}", catName, catRelated))); this.ShortTitle = catName + " - " + catRelated; } this.SetTitle(); this.AddJavaScriptInclude("scripts/pages/sortby.aspx.js", false, false); }
string RenderHTML() { if (_Cache.ContainsKey(_CategoryID)) { return(_Cache[_CategoryID]); } List <ProductCategory> pcs = ProductCategories.GetCategories(); StringBuilder sb = new StringBuilder(); if (_CategoryID == 0) { return("<div class=\"" + _CssClass + "\"><span>暂无相关类别信息!</span></div>"); } else { ProductCategory curCat = ProductCategories.GetCategory(_CategoryID); int parId = curCat.ParentID; string _catId = string.Empty; if (parId != 0) { List <ProductCategory> subCats = ProductCategories.GetChidCategories(parId); if (subCats == null || subCats.Count == 0 || (subCats.Count == 1 && subCats[0].CategoryID == _CategoryID)) { return("<div class=\"" + _CssClass + "\"><span>暂无相关类别信息!</span></div>"); } sb.Append("<div class=\"" + _CssClass + "\">"); ProductQuery query; int count = 0; PagingDataSet <Product> __ps = null; for (int i = 0; i < subCats.Count; i++) { curCat = subCats[i]; if (curCat.CategoryID != _CategoryID) { count = 0; query = new ProductQuery(); query.CategoryID = curCat.CategoryID; __ps = Products.GetProducts(query); if (__ps != null && __ps.Records != null) { count = Products.GetProducts(query).Records.Count; } sb.AppendFormat(_href, GlobalSettings.Encrypt(curCat.CategoryID.ToString()), curCat.CategoryName + "(" + count + ")"); } } sb.Append("</div>"); if (!_Cache.ContainsKey(_CategoryID)) { lock (_lock) { if (!_Cache.ContainsKey(_CategoryID)) { _Cache.Add(_CategoryID, sb.ToString()); } } } } else { return("<div class=\"" + _CssClass + "\"><span>暂无相关类别信息!</span></div>"); } } return(sb.ToString()); }
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(); }