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

T_Rec_RegRecords.cs 21KB

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