123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data.SqlClient;
- using System.Data;
- namespace DAL
- {
- public class AirTicketAgentService
- {
- List<AirTicketAgent> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<AirTicketAgent>.excuteSql(new AirTicketAgent(), "AirTicketAgent", sql, CommandType.Text, param);
- }
- AirTicketAgent excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<AirTicketAgent> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return hdList[0];
- }
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <returns></returns>
- public AirTicketAgent GetById(int id)
- {
- return excuteType("select * from AirTicketAgent where Isdel=0 and Id="+id);
- }
- /// <summary>
- /// 查找所有数据 - 分页
- /// </summary>
- /// <returns></returns>
- public List<AirTicketAgent> GetAll(int pageIndex, out int sumPage, out int totalRecord, string Name)
- {
- string sqlwhere = "IsDel = 0 and Name like '%" + Name + "%'";
- return PageBase<AirTicketAgent>.excutePageSql(new AirTicketAgent(), "AirTicketAgent", "AirTicketAgent", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- //增Add
- public bool Add(AirTicketAgent Dov)
- {
- string sql = "insert into AirTicketAgent values(@DeleName,@Account,@Bank,@OPer,@OPdate,@Isdel);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@DeleName",Dov.Name),
- new SqlParameter("@Account",Dov.Account),
- new SqlParameter("@Bank",Dov.Bank),
- 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(AirTicketAgent Dov)
- {
- string sql = "update AirTicketAgent set DeleName=@DeleName,Account=@Account,Bank=@Bank,OPer=@OPer,OPdate=@OPdate, Isdel=@Isdel where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@DeleName",Dov.Name),
- new SqlParameter("@Account",Dov.Account),
- new SqlParameter("@Bank",Dov.Bank),
- 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 AirTicketAgent set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- public List<AirTicketAgent> GetByNameAndAccount(string name, string account)
- {
- return excuteSql("select * from AirTicketAgent where Isdel=0 and Name=" + name + " and Account=" + account);
- }
- public List<AirTicketAgent> GetAll()
- {
- return excuteSql("select * from AirTicketAgent where isdel = 0 and OPer != '' ");
- }
- }
- }
|