using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using Basic; using System.Collections; /// /// 网站配置 /// namespace Basic.BLL { public class product { public static string GetParentWhere(int _parentid) { Basic.BLL.product bllp = new Basic.BLL.product(); string strWhereParentId = _parentid.ToString(); strWhereParentId += bllp.GetChild("", _parentid); return strWhereParentId; } private string GetChild(string strAllChild, int _parentid) { Basic.DAL.pro_class dalpc = new Basic.DAL.pro_class(); DataTable dt = dalpc.GetList(_parentid); for (int i = 0; i < dt.Rows.Count; i++) { int childId = Convert.ToInt32(dt.Rows[i]["id"].ToString()); strAllChild += "," + childId; strAllChild = GetChild(strAllChild, childId); } return strAllChild; } /// /// 取顶级父级的id /// /// /// public static int GetParentId(int _classid) { int _parentId = _classid; int _parent2 = 0; while (_parentId > 0) { _parent2 = _parentId; Basic.DAL.pro_class dalp = new Basic.DAL.pro_class(); Basic.Model.pro_class modelp = dalp.GetModel(_parentId); if (modelp != null) { _parentId = modelp.parent_id; } } return _parent2; } public static Hashtable GetParentListName(int _classid) { Hashtable htList = new Hashtable(); int _parentId = _classid; int i = 0; while (_parentId > 0) { Basic.DAL.pro_class dalp = new Basic.DAL.pro_class(); Basic.Model.pro_class modelparent = dalp.GetModel(_parentId); i++; htList.Add("title"+i, modelparent.title); htList.Add("id"+i, modelparent.id); if (modelparent != null) { _parentId = modelparent.parent_id; } } return htList; } /// /// 根据某一个列,来获得排列的值 /// /// /// /// public static DataTable GetListGroup(string strWhere,string key) { BasicPage bp=new BasicPage(); DataTable dt = bp.SelectDataBase("news", "select " + key + ",count(id) as countid from tb_product where " + key + "<>'' and " + key + " is not null and " + strWhere + " group by " + key + " order by count(id) desc").Tables[0]; return dt; } /// /// 获取价格范围 /// /// /// public static string[] GetPriceRange(string strWhere) { Basic.DAL.product dalp = new Basic.DAL.product(); Decimal deMax = dalp.GetMaxPrice(strWhere); int intCount = 0; if (deMax % 100.00m > 0.00m) { intCount = (Convert.ToInt32((deMax-(deMax % 100.00m)) / 100.00m) + 1); } else { intCount = Convert.ToInt32( deMax / 100.00m) ; } string[] ArrayRange=new string[ intCount ]; for (int i = 0; i < intCount; i++) { ArrayRange[i] = (i*100)+"-"+((i+1)*100); } return ArrayRange; } } }