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 excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new AirTicketAgent(), "AirTicketAgent", sql, CommandType.Text, param); } AirTicketAgent excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } /// /// 查询所有 /// /// public AirTicketAgent GetById(int id) { return excuteType("select * from AirTicketAgent where Isdel=0 and Id="+id); } /// /// 查找所有数据 - 分页 /// /// public List GetAll(int pageIndex, out int sumPage, out int totalRecord, string Name) { string sqlwhere = "IsDel = 0 and Name like '%" + Name + "%'"; return PageBase.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 GetByNameAndAccount(string name, string account) { return excuteSql("select * from AirTicketAgent where Isdel=0 and Name=" + name + " and Account=" + account); } public List GetAll() { return excuteSql("select * from AirTicketAgent where isdel = 0 and OPer != '' "); } } }