using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Models;
using System.Data.SqlClient;
using System.Data;
namespace DAL
{
///
/// 地接费用多表联查数据访问类
///
public class ViewGroundPayService
{
///
/// 查询所有
///
/// sql语句
/// 可变参数数组
/// 返回集合
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new ViewGroundPay(), "ViewGroundPay", sql, CommandType.Text, param);
}
///
/// 获取单个对象
///
/// sql语句
/// 可变参数数组
/// 返回空或者单个对象
ViewGroundPay excuteType(string sql, params SqlParameter[] param)
{
//查询结果放入对象集合
List ctggdList = excuteSql(sql, param);
//判断集合是否为空
if (ctggdList == null || ctggdList.Count == 0)
//返回null
return null;
//返回单个对象
return ctggdList[0];
}
///
/// 根据编号查询对象信息
///
/// 对象编号
/// 返回空或者单个对象信息
public ViewGroundPay GetViewGroundPayByID(int id)
{
//调用获取单个对象的方法
return excuteType("select * from ViewGroundPay where Id = @id and IsDel = 0", new SqlParameter("@id", id));
}
///
/// 获取全部
///
///
public List GetAll()
{
return excuteSql("select * from ViewGroundPay where IsDel = 0");
}
///
/// 根据编号查询对象信息
///
/// 对象编号
/// 返回空或者对象信息
public List GetByDIId(int DIId)
{
//调用获取单个对象的方法
//return excuteSql("select c.OperatorDate,c.Area,sd.[Name] as PriceType,cc.Price,sd2.[name] as Currency,cc.PriceContent,cc.Remark from CarTouristGuideGroundReservationsContent cc join CarTouristGuideGroundReservations c on c.id = cc.CTGGRId join CreditCardPayment ccp on ccp.Diid = c.Diid and ccp.Cid = c.Id join SetData sd on sd.id = cc.Sid join SetData sd2 on sd2.id = cc.Currency where c.DIID = @DIId and c.IsDel = 0 and ccp.CTable= 79 and ccp.IsPay = 1", new SqlParameter("@DIId", DIId));
//去除ispay=1条件
return excuteSql("select (select Name from SetData where Id=ccp.CTDId) as CarType, ccp.IsMatchCreditCard,ccp.Operator,ccp.AuditGMDate,sd1.name as PaydName,ccp.OrbitalPrivateTransfer,ccp.PayDid,ccp.payee,ccp.ispay,c.OperatorDate,c.Area,sd.[Name] as PriceType,cc.Price,sd2.[name] as Currency,cc.PriceContent,ccp.PayPercentage,cc.Remark from CarTouristGuideGroundReservationsContent cc join CarTouristGuideGroundReservations c on c.id = cc.CTGGRId join CreditCardPayment ccp on ccp.Diid = c.Diid and ccp.Cid = c.Id join SetData sd on sd.id = cc.Sid join SetData sd2 on sd2.id = cc.Currency join setdata sd1 on sd1.id=ccp.PayDid where c.DIID = @DIId and c.IsDel = 0 and ccp.CTable= 79 and ccp.IsAuditGM <> 2 and ccp.isDel=0 and ccp.Operator!=0", new SqlParameter("@DIId", DIId));
}
}
}