public void DataBindClass() { CategoryID3List = ""; Gtypediv2.Visible = false; Gtypediv3.Visible = false; List <Hi.Model.SYS_GType> GtypeModel = new Hi.BLL.SYS_GType().GetList("Deep,ID,ParentId,TypeCode,TypeName,FullCode", " dr='0' and IsEnabled=1 ", "ID asc"); //绑定分类 if (CategoryIDUrl != "0") //行业类别ID 不为空 { Hi.Model.SYS_GType model = GtypeModel.Where(b => b.ID == Convert.ToInt32(CategoryIDUrl)).ToList()[0]; /*new Hi.BLL.SYS_GType().GetModel(Convert.ToInt32(Request.QueryString["CategoryID"]));*/ if (model.Deep == 1) //一级分类 { Gtypediv2.Visible = true; //展示二级分类 GtypeName2.InnerHtml = "<i>" + model.TypeName + "</i>"; CategoryID = model.ID.ToString(); //保存一级分类ID List <Hi.Model.SYS_GType> Lindustry3 = GtypeModel.Where(b => b.Deep == 3 && b.FullCode.Contains(model.TypeCode + "-")).ToList(); foreach (var item in Lindustry3) { CategoryID3List += item.ID + ","; } if (CategoryID3List != "" && CategoryID3List.Length > 0) { CategoryID3List = CategoryID3List.Substring(0, CategoryID3List.Length - 1); } } else if (model.Deep == 2) //二级分类 { Gtypediv2.Visible = true; //展示二级分类 Gtypediv3.Visible = true; //展示三级分类 CategoryID = model.ParentId.ToString(); //保存一级分类ID CategoryID2 = model.ID.ToString(); //保存二级分类ID Hi.Model.SYS_GType model2 = GtypeModel.Where(b => b.ID == Convert.ToInt32(CategoryID)).ToList()[0]; /*new Hi.BLL.SYS_GType().GetModel(Convert.ToInt32(CategoryID));*/ GtypeName2.InnerHtml = "<i>" + model2.TypeName + "</i>"; GtypeName3.InnerHtml = "<i>" + model.TypeName + "</i>"; //绑定三级 List <Hi.Model.SYS_GType> Lindustry3 = GtypeModel.Where(b => b.ParentId == Convert.ToInt32(CategoryID2)).ToList(); //查询分类下所有三级ID foreach (var item in Lindustry3) { CategoryID3List += item.ID + ","; } if (CategoryID3List.Length > 1) { CategoryID3List = CategoryID3List.Substring(0, CategoryID3List.Length - 1); } } else if (model.Deep == 3) //三级分类 { Gtypediv2.Visible = true; //展示二级分类 Gtypediv3.Visible = true; //展示三级分类 string TypeCode1 = model.FullCode.Split('-')[0]; //保存一级分类ID List <Hi.Model.SYS_GType> gTypes1 = GtypeModel.Where(T => T.TypeCode == TypeCode1).ToList(); if (gTypes1.Count > 0) { CategoryID = gTypes1[0].ID.ToString(); } CategoryID2 = model.ParentId.ToString(); //保存二级分类ID CategoryID3 = model.ID.ToString(); //保存二级分类ID Hi.Model.SYS_GType model2 = GtypeModel.Where(b => b.ID == Convert.ToInt32(CategoryID2)).ToList()[0]; /*new Hi.BLL.SYS_GType().GetModel(Convert.ToInt32(CategoryID2));*/ Hi.Model.SYS_GType model1 = GtypeModel.Where(b => b.ID == Convert.ToInt32(CategoryID)).ToList()[0]; /*new Hi.BLL.SYS_GType().GetModel(Convert.ToInt32(CategoryID));*/ GtypeName2.InnerHtml = "<i>" + model1.TypeName + "</i>"; GtypeName3.InnerHtml = "<i>" + model2.TypeName + "</i>"; CategoryID3List = model.ID.ToString(); } List <Hi.Model.SYS_GType> Lindustry2 = GtypeModel.Where(b => b.ParentId == Convert.ToInt32(CategoryID)).ToList(); this.Gtype2.DataSource = Lindustry2; this.Gtype2.DataBind(); if (CategoryID2 != "0") { //绑定三级 List <Hi.Model.SYS_GType> Lindustry3 = GtypeModel.Where(b => b.ParentId == Convert.ToInt32(CategoryID2)).ToList(); this.Gtype3.DataSource = Lindustry3; this.Gtype3.DataBind(); } } //绑定一级分类 List <Hi.Model.SYS_GType> Lindustry = GtypeModel.Where(b => b.ParentId == Convert.ToInt32(0)).ToList(); // new Hi.BLL.SYS_GType().GetList("ID,TypeName", " dr='0' and IsEnabled=1 and ParentId=0 ", "ID asc"); this.RepList.DataSource = Lindustry; this.RepList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if ((HttpContext.Current.Session["UserModel"] as LoginModel) != null) { CompID = (HttpContext.Current.Session["UserModel"] as LoginModel).CompID; } object obj2 = Request["action"]; if (obj2 != null) { if (obj2.ToString() == "yanz")//验证是否还存在下级分类 { int id = 0; if (Request["id"] != null) { id = Convert.ToInt32(Request["id"]); } Response.Write(GetMinCategory(id)); Response.End(); } } if (!IsPostBack) { object obj = Request.QueryString["type"]; if (obj != null) { type = obj.ToString(); if (!Util.IsEmpty(type)) { if (Request.QueryString["disId"] != null) { disID = Request.QueryString["disId"]; } else { disID = "0"; } if (type == "1")//商品分类 { IsExepand = Common.RsertFolding(type, CompID); string strwhere = string.Empty; List <Hi.Model.SYS_GType> FindList = new List <Hi.Model.SYS_GType>(); List <Hi.Model.SYS_GType> l = new Hi.BLL.SYS_GType().GetList("id,TypeName,ParentId", "isnull(dr,0)=0 and isenabled=1 ", " id"); if (string.IsNullOrWhiteSpace(Request["val"])) { FindList = l.Where(T => T.ParentId == 0).ToList(); } else { string SearchValue = Request["val"].Replace("'", "''"); List <Hi.Model.SYS_GType> ParentList = new List <Hi.Model.SYS_GType>(); strwhere += " isnull(dr,0)=0 and isenabled=1 and TypeName like '%" + SearchValue + "%'"; FindList = new Hi.BLL.SYS_GType().GetList("id,TypeName,ParentId", strwhere, " id"); foreach (Hi.Model.SYS_GType model in FindList) { //string NewName = model.CategoryName.Replace(SearchValue, "<i style='color:red'>" + SearchValue + "</i>"); string NewName = model.TypeName; var ParentModel = l.Where(T => T.ID == model.ParentId).ToList(); if (ParentModel.Count > 0) { NewName = ParentModel[0].TypeName + " > " + NewName; } model.TypeName = NewName; ParentList.Add(model); } FindList = ParentList; } if (l.Count > 0 && FindList.Count > 0) { BindHTML(l, FindList, type); } } else if (type == "2")//代理商区域 { List <Hi.Model.BD_DisArea> FindList = new List <Hi.Model.BD_DisArea>(); List <Hi.Model.BD_DisArea> ll = new Hi.BLL.BD_DisArea().GetList("id,AreaName,ParentId", "CompanyID=" + this.CompID + " and isnull(dr,0)=0 ", ""); FindList = ll.Where(T => T.ParentID == 0).ToList(); if (ll.Count > 0 && FindList.Count > 0) { BindHTML(ll, FindList, type); } } else if (type == "3")//代理商分类 { List <Hi.Model.BD_DisType> FindList = new List <Hi.Model.BD_DisType>(); List <Hi.Model.BD_DisType> lll = new Hi.BLL.BD_DisType().GetList("id,ParentId,TypeName", "compid=" + this.CompID + " and isnull(dr,0)=0 ", ""); FindList = lll.Where(T => T.ParentId == 0).ToList(); if (lll.Count > 0 && FindList.Count > 0) { BindHTML(lll, FindList, type); } } else if (type == "4")//代理商地址 { List <Hi.Model.BD_DisAddr> llll = new Hi.BLL.BD_DisAddr().GetList("id,Address", "disid=" + disID + " and isnull(dr,0)=0", ""); if (llll.Count > 0) { BindHTML(llll, llll, type); } } else if (type == "5") {//代理商管理员 List <Hi.Model.BD_Distributor> lllll = new Hi.BLL.BD_Distributor().GetList("id,DisName", "compid=" + this.CompID + " and isnull(dr,0)=0", "Id desc"); if (lllll.Count > 0) { BindHTML(lllll, lllll, type); } } else if (type == "6") {//代理商管理员 List <Hi.Model.BD_Distributor> lllll = new Hi.BLL.BD_Distributor().GetList("id,DisName", "compid=" + this.CompID + " and isnull(dr,0)=0 and AuditState=2 and IsEnabled=1", "Id asc"); if (lllll.Count > 0) { BindHTML(lllll, lllll, type); } } } } } }