using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
namespace DAL
{
///
/// 机票提前询价 录入
///
public class AirAdvanceInquiryService
{
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new AirAdvanceInquiry(), "AirAdvanceInquiry", sql, CommandType.Text, param);
}
AirAdvanceInquiry excuteType(string sql, params SqlParameter[] param)
{
//查询结果放入对象集合
List hdList = excuteSql(sql, param);
AirAdvanceInquiry air = new AirAdvanceInquiry();
//判断集合是否为空
if (hdList == null || hdList.Count == 0)
{
return air;
}
//返回单个对象
return hdList[0];
}
///
/// //增Add
///
/// 酒店提前询价录入类
///
public bool Add(AirAdvanceInquiry aai)
{
string sql = "insert into AirAdvanceInquiry values(@Diid,@Area,@Airlines,@Shift,@StartTime,@EndTime,@SpaceType,@SelectTime,@LowestPrice," +
"@Remark,@Oper,@OperDate,@Isdel,@FullPrice,@InstantPrice);SELECT @@IDENTITY";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@Diid",aai.Diid),
new SqlParameter("@Area",aai.Area),
new SqlParameter("@Airlines",aai.Airlines),
new SqlParameter("@Shift",aai.Shift),
new SqlParameter("@StartTime",aai.StartTime),
new SqlParameter("@EndTime",aai.EndTime),
new SqlParameter("@SpaceType",aai.SpaceType),
new SqlParameter("@SelectTime",aai.SelectTime),
new SqlParameter("@LowestPrice",aai.LowestPrice),
new SqlParameter("@Remark",aai.Remark),
new SqlParameter("@Oper",aai.Oper),
new SqlParameter("@OperDate",aai.OperDate),
new SqlParameter("@Isdel",aai.Isdel),
new SqlParameter("@FullPrice",aai.FullPrice),
new SqlParameter("@InstantPrice",aai.InstantPrice)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// //改Update
///
///
///
public bool Update(AirAdvanceInquiry aai)
{
string sql = "update AirAdvanceInquiry set Diid=@Diid,Area=@Area,Airlines=@Airlines,Shift=@Shift,StartTime=@StartTime,EndTime=@EndTime,SpaceType=@SpaceType,SelectTime=@SelectTime,Remark=@Remark,"
+ "Oper=@Oper,OperDate=@OperDate,Isdel=@Isdel,FullPrice=@FullPrice,InstantPrice=@InstantPrice where Id = @Id";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@Diid",aai.Diid),
new SqlParameter("@Area",aai.Area),
new SqlParameter("@Airlines",aai.Airlines),
new SqlParameter("@Shift",aai.Shift),
new SqlParameter("@StartTime",aai.StartTime),
new SqlParameter("@EndTime",aai.EndTime),
new SqlParameter("@SpaceType",aai.SpaceType),
new SqlParameter("@SelectTime",aai.SelectTime),
new SqlParameter("@LowestPrice",aai.LowestPrice),
new SqlParameter("@Remark",aai.Remark),
new SqlParameter("@Oper",aai.Oper),
new SqlParameter("@OperDate",aai.OperDate),
new SqlParameter("@Isdel",aai.Isdel),
new SqlParameter("@Id",aai.Id),
new SqlParameter("@FullPrice",aai.FullPrice),
new SqlParameter("@InstantPrice",aai.InstantPrice)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// //删
///
///
///
public bool Delete(int id)
{
if (SqlHelper.ExecuteNonQuery("update AirAdvanceInquiry set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
///
/// 根据diid 查询数据
///
///
public List GetAllByTourCode(string diid)
{
return excuteSql("select * from AirAdvanceInquiry Where IsDel = 0 and Diid ='" + diid + "' order by OperDate desc");
}
///
/// 根据id 查询数据
///
///
public AirAdvanceInquiry GetAllById(int id)
{
return excuteType("select * from AirAdvanceInquiry Where IsDel = 0 and id ='" + id + "'");
}
}
}