Нет описания

T_RepositoryLog.cs 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. using CallCenterApi.DB;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace CallCenterApi.DAL
  10. {
  11. /// <summary>
  12. /// 数据访问类:T_RepositoryLog
  13. /// </summary>
  14. public partial class T_RepositoryLog
  15. {
  16. public T_RepositoryLog()
  17. { }
  18. #region BasicMethod
  19. /// <summary>
  20. /// 是否存在该记录
  21. /// </summary>
  22. public bool Exists(int F_LogId)
  23. {
  24. StringBuilder strSql = new StringBuilder();
  25. strSql.Append("select count(1) from T_RepositoryLog");
  26. strSql.Append(" where F_LogId=@F_LogId");
  27. SqlParameter[] parameters = {
  28. new SqlParameter("@F_LogId", SqlDbType.Int,4)
  29. };
  30. parameters[0].Value = F_LogId;
  31. return DbHelperSQL.Exists(strSql.ToString(), parameters);
  32. }
  33. /// <summary>
  34. /// 增加一条数据
  35. /// </summary>
  36. public int Add(CallCenterApi.Model.T_RepositoryLog model)
  37. {
  38. StringBuilder strSql = new StringBuilder();
  39. strSql.Append("insert into T_RepositoryLog(");
  40. strSql.Append("F_RepositoryId,F_Action,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_CreateOn,F_CreateBy,F_Expand1,F_Expand2,F_IntExpand1,F_IntExpand2,F_DeptId)");
  41. strSql.Append(" values (");
  42. strSql.Append("@F_RepositoryId,@F_Action,@F_Title,@F_Content,@F_Description,@F_Url,@F_KeyWords,@F_CreateOn,@F_CreateBy,@F_Expand1,@F_Expand2,@F_IntExpand1,@F_IntExpand2,@F_DeptId)");
  43. strSql.Append(";select @@IDENTITY");
  44. SqlParameter[] parameters = {
  45. new SqlParameter("@F_RepositoryId", SqlDbType.Int,4),
  46. new SqlParameter("@F_Action", SqlDbType.Int,4),
  47. new SqlParameter("@F_Title", SqlDbType.NVarChar,200),
  48. new SqlParameter("@F_Content", SqlDbType.NText),
  49. new SqlParameter("@F_Description", SqlDbType.NText),
  50. new SqlParameter("@F_Url", SqlDbType.NText),
  51. new SqlParameter("@F_KeyWords", SqlDbType.NVarChar,500),
  52. new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
  53. new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
  54. new SqlParameter("@F_Expand1", SqlDbType.NVarChar,100),
  55. new SqlParameter("@F_Expand2", SqlDbType.NVarChar,200),
  56. new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2),
  57. new SqlParameter("@F_IntExpand2", SqlDbType.Int ,4),
  58. new SqlParameter("@F_DeptId", SqlDbType.Int ,4)
  59. };
  60. parameters[0].Value = model.F_RepositoryId;
  61. parameters[1].Value = model.F_Action;
  62. parameters[2].Value = model.F_Title;
  63. parameters[3].Value = model.F_Content;
  64. parameters[4].Value = model.F_Description;
  65. parameters[5].Value = model.F_Url;
  66. parameters[6].Value = model.F_KeyWords;
  67. parameters[7].Value = model.F_CreateOn;
  68. parameters[8].Value = model.F_CreateBy;
  69. parameters[9].Value = model.F_Expand1;
  70. parameters[10].Value = model.F_Expand2;
  71. parameters[11].Value = model.F_IntExpand1;
  72. parameters[12].Value = model.F_IntExpand2;
  73. parameters[13].Value = model.F_DeptId;
  74. object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
  75. if (obj == null)
  76. {
  77. return 0;
  78. }
  79. else
  80. {
  81. return Convert.ToInt32(obj);
  82. }
  83. }
  84. /// <summary>
  85. /// 更新一条数据
  86. /// </summary>
  87. public bool Update(CallCenterApi.Model.T_RepositoryLog model)
  88. {
  89. StringBuilder strSql = new StringBuilder();
  90. strSql.Append("update T_RepositoryLog set ");
  91. strSql.Append("F_RepositoryId=@F_RepositoryId,");
  92. strSql.Append("F_Action=@F_Action,");
  93. strSql.Append("F_Title=@F_Title,");
  94. strSql.Append("F_Content=@F_Content,");
  95. strSql.Append("F_Description=@F_Description,");
  96. strSql.Append("F_Url=@F_Url,");
  97. strSql.Append("F_KeyWords=@F_KeyWords,");
  98. strSql.Append("F_CreateOn=@F_CreateOn,");
  99. strSql.Append("F_CreateBy=@F_CreateBy,");
  100. strSql.Append("F_Expand1=@F_Expand1,");
  101. strSql.Append("F_Expand2=@F_Expand2,");
  102. strSql.Append("F_IntExpand1=@F_IntExpand1,");
  103. strSql.Append("F_DeptId=@F_DeptId");
  104. strSql.Append(" where F_LogId=@F_LogId");
  105. SqlParameter[] parameters = {
  106. new SqlParameter("@F_RepositoryId", SqlDbType.Int,4),
  107. new SqlParameter("@F_Action", SqlDbType.Int,4),
  108. new SqlParameter("@F_Title", SqlDbType.NVarChar,200),
  109. new SqlParameter("@F_Content", SqlDbType.NText),
  110. new SqlParameter("@F_Description", SqlDbType.NText),
  111. new SqlParameter("@F_Url", SqlDbType.NText),
  112. new SqlParameter("@F_KeyWords", SqlDbType.NVarChar,500),
  113. new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
  114. new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
  115. new SqlParameter("@F_Expand1", SqlDbType.NVarChar,100),
  116. new SqlParameter("@F_Expand2", SqlDbType.NVarChar,200),
  117. new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2),
  118. new SqlParameter("@F_DeptId", SqlDbType.Int,4),
  119. new SqlParameter("@F_LogId", SqlDbType.Int,4)};
  120. parameters[0].Value = model.F_RepositoryId;
  121. parameters[1].Value = model.F_Action;
  122. parameters[2].Value = model.F_Title;
  123. parameters[3].Value = model.F_Content;
  124. parameters[4].Value = model.F_Description;
  125. parameters[5].Value = model.F_Url;
  126. parameters[6].Value = model.F_KeyWords;
  127. parameters[7].Value = model.F_CreateOn;
  128. parameters[8].Value = model.F_CreateBy;
  129. parameters[9].Value = model.F_Expand1;
  130. parameters[10].Value = model.F_Expand2;
  131. parameters[11].Value = model.F_IntExpand1;
  132. parameters[12].Value = model.F_DeptId;
  133. parameters[13].Value = model.F_LogId;
  134. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  135. if (rows > 0)
  136. {
  137. return true;
  138. }
  139. else
  140. {
  141. return false;
  142. }
  143. }
  144. /// <summary>
  145. /// 删除一条数据
  146. /// </summary>
  147. public bool Delete(int F_LogId)
  148. {
  149. StringBuilder strSql = new StringBuilder();
  150. strSql.Append("delete from T_RepositoryLog ");
  151. strSql.Append(" where F_LogId=@F_LogId");
  152. SqlParameter[] parameters = {
  153. new SqlParameter("@F_LogId", SqlDbType.Int,4)
  154. };
  155. parameters[0].Value = F_LogId;
  156. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  157. if (rows > 0)
  158. {
  159. return true;
  160. }
  161. else
  162. {
  163. return false;
  164. }
  165. }
  166. /// <summary>
  167. /// 批量删除数据
  168. /// </summary>
  169. public bool DeleteList(string F_LogIdlist)
  170. {
  171. StringBuilder strSql = new StringBuilder();
  172. strSql.Append("delete from T_RepositoryLog ");
  173. strSql.Append(" where F_LogId in (" + F_LogIdlist + ") ");
  174. int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
  175. if (rows > 0)
  176. {
  177. return true;
  178. }
  179. else
  180. {
  181. return false;
  182. }
  183. }
  184. /// <summary>
  185. /// 得到一个对象实体
  186. /// </summary>
  187. public CallCenterApi.Model.T_RepositoryLog GetModel(int F_LogId)
  188. {
  189. StringBuilder strSql = new StringBuilder();
  190. strSql.Append("select top 1 F_IntExpand2,F_LogId,F_DeptId,F_RepositoryId,F_Action,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_CreateOn,F_CreateBy,F_Expand1,F_Expand2,F_IntExpand1 from T_RepositoryLog ");
  191. strSql.Append(" where F_LogId=@F_LogId");
  192. SqlParameter[] parameters = {
  193. new SqlParameter("@F_LogId", SqlDbType.Int,4)
  194. };
  195. parameters[0].Value = F_LogId;
  196. CallCenterApi.Model.T_RepositoryLog model = new CallCenterApi.Model.T_RepositoryLog();
  197. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  198. if (ds.Tables[0].Rows.Count > 0)
  199. {
  200. return DataRowToModel(ds.Tables[0].Rows[0]);
  201. }
  202. else
  203. {
  204. return null;
  205. }
  206. }
  207. /// <summary>
  208. /// 得到一个对象实体
  209. /// </summary>
  210. public CallCenterApi.Model.T_RepositoryLog DataRowToModel(DataRow row)
  211. {
  212. CallCenterApi.Model.T_RepositoryLog model = new CallCenterApi.Model.T_RepositoryLog();
  213. if (row != null)
  214. {
  215. if (row["F_LogId"] != null && row["F_LogId"].ToString() != "")
  216. {
  217. model.F_LogId = int.Parse(row["F_LogId"].ToString());
  218. }
  219. if (row["F_RepositoryId"] != null && row["F_RepositoryId"].ToString() != "")
  220. {
  221. model.F_RepositoryId = int.Parse(row["F_RepositoryId"].ToString());
  222. }
  223. if (row["F_Action"] != null && row["F_Action"].ToString() != "")
  224. {
  225. model.F_Action = int.Parse(row["F_Action"].ToString());
  226. }
  227. if (row["F_Title"] != null)
  228. {
  229. model.F_Title = row["F_Title"].ToString();
  230. }
  231. if (row["F_Content"] != null)
  232. {
  233. model.F_Content = row["F_Content"].ToString();
  234. }
  235. if (row["F_Description"] != null)
  236. {
  237. model.F_Description = row["F_Description"].ToString();
  238. }
  239. if (row["F_Url"] != null)
  240. {
  241. model.F_Url = row["F_Url"].ToString();
  242. }
  243. if (row["F_KeyWords"] != null)
  244. {
  245. model.F_KeyWords = row["F_KeyWords"].ToString();
  246. }
  247. if (row["F_CreateOn"] != null && row["F_CreateOn"].ToString() != "")
  248. {
  249. model.F_CreateOn = DateTime.Parse(row["F_CreateOn"].ToString());
  250. }
  251. if (row["F_CreateBy"] != null && row["F_CreateBy"].ToString() != "")
  252. {
  253. model.F_CreateBy = int.Parse(row["F_CreateBy"].ToString());
  254. }
  255. if (row["F_Expand1"] != null)
  256. {
  257. model.F_Expand1 = row["F_Expand1"].ToString();
  258. }
  259. if (row["F_Expand2"] != null)
  260. {
  261. model.F_Expand2 = row["F_Expand2"].ToString();
  262. }
  263. if (row["F_IntExpand1"] != null && row["F_IntExpand1"].ToString() != "")
  264. {
  265. model.F_IntExpand1 = int.Parse(row["F_IntExpand1"].ToString());
  266. }
  267. if (row["F_IntExpand2"] != null && row["F_IntExpand2"].ToString() != "")
  268. {
  269. model.F_IntExpand2 = int.Parse(row["F_IntExpand2"].ToString());
  270. }
  271. if (row["F_DeptId"] != null && row["F_DeptId"].ToString() != "")
  272. {
  273. model.F_DeptId = int.Parse(row["F_DeptId"].ToString());
  274. }
  275. }
  276. return model;
  277. }
  278. /// <summary>
  279. /// 获得数据列表
  280. /// </summary>
  281. public DataSet GetList(string strWhere)
  282. {
  283. StringBuilder strSql = new StringBuilder();
  284. strSql.Append("select F_LogId,F_RepositoryId,F_DeptId,F_IntExpand2,F_Action,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_CreateOn,F_CreateBy,F_Expand1,F_Expand2,F_IntExpand1 ");
  285. strSql.Append(" FROM T_RepositoryLog ");
  286. if (strWhere.Trim() != "")
  287. {
  288. strSql.Append(" where " + strWhere);
  289. }
  290. return DbHelperSQL.Query(strSql.ToString());
  291. }
  292. /// <summary>
  293. /// 获得前几行数据
  294. /// </summary>
  295. public DataSet GetList(int Top, string strWhere, string filedOrder)
  296. {
  297. StringBuilder strSql = new StringBuilder();
  298. strSql.Append("select ");
  299. if (Top > 0)
  300. {
  301. strSql.Append(" top " + Top.ToString());
  302. }
  303. strSql.Append(" F_LogId,F_RepositoryId,F_DeptId,F_Action,F_IntExpand2,F_Title,F_Content,F_Description,F_Url,F_KeyWords,F_CreateOn,F_CreateBy,F_Expand1,F_Expand2,F_IntExpand1 ");
  304. strSql.Append(" FROM T_RepositoryLog ");
  305. if (strWhere.Trim() != "")
  306. {
  307. strSql.Append(" where " + strWhere);
  308. }
  309. strSql.Append(" order by " + filedOrder);
  310. return DbHelperSQL.Query(strSql.ToString());
  311. }
  312. /// <summary>
  313. /// 获取记录总数
  314. /// </summary>
  315. public int GetRecordCount(string strWhere)
  316. {
  317. StringBuilder strSql = new StringBuilder();
  318. strSql.Append("select count(1) FROM T_RepositoryLog ");
  319. if (strWhere.Trim() != "")
  320. {
  321. strSql.Append(" where " + strWhere);
  322. }
  323. object obj = DbHelperSQL.GetSingle(strSql.ToString());
  324. if (obj == null)
  325. {
  326. return 0;
  327. }
  328. else
  329. {
  330. return Convert.ToInt32(obj);
  331. }
  332. }
  333. /// <summary>
  334. /// 分页获取数据列表
  335. /// </summary>
  336. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  337. {
  338. StringBuilder strSql = new StringBuilder();
  339. strSql.Append("SELECT * FROM ( ");
  340. strSql.Append(" SELECT ROW_NUMBER() OVER (");
  341. if (!string.IsNullOrEmpty(orderby.Trim()))
  342. {
  343. strSql.Append("order by T." + orderby);
  344. }
  345. else
  346. {
  347. strSql.Append("order by T.F_LogId desc");
  348. }
  349. strSql.Append(")AS Row, T.* from T_RepositoryLog T ");
  350. if (!string.IsNullOrEmpty(strWhere.Trim()))
  351. {
  352. strSql.Append(" WHERE " + strWhere);
  353. }
  354. strSql.Append(" ) TT");
  355. strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
  356. return DbHelperSQL.Query(strSql.ToString());
  357. }
  358. #endregion BasicMethod
  359. #region ExtensionMethod
  360. #endregion ExtensionMethod
  361. }
  362. }