高新区管委会,以5.0标准版为基准,从双汇项目拷贝

T_RepositoryInformation.cs 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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_RepositoryInformation
  13. /// </summary>
  14. public partial class T_RepositoryInformation
  15. {
  16. private readonly CallCenterApi.DAL.T_Sys_AccessLog AccessLogdal = new CallCenterApi.DAL.T_Sys_AccessLog();
  17. public T_RepositoryInformation()
  18. { }
  19. #region BasicMethod
  20. /// <summary>
  21. /// 得到最大ID
  22. /// </summary>
  23. public int GetMaxId()
  24. {
  25. return DbHelperSQL.GetMaxID("F_RepositoryId", "T_RepositoryInformation");
  26. }
  27. /// <summary>
  28. /// 是否存在该记录
  29. /// </summary>
  30. public bool Exists(int F_RepositoryId)
  31. {
  32. StringBuilder strSql = new StringBuilder();
  33. strSql.Append("select count(1) from T_RepositoryInformation WITH(NOLOCK)");
  34. strSql.Append(" where F_RepositoryId=@F_RepositoryId");
  35. SqlParameter[] parameters = {
  36. new SqlParameter("@F_RepositoryId", SqlDbType.Int,4)
  37. };
  38. parameters[0].Value = F_RepositoryId;
  39. return DbHelperSQL.Exists(strSql.ToString(), parameters);
  40. }
  41. /// <summary>
  42. /// 增加一条数据
  43. /// </summary>
  44. public int Add(Model.T_RepositoryInformation model,int userId)
  45. {
  46. StringBuilder strSql = new StringBuilder();
  47. strSql.Append("insert into T_RepositoryInformation(");
  48. strSql.Append("F_CategoryId,F_CustomerId,F_CustomerName,F_ManId,F_ManName,F_Title,F_Content,F_Description,F_Comments,F_Url,F_KeyWords,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_CreateName,F_ModifyOn,F_ModifyBy,F_ModifyName,F_DeleteFlag)");
  49. strSql.Append(" values (");
  50. strSql.Append("@F_CategoryId,@F_CustomerId,@F_CustomerName,@F_ManId,@F_ManName,@F_Title,@F_Content,@F_Description,@F_Comments,@F_Url,@F_KeyWords,@F_Expand1,@F_Expand2,@F_IntExpand1,@F_CreateOn,@F_CreateBy,@F_CreateName,@F_ModifyOn,@F_ModifyBy,@F_ModifyName,@F_DeleteFlag)");
  51. strSql.Append(";select @@IDENTITY");
  52. SqlParameter[] parameters = {
  53. new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
  54. new SqlParameter("@F_CustomerId", SqlDbType.Int,4),
  55. new SqlParameter("@F_CustomerName", SqlDbType.NVarChar,100),
  56. new SqlParameter("@F_ManId", SqlDbType.Int,4),
  57. new SqlParameter("@F_ManName", SqlDbType.NVarChar,50),
  58. new SqlParameter("@F_Title", SqlDbType.NVarChar,200),
  59. new SqlParameter("@F_Content", SqlDbType.NText),
  60. new SqlParameter("@F_Description", SqlDbType.NText),
  61. new SqlParameter("@F_Comments", SqlDbType.NVarChar,500),
  62. new SqlParameter("@F_Url", SqlDbType.NVarChar,200),
  63. new SqlParameter("@F_KeyWords", SqlDbType.NVarChar,500),
  64. new SqlParameter("@F_Expand1", SqlDbType.NVarChar,100),
  65. new SqlParameter("@F_Expand2", SqlDbType.NVarChar,200),
  66. new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2),
  67. new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
  68. new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
  69. new SqlParameter("@F_CreateName", SqlDbType.NVarChar,200),
  70. new SqlParameter("@F_ModifyOn", SqlDbType.DateTime),
  71. new SqlParameter("@F_ModifyBy", SqlDbType.Int,4),
  72. new SqlParameter("@F_ModifyName", SqlDbType.NVarChar,200),
  73. new SqlParameter("@F_DeleteFlag", SqlDbType.SmallInt,2)};
  74. parameters[0].Value = model.F_CategoryId;
  75. parameters[1].Value = model.F_CustomerId;
  76. parameters[2].Value = model.F_CustomerName;
  77. parameters[3].Value = model.F_ManId;
  78. parameters[4].Value = model.F_ManName;
  79. parameters[5].Value = model.F_Title;
  80. parameters[6].Value = model.F_Content;
  81. parameters[7].Value = model.F_Description;
  82. parameters[8].Value = model.F_Comments;
  83. parameters[9].Value = model.F_Url;
  84. parameters[10].Value = model.F_KeyWords;
  85. parameters[11].Value = model.F_Expand1;
  86. parameters[12].Value = model.F_Expand2;
  87. parameters[13].Value = model.F_IntExpand1;
  88. parameters[14].Value = model.F_CreateOn;
  89. parameters[15].Value = model.F_CreateBy;
  90. parameters[16].Value = model.F_CreateName;
  91. parameters[17].Value = model.F_ModifyOn;
  92. parameters[18].Value = model.F_ModifyBy;
  93. parameters[19].Value = model.F_ModifyName;
  94. parameters[20].Value = model.F_DeleteFlag;
  95. object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
  96. if (obj == null)
  97. {
  98. return 0;
  99. }
  100. else
  101. {
  102. //日志添加
  103. AccessLogdal.AddAccessLog("新增", "T_RepositoryInformation", Convert.ToInt32(obj), userId);
  104. return Convert.ToInt32(obj);
  105. }
  106. }
  107. /// <summary>
  108. /// 更新一条数据
  109. /// </summary>
  110. public bool Update(Model.T_RepositoryInformation model,int userid)
  111. {
  112. StringBuilder strSql = new StringBuilder();
  113. strSql.Append("update T_RepositoryInformation set ");
  114. strSql.Append("F_CategoryId=@F_CategoryId,");
  115. strSql.Append("F_CustomerId=@F_CustomerId,");
  116. strSql.Append("F_CustomerName=@F_CustomerName,");
  117. strSql.Append("F_ManId=@F_ManId,");
  118. strSql.Append("F_ManName=@F_ManName,");
  119. strSql.Append("F_Title=@F_Title,");
  120. strSql.Append("F_Content=@F_Content,");
  121. strSql.Append("F_Description=@F_Description,");
  122. strSql.Append("F_Comments=@F_Comments,");
  123. strSql.Append("F_Url=@F_Url,");
  124. strSql.Append("F_KeyWords=@F_KeyWords,");
  125. strSql.Append("F_Expand1=@F_Expand1,");
  126. strSql.Append("F_Expand2=@F_Expand2,");
  127. strSql.Append("F_IntExpand1=@F_IntExpand1,");
  128. strSql.Append("F_CreateOn=@F_CreateOn,");
  129. strSql.Append("F_CreateBy=@F_CreateBy,");
  130. strSql.Append("F_CreateName=@F_CreateName,");
  131. strSql.Append("F_ModifyOn=@F_ModifyOn,");
  132. strSql.Append("F_ModifyBy=@F_ModifyBy,");
  133. strSql.Append("F_ModifyName=@F_ModifyName,");
  134. strSql.Append("F_DeleteFlag=@F_DeleteFlag");
  135. strSql.Append(" where F_RepositoryId=@F_RepositoryId");
  136. SqlParameter[] parameters = {
  137. new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
  138. new SqlParameter("@F_CustomerId", SqlDbType.Int,4),
  139. new SqlParameter("@F_CustomerName", SqlDbType.NVarChar,100),
  140. new SqlParameter("@F_ManId", SqlDbType.Int,4),
  141. new SqlParameter("@F_ManName", SqlDbType.NVarChar,50),
  142. new SqlParameter("@F_Title", SqlDbType.NVarChar,200),
  143. new SqlParameter("@F_Content", SqlDbType.NText),
  144. new SqlParameter("@F_Description", SqlDbType.NText),
  145. new SqlParameter("@F_Comments", SqlDbType.NVarChar,500),
  146. new SqlParameter("@F_Url", SqlDbType.NVarChar,200),
  147. new SqlParameter("@F_KeyWords", SqlDbType.NVarChar,500),
  148. new SqlParameter("@F_Expand1", SqlDbType.NVarChar,100),
  149. new SqlParameter("@F_Expand2", SqlDbType.NVarChar,200),
  150. new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2),
  151. new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
  152. new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
  153. new SqlParameter("@F_CreateName", SqlDbType.NVarChar,200),
  154. new SqlParameter("@F_ModifyOn", SqlDbType.DateTime),
  155. new SqlParameter("@F_ModifyBy", SqlDbType.Int,4),
  156. new SqlParameter("@F_ModifyName", SqlDbType.NVarChar,200),
  157. new SqlParameter("@F_DeleteFlag", SqlDbType.SmallInt,2),
  158. new SqlParameter("@F_RepositoryId", SqlDbType.Int,4)};
  159. parameters[0].Value = model.F_CategoryId;
  160. parameters[1].Value = model.F_CustomerId;
  161. parameters[2].Value = model.F_CustomerName;
  162. parameters[3].Value = model.F_ManId;
  163. parameters[4].Value = model.F_ManName;
  164. parameters[5].Value = model.F_Title;
  165. parameters[6].Value = model.F_Content;
  166. parameters[7].Value = model.F_Description;
  167. parameters[8].Value = model.F_Comments;
  168. parameters[9].Value = model.F_Url;
  169. parameters[10].Value = model.F_KeyWords;
  170. parameters[11].Value = model.F_Expand1;
  171. parameters[12].Value = model.F_Expand2;
  172. parameters[13].Value = model.F_IntExpand1;
  173. parameters[14].Value = model.F_CreateOn;
  174. parameters[15].Value = model.F_CreateBy;
  175. parameters[16].Value = model.F_CreateName;
  176. parameters[17].Value = model.F_ModifyOn;
  177. parameters[18].Value = model.F_ModifyBy;
  178. parameters[19].Value = model.F_ModifyName;
  179. parameters[20].Value = model.F_DeleteFlag;
  180. parameters[21].Value = model.F_RepositoryId;
  181. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  182. if (rows > 0)
  183. {
  184. AccessLogdal.AddAccessLog("修改", "T_RepositoryInformation", model.F_RepositoryId, userid);
  185. return true;
  186. }
  187. else
  188. {
  189. return false;
  190. }
  191. }
  192. /// <summary>
  193. /// 删除一条数据
  194. /// </summary>
  195. public bool Delete(int F_RepositoryId,int UserId )
  196. {
  197. StringBuilder strSql = new StringBuilder();
  198. //strSql.Append("delete from T_RepositoryInformation ");
  199. strSql.Append("update T_RepositoryInformation set F_DeleteFlag=1");
  200. strSql.Append(" where F_RepositoryId=@F_RepositoryId");
  201. SqlParameter[] parameters = {
  202. new SqlParameter("@F_RepositoryId", SqlDbType.Int,4)
  203. };
  204. parameters[0].Value = F_RepositoryId;
  205. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  206. if (rows > 0)
  207. {
  208. AccessLogdal.AddAccessLog("删除", "T_RepositoryInformation", F_RepositoryId, UserId);
  209. return true;
  210. }
  211. else
  212. {
  213. return false;
  214. }
  215. }
  216. /// <summary>
  217. /// 批量删除数据
  218. /// </summary>
  219. public bool DeleteList(string F_RepositoryIdlist)
  220. {
  221. StringBuilder strSql = new StringBuilder();
  222. //strSql.Append("delete from T_RepositoryInformation ");
  223. strSql.Append("update T_RepositoryInformation set F_DeleteFlag=1");
  224. strSql.Append(" where F_RepositoryId in (" + F_RepositoryIdlist + ") ");
  225. int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
  226. if (rows > 0)
  227. {
  228. return true;
  229. }
  230. else
  231. {
  232. return false;
  233. }
  234. }
  235. /// <summary>
  236. /// 得到一个对象实体
  237. /// </summary>
  238. public Model.T_RepositoryInformation GetModel(int F_RepositoryId,int userId )
  239. {
  240. StringBuilder strSql = new StringBuilder();
  241. strSql.Append("select top 1 F_RepositoryId,F_CategoryId,F_CustomerId,F_CustomerName,F_ManId,F_ManName,F_Title,F_Content,F_Description,F_Comments,F_Url,F_KeyWords,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_CreateName,F_ModifyOn,F_ModifyBy,F_ModifyName,F_DeleteFlag from T_RepositoryInformation WITH(NOLOCK) ");
  242. strSql.Append(" where F_RepositoryId=@F_RepositoryId");
  243. SqlParameter[] parameters = {
  244. new SqlParameter("@F_RepositoryId", SqlDbType.Int,4)
  245. };
  246. parameters[0].Value = F_RepositoryId;
  247. Model.T_RepositoryInformation model = new Model.T_RepositoryInformation();
  248. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  249. if (ds.Tables[0].Rows.Count > 0)
  250. {
  251. AccessLogdal.AddAccessLog("获取查看", "T_RepositoryInformation", F_RepositoryId, userId);
  252. return DataRowToModel(ds.Tables[0].Rows[0]);
  253. }
  254. else
  255. {
  256. return null;
  257. }
  258. }
  259. /// <summary>
  260. /// 得到一个对象实体
  261. /// </summary>
  262. public Model.T_RepositoryInformation DataRowToModel(DataRow row)
  263. {
  264. Model.T_RepositoryInformation model = new Model.T_RepositoryInformation();
  265. if (row != null)
  266. {
  267. if (row["F_RepositoryId"] != null && row["F_RepositoryId"].ToString() != "")
  268. {
  269. model.F_RepositoryId = int.Parse(row["F_RepositoryId"].ToString());
  270. }
  271. if (row["F_CategoryId"] != null && row["F_CategoryId"].ToString() != "")
  272. {
  273. model.F_CategoryId = int.Parse(row["F_CategoryId"].ToString());
  274. }
  275. if (row["F_CustomerId"] != null && row["F_CustomerId"].ToString() != "")
  276. {
  277. model.F_CustomerId = int.Parse(row["F_CustomerId"].ToString());
  278. }
  279. if (row["F_CustomerName"] != null)
  280. {
  281. model.F_CustomerName = row["F_CustomerName"].ToString();
  282. }
  283. if (row["F_ManId"] != null && row["F_ManId"].ToString() != "")
  284. {
  285. model.F_ManId = int.Parse(row["F_ManId"].ToString());
  286. }
  287. if (row["F_ManName"] != null)
  288. {
  289. model.F_ManName = row["F_ManName"].ToString();
  290. }
  291. if (row["F_Title"] != null)
  292. {
  293. model.F_Title = row["F_Title"].ToString();
  294. }
  295. if (row["F_Content"] != null)
  296. {
  297. model.F_Content = row["F_Content"].ToString();
  298. }
  299. if (row["F_Description"] != null)
  300. {
  301. model.F_Description = row["F_Description"].ToString();
  302. }
  303. if (row["F_Comments"] != null)
  304. {
  305. model.F_Comments = row["F_Comments"].ToString();
  306. }
  307. if (row["F_Url"] != null)
  308. {
  309. model.F_Url = row["F_Url"].ToString();
  310. }
  311. if (row["F_KeyWords"] != null)
  312. {
  313. model.F_KeyWords = row["F_KeyWords"].ToString();
  314. }
  315. if (row["F_Expand1"] != null)
  316. {
  317. model.F_Expand1 = row["F_Expand1"].ToString();
  318. }
  319. if (row["F_Expand2"] != null)
  320. {
  321. model.F_Expand2 = row["F_Expand2"].ToString();
  322. }
  323. if (row["F_IntExpand1"] != null && row["F_IntExpand1"].ToString() != "")
  324. {
  325. model.F_IntExpand1 = int.Parse(row["F_IntExpand1"].ToString());
  326. }
  327. if (row["F_CreateOn"] != null && row["F_CreateOn"].ToString() != "")
  328. {
  329. model.F_CreateOn = DateTime.Parse(row["F_CreateOn"].ToString());
  330. }
  331. if (row["F_CreateBy"] != null && row["F_CreateBy"].ToString() != "")
  332. {
  333. model.F_CreateBy = int.Parse(row["F_CreateBy"].ToString());
  334. }
  335. if (row["F_CreateName"] != null)
  336. {
  337. model.F_CreateName = row["F_CreateName"].ToString();
  338. }
  339. if (row["F_ModifyOn"] != null && row["F_ModifyOn"].ToString() != "")
  340. {
  341. model.F_ModifyOn = DateTime.Parse(row["F_ModifyOn"].ToString());
  342. }
  343. if (row["F_ModifyBy"] != null && row["F_ModifyBy"].ToString() != "")
  344. {
  345. model.F_ModifyBy = int.Parse(row["F_ModifyBy"].ToString());
  346. }
  347. if (row["F_ModifyName"] != null)
  348. {
  349. model.F_ModifyName = row["F_ModifyName"].ToString();
  350. }
  351. if (row["F_DeleteFlag"] != null && row["F_DeleteFlag"].ToString() != "")
  352. {
  353. model.F_DeleteFlag = int.Parse(row["F_DeleteFlag"].ToString());
  354. }
  355. }
  356. return model;
  357. }
  358. /// <summary>
  359. /// 获得数据列表
  360. /// </summary>
  361. public DataSet GetList(string strWhere)
  362. {
  363. StringBuilder strSql = new StringBuilder();
  364. strSql.Append("select F_RepositoryId,F_CategoryId,F_CustomerId,F_CustomerName,F_ManId,F_ManName,F_Title,F_Content,F_Description,F_Comments,F_Url,F_KeyWords,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_CreateName,F_ModifyOn,F_ModifyBy,F_ModifyName,F_DeleteFlag ");
  365. strSql.Append(" FROM T_RepositoryInformation WITH(NOLOCK)");
  366. if (strWhere.Trim() != "")
  367. {
  368. strSql.Append(" where " + strWhere);
  369. }
  370. return DbHelperSQL.Query(strSql.ToString());
  371. }
  372. /// <summary>
  373. /// 获得前几行数据
  374. /// </summary>
  375. public DataSet GetList(int Top, string strWhere, string filedOrder)
  376. {
  377. StringBuilder strSql = new StringBuilder();
  378. strSql.Append("select ");
  379. if (Top > 0)
  380. {
  381. strSql.Append(" top " + Top.ToString());
  382. }
  383. strSql.Append(" F_RepositoryId,F_CategoryId,F_CustomerId,F_CustomerName,F_ManId,F_ManName,F_Title,F_Content,F_Description,F_Comments,F_Url,F_KeyWords,F_Expand1,F_Expand2,F_IntExpand1,F_CreateOn,F_CreateBy,F_CreateName,F_ModifyOn,F_ModifyBy,F_ModifyName,F_DeleteFlag ");
  384. strSql.Append(" FROM T_RepositoryInformation WITH(NOLOCK)");
  385. if (strWhere.Trim() != "")
  386. {
  387. strSql.Append(" where " + strWhere);
  388. }
  389. strSql.Append(" order by " + filedOrder);
  390. return DbHelperSQL.Query(strSql.ToString());
  391. }
  392. /// <summary>
  393. /// 获取记录总数
  394. /// </summary>
  395. public int GetRecordCount(string strWhere)
  396. {
  397. StringBuilder strSql = new StringBuilder();
  398. strSql.Append("select count(1) FROM T_RepositoryInformation WITH(NOLOCK)");
  399. if (strWhere.Trim() != "")
  400. {
  401. strSql.Append(" where " + strWhere);
  402. }
  403. object obj = DbHelperSQL.GetSingle(strSql.ToString());
  404. if (obj == null)
  405. {
  406. return 0;
  407. }
  408. else
  409. {
  410. return Convert.ToInt32(obj);
  411. }
  412. }
  413. /// <summary>
  414. /// 分页获取数据列表
  415. /// </summary>
  416. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  417. {
  418. StringBuilder strSql = new StringBuilder();
  419. strSql.Append("SELECT * FROM ( ");
  420. strSql.Append(" SELECT ROW_NUMBER() OVER (");
  421. if (!string.IsNullOrEmpty(orderby.Trim()))
  422. {
  423. strSql.Append("order by T." + orderby);
  424. }
  425. else
  426. {
  427. strSql.Append("order by T.F_RepositoryId desc");
  428. }
  429. strSql.Append(")AS Row, T.* from T_RepositoryInformation T WITH(NOLOCK)");
  430. if (!string.IsNullOrEmpty(strWhere.Trim()))
  431. {
  432. strSql.Append(" WHERE " + strWhere);
  433. }
  434. strSql.Append(" ) TT");
  435. strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
  436. return DbHelperSQL.Query(strSql.ToString());
  437. }
  438. #endregion BasicMethod
  439. #region ExtensionMethod
  440. #endregion ExtensionMethod
  441. }
  442. }