123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- 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
- {
- /// <summary>
- /// 酒店提前询价录入 数据访问类
- /// </summary>
- public class HotelAdvanceInquiryService
- {
- List<HotelAdvanceInquiry> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<HotelAdvanceInquiry>.excuteSql(new HotelAdvanceInquiry(), "HotelAdvanceInquiry", sql, CommandType.Text, param);
- }
- HotelAdvanceInquiry excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<HotelAdvanceInquiry> hdList = excuteSql(sql, param);
- HotelAdvanceInquiry air = new HotelAdvanceInquiry();
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- {
- return air;
- }
- //返回单个对象
- return hdList[0];
- }
- /// <summary>
- /// //增Add
- /// </summary>
- /// <param name="Hai">酒店提前询价录入类</param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// //改Update
- /// </summary>
- /// <param name="Hai"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// //删
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 根据diid 查询数据
- /// </summary>
- /// <returns></returns>
- public List<HotelAdvanceInquiry> GetAllByTourCode(string diid)
- {
- return excuteSql("select * from HotelAdvanceInquiry Where IsDel = 0 and Diid ='"+ diid + "' order by OperDate desc");
- }
- /// <summary>
- /// 根据id 查询数据
- /// </summary>
- /// <returns></returns>
- public HotelAdvanceInquiry GetAllById(int id)
- {
- return excuteType("select * from HotelAdvanceInquiry Where IsDel = 0 and id ='" + id + "'");
- }
- }
- }
|