暫無描述

T_QC_IndexRes.cs 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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_QC_IndexRes
  13. /// </summary>
  14. public partial class T_QC_IndexRes
  15. {
  16. public T_QC_IndexRes()
  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_QC_IndexRes");
  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(Model.T_QC_IndexRes model)
  37. {
  38. StringBuilder strSql = new StringBuilder();
  39. strSql.Append("insert into T_QC_IndexRes(");
  40. strSql.Append("CallRecordsId,F_IndexId,F_Score,F_QCScore,F_Remark)");
  41. strSql.Append(" values (");
  42. strSql.Append("@CallRecordsId,@F_IndexId,@F_Score,@F_QCScore,@F_Remark)");
  43. strSql.Append(";select @@IDENTITY");
  44. SqlParameter[] parameters = {
  45. new SqlParameter("@CallRecordsId", SqlDbType.Int,4),
  46. new SqlParameter("@F_IndexId", SqlDbType.Int,4),
  47. new SqlParameter("@F_Score", SqlDbType.Int,4),
  48. new SqlParameter("@F_QCScore", SqlDbType.Int,4),
  49. new SqlParameter("@F_Remark", SqlDbType.NVarChar,2000)};
  50. parameters[0].Value = model.CallRecordsId;
  51. parameters[1].Value = model.F_IndexId;
  52. parameters[2].Value = model.F_Score;
  53. parameters[3].Value = model.F_QCScore;
  54. parameters[4].Value = model.F_Remark;
  55. object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
  56. if (obj == null)
  57. {
  58. return 0;
  59. }
  60. else
  61. {
  62. return Convert.ToInt32(obj);
  63. }
  64. }
  65. /// <summary>
  66. /// 更新一条数据
  67. /// </summary>
  68. public bool Update(Model.T_QC_IndexRes model)
  69. {
  70. StringBuilder strSql = new StringBuilder();
  71. strSql.Append("update T_QC_IndexRes set ");
  72. strSql.Append("CallRecordsId=@CallRecordsId,");
  73. strSql.Append("F_IndexId=@F_IndexId,");
  74. strSql.Append("F_Score=@F_Score,");
  75. strSql.Append("F_QCScore=@F_QCScore,");
  76. strSql.Append("F_Remark=@F_Remark");
  77. strSql.Append(" where F_Id=@F_Id");
  78. SqlParameter[] parameters = {
  79. new SqlParameter("@CallRecordsId", SqlDbType.Int,4),
  80. new SqlParameter("@F_IndexId", SqlDbType.Int,4),
  81. new SqlParameter("@F_Score", SqlDbType.Int,4),
  82. new SqlParameter("@F_QCScore", SqlDbType.Int,4),
  83. new SqlParameter("@F_Remark", SqlDbType.NVarChar,2000),
  84. new SqlParameter("@F_Id", SqlDbType.Int,4)};
  85. parameters[0].Value = model.CallRecordsId;
  86. parameters[1].Value = model.F_IndexId;
  87. parameters[2].Value = model.F_Score;
  88. parameters[3].Value = model.F_QCScore;
  89. parameters[4].Value = model.F_Remark;
  90. parameters[5].Value = model.F_Id;
  91. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  92. if (rows > 0)
  93. {
  94. return true;
  95. }
  96. else
  97. {
  98. return false;
  99. }
  100. }
  101. /// <summary>
  102. /// 删除一条数据
  103. /// </summary>
  104. public bool Delete(int F_Id)
  105. {
  106. StringBuilder strSql = new StringBuilder();
  107. strSql.Append("delete from T_QC_IndexRes ");
  108. strSql.Append(" where F_Id=@F_Id");
  109. SqlParameter[] parameters = {
  110. new SqlParameter("@F_Id", SqlDbType.Int,4)
  111. };
  112. parameters[0].Value = F_Id;
  113. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  114. if (rows > 0)
  115. {
  116. return true;
  117. }
  118. else
  119. {
  120. return false;
  121. }
  122. }
  123. /// <summary>
  124. /// 批量删除数据
  125. /// </summary>
  126. public bool DeleteList(string F_Idlist)
  127. {
  128. StringBuilder strSql = new StringBuilder();
  129. strSql.Append("delete from T_QC_IndexRes ");
  130. strSql.Append(" where F_Id in (" + F_Idlist + ") ");
  131. int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
  132. if (rows > 0)
  133. {
  134. return true;
  135. }
  136. else
  137. {
  138. return false;
  139. }
  140. }
  141. /// <summary>
  142. /// 得到一个对象实体
  143. /// </summary>
  144. public Model.T_QC_IndexRes GetModel(int F_Id)
  145. {
  146. StringBuilder strSql = new StringBuilder();
  147. strSql.Append("select top 1 F_Id,CallRecordsId,F_IndexId,F_Score,F_QCScore,F_Remark from T_QC_IndexRes ");
  148. strSql.Append(" where F_Id=@F_Id");
  149. SqlParameter[] parameters = {
  150. new SqlParameter("@F_Id", SqlDbType.Int,4)
  151. };
  152. parameters[0].Value = F_Id;
  153. Model.T_QC_IndexRes model = new Model.T_QC_IndexRes();
  154. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  155. if (ds.Tables[0].Rows.Count > 0)
  156. {
  157. if (ds.Tables[0].Rows[0]["F_Id"] != null && ds.Tables[0].Rows[0]["F_Id"].ToString() != "")
  158. {
  159. model.F_Id = int.Parse(ds.Tables[0].Rows[0]["F_Id"].ToString());
  160. }
  161. if (ds.Tables[0].Rows[0]["CallRecordsId"] != null && ds.Tables[0].Rows[0]["CallRecordsId"].ToString() != "")
  162. {
  163. model.CallRecordsId = int.Parse(ds.Tables[0].Rows[0]["CallRecordsId"].ToString());
  164. }
  165. if (ds.Tables[0].Rows[0]["F_IndexId"] != null && ds.Tables[0].Rows[0]["F_IndexId"].ToString() != "")
  166. {
  167. model.F_IndexId = int.Parse(ds.Tables[0].Rows[0]["F_IndexId"].ToString());
  168. }
  169. if (ds.Tables[0].Rows[0]["F_Score"] != null && ds.Tables[0].Rows[0]["F_Score"].ToString() != "")
  170. {
  171. model.F_Score = int.Parse(ds.Tables[0].Rows[0]["F_Score"].ToString());
  172. }
  173. if (ds.Tables[0].Rows[0]["F_QCScore"] != null && ds.Tables[0].Rows[0]["F_QCScore"].ToString() != "")
  174. {
  175. model.F_QCScore = int.Parse(ds.Tables[0].Rows[0]["F_QCScore"].ToString());
  176. }
  177. if (ds.Tables[0].Rows[0]["F_Remark"] != null && ds.Tables[0].Rows[0]["F_Remark"].ToString() != "")
  178. {
  179. model.F_Remark = ds.Tables[0].Rows[0]["F_Remark"].ToString();
  180. }
  181. return model;
  182. }
  183. else
  184. {
  185. return null;
  186. }
  187. }
  188. /// <summary>
  189. /// 获得数据列表
  190. /// </summary>
  191. public DataSet GetList(string strWhere)
  192. {
  193. StringBuilder strSql = new StringBuilder();
  194. strSql.Append("select F_Id,CallRecordsId,F_IndexId,F_Score,F_QCScore,F_Remark ");
  195. strSql.Append(" FROM T_QC_IndexRes ");
  196. if (strWhere.Trim() != "")
  197. {
  198. strSql.Append(" where " + strWhere);
  199. }
  200. return DbHelperSQL.Query(strSql.ToString());
  201. }
  202. /// <summary>
  203. /// 获得前几行数据
  204. /// </summary>
  205. public DataSet GetList(int Top, string strWhere, string filedOrder)
  206. {
  207. StringBuilder strSql = new StringBuilder();
  208. strSql.Append("select ");
  209. if (Top > 0)
  210. {
  211. strSql.Append(" top " + Top.ToString());
  212. }
  213. strSql.Append(" F_Id,CallRecordsId,F_IndexId,F_Score,F_QCScore,F_Remark ");
  214. strSql.Append(" FROM T_QC_IndexRes ");
  215. if (strWhere.Trim() != "")
  216. {
  217. strSql.Append(" where " + strWhere);
  218. }
  219. strSql.Append(" order by " + filedOrder);
  220. return DbHelperSQL.Query(strSql.ToString());
  221. }
  222. /// <summary>
  223. /// 获取记录总数
  224. /// </summary>
  225. public int GetRecordCount(string strWhere)
  226. {
  227. StringBuilder strSql = new StringBuilder();
  228. strSql.Append("select count(1) FROM T_QC_IndexRes ");
  229. if (strWhere.Trim() != "")
  230. {
  231. strSql.Append(" where " + strWhere);
  232. }
  233. object obj = DbHelperSQL.GetSingle(strSql.ToString());
  234. if (obj == null)
  235. {
  236. return 0;
  237. }
  238. else
  239. {
  240. return Convert.ToInt32(obj);
  241. }
  242. }
  243. /// <summary>
  244. /// 分页获取数据列表
  245. /// </summary>
  246. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  247. {
  248. StringBuilder strSql = new StringBuilder();
  249. strSql.Append("SELECT * FROM ( ");
  250. strSql.Append(" SELECT ROW_NUMBER() OVER (");
  251. if (!string.IsNullOrEmpty(orderby.Trim()))
  252. {
  253. strSql.Append("order by T." + orderby);
  254. }
  255. else
  256. {
  257. strSql.Append("order by T.F_Id desc");
  258. }
  259. strSql.Append(")AS Row, T.* from T_QC_IndexRes T ");
  260. if (!string.IsNullOrEmpty(strWhere.Trim()))
  261. {
  262. strSql.Append(" WHERE " + strWhere);
  263. }
  264. strSql.Append(" ) TT");
  265. strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
  266. return DbHelperSQL.Query(strSql.ToString());
  267. }
  268. #endregion Method
  269. }
  270. }