123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data.SqlClient;
- using System.Data;
- namespace DAL
- {
- /// <summary>
- /// 机票预订数据访问类
- /// </summary>
- public class AirTicketReservationsService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<AirTicketReservations> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<AirTicketReservations>.excuteSql(new AirTicketReservations(), "AirTicketReservations", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- AirTicketReservations excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<AirTicketReservations> ctggdList = excuteSql(sql, param);
- //判断集合是否为空
- if (ctggdList == null || ctggdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return ctggdList[0];
- }
- /// <summary>
- /// 根据Id查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public AirTicketReservations GetAirTicketReservationsByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from AirTicketReservations where id = @id and IsDel = 0", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 根据Diid查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public List<AirTicketReservations> GetAirTicketReservationsByDIID(int DIID)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from AirTicketReservations where Diid = @id and IsDel = 0 order by FlightsDate", new SqlParameter("@id", DIID));
- }
- /// <summary>
- /// 根据Diid查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public List<AirTicketReservations> GetAirTicketReservationsByDIIDAndUId(int DIID,int UId)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from AirTicketReservations where Diid = @id and IsDel = 0 and Operator=" + UId + " order by FlightsDate", new SqlParameter("@id", DIID));
- }
- /// <summary>
- /// 根据Diid,Ctype查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public List<AirTicketReservations> GetAirTicketReservationsByDIID(int DIID, int CType)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from AirTicketReservations where Diid =" + DIID + " and IsDel = 0 and CType=" + CType + " order by FlightsDate");
- }
- /// <summary>
- /// 获取全部
- /// </summary>
- /// <returns></returns>
- public List<AirTicketReservations> GetAll()
- {
- return excuteSql("select * from AirTicketReservations where IsDel = 0");
- }
- /// <summary>
- /// 获取全部 - 分页
- /// </summary>
- /// <returns></returns>
- public List<AirTicketReservations> GetAirTicketReservations(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string arrayUsersId)
- {
- string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and Operator in (" + arrayUsersId + ")";
- return PageBase<AirTicketReservations>.excutePageSql(new AirTicketReservations(), "AirTicketReservations", "AirTicketReservations", "*", "FlightsDate asc ,flightsTime asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <returns></returns>
- public bool AddAirTicketReservations(AirTicketReservations atr, out int id)
- {
- string sql = "insert into AirTicketReservations values(@DIId,@FlightsCode,@FlightsDate,@FlightsTime,@ArrivedTime,@IsCheckIn,@IsSetSeat,@IsPackage,@IsBagHandle,@IsTrain,@CType,"
- + "@FlightsCity,@LeaveDescription,@FlightsDescription,@ReturnDescription,@ClientNum,@ClientName,@PrePrice,@PreCurrency,@Price,@Currency,@PriceDescription,@TicketNumber,@TicketCode,@Remark,"
- + "@Operator,@OperatorDate,@IsDel,@PassengerType);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@DIId",atr.DIId),
- new SqlParameter("@FlightsCode",atr.FlightsCode),
- new SqlParameter("@FlightsDate",atr.FlightsDate),
- new SqlParameter("@FlightsTime",atr.FlightsTime),
- new SqlParameter("@ArrivedTime",atr.ArrivedTime),
- new SqlParameter("@IsCheckIn",atr.IsCheckIn),
- new SqlParameter("@IsSetSeat",atr.IsSetSeat),
- new SqlParameter("@IsPackage",atr.IsPackage),
- new SqlParameter("@IsBagHandle",atr.IsBagHandle),
- new SqlParameter("@IsTrain",atr.IsTrain),
- new SqlParameter("@CType",atr.CType),
- new SqlParameter("@FlightsCity",atr.FlightsCity),
- new SqlParameter("@LeaveDescription",atr.LeaveDescription),
- new SqlParameter("@FlightsDescription",atr.FlightsDescription),
- new SqlParameter("@ReturnDescription",atr.ReturnDescription),
- new SqlParameter("@ClientNum",atr.ClientNum),
- new SqlParameter("@ClientName",atr.ClientName),
- new SqlParameter("@PrePrice",atr.PrePrice),
- new SqlParameter("@PreCurrency",atr.PreCurrency),
- new SqlParameter("@Price",atr.Price),
- new SqlParameter("@Currency",atr.Currency),
- new SqlParameter("@PriceDescription",atr.PriceDescription),
- new SqlParameter("@TicketNumber",atr.TicketNumber),
- new SqlParameter("@TicketCode",atr.TicketCode),
- new SqlParameter("@Remark",atr.Remark),
- new SqlParameter("@Operator",atr.Operators),
- new SqlParameter("@OperatorDate",atr.OperatorsDate),
- new SqlParameter("@IsDel",atr.IsDel),
- new SqlParameter("@PassengerType",atr.PassengerType)
- };
- int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
- if (obj > 0)
- {
- id = obj;
- return true;
- }
- id = 0;
- return false;
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <returns></returns>
- public bool EditAirTicketReservations(AirTicketReservations atr)
- {
- string sql = "update AirTicketReservations set DIId = @DIId,FlightsCode = @FlightsCode,FlightsDate = @FlightsDate,FlightsTime = @FlightsTime,"
- + "ArrivedTime=@ArrivedTime,IsCheckIn=@IsCheckIn,IsSetSeat=@IsSetSeat,IsPackage=@IsPackage,IsBagHandle=@IsBagHandle,IsTrain=@IsTrain,CType=@CType,FlightsCity = @FlightsCity,LeaveDescription = @LeaveDescription,"
- + "FlightsDescription = @FlightsDescription,ReturnDescription = @ReturnDescription,ClientNum=@ClientNum,ClientName = @ClientName,"
- + "PrePrice = @PrePrice,PreCurrency = @PreCurrency,Price = @Price,Currency = @Currency,PriceDescription = @PriceDescription,TicketNumber=@TicketNumber,"
- + "TicketCode=@TicketCode,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,PassengerType=@PassengerType where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@DIId",atr.DIId),
- new SqlParameter("@FlightsCode",atr.FlightsCode),
- new SqlParameter("@FlightsDate",atr.FlightsDate),
- new SqlParameter("@FlightsTime",atr.FlightsTime),
- new SqlParameter("@ArrivedTime",atr.ArrivedTime),
- new SqlParameter("@IsCheckIn",atr.IsCheckIn),
- new SqlParameter("@IsSetSeat",atr.IsSetSeat),
- new SqlParameter("@IsPackage",atr.IsPackage),
- new SqlParameter("@IsBagHandle",atr.IsBagHandle),
- new SqlParameter("@IsTrain",atr.IsTrain),
- new SqlParameter("@CType",atr.CType),
- new SqlParameter("@FlightsCity",atr.FlightsCity),
- new SqlParameter("@LeaveDescription",atr.LeaveDescription),
- new SqlParameter("@FlightsDescription",atr.FlightsDescription),
- new SqlParameter("@ReturnDescription",atr.ReturnDescription),
- new SqlParameter("@ClientNum",atr.ClientNum),
- new SqlParameter("@ClientName",atr.ClientName),
- new SqlParameter("@PrePrice",atr.PrePrice),
- new SqlParameter("@PreCurrency",atr.PreCurrency),
- new SqlParameter("@Price",atr.Price),
- new SqlParameter("@Currency",atr.Currency),
- new SqlParameter("@PriceDescription",atr.PriceDescription),
- new SqlParameter("@TicketNumber",atr.TicketNumber),
- new SqlParameter("@TicketCode",atr.TicketCode),
- new SqlParameter("@Remark",atr.Remark),
- new SqlParameter("@Operator",atr.Operators),
- new SqlParameter("@OperatorDate",atr.OperatorsDate),
- new SqlParameter("@Id",atr.Id),
- new SqlParameter("@PassengerType",atr.PassengerType)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelAirTicketReservations(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update AirTicketReservations set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- public List<AirTicketReservations> GetByIds(List<int> ids)
- {
- var idsStr = string.Join(",",ids).TrimEnd(',') ;
- string sql = "select * from AirTicketReservations where IsDel = 0 And id in(" + idsStr + ")";
- return excuteSql(sql);
- }
- public List<AirTicketReservations> GetByDiiDs(List<int> diids)
- {
- var diidsStr = string.Join(",", diids).TrimEnd(',');
- string sql = "select * from AirTicketReservations where IsDel = 0 And diid in(" + diidsStr + ")";
- return excuteSql(sql);
- }
- }
- }
|