AirTicketReservationsService.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data.SqlClient;
  7. using System.Data;
  8. namespace DAL
  9. {
  10. /// <summary>
  11. /// 机票预订数据访问类
  12. /// </summary>
  13. public class AirTicketReservationsService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<AirTicketReservations> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<AirTicketReservations>.excuteSql(new AirTicketReservations(), "AirTicketReservations", sql, CommandType.Text, param);
  24. }
  25. /// <summary>
  26. /// 获取单个对象
  27. /// </summary>
  28. /// <param name="sql">sql语句</param>
  29. /// <param name="param">可变参数数组</param>
  30. /// <returns>返回空或者单个对象</returns>
  31. AirTicketReservations excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<AirTicketReservations> ctggdList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (ctggdList == null || ctggdList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return ctggdList[0];
  41. }
  42. /// <summary>
  43. /// 根据Id查询对象信息
  44. /// </summary>
  45. /// <param name="id">对象编号</param>
  46. /// <returns>返回空或者单个对象信息</returns>
  47. public AirTicketReservations GetAirTicketReservationsByID(int id)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteType("select * from AirTicketReservations where id = @id and IsDel = 0", new SqlParameter("@id", id));
  51. }
  52. /// <summary>
  53. /// 根据Diid查询对象信息
  54. /// </summary>
  55. /// <param name="id">对象编号</param>
  56. /// <returns>返回空或者单个对象信息</returns>
  57. public List<AirTicketReservations> GetAirTicketReservationsByDIID(int DIID)
  58. {
  59. //调用获取单个对象的方法
  60. return excuteSql("select * from AirTicketReservations where Diid = @id and IsDel = 0 order by FlightsDate", new SqlParameter("@id", DIID));
  61. }
  62. /// <summary>
  63. /// 根据Diid查询对象信息
  64. /// </summary>
  65. /// <param name="id">对象编号</param>
  66. /// <returns>返回空或者单个对象信息</returns>
  67. public List<AirTicketReservations> GetAirTicketReservationsByDIIDAndUId(int DIID,int UId)
  68. {
  69. //调用获取单个对象的方法
  70. return excuteSql("select * from AirTicketReservations where Diid = @id and IsDel = 0 and Operator=" + UId + " order by FlightsDate", new SqlParameter("@id", DIID));
  71. }
  72. /// <summary>
  73. /// 根据Diid,Ctype查询对象信息
  74. /// </summary>
  75. /// <param name="id">对象编号</param>
  76. /// <returns>返回空或者单个对象信息</returns>
  77. public List<AirTicketReservations> GetAirTicketReservationsByDIID(int DIID, int CType)
  78. {
  79. //调用获取单个对象的方法
  80. return excuteSql("select * from AirTicketReservations where Diid =" + DIID + " and IsDel = 0 and CType=" + CType + " order by FlightsDate");
  81. }
  82. /// <summary>
  83. /// 获取全部
  84. /// </summary>
  85. /// <returns></returns>
  86. public List<AirTicketReservations> GetAll()
  87. {
  88. return excuteSql("select * from AirTicketReservations where IsDel = 0");
  89. }
  90. /// <summary>
  91. /// 获取全部 - 分页
  92. /// </summary>
  93. /// <returns></returns>
  94. public List<AirTicketReservations> GetAirTicketReservations(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string arrayUsersId)
  95. {
  96. string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and Operator in (" + arrayUsersId + ")";
  97. return PageBase<AirTicketReservations>.excutePageSql(new AirTicketReservations(), "AirTicketReservations", "AirTicketReservations", "*", "FlightsDate asc ,flightsTime asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  98. }
  99. /// <summary>
  100. /// 增加
  101. /// </summary>
  102. /// <returns></returns>
  103. public bool AddAirTicketReservations(AirTicketReservations atr, out int id)
  104. {
  105. string sql = "insert into AirTicketReservations values(@DIId,@FlightsCode,@FlightsDate,@FlightsTime,@ArrivedTime,@IsCheckIn,@IsSetSeat,@IsPackage,@IsBagHandle,@IsTrain,@CType,"
  106. + "@FlightsCity,@LeaveDescription,@FlightsDescription,@ReturnDescription,@ClientNum,@ClientName,@PrePrice,@PreCurrency,@Price,@Currency,@PriceDescription,@TicketNumber,@TicketCode,@Remark,"
  107. + "@Operator,@OperatorDate,@IsDel,@PassengerType);SELECT @@IDENTITY";
  108. SqlParameter[] parameter = new SqlParameter[]{
  109. new SqlParameter("@DIId",atr.DIId),
  110. new SqlParameter("@FlightsCode",atr.FlightsCode),
  111. new SqlParameter("@FlightsDate",atr.FlightsDate),
  112. new SqlParameter("@FlightsTime",atr.FlightsTime),
  113. new SqlParameter("@ArrivedTime",atr.ArrivedTime),
  114. new SqlParameter("@IsCheckIn",atr.IsCheckIn),
  115. new SqlParameter("@IsSetSeat",atr.IsSetSeat),
  116. new SqlParameter("@IsPackage",atr.IsPackage),
  117. new SqlParameter("@IsBagHandle",atr.IsBagHandle),
  118. new SqlParameter("@IsTrain",atr.IsTrain),
  119. new SqlParameter("@CType",atr.CType),
  120. new SqlParameter("@FlightsCity",atr.FlightsCity),
  121. new SqlParameter("@LeaveDescription",atr.LeaveDescription),
  122. new SqlParameter("@FlightsDescription",atr.FlightsDescription),
  123. new SqlParameter("@ReturnDescription",atr.ReturnDescription),
  124. new SqlParameter("@ClientNum",atr.ClientNum),
  125. new SqlParameter("@ClientName",atr.ClientName),
  126. new SqlParameter("@PrePrice",atr.PrePrice),
  127. new SqlParameter("@PreCurrency",atr.PreCurrency),
  128. new SqlParameter("@Price",atr.Price),
  129. new SqlParameter("@Currency",atr.Currency),
  130. new SqlParameter("@PriceDescription",atr.PriceDescription),
  131. new SqlParameter("@TicketNumber",atr.TicketNumber),
  132. new SqlParameter("@TicketCode",atr.TicketCode),
  133. new SqlParameter("@Remark",atr.Remark),
  134. new SqlParameter("@Operator",atr.Operators),
  135. new SqlParameter("@OperatorDate",atr.OperatorsDate),
  136. new SqlParameter("@IsDel",atr.IsDel),
  137. new SqlParameter("@PassengerType",atr.PassengerType)
  138. };
  139. int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
  140. if (obj > 0)
  141. {
  142. id = obj;
  143. return true;
  144. }
  145. id = 0;
  146. return false;
  147. }
  148. /// <summary>
  149. /// 编辑
  150. /// </summary>
  151. /// <returns></returns>
  152. public bool EditAirTicketReservations(AirTicketReservations atr)
  153. {
  154. string sql = "update AirTicketReservations set DIId = @DIId,FlightsCode = @FlightsCode,FlightsDate = @FlightsDate,FlightsTime = @FlightsTime,"
  155. + "ArrivedTime=@ArrivedTime,IsCheckIn=@IsCheckIn,IsSetSeat=@IsSetSeat,IsPackage=@IsPackage,IsBagHandle=@IsBagHandle,IsTrain=@IsTrain,CType=@CType,FlightsCity = @FlightsCity,LeaveDescription = @LeaveDescription,"
  156. + "FlightsDescription = @FlightsDescription,ReturnDescription = @ReturnDescription,ClientNum=@ClientNum,ClientName = @ClientName,"
  157. + "PrePrice = @PrePrice,PreCurrency = @PreCurrency,Price = @Price,Currency = @Currency,PriceDescription = @PriceDescription,TicketNumber=@TicketNumber,"
  158. + "TicketCode=@TicketCode,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,PassengerType=@PassengerType where Id = @Id";
  159. SqlParameter[] parameter = new SqlParameter[]{
  160. new SqlParameter("@DIId",atr.DIId),
  161. new SqlParameter("@FlightsCode",atr.FlightsCode),
  162. new SqlParameter("@FlightsDate",atr.FlightsDate),
  163. new SqlParameter("@FlightsTime",atr.FlightsTime),
  164. new SqlParameter("@ArrivedTime",atr.ArrivedTime),
  165. new SqlParameter("@IsCheckIn",atr.IsCheckIn),
  166. new SqlParameter("@IsSetSeat",atr.IsSetSeat),
  167. new SqlParameter("@IsPackage",atr.IsPackage),
  168. new SqlParameter("@IsBagHandle",atr.IsBagHandle),
  169. new SqlParameter("@IsTrain",atr.IsTrain),
  170. new SqlParameter("@CType",atr.CType),
  171. new SqlParameter("@FlightsCity",atr.FlightsCity),
  172. new SqlParameter("@LeaveDescription",atr.LeaveDescription),
  173. new SqlParameter("@FlightsDescription",atr.FlightsDescription),
  174. new SqlParameter("@ReturnDescription",atr.ReturnDescription),
  175. new SqlParameter("@ClientNum",atr.ClientNum),
  176. new SqlParameter("@ClientName",atr.ClientName),
  177. new SqlParameter("@PrePrice",atr.PrePrice),
  178. new SqlParameter("@PreCurrency",atr.PreCurrency),
  179. new SqlParameter("@Price",atr.Price),
  180. new SqlParameter("@Currency",atr.Currency),
  181. new SqlParameter("@PriceDescription",atr.PriceDescription),
  182. new SqlParameter("@TicketNumber",atr.TicketNumber),
  183. new SqlParameter("@TicketCode",atr.TicketCode),
  184. new SqlParameter("@Remark",atr.Remark),
  185. new SqlParameter("@Operator",atr.Operators),
  186. new SqlParameter("@OperatorDate",atr.OperatorsDate),
  187. new SqlParameter("@Id",atr.Id),
  188. new SqlParameter("@PassengerType",atr.PassengerType)
  189. };
  190. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  191. return true;
  192. return false;
  193. }
  194. /// <summary>
  195. /// 删除
  196. /// </summary>
  197. /// <param name="id"></param>
  198. /// <returns></returns>
  199. public bool DelAirTicketReservations(int id)
  200. {
  201. if (SqlHelper.ExecuteNonQuery("update AirTicketReservations set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  202. return true;
  203. return false;
  204. }
  205. public List<AirTicketReservations> GetByIds(List<int> ids)
  206. {
  207. var idsStr = string.Join(",",ids).TrimEnd(',') ;
  208. string sql = "select * from AirTicketReservations where IsDel = 0 And id in(" + idsStr + ")";
  209. return excuteSql(sql);
  210. }
  211. public List<AirTicketReservations> GetByDiiDs(List<int> diids)
  212. {
  213. var diidsStr = string.Join(",", diids).TrimEnd(',');
  214. string sql = "select * from AirTicketReservations where IsDel = 0 And diid in(" + diidsStr + ")";
  215. return excuteSql(sql);
  216. }
  217. }
  218. }