using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Models;
using System.Data.SqlClient;
using System.Data;
namespace DAL
{
///
/// 酒店预订费用多表联查数据访问类 - 用于Excel
///
public class ViewHotelPayService
{
///
/// 查询所有
///
/// sql语句
/// 可变参数数组
/// 返回集合
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new ViewHotelPay(), "ViewHotelPay", sql, CommandType.Text, param);
}
///
/// 获取单个对象
///
/// sql语句
/// 可变参数数组
/// 返回空或者单个对象
ViewHotelPay excuteType(string sql, params SqlParameter[] param)
{
//查询结果放入对象集合
List ctggdList = excuteSql(sql, param);
//判断集合是否为空
if (ctggdList == null || ctggdList.Count == 0)
//返回null
return null;
//返回单个对象
return ctggdList[0];
}
///
/// 根据编号查询对象信息
///
/// 对象编号
/// 返回空或者单个对象信息
public ViewHotelPay GetViewHotelPayByID(int id)
{
//调用获取单个对象的方法
return excuteType("select * from ViewHotelPay where Id = @id and IsDel = 0", new SqlParameter("@id", id));
}
///
/// 获取全部
///
///
public List GetAll()
{
return excuteSql("select * from ViewHotelPay where IsDel = 0");
}
///
/// 根据编号查询对象信息
///
/// 对象编号
/// 返回空或者对象信息
public List GetByDIId(int DIId)
{
//调用获取单个对象的方法
//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));
//去除ispay=1
//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));
return excuteSql("select (select Name from SetData where Id=ccp.CTDId)as CarType,hr.CheckType, ccp.IsMatchCreditCard,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.GovernmentRent,hr.CityTax,hr.DoubleRoomPrice,hr.DoubleRoomCount,hr.SuiteRoomPrice,hr.SuiteRoomCount," +
"hr.OtherRoomPrice,hr.OtherRoomCount,hr.Commission,hr.Budget,((ccp.PayMoney * ccp.DayRate) +hr.breakfastPrice) as PayMoney,(hr.Budget - " +
"(hr.SingleRoomPrice * hr.SingleRoomCount + hr.DoubleRoomPrice * hr.DoubleRoomCount + hr.SuiteRoomPrice * hr.SuiteRoomCount + hr.OtherRoomPrice " +
"* hr.OtherRoomCount + hr.Commission)) as Spread,(ccp.PayMoney+hr.breakfastPrice) as moneys,ccp.DayRate,hr.breakfastPrice as breakfasePrice " +
"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 =1 or ccp.IsAuditGM=3 and ccp.IsPay=1 and ccp.isDel=0 and " +
"hr.operator is not null and hr.operator > 0 order by checkindate ASC", new SqlParameter("@DIId", DIId));
}
}
}