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 HotelAdvanceInquiryService
{
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new HotelAdvanceInquiry(), "HotelAdvanceInquiry", sql, CommandType.Text, param);
}
HotelAdvanceInquiry excuteType(string sql, params SqlParameter[] param)
{
//查询结果放入对象集合
List hdList = excuteSql(sql, param);
HotelAdvanceInquiry air = new HotelAdvanceInquiry();
//判断集合是否为空
if (hdList == null || hdList.Count == 0)
{
return air;
}
//返回单个对象
return hdList[0];
}
///
/// //增Add
///
/// 酒店提前询价录入类
///
public bool Add(HotelAdvanceInquiry Hai)
{
string sql = "insert into HotelAdvanceInquiry values(@Diid,@Area,@HotelName,@RoomType,@SelectTime,@LowestPrice,@Remark,@Oper,@OperDate,@Isdel);SELECT @@IDENTITY";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@Diid",Hai.Diid),
new SqlParameter("@Area",Hai.Area),
new SqlParameter("@HotelName",Hai.HotelName),
new SqlParameter("@RoomType",Hai.RoomType),
new SqlParameter("@SelectTime",Hai.SelectTime),
new SqlParameter("@LowestPrice",Hai.LowestPrice),
new SqlParameter("@Remark",Hai.Remark),
new SqlParameter("@Oper",Hai.Oper),
new SqlParameter("@OperDate",Hai.OperDate),
new SqlParameter("@Isdel",Hai.Isdel)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// //改Update
///
///
///
public bool Update(HotelAdvanceInquiry Hai)
{
string sql = "update HotelAdvanceInquiry set Diid=@Diid,Area=@Area,HotelName=@HotelName,RoomType=@RoomType,SelectTime=@SelectTime,Remark=@Remark,"
+ "Oper=@Oper,OperDate=@OperDate,Isdel=@Isdel where Id = @Id";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@Diid",Hai.Diid),
new SqlParameter("@Area",Hai.Area),
new SqlParameter("@HotelName",Hai.HotelName),
new SqlParameter("@RoomType",Hai.RoomType),
new SqlParameter("@SelectTime",Hai.SelectTime),
new SqlParameter("@LowestPrice",Hai.LowestPrice),
new SqlParameter("@Remark",Hai.Remark),
new SqlParameter("@Oper",Hai.Oper),
new SqlParameter("@OperDate",Hai.OperDate),
new SqlParameter("@Isdel",Hai.Isdel),
new SqlParameter("@Id",Hai.Id)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// //删
///
///
///
public bool Delete(int id)
{
if (SqlHelper.ExecuteNonQuery("update HotelAdvanceInquiry 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 HotelAdvanceInquiry Where IsDel = 0 and Diid ='"+ diid + "' order by OperDate desc");
}
///
/// 根据id 查询数据
///
///
public HotelAdvanceInquiry GetAllById(int id)
{
return excuteType("select * from HotelAdvanceInquiry Where IsDel = 0 and id ='" + id + "'");
}
}
}