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 TravelList_ExternalService { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new TravelList_External(), "TravelList_External", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 TravelList_External excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } /// /// 根据编号查询对象信息 /// /// 对象编号 /// 返回空或者单个对象信息 public TravelList_External GetById(int id) { //调用获取单个对象的方法 return excuteType("select * from TravelList_External where Id = @id", new SqlParameter("@id", id)); } /// /// 根据团组编号查询信息 /// /// 返回空或者对象信息 public List GetByDiid(int Diid) { //调用获取单个对象的方法 return excuteSql("select * from TravelList_External where Diid =" + Diid + " and Isdel=0 order by Id"); } /// /// 获取全部 /// /// public List GetAll() { return excuteSql("select * from TravelList_External where Isdel=0"); } /// /// 增加 /// /// /// public bool AddTravelList_External(TravelList_External hd) { string sql = "insert into TravelList_External values(@Diid,@Days,@Date,@WeekDay,@Traffic_First,@Traffic_Second,@Trip,@OPer,@OPdate,@Isdel)"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",hd.Diid), new SqlParameter("@Days",hd.Days), new SqlParameter("@Date",hd.Date), new SqlParameter("@WeekDay",hd.WeekDay), new SqlParameter("@Traffic_First",hd.Traffic_First), new SqlParameter("@Traffic_Second",hd.Traffic_Second), new SqlParameter("@Trip",hd.Trip), new SqlParameter("@OPer",hd.OPer), new SqlParameter("@OPdate",hd.OPdate), new SqlParameter("@Isdel",hd.Isdel) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 编辑 /// /// /// public bool EditTravelList_External(TravelList_External hd) { string sql = "update TravelList_External set Diid=@Diid,Days = @Days,Date = @Date,WeekDay = @WeekDay,Traffic_First = @Traffic_First," + "Traffic_Second = @Traffic_Second,Trip = @Trip,OPer = @OPer,OPdate = @OPdate,Isdel = @Isdel where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",hd.Diid), new SqlParameter("@Days",hd.Days), new SqlParameter("@Date",hd.Date), new SqlParameter("@WeekDay",hd.WeekDay), new SqlParameter("@Traffic_First",hd.Traffic_First), new SqlParameter("@Traffic_Second",hd.Traffic_Second), new SqlParameter("@Trip",hd.Trip), new SqlParameter("@OPer",hd.OPer), new SqlParameter("@OPdate",hd.OPdate), new SqlParameter("@Isdel",hd.Isdel), new SqlParameter("@Id",hd.Id) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 20210818 贾文滔 /// 根据ID执行delete操作 /// /// /// public bool DelTravelList_External(int id) { if (SqlHelper.ExecuteNonQuery("delete TravelList_External where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } /// /// 20210818 贾文滔 /// 根据id执行清空"trip" 字段操作 /// /// /// public bool Clean(int id) { if (SqlHelper.ExecuteNonQuery("update TravelList_External set Trip='' where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } /// /// 20210818 贾文滔 /// 根据团号和ID范围执行delete操作 /// /// /// /// /// public bool DelOld(int Diid, int start, int end) { if (SqlHelper.ExecuteNonQuery("delete from TravelList_External where Diid=" + Diid + " and ( Id>=" + start + " and Id<=" + end + ")", CommandType.Text) > 0) return true; return false; } /// /// 20210818 /// 根据团号diid 执行更新ISDEL=1的删除操作 /// /// /// public bool DelByDiid(int diid) { if (SqlHelper.ExecuteNonQuery("update TravelList_External set Isdel=1 where Diid=" + diid, CommandType.Text) > 0) return true; return false; } } }