123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using Models;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- namespace DAL
- {
- public class AirTicketBlackCodeService
- {
- List<AirTicketBlackCode> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<AirTicketBlackCode>.excuteSql(new AirTicketBlackCode(), "AirTicketBlackCode", sql, CommandType.Text, param);
- }
- AirTicketBlackCode excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<AirTicketBlackCode> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return hdList[0];
- }
- //增Add
- public bool Add(AirTicketBlackCode Dov)
- {
- string sql = "insert into AirTicketBlackCode values(@Diid,@LeaveCode,@BlackCode,@ReturnCode,@Price,@NowPrice,@BCPrice,@ECPrice,@Oper,@Opdate,@Isdel);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",Dov.Diid),
- new SqlParameter("@LeaveCode",Dov.LeaveCode),
- new SqlParameter("@BlackCode",Dov.BlackCode),
- new SqlParameter("@ReturnCode",Dov.ReturnCode),
- new SqlParameter("@Price",Dov.Price),
- new SqlParameter("@NowPrice",Dov.NowPrice),
- new SqlParameter("@BCPrice",Dov.BCPrice),
- new SqlParameter("@ECPrice",Dov.ECPrice),
- new SqlParameter("@OPer",Dov.OPer),
- new SqlParameter("@Opdate",Dov.Opdate),
- new SqlParameter("@Isdel",Dov.Isdel)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- //改Update
- public bool Edit(AirTicketBlackCode Dov)
- {
- string sql = "update AirTicketBlackCode set Did=@Diid,LeaveCode=@LeaveCode,BlackCode=@BlackCode,"
- + "ReturnCode=@ReturnCode,Price=@Price,NowPrice=@NowPrice,BCPrice=@BCPrice,ECPrice=@ECPrice,Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",Dov.Diid),
- new SqlParameter("@LeaveCode",Dov.LeaveCode),
- new SqlParameter("@BlackCode",Dov.BlackCode),
- new SqlParameter("@ReturnCode",Dov.ReturnCode),
- new SqlParameter("@Price",Dov.Price),
- new SqlParameter("@NowPrice",Dov.NowPrice),
- new SqlParameter("@BCPrice",Dov.BCPrice),
- new SqlParameter("@ECPrice",Dov.ECPrice),
- new SqlParameter("@OPer",Dov.OPer),
- new SqlParameter("@Opdate",Dov.Opdate),
- new SqlParameter("@Isdel",Dov.Isdel),
- new SqlParameter("@Id",Dov.Id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- //删
- public bool delOA(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update AirTicketBlackCode set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 查找所有数据 - 分页
- /// </summary>
- /// <returns></returns>
- public List<AirTicketBlackCode> GetAll(int diid)
- {
- return excuteSql("select * from AirTicketBlackCode where Isdel=0 and Did=" + diid + " order by Id");
- }
- public AirTicketBlackCode getById(int id)
- {
- return excuteType("select * from AirTicketBlackCode where Isdel=0 and Id=@id", new SqlParameter("@id", id));
- }
- public AirTicketBlackCode getByDiid(int diid)
- {
- return excuteType("select * from AirTicketBlackCode where Isdel=0 and did=@diid", new SqlParameter("@diid", diid));
- }
- }
- }
|