HotelAdvanceInquiryService.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 HotelAdvanceInquiryService
  15. {
  16. List<HotelAdvanceInquiry> excuteSql(string sql, params SqlParameter[] param)
  17. {
  18. return ServiceBase<HotelAdvanceInquiry>.excuteSql(new HotelAdvanceInquiry(), "HotelAdvanceInquiry", sql, CommandType.Text, param);
  19. }
  20. HotelAdvanceInquiry excuteType(string sql, params SqlParameter[] param)
  21. {
  22. //查询结果放入对象集合
  23. List<HotelAdvanceInquiry> hdList = excuteSql(sql, param);
  24. HotelAdvanceInquiry air = new HotelAdvanceInquiry();
  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="Hai">酒店提前询价录入类</param>
  37. /// <returns></returns>
  38. public bool Add(HotelAdvanceInquiry Hai)
  39. {
  40. string sql = "insert into HotelAdvanceInquiry values(@Diid,@Area,@HotelName,@RoomType,@SelectTime,@LowestPrice,@Remark,@Oper,@OperDate,@Isdel);SELECT @@IDENTITY";
  41. SqlParameter[] parameter = new SqlParameter[]{
  42. new SqlParameter("@Diid",Hai.Diid),
  43. new SqlParameter("@Area",Hai.Area),
  44. new SqlParameter("@HotelName",Hai.HotelName),
  45. new SqlParameter("@RoomType",Hai.RoomType),
  46. new SqlParameter("@SelectTime",Hai.SelectTime),
  47. new SqlParameter("@LowestPrice",Hai.LowestPrice),
  48. new SqlParameter("@Remark",Hai.Remark),
  49. new SqlParameter("@Oper",Hai.Oper),
  50. new SqlParameter("@OperDate",Hai.OperDate),
  51. new SqlParameter("@Isdel",Hai.Isdel)
  52. };
  53. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  54. return true;
  55. return false;
  56. }
  57. /// <summary>
  58. /// //改Update
  59. /// </summary>
  60. /// <param name="Hai"></param>
  61. /// <returns></returns>
  62. public bool Update(HotelAdvanceInquiry Hai)
  63. {
  64. string sql = "update HotelAdvanceInquiry set Diid=@Diid,Area=@Area,HotelName=@HotelName,RoomType=@RoomType,SelectTime=@SelectTime,Remark=@Remark,"
  65. + "Oper=@Oper,OperDate=@OperDate,Isdel=@Isdel where Id = @Id";
  66. SqlParameter[] parameter = new SqlParameter[]{
  67. new SqlParameter("@Diid",Hai.Diid),
  68. new SqlParameter("@Area",Hai.Area),
  69. new SqlParameter("@HotelName",Hai.HotelName),
  70. new SqlParameter("@RoomType",Hai.RoomType),
  71. new SqlParameter("@SelectTime",Hai.SelectTime),
  72. new SqlParameter("@LowestPrice",Hai.LowestPrice),
  73. new SqlParameter("@Remark",Hai.Remark),
  74. new SqlParameter("@Oper",Hai.Oper),
  75. new SqlParameter("@OperDate",Hai.OperDate),
  76. new SqlParameter("@Isdel",Hai.Isdel),
  77. new SqlParameter("@Id",Hai.Id)
  78. };
  79. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  80. return true;
  81. return false;
  82. }
  83. /// <summary>
  84. /// //删
  85. /// </summary>
  86. /// <param name="id"></param>
  87. /// <returns></returns>
  88. public bool Delete(int id)
  89. {
  90. if (SqlHelper.ExecuteNonQuery("update HotelAdvanceInquiry set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  91. return true;
  92. return false;
  93. }
  94. /// <summary>
  95. /// 根据diid 查询数据
  96. /// </summary>
  97. /// <returns></returns>
  98. public List<HotelAdvanceInquiry> GetAllByTourCode(string diid)
  99. {
  100. return excuteSql("select * from HotelAdvanceInquiry Where IsDel = 0 and Diid ='"+ diid + "' order by OperDate desc");
  101. }
  102. /// <summary>
  103. /// 根据id 查询数据
  104. /// </summary>
  105. /// <returns></returns>
  106. public HotelAdvanceInquiry GetAllById(int id)
  107. {
  108. return excuteType("select * from HotelAdvanceInquiry Where IsDel = 0 and id ='" + id + "'");
  109. }
  110. }
  111. }