您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

120 行
4.0 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data;
  6. using Basic;
  7. using System.Collections;
  8. /// <summary>
  9. /// 网站配置
  10. /// </summary>
  11. namespace Basic.BLL
  12. {
  13. public class product
  14. {
  15. public static string GetParentWhere(int _parentid)
  16. {
  17. Basic.BLL.product bllp = new Basic.BLL.product();
  18. string strWhereParentId = _parentid.ToString();
  19. strWhereParentId += bllp.GetChild("", _parentid);
  20. return strWhereParentId;
  21. }
  22. private string GetChild(string strAllChild, int _parentid)
  23. {
  24. Basic.DAL.pro_class dalpc = new Basic.DAL.pro_class();
  25. DataTable dt = dalpc.GetList(_parentid);
  26. for (int i = 0; i < dt.Rows.Count; i++)
  27. {
  28. int childId = Convert.ToInt32(dt.Rows[i]["id"].ToString());
  29. strAllChild += "," + childId;
  30. strAllChild = GetChild(strAllChild, childId);
  31. }
  32. return strAllChild;
  33. }
  34. /// <summary>
  35. /// 取顶级父级的id
  36. /// </summary>
  37. /// <param name="_classid"></param>
  38. /// <returns></returns>
  39. public static int GetParentId(int _classid)
  40. {
  41. int _parentId = _classid;
  42. int _parent2 = 0;
  43. while (_parentId > 0)
  44. {
  45. _parent2 = _parentId;
  46. Basic.DAL.pro_class dalp = new Basic.DAL.pro_class();
  47. Basic.Model.pro_class modelp = dalp.GetModel(_parentId);
  48. if (modelp != null)
  49. {
  50. _parentId = modelp.parent_id;
  51. }
  52. }
  53. return _parent2;
  54. }
  55. public static Hashtable GetParentListName(int _classid)
  56. {
  57. Hashtable htList = new Hashtable();
  58. int _parentId = _classid;
  59. int i = 0;
  60. while (_parentId > 0)
  61. {
  62. Basic.DAL.pro_class dalp = new Basic.DAL.pro_class();
  63. Basic.Model.pro_class modelparent = dalp.GetModel(_parentId);
  64. i++;
  65. htList.Add("title"+i, modelparent.title);
  66. htList.Add("id"+i, modelparent.id);
  67. if (modelparent != null)
  68. {
  69. _parentId = modelparent.parent_id;
  70. }
  71. }
  72. return htList;
  73. }
  74. /// <summary>
  75. /// 根据某一个列,来获得排列的值
  76. /// </summary>
  77. /// <param name="strWhere"></param>
  78. /// <param name="key"></param>
  79. /// <returns></returns>
  80. public static DataTable GetListGroup(string strWhere,string key)
  81. {
  82. BasicPage bp=new BasicPage();
  83. 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];
  84. return dt;
  85. }
  86. /// <summary>
  87. /// 获取价格范围
  88. /// </summary>
  89. /// <param name="strWhere"></param>
  90. /// <returns></returns>
  91. public static string[] GetPriceRange(string strWhere)
  92. {
  93. Basic.DAL.product dalp = new Basic.DAL.product();
  94. Decimal deMax = dalp.GetMaxPrice(strWhere);
  95. int intCount = 0;
  96. if (deMax % 100.00m > 0.00m)
  97. {
  98. intCount = (Convert.ToInt32((deMax-(deMax % 100.00m)) / 100.00m) + 1);
  99. }
  100. else
  101. {
  102. intCount = Convert.ToInt32( deMax / 100.00m) ;
  103. }
  104. string[] ArrayRange=new string[ intCount ];
  105. for (int i = 0; i < intCount; i++)
  106. {
  107. ArrayRange[i] = (i*100)+"-"+((i+1)*100);
  108. }
  109. return ArrayRange;
  110. }
  111. }
  112. }