TravelList_ExternalService.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using Models;
  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. namespace DAL
  9. {
  10. public class TravelList_ExternalService
  11. {
  12. /// <summary>
  13. /// 查询所有
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<TravelList_External> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<TravelList_External>.excuteSql(new TravelList_External(), "TravelList_External", sql, CommandType.Text, param);
  21. }
  22. /// <summary>
  23. /// 获取单个对象
  24. /// </summary>
  25. /// <param name="sql">sql语句</param>
  26. /// <param name="param">可变参数数组</param>
  27. /// <returns>返回空或者单个对象</returns>
  28. TravelList_External excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<TravelList_External> hdList = excuteSql(sql, param);
  32. //判断集合是否为空
  33. if (hdList == null || hdList.Count == 0)
  34. //返回null
  35. return null;
  36. //返回单个对象
  37. return hdList[0];
  38. }
  39. /// <summary>
  40. /// 根据编号查询对象信息
  41. /// </summary>
  42. /// <param name="id">对象编号</param>
  43. /// <returns>返回空或者单个对象信息</returns>
  44. public TravelList_External GetById(int id)
  45. {
  46. //调用获取单个对象的方法
  47. return excuteType("select * from TravelList_External where Id = @id", new SqlParameter("@id", id));
  48. }
  49. /// <summary>
  50. /// 根据团组编号查询信息
  51. /// </summary>
  52. /// <returns>返回空或者对象信息</returns>
  53. public List<TravelList_External> GetByDiid(int Diid)
  54. {
  55. //调用获取单个对象的方法
  56. return excuteSql("select * from TravelList_External where Diid =" + Diid + " and Isdel=0 order by Id");
  57. }
  58. /// <summary>
  59. /// 获取全部
  60. /// </summary>
  61. /// <returns></returns>
  62. public List<TravelList_External> GetAll()
  63. {
  64. return excuteSql("select * from TravelList_External where Isdel=0");
  65. }
  66. /// <summary>
  67. /// 增加
  68. /// </summary>
  69. /// <param name="cd"></param>
  70. /// <returns></returns>
  71. public bool AddTravelList_External(TravelList_External hd)
  72. {
  73. string sql = "insert into TravelList_External values(@Diid,@Days,@Date,@WeekDay,@Traffic_First,@Traffic_Second,@Trip,@OPer,@OPdate,@Isdel)";
  74. SqlParameter[] parameter = new SqlParameter[]{
  75. new SqlParameter("@Diid",hd.Diid),
  76. new SqlParameter("@Days",hd.Days),
  77. new SqlParameter("@Date",hd.Date),
  78. new SqlParameter("@WeekDay",hd.WeekDay),
  79. new SqlParameter("@Traffic_First",hd.Traffic_First),
  80. new SqlParameter("@Traffic_Second",hd.Traffic_Second),
  81. new SqlParameter("@Trip",hd.Trip),
  82. new SqlParameter("@OPer",hd.OPer),
  83. new SqlParameter("@OPdate",hd.OPdate),
  84. new SqlParameter("@Isdel",hd.Isdel)
  85. };
  86. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  87. return true;
  88. return false;
  89. }
  90. /// <summary>
  91. /// 编辑
  92. /// </summary>
  93. /// <param name="sdt"></param>
  94. /// <returns></returns>
  95. public bool EditTravelList_External(TravelList_External hd)
  96. {
  97. string sql = "update TravelList_External set Diid=@Diid,Days = @Days,Date = @Date,WeekDay = @WeekDay,Traffic_First = @Traffic_First,"
  98. + "Traffic_Second = @Traffic_Second,Trip = @Trip,OPer = @OPer,OPdate = @OPdate,Isdel = @Isdel where Id = @Id";
  99. SqlParameter[] parameter = new SqlParameter[]{
  100. new SqlParameter("@Diid",hd.Diid),
  101. new SqlParameter("@Days",hd.Days),
  102. new SqlParameter("@Date",hd.Date),
  103. new SqlParameter("@WeekDay",hd.WeekDay),
  104. new SqlParameter("@Traffic_First",hd.Traffic_First),
  105. new SqlParameter("@Traffic_Second",hd.Traffic_Second),
  106. new SqlParameter("@Trip",hd.Trip),
  107. new SqlParameter("@OPer",hd.OPer),
  108. new SqlParameter("@OPdate",hd.OPdate),
  109. new SqlParameter("@Isdel",hd.Isdel),
  110. new SqlParameter("@Id",hd.Id)
  111. };
  112. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  113. return true;
  114. return false;
  115. }
  116. /// <summary>
  117. /// 20210818 贾文滔
  118. /// 根据ID执行delete操作
  119. /// </summary>
  120. /// <param name="id"></param>
  121. /// <returns></returns>
  122. public bool DelTravelList_External(int id)
  123. {
  124. if (SqlHelper.ExecuteNonQuery("delete TravelList_External where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  125. return true;
  126. return false;
  127. }
  128. /// <summary>
  129. /// 20210818 贾文滔
  130. /// 根据id执行清空"trip" 字段操作
  131. /// </summary>
  132. /// <param name="id"></param>
  133. /// <returns></returns>
  134. public bool Clean(int id)
  135. {
  136. if (SqlHelper.ExecuteNonQuery("update TravelList_External set Trip='' where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  137. return true;
  138. return false;
  139. }
  140. /// <summary>
  141. /// 20210818 贾文滔
  142. /// 根据团号和ID范围执行delete操作
  143. /// </summary>
  144. /// <param name="Diid"></param>
  145. /// <param name="start"></param>
  146. /// <param name="end"></param>
  147. /// <returns></returns>
  148. public bool DelOld(int Diid, int start, int end)
  149. {
  150. if (SqlHelper.ExecuteNonQuery("delete from TravelList_External where Diid=" + Diid + " and ( Id>=" + start + " and Id<=" + end + ")", CommandType.Text) > 0)
  151. return true;
  152. return false;
  153. }
  154. /// <summary>
  155. /// 20210818
  156. /// 根据团号diid 执行更新ISDEL=1的删除操作
  157. /// </summary>
  158. /// <param name="diid"></param>
  159. /// <returns></returns>
  160. public bool DelByDiid(int diid)
  161. {
  162. if (SqlHelper.ExecuteNonQuery("update TravelList_External set Isdel=1 where Diid=" + diid, CommandType.Text) > 0)
  163. return true;
  164. return false;
  165. }
  166. }
  167. }