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 OfficialActivitiesService { List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new OfficialActivities(), "OfficalActivities", sql, CommandType.Text, param); } OfficialActivities excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } //增Add public bool Add(OfficialActivities Dov) { string sql = "insert into OfficialActivities values(@Diid,@Dovid,@Client,@Date,@Time,@Address,@Contact,@Job,@Tel,@Form,@Setting,@Dresscode,@Attendees,@IsNeedTrans,@Translators,@Language," + "@Trip,@Oper,@OpDate,@Isdel,@Type,@IsSubmitApproval,@IsPay);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",Dov.Diid), new SqlParameter("@Dovid",Dov.Dovid), new SqlParameter("@Client",Dov.Client), new SqlParameter("@Date",Dov.Date), new SqlParameter("@Time",Dov.Time), new SqlParameter("@Address",Dov.Address), new SqlParameter("@Contact",Dov.Contact), new SqlParameter("@Job",Dov.Job), new SqlParameter("@Tel",Dov.Tel), new SqlParameter("@Form",Dov.Form), new SqlParameter("@Setting",Dov.Setting), new SqlParameter("@Dresscode",Dov.Dresscode), new SqlParameter("@Attendees",Dov.Attendees), new SqlParameter("@IsNeedTrans",Dov.IsNeedTrans), new SqlParameter("@Translators",Dov.Translators), new SqlParameter("@Language",Dov.Language), new SqlParameter("@Trip",Dov.Trip), new SqlParameter("@Oper",Dov.Oper), new SqlParameter("@OpDate",Dov.OpDate), new SqlParameter("@Isdel",Dov.Isdel), new SqlParameter("@Type",Dov.Type), new SqlParameter("@IsSubmitApproval",Dov.IsSubmitApproval), new SqlParameter("@IsPay",Dov.IsPay), }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } //改Update public bool Edit(OfficialActivities Dov) { string sql = "update OfficialActivities set Diid=@Diid,Dovid=@Dovid,Client=@Client,Date=@Date,Time=@Time,Address=@Address,Contact=@Contact,Job=@Job," + "Tel=@Tel,Form=@Form,Setting=@Setting,Dresscode=@Dresscode,Attendees=@Attendees,IsNeedTrans=@IsNeedTrans,Translators=@Translators,Language=@Language," + "Trip=@Trip,Oper=@Oper,OpDate=@OpDate,Isdel=@Isdel,Type=@Type,IsSubmitApproval=@IsSubmitApproval,IsPay=@IsPay where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",Dov.Diid), new SqlParameter("@Dovid",Dov.Dovid), new SqlParameter("@Client",Dov.Client), new SqlParameter("@Date",Dov.Date), new SqlParameter("@Time",Dov.Time), new SqlParameter("@Address",Dov.Address), new SqlParameter("@Contact",Dov.Contact), new SqlParameter("@Job",Dov.Job), new SqlParameter("@Tel",Dov.Tel), new SqlParameter("@Form",Dov.Form), new SqlParameter("@Setting",Dov.Setting), new SqlParameter("@Dresscode",Dov.Dresscode), new SqlParameter("@Attendees",Dov.Attendees), new SqlParameter("@IsNeedTrans",Dov.IsNeedTrans), new SqlParameter("@Translators",Dov.Translators), new SqlParameter("@Language",Dov.Language), new SqlParameter("@Trip",Dov.Trip), new SqlParameter("@Oper",Dov.Oper), new SqlParameter("@OpDate",Dov.OpDate), new SqlParameter("@Isdel",Dov.Isdel), new SqlParameter("@Id",Dov.Id), new SqlParameter("@Type",Dov.Type), new SqlParameter("@IsSubmitApproval",Dov.IsSubmitApproval), new SqlParameter("@IsPay",Dov.IsPay), }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } //删 public bool delOA(int id) { if (SqlHelper.ExecuteNonQuery("update OfficialActivities set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } /// /// 根据团组ID查询多个信息 /// /// /// public List getByDiid(int diid) { return excuteSql("select * from OfficialActivities where Isdel=0 and Diid=@diid order by Date", new SqlParameter("@diid", diid)); } /// /// 根据团组查询多个信息 /// /// /// public List getByDiidAndDate(int diid,string date) { return excuteSql("select * from OfficialActivities where Isdel=0 and Diid=@diid and IsSubmitApproval=0 and Date=@Date order by Date", new SqlParameter("@diid", diid), new SqlParameter("@Date", date)); } /// /// 根据Id查单条信息 /// /// /// public OfficialActivities getById(int id) { return excuteType("select * from OfficialActivities where Isdel=0 and Id=@id", new SqlParameter("@id", id)); } /// /// 根据Id查单条信息 /// /// /// public OfficialActivities getBySingleDiid(int diid) { return excuteType("select * from OfficialActivities where Isdel=0 and diid=@diid", new SqlParameter("@diid", diid)); } /// /// 根据Id查单条信息 /// /// /// public OfficialActivities getBySingleDiidAndCountry(int diid,string country) { return excuteType("select * from OfficialActivities where Isdel=0 and diid=" + diid + " and Client like '%" + country + "%'"); } /// /// 雷怡 2021-08-30 10:20 /// 查询所有 /// /// public List getAll() { return excuteSql("select * from OfficialActivities where Isdel=0 order by Date desc"); } } }