using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; using Models; namespace DAL { /// /// 雷怡 2021-10-12 11:52 /// 外部行程用户关联团组行程Diid表数据访问层 /// public class TravelUsersAndDiidService { List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new TravelUsersAndDiid(), "TravelUsersAndDiid", sql, CommandType.Text, param); } TravelUsersAndDiid excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); TravelUsersAndDiid tuad = new TravelUsersAndDiid(); //判断集合是否为空 if (hdList == null || hdList.Count == 0) { return tuad; } //返回单个对象 return hdList[0]; } /// /// 雷怡 2021-10-14 15:55 /// 增Add /// /// /// public bool Add(TravelUsersAndDiid tuad) { string sql = "insert into TravelUsersAndDiid values(@TravelUsersId,@Diid,@Oper,@OperDate,@Isdel);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@TravelUsersId",tuad.TravelUsersId), new SqlParameter("@Diid",tuad.Diid), new SqlParameter("@Oper",tuad.Oper), new SqlParameter("@OperDate",tuad.OperDate), new SqlParameter("@Isdel",tuad.Isdel) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 雷怡 2021-10-25 11:43 /// 通过行程用户id 查询 /// /// /// public List GetByTravelUsersId(int TravelUsersId) { string sql = "select * from TravelUsersAndDiid where Isdel = 0 and TravelUsersId = " + TravelUsersId; return excuteSql(sql); } /// /// 雷怡 2021-10-14 15:55 /// 删除 Del /// /// /// public bool Del(int id) { string sql = "update TravelUsersAndDiid set Isdel = 1 where Id ="+id; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, null) > 0) return true; return false; } } }