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