市长热线演示版

T_Sys_RoleFunction.cs 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using HySoft.DBUtility;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. namespace HySoft.BaseCallCenter.DAL
  9. {
  10. /// <summary>
  11. /// 数据访问类:T_Sys_RoleFunction
  12. /// </summary>
  13. public partial class T_Sys_RoleFunction
  14. {
  15. public T_Sys_RoleFunction()
  16. { }
  17. #region BasicMethod
  18. /// <summary>
  19. /// 得到最大ID
  20. /// </summary>
  21. public int GetMaxId()
  22. {
  23. return DbHelperSQL.GetMaxID("F_RoleId", "T_Sys_RoleFunction");
  24. }
  25. /// <summary>
  26. /// 是否存在该记录
  27. /// </summary>
  28. public bool Exists(int F_RoleId, int F_FunctionId)
  29. {
  30. StringBuilder strSql = new StringBuilder();
  31. strSql.Append("select count(1) from T_Sys_RoleFunction");
  32. strSql.Append(" where F_RoleId=@F_RoleId and F_FunctionId=@F_FunctionId ");
  33. SqlParameter[] parameters = {
  34. new SqlParameter("@F_RoleId", SqlDbType.Int,4),
  35. new SqlParameter("@F_FunctionId", SqlDbType.Int,4) };
  36. parameters[0].Value = F_RoleId;
  37. parameters[1].Value = F_FunctionId;
  38. return DbHelperSQL.Exists(strSql.ToString(), parameters);
  39. }
  40. /// <summary>
  41. /// 增加一条数据
  42. /// </summary>
  43. public bool Add(HySoft.BaseCallCenter.Model.T_Sys_RoleFunction model)
  44. {
  45. StringBuilder strSql = new StringBuilder();
  46. strSql.Append("insert into T_Sys_RoleFunction(");
  47. strSql.Append("F_RoleId,F_FunctionId,F_IsKey)");
  48. strSql.Append(" values (");
  49. strSql.Append("@F_RoleId,@F_FunctionId,@F_IsKey)");
  50. SqlParameter[] parameters = {
  51. new SqlParameter("@F_RoleId", SqlDbType.Int,4),
  52. new SqlParameter("@F_FunctionId", SqlDbType.Int,4),
  53. new SqlParameter("@F_IsKey", SqlDbType.Int,4)};
  54. parameters[0].Value = model.F_RoleId;
  55. parameters[1].Value = model.F_FunctionId;
  56. parameters[2].Value = model.F_IsKey;
  57. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  58. if (rows > 0)
  59. {
  60. return true;
  61. }
  62. else
  63. {
  64. return false;
  65. }
  66. }
  67. /// <summary>
  68. /// 更新一条数据
  69. /// </summary>
  70. public bool Update(HySoft.BaseCallCenter.Model.T_Sys_RoleFunction model)
  71. {
  72. StringBuilder strSql = new StringBuilder();
  73. strSql.Append("update T_Sys_RoleFunction set ");
  74. strSql.Append("F_IsKey=@F_IsKey");
  75. strSql.Append(" where F_RoleId=@F_RoleId and F_FunctionId=@F_FunctionId ");
  76. SqlParameter[] parameters = {
  77. new SqlParameter("@F_IsKey", SqlDbType.Int,4),
  78. new SqlParameter("@F_RoleId", SqlDbType.Int,4),
  79. new SqlParameter("@F_FunctionId", SqlDbType.Int,4)};
  80. parameters[0].Value = model.F_IsKey;
  81. parameters[1].Value = model.F_RoleId;
  82. parameters[2].Value = model.F_FunctionId;
  83. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  84. if (rows > 0)
  85. {
  86. return true;
  87. }
  88. else
  89. {
  90. return false;
  91. }
  92. }
  93. /// <summary>
  94. /// 删除一条数据
  95. /// </summary>
  96. public bool Delete(int F_RoleId, int F_FunctionId)
  97. {
  98. StringBuilder strSql = new StringBuilder();
  99. strSql.Append("delete from T_Sys_RoleFunction ");
  100. strSql.Append(" where F_RoleId=@F_RoleId and F_FunctionId=@F_FunctionId ");
  101. SqlParameter[] parameters = {
  102. new SqlParameter("@F_RoleId", SqlDbType.Int,4),
  103. new SqlParameter("@F_FunctionId", SqlDbType.Int,4) };
  104. parameters[0].Value = F_RoleId;
  105. parameters[1].Value = F_FunctionId;
  106. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  107. if (rows > 0)
  108. {
  109. return true;
  110. }
  111. else
  112. {
  113. return false;
  114. }
  115. }
  116. /// <summary>
  117. /// 删除一条数据
  118. /// </summary>
  119. public bool Delete1(int F_RoleId)
  120. {
  121. StringBuilder strSql = new StringBuilder();
  122. strSql.Append("delete from T_Sys_RoleFunction ");
  123. strSql.Append(" where F_RoleId=@F_RoleId ");
  124. SqlParameter[] parameters = {
  125. new SqlParameter("@F_RoleId", SqlDbType.Int,4) };
  126. parameters[0].Value = F_RoleId;
  127. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  128. if (rows > 0)
  129. {
  130. return true;
  131. }
  132. else
  133. {
  134. return false;
  135. }
  136. }
  137. /// <summary>
  138. /// 得到一个对象实体
  139. /// </summary>
  140. public HySoft.BaseCallCenter.Model.T_Sys_RoleFunction GetModel(int F_RoleId, int F_FunctionId)
  141. {
  142. StringBuilder strSql = new StringBuilder();
  143. strSql.Append("select top 1 F_RoleId,F_FunctionId,F_IsKey from T_Sys_RoleFunction ");
  144. strSql.Append(" where F_RoleId=@F_RoleId and F_FunctionId=@F_FunctionId ");
  145. SqlParameter[] parameters = {
  146. new SqlParameter("@F_RoleId", SqlDbType.Int,4),
  147. new SqlParameter("@F_FunctionId", SqlDbType.Int,4) };
  148. parameters[0].Value = F_RoleId;
  149. parameters[1].Value = F_FunctionId;
  150. HySoft.BaseCallCenter.Model.T_Sys_RoleFunction model = new HySoft.BaseCallCenter.Model.T_Sys_RoleFunction();
  151. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  152. if (ds.Tables[0].Rows.Count > 0)
  153. {
  154. return DataRowToModel(ds.Tables[0].Rows[0]);
  155. }
  156. else
  157. {
  158. return null;
  159. }
  160. }
  161. /// <summary>
  162. /// 得到一个对象实体
  163. /// </summary>
  164. public HySoft.BaseCallCenter.Model.T_Sys_RoleFunction DataRowToModel(DataRow row)
  165. {
  166. HySoft.BaseCallCenter.Model.T_Sys_RoleFunction model = new HySoft.BaseCallCenter.Model.T_Sys_RoleFunction();
  167. if (row != null)
  168. {
  169. if (row["F_RoleId"] != null && row["F_RoleId"].ToString() != "")
  170. {
  171. model.F_RoleId = int.Parse(row["F_RoleId"].ToString());
  172. }
  173. if (row["F_FunctionId"] != null && row["F_FunctionId"].ToString() != "")
  174. {
  175. model.F_FunctionId = int.Parse(row["F_FunctionId"].ToString());
  176. }
  177. if (row["F_IsKey"] != null && row["F_IsKey"].ToString() != "")
  178. {
  179. model.F_IsKey = int.Parse(row["F_IsKey"].ToString());
  180. }
  181. }
  182. return model;
  183. }
  184. /// <summary>
  185. /// 获得数据列表
  186. /// </summary>
  187. public DataSet GetList(string strWhere)
  188. {
  189. StringBuilder strSql = new StringBuilder();
  190. strSql.Append("select F_RoleId,F_FunctionId,F_IsKey ");
  191. strSql.Append(" FROM T_Sys_RoleFunction ");
  192. if (strWhere.Trim() != "")
  193. {
  194. strSql.Append(" where " + strWhere);
  195. }
  196. return DbHelperSQL.Query(strSql.ToString());
  197. }
  198. /// <summary>
  199. /// 获得前几行数据
  200. /// </summary>
  201. public DataSet GetList(int Top, string strWhere, string filedOrder)
  202. {
  203. StringBuilder strSql = new StringBuilder();
  204. strSql.Append("select ");
  205. if (Top > 0)
  206. {
  207. strSql.Append(" top " + Top.ToString());
  208. }
  209. strSql.Append(" F_RoleId,F_FunctionId,F_IsKey ");
  210. strSql.Append(" FROM T_Sys_RoleFunction ");
  211. if (strWhere.Trim() != "")
  212. {
  213. strSql.Append(" where " + strWhere);
  214. }
  215. strSql.Append(" order by " + filedOrder);
  216. return DbHelperSQL.Query(strSql.ToString());
  217. }
  218. /// <summary>
  219. /// 获取记录总数
  220. /// </summary>
  221. public int GetRecordCount(string strWhere)
  222. {
  223. StringBuilder strSql = new StringBuilder();
  224. strSql.Append("select count(1) FROM T_Sys_RoleFunction ");
  225. if (strWhere.Trim() != "")
  226. {
  227. strSql.Append(" where " + strWhere);
  228. }
  229. object obj = DbHelperSQL.GetSingle(strSql.ToString());
  230. if (obj == null)
  231. {
  232. return 0;
  233. }
  234. else
  235. {
  236. return Convert.ToInt32(obj);
  237. }
  238. }
  239. /// <summary>
  240. /// 分页获取数据列表
  241. /// </summary>
  242. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  243. {
  244. StringBuilder strSql = new StringBuilder();
  245. strSql.Append("SELECT * FROM ( ");
  246. strSql.Append(" SELECT ROW_NUMBER() OVER (");
  247. if (!string.IsNullOrEmpty(orderby.Trim()))
  248. {
  249. strSql.Append("order by T." + orderby);
  250. }
  251. else
  252. {
  253. strSql.Append("order by T.F_FunctionId desc");
  254. }
  255. strSql.Append(")AS Row, T.* from T_Sys_RoleFunction T ");
  256. if (!string.IsNullOrEmpty(strWhere.Trim()))
  257. {
  258. strSql.Append(" WHERE " + strWhere);
  259. }
  260. strSql.Append(" ) TT");
  261. strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
  262. return DbHelperSQL.Query(strSql.ToString());
  263. }
  264. #endregion BasicMethod
  265. #region ExtensionMethod
  266. #endregion ExtensionMethod
  267. }
  268. }