using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
namespace DAL
{
///
/// 团组附件下载统计数据访问层
///
public class TeamAttachmentService
{
///
/// 查询所有数据
///
/// sql语句
/// 可变参数数组
/// 返回集合
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new TeamAttachmentInfo(), "TeamAttachmentInfo", sql, CommandType.Text, param);
}
///
/// 获取单个对象
///
/// sql语句
/// 可变参数数组
/// 返回空或者单个对象
TeamAttachmentInfo excuteType(string sql, params SqlParameter[] param)
{
//查询结果放入对象集合
List ctggdList = excuteSql(sql, param);
//判断集合是否为空
if (ctggdList == null || ctggdList.Count == 0)
//返回null
return null;
//返回单个对象
return ctggdList[0];
}
//增Add
public bool Add(TeamAttachmentInfo tai)
{
string sql = "insert into TeamAttachment values(@Diid,@AirNumber,@HotelNumber,@VisaNumber,@InvitedNumber,@OfficialNumber,@PickNumber,@Oper,@OperDate,@Isdel);SELECT @@IDENTITY";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@Diid",tai.Diid),
new SqlParameter("@AirNumber",tai.AirNumber),
new SqlParameter("@HotelNumber",tai.HotelNumber),
new SqlParameter("@VisaNumber",tai.VisaNumber),
new SqlParameter("@InvitedNumber",tai.InvitedNumber),
new SqlParameter("@OfficialNumber",tai.OfficialNumber),
new SqlParameter("@PickNumber",tai.PickNumber),
new SqlParameter("@Oper",tai.Oper),
new SqlParameter("@OperDate",tai.OperDate),
new SqlParameter("@Isdel",tai.Isdel)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
//删Delete
public bool Del(int id)
{
if (SqlHelper.ExecuteNonQuery("update TeamAttachment set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
//改Update
public bool Edit(TeamAttachmentInfo tai)
{
string sql = "update TeamAttachment set AirNumber=@AirNumber,HotelNumber=@HotelNumber,VisaNumber=@VisaNumber,InvitedNumber=@InvitedNumber," +
"OfficialNumber=@OfficialNumber,PickNumber=@PickNumber,Oper=@Oper,OperDate=@OperDate,Isdel=@Isdel where Id = @Id";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@AirNumber",tai.AirNumber),
new SqlParameter("@HotelNumber",tai.HotelNumber),
new SqlParameter("@VisaNumber",tai.VisaNumber),
new SqlParameter("@InvitedNumber",tai.InvitedNumber),
new SqlParameter("@OfficialNumber",tai.OfficialNumber),
new SqlParameter("@PickNumber",tai.PickNumber),
new SqlParameter("@Oper",tai.Oper),
new SqlParameter("@OperDate",tai.OperDate),
new SqlParameter("@Isdel",tai.Isdel),
new SqlParameter("@Id",tai.Id)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 根据团组id singer
///
/// 团组id
///
public TeamAttachmentInfo GetByDiid(int diid)
{
//调用获取单个对象的方法
return excuteType("select * from TeamAttachment where IsDel=0 and Diid=@diid ", new SqlParameter("@diid", diid));
}
///
/// 根据团组id
///
/// 团组id
///
public List GetByDiids(int diid)
{
//调用获取单个对象的方法
return excuteSql("select * from TeamAttachment where IsDel=0 and Diid=@diid ", new SqlParameter("@diid", diid));
}
}
}