暂无描述

article_category.cs 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Reflection;
  6. using System.Text;
  7. namespace CallCenterApi.BLL
  8. {
  9. /// <summary>
  10. ///文章类别表
  11. /// </summary>
  12. public partial class article_category
  13. {
  14. // private readonly Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); //获得系统配置信息
  15. private readonly DAL.article_category dal;
  16. public article_category()
  17. {
  18. dal = new DAL.article_category();
  19. }
  20. #region 基本方法================================
  21. /// <summary>
  22. /// 是否存在该记录
  23. /// </summary>
  24. public bool Exists(int id)
  25. {
  26. return dal.Exists(id);
  27. }
  28. /// <summary>
  29. /// 增加一条数据
  30. /// </summary>
  31. public int Add(Model.article_category model)
  32. {
  33. return dal.Add(model);
  34. }
  35. /// <summary>
  36. /// 更新一条数据
  37. /// </summary>
  38. public bool Update(Model.article_category model)
  39. {
  40. return dal.Update(model);
  41. }
  42. /// <summary>
  43. /// 删除一条数据
  44. /// </summary>
  45. public bool Delete(int id)
  46. {
  47. return dal.Delete(id);
  48. }
  49. /// <summary>
  50. /// 删除多条数据
  51. /// </summary>
  52. public bool DeleteBatch(string where)
  53. {
  54. return dal.DeleteBatch(where);
  55. }
  56. /// <summary>
  57. /// 得到一个对象实体
  58. /// </summary>
  59. public Model.article_category GetModel(int id)
  60. {
  61. return dal.GetModel(id);
  62. }
  63. /// <summary>
  64. /// 取得所有类别列表
  65. /// </summary>
  66. /// <param name="parent_id">父ID</param>
  67. /// <param name="channel_id">频道ID</param>
  68. /// <returns>DataTable</returns>
  69. public DataTable GetList(int parent_id)
  70. {
  71. return dal.GetList(parent_id);
  72. }
  73. /// <summary>
  74. /// 取得该频道下所有类别列表
  75. /// </summary>
  76. /// <param name="parent_id">父ID</param>
  77. /// <param name="channel_name">频道名称</param>
  78. /// <returns>DataTable</returns>
  79. public DataTable GetList(int parent_id, string channel_name)
  80. {
  81. //int channel_id = new BLL.site_channel().GetChannelId(channel_name);
  82. return dal.GetList(parent_id);
  83. }
  84. public List<Model.article_category> DataTableToList(DataTable dt)
  85. {
  86. List<Model.article_category> list = new List<Model.article_category>();
  87. int rowsCount = dt.Rows.Count;
  88. if (rowsCount > 0)
  89. {
  90. CallCenterApi.Model.article_category model;
  91. for (int n = 0; n < rowsCount; n++)
  92. {
  93. model = new Model.article_category();
  94. if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
  95. {
  96. model.id = int.Parse(dt.Rows[n]["id"].ToString());
  97. }
  98. if (dt.Rows[n]["parentid"] != null && dt.Rows[n]["parentid"].ToString() != "")
  99. {
  100. model.parentid = int.Parse(dt.Rows[n]["parentid"].ToString());
  101. }
  102. if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "")
  103. {
  104. model.title = dt.Rows[n]["title"].ToString();
  105. }
  106. if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "")
  107. {
  108. model.sort = int.Parse(dt.Rows[n]["sort"].ToString());
  109. }
  110. if (dt.Rows[n]["status"] != null && dt.Rows[n]["status"].ToString() != "")
  111. {
  112. model.status = int.Parse(dt.Rows[n]["status"].ToString());
  113. }
  114. if (dt.Columns.Contains("parenttitle"))
  115. {
  116. if (dt.Rows[n]["parenttitle"] != null && dt.Rows[n]["parenttitle"].ToString() != "")
  117. {
  118. model.parenttitle = dt.Rows[n]["parenttitle"].ToString();
  119. }
  120. }
  121. list.Add(model);
  122. }
  123. }
  124. return list;
  125. }
  126. #endregion
  127. #region 扩展方法================================
  128. /// <summary>
  129. /// 取得指定类别下的列表(一层)
  130. /// </summary>
  131. /// <param name="top">显示条数</param>
  132. /// <param name="parent_id">父ID</param>
  133. /// <param name="channel_id">频道ID</param>
  134. /// <returns>DataTable</returns>
  135. public DataTable GetChildList(int top, int parent_id, int channel_id)
  136. {
  137. return dal.GetChildList(top, parent_id);
  138. }
  139. /// <summary>
  140. /// 取得该频道指定类别下的列表
  141. /// </summary>
  142. /// <param name="parent_id"></param>
  143. /// <param name="channel_name"></param>
  144. /// <returns></returns>
  145. public DataTable GetChildList(int top, int parent_id, string channel_name)
  146. {
  147. // int channel_id = new BLL.site_channel().GetChannelId(channel_name);
  148. return dal.GetChildList(top, parent_id);
  149. }
  150. /// <summary>
  151. /// 返回类别名称
  152. /// </summary>
  153. public string GetTitle(int id)
  154. {
  155. return dal.GetTitle(id);
  156. }
  157. /// <summary>
  158. /// 返回父节点的ID
  159. /// </summary>
  160. public int GetParentId(int id)
  161. {
  162. return dal.GetParentId(id);
  163. }
  164. /// <summary>
  165. /// 修改一列数据
  166. /// </summary>
  167. public bool UpdateField(int id, string strValue)
  168. {
  169. return dal.UpdateField(id, strValue);
  170. }
  171. #endregion
  172. }
  173. }