Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

121 righe
4.0 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using Basic;
using System.Collections;
/// <summary>
/// 网站配置
/// </summary>
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;
}
/// <summary>
/// 取顶级父级的id
/// </summary>
/// <param name="_classid"></param>
/// <returns></returns>
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;
}
/// <summary>
/// 根据某一个列,来获得排列的值
/// </summary>
/// <param name="strWhere"></param>
/// <param name="key"></param>
/// <returns></returns>
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;
}
/// <summary>
/// 获取价格范围
/// </summary>
/// <param name="strWhere"></param>
/// <returns></returns>
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;
}
}
}