新野县12345_后端

T_Sys_RoleFunction.cs 10KB

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