鄂尔多斯-招源科技

article.cs 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. using System;
  2. using System.Data;
  3. using System.Collections.Generic;
  4. namespace CallCenterApi.BLL
  5. {
  6. /// <summary>
  7. /// 文章内容
  8. /// </summary>
  9. public partial class article
  10. {
  11. //private readonly Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig();//获得系统配置信息
  12. private readonly CallCenterApi.DAL.article dal;
  13. public article()
  14. {
  15. dal = new CallCenterApi.DAL.article();
  16. }
  17. #region 基本方法================================
  18. /// <summary>
  19. /// 是否存在该记录
  20. /// </summary>
  21. public bool Exists(int channel_id, int article_id)
  22. {
  23. //string channelName = new BLL.site_channel().GetChannelName(channel_id);//查询频道名称
  24. //if (string.IsNullOrEmpty(channelName))
  25. //{
  26. // return false;
  27. //}
  28. return dal.Exists(article_id);
  29. }
  30. /// <summary>
  31. /// 是否存在该记录
  32. /// </summary>
  33. public bool Exists(string call_index)
  34. {
  35. if (string.IsNullOrEmpty(call_index))
  36. {
  37. return false;
  38. }
  39. //string channelName = new BLL.site_channel().GetChannelName(channel_id);//查询频道名称
  40. //if (string.IsNullOrEmpty(channelName))
  41. //{
  42. // return false;
  43. //}
  44. return dal.Exists(call_index);
  45. }
  46. /// <summary>
  47. /// 增加一条数据
  48. /// </summary>
  49. public int Add(Model.article model)
  50. {
  51. return dal.Add(model);
  52. }
  53. /// <summary>
  54. /// 更新一条数据
  55. /// </summary>
  56. public bool Update(Model.article model)
  57. {
  58. return dal.Update(model);
  59. }
  60. /// <summary>
  61. /// 删除一条数据
  62. /// </summary>
  63. public bool Delete(int article_id)
  64. {
  65. //string channelName = new BLL.site_channel().GetChannelName(channel_id);//查询频道名称
  66. //if (string.IsNullOrEmpty(channelName))
  67. //{
  68. // return false;
  69. //}
  70. string content = dal.GetContent(article_id);//获取信息内容
  71. bool result = dal.Delete(article_id);//删除内容
  72. //if (result && !string.IsNullOrEmpty(content))
  73. //{
  74. // FileHelper.DeleteContentPic(content, sysConfig.webpath + sysConfig.filepath); //删除内容图片
  75. //}
  76. return result;
  77. }
  78. /// <summary>
  79. /// 删除一条数据
  80. /// </summary>
  81. public bool DeleteBatch(string where)
  82. {
  83. bool result = dal.DeleteBatch(where);//删除内容
  84. return result;
  85. }
  86. /// <summary>
  87. /// 得到一个对象实体
  88. /// </summary>
  89. public Model.article GetModel(int article_id)
  90. {
  91. //string channelName = new BLL.site_channel().GetChannelName(channel_id);//查询频道名称
  92. //if (string.IsNullOrEmpty(channelName))
  93. //{
  94. // return null;
  95. //}
  96. return dal.GetModel(article_id);
  97. }
  98. /// <summary>
  99. /// 得到一个对象实体
  100. /// </summary>
  101. public Model.article GetModel(string call_index)
  102. {
  103. //string channelName = new BLL.site_channel().GetChannelName(channel_id);//查询频道名称
  104. //if (string.IsNullOrEmpty(channelName))
  105. //{
  106. // return null;
  107. //}
  108. return dal.GetModel(call_index);
  109. }
  110. public List<Model.article> DataTableToList(DataTable dt)
  111. {
  112. List<Model.article> list = new List<Model.article>();
  113. int rowsCount = dt.Rows.Count;
  114. if (rowsCount > 0)
  115. {
  116. CallCenterApi.Model.article model;
  117. for (int n = 0; n < rowsCount; n++)
  118. {
  119. model = new CallCenterApi.Model.article();
  120. if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
  121. {
  122. model.id = int.Parse(dt.Rows[n]["id"].ToString());
  123. }
  124. if (dt.Rows[n]["category_id"] != null && dt.Rows[n]["category_id"].ToString() != "")
  125. {
  126. model.category_id = Convert.ToInt32(dt.Rows[n]["category_id"]);
  127. }
  128. //if (dt.Rows[n]["trade_no"] != null && dt.Rows[n]["trade_no"].ToString() != "")
  129. //{
  130. // model.trade_no = dt.Rows[n]["trade_no"].ToString();
  131. //}
  132. if (dt.Rows[n]["title"] != DBNull.Value && dt.Rows[n]["title"].ToString() != "")
  133. {
  134. model.title = dt.Rows[n]["title"].ToString();
  135. }
  136. if (dt.Rows[n]["img_url"] != null && dt.Rows[n]["img_url"].ToString() != "")
  137. {
  138. model.img_url = dt.Rows[n]["img_url"].ToString();
  139. }
  140. if (dt.Rows[n]["zhaiyao"] != null && dt.Rows[n]["zhaiyao"].ToString() != "")
  141. {
  142. model.zhaiyao = dt.Rows[n]["zhaiyao"].ToString();
  143. }
  144. if (dt.Rows[n]["content"] != null && dt.Rows[n]["content"].ToString() != "")
  145. {
  146. model.content = dt.Rows[n]["content"].ToString();
  147. }
  148. if (dt.Rows[n]["sort_id"] != null && dt.Rows[n]["sort_id"].ToString() != "")
  149. {
  150. model.sort_id = Convert.ToInt32(dt.Rows[n]["sort_id"]);
  151. }
  152. if (dt.Rows[n]["status"] != null && dt.Rows[n]["status"].ToString() != "")
  153. {
  154. model.status = Convert.ToInt32(dt.Rows[n]["status"]);
  155. }
  156. if (dt.Rows[n]["add_time"] != null && dt.Rows[n]["add_time"].ToString() != "")
  157. {
  158. model.add_time = Convert.ToDateTime(dt.Rows[n]["add_time"]);
  159. }
  160. if (dt.Rows[n]["update_time"] != DBNull.Value && dt.Rows[n]["update_time"].ToString() != "")
  161. {
  162. model.update_time = Convert.ToDateTime(dt.Rows[n]["update_time"]);
  163. }
  164. else
  165. {
  166. model.update_time = null;
  167. }
  168. if (dt.Rows[n]["sell_price"] != DBNull.Value && dt.Rows[n]["sell_price"].ToString() != "")
  169. {
  170. model.sell_price = decimal.Parse(dt.Rows[n]["sell_price"].ToString());
  171. }
  172. else
  173. {
  174. model.sell_price = null;
  175. }
  176. if (dt.Rows[n]["goods_no"] != null && dt.Rows[n]["goods_no"].ToString() != "")
  177. {
  178. model.goods_no = dt.Rows[n]["goods_no"].ToString();
  179. }
  180. if (dt.Rows[n]["department"] != null && dt.Rows[n]["department"].ToString() != "")
  181. {
  182. model.department = Convert.ToInt32(dt.Rows[n]["department"]);
  183. }
  184. if (dt.Rows[n]["categorytitle"] != null && dt.Rows[n]["categorytitle"].ToString() != "")
  185. {
  186. model.categorytitle = dt.Rows[n]["categorytitle"].ToString();
  187. }
  188. list.Add(model);
  189. }
  190. }
  191. return list;
  192. }
  193. #endregion
  194. #region 扩展方法================================
  195. /// <summary>
  196. /// 是否存在标题
  197. /// </summary>
  198. public bool ExistsTitle(int channel_id, string title)
  199. {
  200. return dal.ExistsTitle(title);
  201. }
  202. /// <summary>
  203. /// 是否存在标题
  204. /// </summary>
  205. public bool ExistsTitle(int channel_id, int category_id, string title)
  206. {
  207. return dal.ExistsTitle(category_id, title);
  208. }
  209. /// <summary>
  210. /// 返回信息标题
  211. /// </summary>
  212. public string GetTitle(int channel_id, int article_id)
  213. {
  214. return dal.GetTitle(article_id);
  215. }
  216. /// <summary>
  217. /// 返回信息内容
  218. /// </summary>
  219. public string GetContent(string channel_name, int article_id)
  220. {
  221. return dal.GetContent(article_id);
  222. }
  223. /// <summary>
  224. /// 返回信息内容
  225. /// </summary>
  226. public string GetContent(string channel_name, string call_index)
  227. {
  228. return dal.GetContent(call_index);
  229. }
  230. /// <summary>
  231. /// 返回信息封面图
  232. /// </summary>
  233. public string GetImgUrl(int channel_id, int article_id)
  234. {
  235. return dal.GetImgUrl(article_id);
  236. }
  237. /// <summary>
  238. /// 获取阅读次数
  239. /// </summary>
  240. public int GetClick(int channel_id, int article_id)
  241. {
  242. return dal.GetClick(article_id);
  243. }
  244. /// <summary>
  245. /// 返回数据总数
  246. /// </summary>
  247. public int GetCount(int channel_id, string strWhere)
  248. {
  249. return dal.GetCount(strWhere);
  250. }
  251. /// <summary>
  252. /// 返回商品库存数量
  253. /// </summary>
  254. public int GetStockQuantity(int channel_id, int article_id)
  255. {
  256. return dal.GetStockQuantity(article_id);
  257. }
  258. /// <summary>
  259. /// 修改一列数据
  260. /// </summary>
  261. public bool UpdateField(int channel_id, int article_id, string strValue)
  262. {
  263. return dal.UpdateField(article_id, strValue);
  264. }
  265. /// <summary>
  266. /// 获取微信推送实体
  267. /// </summary>
  268. public Model.article GetWXModel(int channel_id, int article_id)
  269. {
  270. DataTable dt = dal.GetList(1, "id=" + article_id, "id desc").Tables[0];
  271. if (dt.Rows.Count == 0)
  272. {
  273. return null;
  274. }
  275. Model.article model = new Model.article();
  276. model.id = int.Parse(dt.Rows[0]["id"].ToString());
  277. model.title = dt.Rows[0]["title"].ToString();
  278. model.img_url = dt.Rows[0]["img_url"].ToString();
  279. model.zhaiyao = dt.Rows[0]["zhaiyao"].ToString();
  280. model.content = dt.Rows[0]["content"].ToString();
  281. return model;
  282. }
  283. #endregion
  284. }
  285. }