Нет описания

T_Cus_CustomerExpand.cs 17KB

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