HotelReservationsService.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Data.Common;
  9. namespace DAL
  10. {
  11. /// <summary>
  12. /// 酒店预订数据访问类
  13. /// </summary>
  14. public class HotelReservationsService
  15. {
  16. /// <summary>
  17. /// 查询所有
  18. /// </summary>
  19. /// <param name="sql">sql语句</param>
  20. /// <param name="param">可变参数数组</param>
  21. /// <returns>返回集合</returns>
  22. List<HotelReservations> excuteSql(string sql, params SqlParameter[] param)
  23. {
  24. return ServiceBase<HotelReservations>.excuteSql(new HotelReservations(), "HotelReservations", sql, CommandType.Text, param);
  25. }
  26. /// <summary>
  27. /// 获取单个对象
  28. /// </summary>
  29. /// <param name="sql">sql语句</param>
  30. /// <param name="param">可变参数数组</param>
  31. /// <returns>返回空或者单个对象</returns>
  32. HotelReservations excuteType(string sql, params SqlParameter[] param)
  33. {
  34. //查询结果放入对象集合
  35. List<HotelReservations> hrList = excuteSql(sql, param);
  36. //判断集合是否为空
  37. if (hrList == null || hrList.Count == 0)
  38. //返回null
  39. return null;
  40. //返回单个对象
  41. return hrList[0];
  42. }
  43. /// <summary>
  44. /// 根据编号查询对象信息
  45. /// </summary>
  46. /// <param name="id">对象编号</param>
  47. /// <returns>返回空或者单个对象信息</returns>
  48. public HotelReservations GetHotelReservationsByID(int id)
  49. {
  50. //调用获取单个对象的方法
  51. return excuteType("select *,datediff(DD,checkindate,checkoutdate) as dayDiff from HotelReservations where Id = @id and isdel=0", new SqlParameter("@id", id));
  52. }
  53. /// <summary>
  54. /// 获得签证酒店信息
  55. /// </summary>
  56. /// <param name="diid">团组编号</param>
  57. /// <param name="city">出访国家下的 城市</param>
  58. /// <returns></returns>
  59. public HotelReservations GetHotelReservationsByDiidAndCity(int diid,string city)
  60. {
  61. //调用获取单个对象的方法
  62. return excuteType("select * from HotelReservations where isdel=0 and Diid="+diid+" and City='"+city+"'");
  63. }
  64. /// <summary>
  65. /// 根据编号查询对象天数
  66. /// </summary>
  67. /// <param name="id">对象编号</param>
  68. /// <returns>返回空或者单个对象信息</returns>
  69. public object GetHotelReservationsDayDiffByID(int id)
  70. {
  71. //调用获取单个对象的方法
  72. return SqlHelper.ExecuteScalar("select datediff(DD,checkindate,checkoutdate) as dayDiff from HotelReservations where Id = @id and isdel=0", CommandType.Text, new SqlParameter("@id", id));
  73. }
  74. /// <summary>
  75. /// 根据编号查询对象信息
  76. /// </summary>
  77. /// <param name="id">对象编号</param>
  78. /// <returns>返回空或者对象信息</returns>
  79. public List<HotelReservations> GetHotelReservationsByGuestName(string guestName)
  80. {
  81. //调用获取单个对象的方法
  82. return excuteSql("select * from HotelReservations where GuestName like '%"+ guestName + "%' and IsDel = 0");
  83. }
  84. /// <summary>
  85. /// 根据编号查询对象信息
  86. /// </summary>
  87. /// <param name="id">对象编号</param>
  88. /// <returns>返回空或者对象信息</returns>
  89. public List<HotelReservations> GetHotelReservationsByDIId(int DIId, string arrayUsersId)
  90. {
  91. //调用获取单个对象的方法
  92. return excuteSql("select * from HotelReservations where DIId = @DIId and IsDel = 0 and Operator in (" + arrayUsersId + ") order by CheckInDate asc", new SqlParameter("@DIId", DIId));
  93. }
  94. /// <summary>
  95. ///
  96. /// </summary>
  97. /// <param name="DIId"></param>
  98. /// <returns></returns>
  99. public List<HotelReservations> GetByDIId(int DIId)
  100. {
  101. //调用获取单个对象的方法
  102. return excuteSql("select * from HotelReservations where DIId = @DIId and IsDel = 0 and Operator!=0 order by CheckInDate asc", new SqlParameter("@DIId", DIId));
  103. }
  104. /// <summary>
  105. ///
  106. /// </summary>
  107. /// <param name="DIId"></param>
  108. /// <returns></returns>
  109. public List<HotelReservations> GetByDIIdUId(int DIId,int UId)
  110. {
  111. //调用获取单个对象的方法
  112. return excuteSql("select * from HotelReservations where DIId = @DIId and IsDel = 0 and Operator="+UId+" order by CheckInDate asc", new SqlParameter("@DIId", DIId));
  113. }
  114. /// <summary>
  115. /// 根据编号查询对象信息
  116. /// </summary>
  117. /// <param name="id">对象编号</param>
  118. /// <returns>返回空或者对象信息</returns>
  119. public HotelReservations GetHotelReservationsByDIIdEntity(int DIId)
  120. {
  121. //调用获取单个对象的方法
  122. return excuteType("select * from HotelReservations where DIId = @DIId and IsDel = 0", new SqlParameter("@DIId", DIId));
  123. }
  124. /// <summary>
  125. /// 新增
  126. /// </summary>
  127. /// <param name="sdt">对象</param>
  128. public bool AddHotelReservations(HotelReservations hr, out int id)
  129. {
  130. string sql = "insert into HotelReservations values(@DIId,@GTId,@CheckNumber, @ReservationsWebsite,@ReservationsNo, @DetermineNo,@City," +
  131. " @HotelName, @HotelAddress,@HotelTel,@HotelFax, @GuestName,@CheckInDate,@CheckOutDate,@Budget,@BudgetCurrency,@SingleRoomCount," +
  132. "@SingleRoomPrice, @DoubleRoomCount,@DoubleRoomPrice, @SuiteRoomCount, @SuiteRoomPrice,@OtherRoomCount, @OtherRoomPrice, @Commission," +
  133. "@CommissionCurrency,@CommissionMark,@RoomExplanation, @Attachment,@Remark,@CardPrice,@IsCardPrice,@Operator,@OperatorDate,@IsDel," +
  134. "@breakfastPrice,@isoppay,@cboOne,@cboTwo,@cboThree,@cboFour,@PredictSingleRoom,@PredictDoubleRoom,@PredictSuiteRoom,@PredictOtherRoom," +
  135. "@CityTax,@GovernmentRent,@CheckType);SELECT @@IDENTITY";
  136. SqlParameter[] parameter = new SqlParameter[]{
  137. new SqlParameter("@DIId",hr.DIId),
  138. new SqlParameter("@GTId",hr.GTId),
  139. new SqlParameter("@CheckNumber",hr.CheckNumber),
  140. new SqlParameter("@ReservationsWebsite",hr.ReservationsWebsite),
  141. new SqlParameter("@ReservationsNo",hr.ReservationsNo),
  142. new SqlParameter("@DetermineNo",hr.DetermineNo),
  143. new SqlParameter("@City",hr.City),
  144. new SqlParameter("@HotelName",hr.HotelName),
  145. new SqlParameter("@HotelAddress",hr.HotelAddress),
  146. new SqlParameter("@HotelTel",hr.HotelTel),
  147. new SqlParameter("@HotelFax",hr.HotelFax),
  148. new SqlParameter("@GuestName",hr.GuestName),
  149. new SqlParameter("@CheckInDate",hr.CheckInDate),
  150. new SqlParameter("@CheckOutDate",hr.CheckOutDate),
  151. new SqlParameter("@Budget",hr.Budget),
  152. new SqlParameter("@BudgetCurrency",hr.BudgetCurrency),
  153. new SqlParameter("@SingleRoomCount",hr.SingleRoomCount),
  154. new SqlParameter("@SingleRoomPrice",hr.SingleRoomPrice),
  155. new SqlParameter("@DoubleRoomCount",hr.DoubleRoomCount),
  156. new SqlParameter("@DoubleRoomPrice",hr.DoubleRoomPrice),
  157. new SqlParameter("@SuiteRoomCount",hr.SuiteRoomCount),
  158. new SqlParameter("@SuiteRoomPrice",hr.SuiteRoomPrice),
  159. new SqlParameter("@OtherRoomCount",hr.OtherRoomCount),
  160. new SqlParameter("@OtherRoomPrice",hr.OtherRoomPrice),
  161. new SqlParameter("@Commission",hr.Commission),
  162. new SqlParameter("@CommissionCurrency",hr.CommissionCurrency),
  163. new SqlParameter("@CommissionMark",hr.CommissionMark),
  164. new SqlParameter("@RoomExplanation",hr.RoomExplanation),
  165. new SqlParameter("@Attachment",hr.Attachment),
  166. new SqlParameter("@Remark",hr.Remark),
  167. new SqlParameter("@CardPrice",hr.CardPrice),
  168. new SqlParameter("@IsCardPrice",hr.IsCardPrice),
  169. new SqlParameter("@Operator",hr.Operators),
  170. new SqlParameter("@OperatorDate",hr.OperatorsDate),
  171. new SqlParameter("@IsDel",hr.IsDel),
  172. new SqlParameter("@breakfastPrice",hr.BreakfastPrice),
  173. new SqlParameter("@isoppay",hr.Isoppay),
  174. //-------
  175. new SqlParameter("@cboOne",hr.cboOne),
  176. new SqlParameter("@cboTwo",hr.CboTwo),
  177. new SqlParameter("@cboThree",hr.CboThree),
  178. new SqlParameter("@cboFour",hr.CboFour),
  179. new SqlParameter("@PredictSingleRoom",hr.PredictSingleRoom ),
  180. new SqlParameter("@PredictDoubleRoom",hr.PredictDoubleRoom ),
  181. new SqlParameter("@PredictSuiteRoom",hr.PredictSuiteRoom ),
  182. new SqlParameter("@PredictOtherRoom",hr.PredictOtherRoom ),
  183. new SqlParameter("@CityTax",hr.CityTax),
  184. new SqlParameter("@GovernmentRent",hr.GovernmentRent),
  185. new SqlParameter("@CheckType",hr.CheckType)
  186. };
  187. int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
  188. if (obj > 0)
  189. {
  190. id = obj;
  191. return true;
  192. }
  193. id = 0;
  194. return false;
  195. }
  196. /// <summary>
  197. /// 编辑
  198. /// </summary>
  199. /// <param name="sdt"></param>
  200. /// <returns></returns>
  201. public bool EditHotelReservations(HotelReservations hr)
  202. {
  203. string sql = "update HotelReservations set DIId = @DIId,GTId = @GTId,CheckNumber = @CheckNumber,ReservationsWebsite = @ReservationsWebsite,ReservationsNo" +
  204. " = @ReservationsNo,DetermineNo = @DetermineNo ,City = @City,HotelName = @HotelName,HotelAddress = @HotelAddress,HotelTel = @HotelTel,HotelFax = @HotelFax," +
  205. "GuestName = @GuestName,CheckInDate = @CheckInDate ,CheckOutDate = @CheckOutDate,Budget = @Budget,BudgetCurrency =@BudgetCurrency,SingleRoomCount = @SingleRoomCount," +
  206. "SingleRoomPrice = @SingleRoomPrice,DoubleRoomCount = @DoubleRoomCount,DoubleRoomPrice = @DoubleRoomPrice,SuiteRoomCount = @SuiteRoomCount," +
  207. "SuiteRoomPrice = @SuiteRoomPrice ,OtherRoomCount = @OtherRoomCount,OtherRoomPrice = @OtherRoomPrice,Commission = @Commission,CommissionCurrency = @CommissionCurrency," +
  208. "CommissionMark = @CommissionMark,RoomExplanation = @RoomExplanation,Attachment = @Attachment,Remark = @Remark,CardPrice=@CardPrice,Operator = @Operator," +
  209. "OperatorDate = @OperatorDate,breakfastPrice = @breakfastPrice,isoppay = @isoppay,cboOne=@cboOne,cboTwo=@cboTwo,cboThree=@cboThree,cboFour=@cboFour," +
  210. "PredictSingleRoom=@PredictSingleRoom,PredictDoubleRoom=@PredictDoubleRoom,PredictSuiteRoom=@PredictSuiteRoom,PredictOtherRoom=@PredictOtherRoom," +
  211. "CityTax=@CityTax,GovernmentRent=@GovernmentRent,CheckType=@CheckType where Id = @Id;";
  212. SqlParameter[] parameter = new SqlParameter[]{
  213. new SqlParameter("@DIId",hr.DIId),
  214. new SqlParameter("@GTId",hr.GTId),
  215. new SqlParameter("@CheckNumber",hr.CheckNumber),
  216. new SqlParameter("@ReservationsWebsite",hr.ReservationsWebsite),
  217. new SqlParameter("@ReservationsNo",hr.ReservationsNo),
  218. new SqlParameter("@DetermineNo",hr.DetermineNo),
  219. new SqlParameter("@City",hr.City),
  220. new SqlParameter("@HotelName",hr.HotelName),
  221. new SqlParameter("@HotelAddress",hr.HotelAddress),
  222. new SqlParameter("@HotelTel",hr.HotelTel),
  223. new SqlParameter("@HotelFax",hr.HotelFax),
  224. new SqlParameter("@GuestName",hr.GuestName),
  225. new SqlParameter("@CheckInDate",hr.CheckInDate),
  226. new SqlParameter("@CheckOutDate",hr.CheckOutDate),
  227. new SqlParameter("@Budget",hr.Budget),
  228. new SqlParameter("@BudgetCurrency",hr.BudgetCurrency),
  229. new SqlParameter("@SingleRoomCount",hr.SingleRoomCount),
  230. new SqlParameter("@SingleRoomPrice",hr.SingleRoomPrice),
  231. new SqlParameter("@DoubleRoomCount",hr.DoubleRoomCount),
  232. new SqlParameter("@DoubleRoomPrice",hr.DoubleRoomPrice),
  233. new SqlParameter("@SuiteRoomCount",hr.SuiteRoomCount),
  234. new SqlParameter("@SuiteRoomPrice",hr.SuiteRoomPrice),
  235. new SqlParameter("@OtherRoomCount",hr.OtherRoomCount),
  236. new SqlParameter("@OtherRoomPrice",hr.OtherRoomPrice),
  237. new SqlParameter("@Commission",hr.Commission),
  238. new SqlParameter("@CommissionCurrency",hr.CommissionCurrency),
  239. new SqlParameter("@CommissionMark",hr.CommissionMark),
  240. new SqlParameter("@RoomExplanation",hr.RoomExplanation),
  241. new SqlParameter("@Attachment",hr.Attachment),
  242. new SqlParameter("@Remark",hr.Remark),
  243. new SqlParameter("@CardPrice",hr.CardPrice),
  244. new SqlParameter("@Operator",hr.Operators),
  245. new SqlParameter("@OperatorDate",hr.OperatorsDate),
  246. new SqlParameter("@breakfastPrice",hr.BreakfastPrice),
  247. new SqlParameter("@isoppay",hr.Isoppay),
  248. //-------
  249. new SqlParameter("@cboOne",hr.CboOne),
  250. new SqlParameter("@cboTwo",hr.CboTwo),
  251. new SqlParameter("@cboThree",hr.CboThree),
  252. new SqlParameter("@cboFour",hr.CboFour),
  253. new SqlParameter("@Id",hr.Id),
  254. new SqlParameter("@PredictSingleRoom",hr.PredictSingleRoom ),
  255. new SqlParameter("@PredictDoubleRoom",hr.PredictDoubleRoom ),
  256. new SqlParameter("@PredictSuiteRoom",hr.PredictSuiteRoom ),
  257. new SqlParameter("@PredictOtherRoom",hr.PredictOtherRoom ),
  258. new SqlParameter("@CityTax",hr.CityTax),
  259. new SqlParameter("@GovernmentRent",hr.GovernmentRent),
  260. new SqlParameter("@CheckType",hr.CheckType)
  261. };
  262. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  263. return true;
  264. return false;
  265. }
  266. /// <summary>
  267. /// 删除
  268. /// </summary>
  269. /// <param name="id"></param>
  270. /// <returns></returns>
  271. public bool DelHotelReservations(int id)
  272. {
  273. if (SqlHelper.ExecuteNonQuery("update HotelReservations set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  274. return true;
  275. return false;
  276. }
  277. /// <summary>
  278. /// LiuChengYi 2014/4/16
  279. /// 用于出访国家的数据统计
  280. /// </summary>
  281. /// <returns></returns>
  282. public DataTable ReportHotelReservationsInfo()
  283. {
  284. return SqlHelper.TransferProcedure("HotelReservationsList", CommandType.StoredProcedure);
  285. }
  286. /// <summary>
  287. /// LiuChengYi 2014/05/09
  288. /// 用作微信平台上对入住酒店的查询
  289. /// </summary>
  290. /// <param name="tourCode"></param>
  291. /// <returns></returns>
  292. public DataTable QueryCheckHotel(string tourCode)
  293. {
  294. SqlParameter[] pars =
  295. {
  296. new SqlParameter("@tourCode",tourCode)
  297. };
  298. return SqlHelper.TransferProcedure("QueryCheckHotel_Weixin", CommandType.StoredProcedure, pars);
  299. }
  300. /// <summary>
  301. /// LiuChengYi 2014/4/16
  302. /// 用于出访国家的数据统计
  303. /// </summary>
  304. /// <returns></returns>
  305. public DataTable ReportHotelReservationsInfo(string year)
  306. {
  307. SqlParameter[] pars =
  308. {
  309. new SqlParameter("@year",year)
  310. };
  311. return SqlHelper.TransferProcedure("HotelReservationsList", CommandType.StoredProcedure, pars);
  312. }
  313. /// <summary>
  314. ///雷怡 2021-08-16 14:23
  315. ///确认信用卡是否刷卡成功 标识
  316. /// </summary>
  317. /// <param name="IsCardPrice"></param>
  318. /// <param name="Id"></param>
  319. /// <returns></returns>
  320. public bool GetIsCardPrice(int IsCardPrice,int Id)
  321. {
  322. string sql = " update HotelReservations set IsCardPrice=@IsCardPrice where Id=@Id";
  323. SqlParameter[] parameter = new SqlParameter[]{
  324. new SqlParameter("@IsCardPrice",IsCardPrice),
  325. new SqlParameter("@Id",Id)
  326. };
  327. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  328. return true;
  329. return false;
  330. }
  331. }
  332. }