25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
6.4 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. /// <summary>
  6. /// 网站配置
  7. /// </summary>
  8. namespace Basic.BLL
  9. {
  10. public class attribute
  11. {
  12. /// <summary>
  13. /// 读取attribute分类的名字
  14. /// </summary>
  15. public static string GetTitle(int id)
  16. {
  17. Basic.DAL.attribute dala = new Basic.DAL.attribute();
  18. Basic.Model.attribute modela = dala.GetModel(id);
  19. string strTitle = "";
  20. if (modela != null)
  21. {
  22. strTitle = modela.title;
  23. }
  24. return strTitle;
  25. }
  26. /// <summary>
  27. /// 获取根据产品id和属性id获取属性的名字
  28. /// </summary>
  29. /// <param name="_attrid"></param>
  30. /// <param name="_proid"></param>
  31. /// <returns></returns>
  32. public static string GetListTitle(int _attrid, int _proid)
  33. {
  34. Basic.DAL.product_attribute_list dal = new Basic.DAL.product_attribute_list();
  35. Basic.Model.product_attribute_list model = dal.GetModel(_attrid, _proid);
  36. if (model != null)
  37. {
  38. return model.title;
  39. }
  40. else
  41. {
  42. return "";
  43. }
  44. }
  45. public static string GetAllAttrId(int _color, string _size, int _proid)
  46. {
  47. string strAttrId = "";
  48. strAttrId += _color + ",";
  49. if (_size != "")
  50. {
  51. string[] ArraySize = _size.Split(',');
  52. for (int i = 0; i < ArraySize.Length; i++)
  53. {
  54. strAttrId += ArraySize[i] + ",";
  55. }
  56. }
  57. if (strAttrId != "")
  58. {
  59. strAttrId = strAttrId.Substring(0, strAttrId.Length - 1);
  60. }
  61. return strAttrId;
  62. }
  63. public static string GetAllAttr(int _color, string _size, int _proid)
  64. {
  65. string strAttrId = "";
  66. strAttrId += GetListTitle(_color, _proid) + ",";
  67. if (_size != "")
  68. {
  69. string[] ArraySize = _size.Split(',');
  70. for (int i = 0; i < ArraySize.Length; i++)
  71. {
  72. strAttrId += GetListTitle(Convert.ToInt32(ArraySize[i]), _proid) + ",";
  73. }
  74. }
  75. if (strAttrId != "")
  76. {
  77. strAttrId = strAttrId.Substring(0, strAttrId.Length - 1);
  78. }
  79. return strAttrId;
  80. }
  81. public static string GetAttriString(int _color, string _size)
  82. {
  83. string strWhereSize = "";
  84. if (_size != "")
  85. {
  86. strWhereSize += "-" + _size.Replace(",", "-") + "-";
  87. }
  88. string strWhereColor = "";
  89. if (_color != 0)
  90. {
  91. strWhereColor += "-" + _color + "-";
  92. }
  93. string strWhere = strWhereColor + strWhereSize;
  94. strWhere = strWhere.Replace("--", "-");
  95. return strWhere;
  96. }
  97. //显示属性名称
  98. public static string ShowSizeAttribute(string _size, int _proid)
  99. {
  100. string strResult = "";
  101. if (!string.IsNullOrEmpty(_size))
  102. {
  103. string[] ArraySzie = _size.Split(',');
  104. for (int m = 0; m < ArraySzie.Length; m++)
  105. {
  106. strResult += attribute.GetListTitle(Convert.ToInt32(ArraySzie[m]), _proid) + ",";
  107. }
  108. }
  109. strResult = strResult.Trim();
  110. return strResult;
  111. }
  112. //显示属性名称
  113. public static string ShowAttribute(int _color, string _size, int _proid)
  114. {
  115. string strResult = "";
  116. Basic.DAL.product_attribute_list dala = new Basic.DAL.product_attribute_list();
  117. Basic.Model.product_attribute_list modela = dala.GetModel(_color, _proid);
  118. if (modela != null)
  119. {
  120. strResult += modela.title + ",";
  121. }
  122. strResult += ShowSizeAttribute(_size, _proid);
  123. strResult = strResult.Trim(',');
  124. return strResult;
  125. }
  126. public static int GetKucun(string attrid, int _proid)
  127. {
  128. int Kucun = 0;
  129. Basic.DAL.product_attribute_value dalpav = new Basic.DAL.product_attribute_value();
  130. Basic.Model.product_attribute_value modelpayv = dalpav.GetModel(_proid, ("-" + attrid.Replace(",", "-") + "-"));
  131. if (modelpayv != null)
  132. {
  133. Kucun = modelpayv.count;
  134. }
  135. else
  136. {
  137. Basic.DAL.product dalp = new Basic.DAL.product();
  138. Basic.Model.product modelp = dalp.GetModel(_proid);
  139. if (modelp != null)
  140. {
  141. Kucun = modelp.kucun;
  142. }
  143. }
  144. return Kucun;
  145. }
  146. public static string CountKucun(string attrid,int _proid,int _count,string strProInfo)
  147. {
  148. bool Flag = true;
  149. int Kucun = 0;
  150. int yiyouCount = 0;
  151. Basic.DAL.product_attribute_value dalpav = new Basic.DAL.product_attribute_value();
  152. Basic.Model.product_attribute_value modelpayv = dalpav.GetModel(_proid,("-"+attrid.Replace(",","-")+"-"));
  153. if (modelpayv != null)
  154. {
  155. Kucun = modelpayv.count;
  156. if (Kucun < _count)
  157. {
  158. Flag = false;
  159. }
  160. }
  161. else
  162. {
  163. Basic.DAL.product dalp = new Basic.DAL.product();
  164. Basic.Model.product modelp = dalp.GetModel(_proid);
  165. if (modelp != null)
  166. {
  167. if (modelp.kucun < _count)
  168. {
  169. Flag = false;
  170. }
  171. }
  172. else
  173. {
  174. Flag = false;
  175. }
  176. }
  177. if (!Flag)
  178. {
  179. return "产品["+strProInfo.Trim()+"]库存少于购买数量。 ";
  180. }
  181. else
  182. {
  183. return "";
  184. }
  185. }
  186. }
  187. }