BLL_iNethinkCMS_Guestbook.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*******************************************************************************
  2. * iNethinkCMS - 网站内容管理系统
  3. * Copyright (C) 2012-2013 inethink.com
  4. *
  5. * @author jackyang <69991000@qq.com>
  6. * @website http://cms.inethink.com
  7. * @version 1.3.6.0 (2013-08-14)
  8. *
  9. * This is licensed under the GNU LGPL, version 3.0 or later.
  10. * For details, see: http://www.gnu.org/licenses/gpl-3.0.html
  11. *******************************************************************************/
  12. using System;
  13. using System.Data;
  14. using System.Collections.Generic;
  15. using iNethinkCMS.Model;
  16. namespace iNethinkCMS.BLL
  17. {
  18. /// <summary>
  19. /// 留言信息
  20. /// </summary>
  21. public partial class BLL_iNethinkCMS_Plugs_Guestbook
  22. {
  23. private readonly iNethinkCMS.DAL.DAL_iNethinkCMS_Plugs_Guestbook dal = new iNethinkCMS.DAL.DAL_iNethinkCMS_Plugs_Guestbook();
  24. public BLL_iNethinkCMS_Plugs_Guestbook()
  25. { }
  26. /// <summary>
  27. /// 是否存在该记录
  28. /// </summary>
  29. public bool Exists(int ID)
  30. {
  31. return dal.Exists(ID);
  32. }
  33. /// <summary>
  34. /// 增加一条数据
  35. /// </summary>
  36. public int Add(iNethinkCMS.Model.Model_iNethinkCMS_Plugs_Guestbook model)
  37. {
  38. return dal.Add(model);
  39. }
  40. /// <summary>
  41. /// 更新一条数据
  42. /// </summary>
  43. public bool Update(iNethinkCMS.Model.Model_iNethinkCMS_Plugs_Guestbook model)
  44. {
  45. return dal.Update(model);
  46. }
  47. /// <summary>
  48. /// 删除一条数据
  49. /// </summary>
  50. public bool Delete(int ID)
  51. {
  52. return dal.Delete(ID);
  53. }
  54. /// <summary>
  55. /// 删除一条数据
  56. /// </summary>
  57. public bool DeleteList(string IDlist)
  58. {
  59. return dal.DeleteList(IDlist);
  60. }
  61. /// <summary>
  62. /// 得到一个对象实体
  63. /// </summary>
  64. public iNethinkCMS.Model.Model_iNethinkCMS_Plugs_Guestbook GetModel(int ID)
  65. {
  66. return dal.GetModel(ID);
  67. }
  68. /// <summary>
  69. /// 得到一个对象实体,从缓存中
  70. /// </summary>
  71. public iNethinkCMS.Model.Model_iNethinkCMS_Plugs_Guestbook GetModelByCache(int ID)
  72. {
  73. string CacheKey = iNethinkCMS.Command.Command_Configuration.GetConfigString("CacheKey");
  74. CacheKey = CacheKey + "_Model_iNethinkCMS_Plugs_GuestbookModel_" + ID;
  75. object objModel = iNethinkCMS.Command.Command_DataCache.GetCache(CacheKey);
  76. if (objModel == null)
  77. {
  78. try
  79. {
  80. objModel = dal.GetModel(ID);
  81. if (objModel != null)
  82. {
  83. int ModelCache = iNethinkCMS.Command.Command_Configuration.GetConfigInt("CacheTime");
  84. iNethinkCMS.Command.Command_DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddSeconds(ModelCache), TimeSpan.Zero);
  85. }
  86. }
  87. catch
  88. {
  89. }
  90. }
  91. return (iNethinkCMS.Model.Model_iNethinkCMS_Plugs_Guestbook)objModel;
  92. }
  93. /// <summary>
  94. /// 获得数据列表
  95. /// </summary>
  96. public DataSet GetList(string strWhere)
  97. {
  98. return dal.GetList(strWhere);
  99. }
  100. /// <summary>
  101. /// 获得前几行数据
  102. /// </summary>
  103. public DataSet GetList(int Top, string strWhere, string filedOrder)
  104. {
  105. return dal.GetList(Top, strWhere, filedOrder);
  106. }
  107. /// <summary>
  108. /// 获得数据列表
  109. /// </summary>
  110. public List<iNethinkCMS.Model.Model_iNethinkCMS_Plugs_Guestbook> GetModelList(string strWhere)
  111. {
  112. DataSet ds = dal.GetList(strWhere);
  113. return DataTableToList(ds.Tables[0]);
  114. }
  115. /// <summary>
  116. /// 获得数据列表
  117. /// </summary>
  118. public List<iNethinkCMS.Model.Model_iNethinkCMS_Plugs_Guestbook> DataTableToList(DataTable dt)
  119. {
  120. List<iNethinkCMS.Model.Model_iNethinkCMS_Plugs_Guestbook> modelList = new List<iNethinkCMS.Model.Model_iNethinkCMS_Plugs_Guestbook>();
  121. int rowsCount = dt.Rows.Count;
  122. if (rowsCount > 0)
  123. {
  124. iNethinkCMS.Model.Model_iNethinkCMS_Plugs_Guestbook model;
  125. for (int n = 0; n < rowsCount; n++)
  126. {
  127. model = dal.DataRowToModel(dt.Rows[n]);
  128. if (model != null)
  129. {
  130. modelList.Add(model);
  131. }
  132. }
  133. }
  134. return modelList;
  135. }
  136. /// <summary>
  137. /// 获得数据列表
  138. /// </summary>
  139. public DataSet GetAllList()
  140. {
  141. return GetList("");
  142. }
  143. /// <summary>
  144. /// 分页获取数据列表
  145. /// </summary>
  146. public int GetRecordCount(string strWhere)
  147. {
  148. return dal.GetRecordCount(strWhere);
  149. }
  150. /// <summary>
  151. /// 分页获取数据列表
  152. /// </summary>
  153. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  154. {
  155. return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
  156. }
  157. }
  158. }