No Description

T_RepositoryLog.cs 14KB

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