AirAdvanceInquiryService.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Models;
  9. namespace DAL
  10. {
  11. /// <summary>
  12. /// 机票提前询价 录入
  13. /// </summary>
  14. public class AirAdvanceInquiryService
  15. {
  16. List<AirAdvanceInquiry> excuteSql(string sql, params SqlParameter[] param)
  17. {
  18. return ServiceBase<AirAdvanceInquiry>.excuteSql(new AirAdvanceInquiry(), "AirAdvanceInquiry", sql, CommandType.Text, param);
  19. }
  20. AirAdvanceInquiry excuteType(string sql, params SqlParameter[] param)
  21. {
  22. //查询结果放入对象集合
  23. List<AirAdvanceInquiry> hdList = excuteSql(sql, param);
  24. AirAdvanceInquiry air = new AirAdvanceInquiry();
  25. //判断集合是否为空
  26. if (hdList == null || hdList.Count == 0)
  27. {
  28. return air;
  29. }
  30. //返回单个对象
  31. return hdList[0];
  32. }
  33. /// <summary>
  34. /// //增Add
  35. /// </summary>
  36. /// <param name="aai">酒店提前询价录入类</param>
  37. /// <returns></returns>
  38. public bool Add(AirAdvanceInquiry aai)
  39. {
  40. string sql = "insert into AirAdvanceInquiry values(@Diid,@Area,@Airlines,@Shift,@StartTime,@EndTime,@SpaceType,@SelectTime,@LowestPrice," +
  41. "@Remark,@Oper,@OperDate,@Isdel,@FullPrice,@InstantPrice);SELECT @@IDENTITY";
  42. SqlParameter[] parameter = new SqlParameter[]{
  43. new SqlParameter("@Diid",aai.Diid),
  44. new SqlParameter("@Area",aai.Area),
  45. new SqlParameter("@Airlines",aai.Airlines),
  46. new SqlParameter("@Shift",aai.Shift),
  47. new SqlParameter("@StartTime",aai.StartTime),
  48. new SqlParameter("@EndTime",aai.EndTime),
  49. new SqlParameter("@SpaceType",aai.SpaceType),
  50. new SqlParameter("@SelectTime",aai.SelectTime),
  51. new SqlParameter("@LowestPrice",aai.LowestPrice),
  52. new SqlParameter("@Remark",aai.Remark),
  53. new SqlParameter("@Oper",aai.Oper),
  54. new SqlParameter("@OperDate",aai.OperDate),
  55. new SqlParameter("@Isdel",aai.Isdel),
  56. new SqlParameter("@FullPrice",aai.FullPrice),
  57. new SqlParameter("@InstantPrice",aai.InstantPrice)
  58. };
  59. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  60. return true;
  61. return false;
  62. }
  63. /// <summary>
  64. /// //改Update
  65. /// </summary>
  66. /// <param name="aai"></param>
  67. /// <returns></returns>
  68. public bool Update(AirAdvanceInquiry aai)
  69. {
  70. string sql = "update AirAdvanceInquiry set Diid=@Diid,Area=@Area,Airlines=@Airlines,Shift=@Shift,StartTime=@StartTime,EndTime=@EndTime,SpaceType=@SpaceType,SelectTime=@SelectTime,Remark=@Remark,"
  71. + "Oper=@Oper,OperDate=@OperDate,Isdel=@Isdel,FullPrice=@FullPrice,InstantPrice=@InstantPrice where Id = @Id";
  72. SqlParameter[] parameter = new SqlParameter[]{
  73. new SqlParameter("@Diid",aai.Diid),
  74. new SqlParameter("@Area",aai.Area),
  75. new SqlParameter("@Airlines",aai.Airlines),
  76. new SqlParameter("@Shift",aai.Shift),
  77. new SqlParameter("@StartTime",aai.StartTime),
  78. new SqlParameter("@EndTime",aai.EndTime),
  79. new SqlParameter("@SpaceType",aai.SpaceType),
  80. new SqlParameter("@SelectTime",aai.SelectTime),
  81. new SqlParameter("@LowestPrice",aai.LowestPrice),
  82. new SqlParameter("@Remark",aai.Remark),
  83. new SqlParameter("@Oper",aai.Oper),
  84. new SqlParameter("@OperDate",aai.OperDate),
  85. new SqlParameter("@Isdel",aai.Isdel),
  86. new SqlParameter("@Id",aai.Id),
  87. new SqlParameter("@FullPrice",aai.FullPrice),
  88. new SqlParameter("@InstantPrice",aai.InstantPrice)
  89. };
  90. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  91. return true;
  92. return false;
  93. }
  94. /// <summary>
  95. /// //删
  96. /// </summary>
  97. /// <param name="id"></param>
  98. /// <returns></returns>
  99. public bool Delete(int id)
  100. {
  101. if (SqlHelper.ExecuteNonQuery("update AirAdvanceInquiry set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  102. return true;
  103. return false;
  104. }
  105. /// <summary>
  106. /// 根据diid 查询数据
  107. /// </summary>
  108. /// <returns></returns>
  109. public List<AirAdvanceInquiry> GetAllByTourCode(string diid)
  110. {
  111. return excuteSql("select * from AirAdvanceInquiry Where IsDel = 0 and Diid ='" + diid + "' order by OperDate desc");
  112. }
  113. /// <summary>
  114. /// 根据id 查询数据
  115. /// </summary>
  116. /// <returns></returns>
  117. public AirAdvanceInquiry GetAllById(int id)
  118. {
  119. return excuteType("select * from AirAdvanceInquiry Where IsDel = 0 and id ='" + id + "'");
  120. }
  121. }
  122. }