ViewHotelPayService.cs 6.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. /// 酒店预订费用多表联查数据访问类 - 用于Excel
  12. /// </summary>
  13. public class ViewHotelPayService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<ViewHotelPay> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<ViewHotelPay>.excuteSql(new ViewHotelPay(), "ViewHotelPay", 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. ViewHotelPay excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<ViewHotelPay> 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. /// 根据编号查询对象信息
  44. /// </summary>
  45. /// <param name="id">对象编号</param>
  46. /// <returns>返回空或者单个对象信息</returns>
  47. public ViewHotelPay GetViewHotelPayByID(int id)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteType("select * from ViewHotelPay where Id = @id and IsDel = 0", new SqlParameter("@id", id));
  51. }
  52. /// <summary>
  53. /// 获取全部
  54. /// </summary>
  55. /// <returns></returns>
  56. public List<ViewHotelPay> GetAll()
  57. {
  58. return excuteSql("select * from ViewHotelPay where IsDel = 0");
  59. }
  60. /// <summary>
  61. /// 根据编号查询对象信息
  62. /// </summary>
  63. /// <param name="id">对象编号</param>
  64. /// <returns>返回空或者对象信息</returns>
  65. public List<ViewHotelPay> GetByDIId(int DIId)
  66. {
  67. //调用获取单个对象的方法
  68. //return excuteSql("select hr.CheckInDate,hr.CheckOutDate,hr.OperatorDate,hr.City,hr.HotelName,sd.[Name],hr.SingleRoomPrice,hr.SingleRoomCount,hr.DoubleRoomPrice,hr.DoubleRoomCount,hr.SuiteRoomPrice,hr.SuiteRoomCount,hr.OtherRoomPrice,hr.OtherRoomCount,hr.Commission,hr.Budget,ccp.PayMoney,(hr.Budget - (hr.SingleRoomPrice * hr.SingleRoomCount + hr.DoubleRoomPrice * hr.DoubleRoomCount + hr.SuiteRoomPrice * hr.SuiteRoomCount + hr.OtherRoomPrice * hr.OtherRoomCount + hr.Commission)) as Spread,((hr.SingleRoomPrice * hr.SingleRoomCount + hr.DoubleRoomPrice * hr.DoubleRoomCount + hr.SuiteRoomPrice * hr.SuiteRoomCount + hr.OtherRoomPrice * hr.OtherRoomCount + hr.Commission)*(datediff(dd,checkindate,checkoutdate))) as moneys,ccp.DayRate from HotelReservations hr join CreditCardPayment ccp on ccp.Diid = hr.Diid and ccp.Cid = hr.Id join SetData sd on sd.Id =ccp.PaymentCurrency where hr.DIID = @DIID and hr.IsDel = 0 and ccp.CTable=76 and ccp.IsPay = 1 order by checkindate ASC", new SqlParameter("@DIId", DIId));
  69. //去除ispay=1
  70. //return excuteSql("select ccp.Operator,sd1.name as PaydName,ccp.OrbitalPrivateTransfer,ccp.PayDid,ccp.payee,ccp.ispay,hr.CheckInDate,hr.CheckOutDate,hr.OperatorDate,hr.City,hr.HotelName,sd.[Name],hr.SingleRoomPrice,hr.SingleRoomCount,hr.DoubleRoomPrice,hr.DoubleRoomCount,hr.SuiteRoomPrice,hr.SuiteRoomCount,hr.OtherRoomPrice,hr.OtherRoomCount,hr.Commission,hr.Budget,(ccp.PayMoney * ccp.DayRate) as PayMoney,(hr.Budget - (hr.SingleRoomPrice * hr.SingleRoomCount + hr.DoubleRoomPrice * hr.DoubleRoomCount + hr.SuiteRoomPrice * hr.SuiteRoomCount + hr.OtherRoomPrice * hr.OtherRoomCount + hr.Commission)) as Spread,((hr.SingleRoomPrice * hr.SingleRoomCount + hr.DoubleRoomPrice * hr.DoubleRoomCount + hr.SuiteRoomPrice * hr.SuiteRoomCount + hr.OtherRoomPrice * hr.OtherRoomCount + hr.Commission)*(datediff(dd,checkindate,checkoutdate))) as moneys,ccp.DayRate from HotelReservations hr join CreditCardPayment ccp on ccp.Diid = hr.Diid and ccp.Cid = hr.Id join SetData sd on sd.Id =ccp.PaymentCurrency join setdata sd1 on sd1.id=ccp.PayDid where hr.DIID = @DIID and hr.IsDel = 0 and ccp.CTable=76 and ccp.IsAuditGM <> 2 and ccp.isDel=0 order by checkindate ASC", new SqlParameter("@DIId", DIId));
  71. return excuteSql("select (select Name from SetData where Id=ccp.CTDId)as CarType,hr.CheckType, ccp.IsMatchCreditCard,ccp.Operator,sd1.name as PaydName," +
  72. "ccp.OrbitalPrivateTransfer,ccp.PayDid,ccp.payee,ccp.ispay,hr.CheckInDate,hr.CheckOutDate,hr.OperatorDate,hr.City,hr.HotelName,sd.[Name]," +
  73. "hr.SingleRoomPrice,hr.SingleRoomCount,hr.GovernmentRent,hr.CityTax,hr.DoubleRoomPrice,hr.DoubleRoomCount,hr.SuiteRoomPrice,hr.SuiteRoomCount," +
  74. "hr.OtherRoomPrice,hr.OtherRoomCount,hr.Commission,hr.Budget,((ccp.PayMoney * ccp.DayRate) +hr.breakfastPrice) as PayMoney,(hr.Budget - " +
  75. "(hr.SingleRoomPrice * hr.SingleRoomCount + hr.DoubleRoomPrice * hr.DoubleRoomCount + hr.SuiteRoomPrice * hr.SuiteRoomCount + hr.OtherRoomPrice " +
  76. "* hr.OtherRoomCount + hr.Commission)) as Spread,(ccp.PayMoney+hr.breakfastPrice) as moneys,ccp.DayRate,hr.breakfastPrice as breakfasePrice " +
  77. "from HotelReservations hr join CreditCardPayment ccp on ccp.Diid = hr.Diid and ccp.Cid = hr.Id join SetData sd on sd.Id =ccp.PaymentCurrency " +
  78. "join setdata sd1 on sd1.id=ccp.PayDid where hr.DIID = @DIId and hr.IsDel = 0 and ccp.CTable=76 and ccp.IsAuditGM =1 or ccp.IsAuditGM=3 and ccp.IsPay=1 and ccp.isDel=0 and " +
  79. "hr.operator is not null and hr.operator > 0 order by checkindate ASC", new SqlParameter("@DIId", DIId));
  80. }
  81. }
  82. }