IBaseDataLaye.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data;
  5. namespace LYFZ.WeixinServiceDate.StandardInterface
  6. {
  7. /// <summary>
  8. /// 数据层基础接口
  9. /// </summary>
  10. public interface IBaseDataLaye
  11. {
  12. #region 属性
  13. /// <summary>
  14. /// 数据表模型对象
  15. /// </summary>
  16. object ObjModel { get; }
  17. /// <summary>
  18. /// 数据表名
  19. /// </summary>
  20. string TableName { get; set; }
  21. /// <summary>
  22. /// 数据表字段名字符串,字段名以“,”号分隔
  23. /// </summary>
  24. string TableFieldNameString { get; set; }
  25. /// <summary>
  26. /// 数据表字段名数组
  27. /// </summary>
  28. string[] TableFieldNames { get; }
  29. #endregion
  30. #region 检查记录
  31. /// <summary>
  32. /// 是否存在该记录
  33. /// </summary>
  34. bool Exists(int ID);
  35. /// <summary>
  36. /// 根据筛选条件判断是否存在该记录
  37. /// </summary>
  38. /// <param name="filterFieldName">筛选字段名</param>
  39. /// <param name="filterValue">筛选值</param>
  40. /// <returns></returns>
  41. bool Exists(string filterFieldName, object filterValue);
  42. /// <summary>
  43. /// 判断是否存某个字段
  44. /// </summary>
  45. /// <param name="columnName">列名称</param>
  46. /// <returns>是否存在</returns>
  47. bool ColumnExists(string columnName);
  48. #endregion
  49. #region 公共方法
  50. /// <summary>
  51. /// 获取最大ID()
  52. /// </summary>
  53. /// <returns></returns>
  54. int GetMaxID();
  55. /// <summary>
  56. /// 获取某字段最大值(获取字段必须为数字类型)
  57. /// </summary>
  58. /// <param name="FieldName">字段名</param>
  59. /// <returns></returns>
  60. int GetMaxID(string FieldName);
  61. #endregion
  62. #region 增加数据
  63. /// <summary>
  64. /// 增加一条数据
  65. /// </summary>
  66. /// <param name="model">Model对象</param>
  67. /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
  68. /// <returns></returns>
  69. bool Add(object model, string overlookFieldList = "ID");
  70. /// <summary>
  71. /// 获取更新数据的UpdateCommandInfo对象
  72. /// </summary>
  73. /// <param name="model"></param>
  74. /// <param name="overlookFieldList">要忽略的字段集合 多个字段名有“,”号分隔</param>
  75. /// <returns></returns>
  76. object GetAddCommandInfoObject(object model, string overlookFieldList = "ID");
  77. #endregion
  78. #region 删除数据
  79. /// <summary>
  80. /// 删除一条数据
  81. /// </summary>
  82. bool Delete(int ID);
  83. /// <summary>
  84. /// 按ID列表批量删除数据
  85. /// </summary>
  86. /// <param name="idList">ID列表,多个用“,”分隔</param>
  87. bool DeleteList(string idList);
  88. /// <summary>
  89. /// 批量删除数据
  90. /// </summary>
  91. /// <param name="filterFieldName">筛选字段名</param>
  92. /// <param name="valueList">值列表,多个值用“,”分隔,字符串值用“'”号包含</param>
  93. bool DeleteList(string filterFieldName, string valueList);
  94. /// <summary>
  95. /// 根据筛选字段删除数据
  96. /// </summary>
  97. /// <param name="filterValue">筛选值</param>
  98. /// <param name="filterFieldName">筛选字段名</param>
  99. /// <param name="operators">筛选SQL运算符</param>
  100. /// <returns></returns>
  101. bool Delete(object filterValue, string filterFieldName = "ID", string operators = "=");
  102. /// <summary>
  103. /// 根据where条件删除数据 不建义使用此方法
  104. /// </summary>
  105. /// <param name="whereStr">Wher条件,不包含“where”关键字</param>
  106. /// <returns></returns>
  107. bool Delete(string whereStr);
  108. /// <summary>
  109. /// 根据筛选字段或where条件删除数据
  110. /// </summary>
  111. /// <param name="filterFieldName">筛选字段名</param>
  112. /// <param name="operators">筛选SQL运算符</param>
  113. /// <param name="filterValue">筛选值</param>
  114. /// <param name="whereStr">Wher条件,传入条件语句时筛选字段无效不建义使用 不包含“where”关键字</param>
  115. /// <returns></returns>
  116. object GetDeleteCommandInfoObject(string filterFieldName = "ID", string operators = "=", object filterValue = null, string whereStr = null);
  117. #endregion
  118. #region 更新数据
  119. /// <summary>
  120. /// 更新一条数据
  121. /// </summary>
  122. /// <param name="model">Model对象</param>
  123. /// <param name="filterFieldName">筛选字段名称</param>
  124. /// <param name="operators">SQL筛选运算符号</param>
  125. /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
  126. /// <returns></returns>
  127. bool Update(object model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID");
  128. /// <summary>
  129. /// 根据Wher条件更新数据 不建义使用此方法
  130. /// </summary>
  131. /// <param name="model">Model对象</param>
  132. /// <param name="whereStr">Wher条件,不包含“where”关键字</param>
  133. /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
  134. /// <returns></returns>
  135. bool Update(object model, string whereStr, string overlookFieldList = "ID");
  136. /// <summary>
  137. /// 获取更新数据的UpdateCommandInfo对象 根据筛选字段和SQL筛选运算符号更新数据(内部方法)
  138. /// </summary>
  139. /// <param name="model">Model对象</param>
  140. /// <param name="filterFieldName">筛选字段名称</param>
  141. /// <param name="operators">忽略字段名列表 字段名之间用“,”号分隔</param>
  142. /// <param name="overlookFieldList">Wher条件,当指定条件语句时筛选字段设置无效,不包含“where”关键字 不建义使用此参数</param>
  143. /// <param name="whereStr"></param>
  144. /// <returns></returns>
  145. object GetUpdateCommandInfoObject(object model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID", string whereStr = null);
  146. #endregion
  147. #region 查询数据
  148. /// <summary>
  149. /// 得到一个对象实体
  150. /// </summary>
  151. object GetModelObject(int ID);
  152. /// <summary>
  153. /// 得到一个对象实体
  154. /// </summary>
  155. object DataRowToModelObject(DataRow row);
  156. /// <summary>
  157. /// 根据筛选条件获取一条数据Model对象
  158. /// </summary>
  159. /// <param name="filterFieldName">筛选条件字段名</param>
  160. /// <param name="filterValue">值</param>
  161. /// <returns></returns>
  162. object GetModelObject(string filterFieldName, object filterValue);
  163. /// <summary>
  164. /// 根据筛选条件获取一条数据Model对象
  165. /// </summary>
  166. /// <param name="filterFieldName">筛选条件字段名</param>
  167. /// <param name="filterValue">值</param>
  168. /// <param name="operators">SQL筛选运算符号</param>
  169. /// <returns></returns>
  170. object GetModelObject(string filterFieldName, object filterValue, string operators);
  171. /// <summary>
  172. /// 获取一条数据DataRow对象
  173. /// </summary>
  174. /// <param name="ID">id</param>
  175. /// <returns></returns>
  176. DataRow GetDataRow(int id);
  177. /// <summary>
  178. /// 根据筛选条件获取一条数据DataRow对象
  179. /// </summary>
  180. /// <param name="filterFieldName">筛选条件字段名</param>
  181. /// <param name="filterValue">值</param>
  182. /// <param name="operators">筛选SQL运算符</param>
  183. /// <returns></returns>
  184. DataRow GetDataRow(string filterFieldName, object filterValue, string operators = "=");
  185. /// <summary>
  186. /// 根据筛选条件获取一条数据DataRow对象(运算符是“=”)
  187. /// </summary>
  188. /// <param name="filterFieldName">筛选条件字段名</param>
  189. /// <param name="filterValue">值</param>
  190. /// <returns></returns>
  191. DataRow GetDataRow(string filterFieldName, object filterValue);
  192. /// <summary>
  193. /// 得到一个对象实体
  194. /// </summary>
  195. object DataRowToModel(DataRow row, object model);
  196. /// <summary>
  197. /// 获得数据列表
  198. /// </summary>
  199. /// <param name="strWhere">条件语句 不包含 where 关键字</param>
  200. /// <param name="filedOrder">SQL排序 如:id desc</param>
  201. DataSet GetList(string strWhere, string filedOrder = "ID desc");
  202. /// <summary>
  203. /// 获得前几行数据
  204. /// </summary>
  205. /// <param name="Top">行数</param>
  206. /// <param name="strWhere">条件 不包含 where 关键字</param>
  207. /// <param name="filedOrder">SQL排序 如:id asc</param>
  208. /// <returns></returns>
  209. DataSet GetList(int Top, string strWhere, string filedOrder = "ID asc");
  210. /// <summary>
  211. /// 获得全部数据列表
  212. /// </summary>
  213. /// <param name="filedOrder">SQL排序 如:id desc</param>
  214. DataSet GetAllList(string filedOrder = "ID desc");
  215. #endregion
  216. #region 数据分页
  217. /// <summary>
  218. /// 获取分页后总页数
  219. /// </summary>
  220. /// <param name="strWhere">筛选条件</param>
  221. /// <param name="pageSize">页面大小</param>
  222. /// <returns></returns>
  223. int GetByPageCount(string strWhere, int pageSize);
  224. /// <summary>
  225. /// 获取记录总数
  226. /// </summary>
  227. int GetRecordCount(string strWhere);
  228. /// <summary>
  229. /// 分页获取数据列表
  230. /// </summary>
  231. /// <param name="strWhere">筛选条件</param>
  232. /// <param name="pageIndex">当前页 不能小于0的整数</param>
  233. /// <param name="pageSize">页面大小,每页显示条数 不能小于0的整数</param>
  234. /// <param name="orderby">排序</param>
  235. /// <returns></returns>
  236. DataSet GetListByPage(string strWhere, int pageIndex, int pageSize, string orderby = "id desc");
  237. /// <summary>
  238. /// 分页获取数据列表
  239. /// </summary>
  240. /// <param name="strWhere">筛选条件</param>
  241. /// <param name="orderby">排序</param>
  242. /// <param name="pageIndex">当前页</param>
  243. /// <param name="pageSize">页面大小,每页显示条数</param>
  244. /// <param name="pageCount">返回总页数</param>
  245. /// <returns></returns>
  246. DataSet GetListByPage(string strWhere, string orderby, int pageIndex, int pageSize, ref int pageCount);
  247. /// <summary>
  248. /// 分页获取数据列表
  249. /// </summary>
  250. /// <param name="strWhere">条件</param>
  251. /// <param name="orderby">排序</param>
  252. /// <param name="startIndex">开始index</param>
  253. /// <param name="endIndex">结束index</param>
  254. /// <returns></returns>
  255. DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex);
  256. #endregion
  257. }
  258. }