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 DeleClientNeedsService { List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new DeleClientNeeds(), "DeleClientNeeds", sql, CommandType.Text, param); } DeleClientNeeds excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } /// /// 根据ID查询 /// /// public DeleClientNeeds GetById(int id) { return excuteType("select * from DeleClientNeeds where Isdel=0 and Id=" + id); } public List GetAll() { return excuteSql("select * from DeleClientNeeds where Isdel=0 "); } public DeleClientNeeds GetByDIId(int DIID) { return excuteType("select * from DeleClientNeeds where Isdel=0 and Diid=" + DIID); } //增Add public bool Add(DeleClientNeeds Dov) { string sql = "insert into DeleClientNeeds values(@Diid,@OffActPlace,@OffActLetter,@TransNeed,@TranLanguage,@TranScene,@VisaNeeds," + "@Hobby,@CarNeeds,@GuideNeeds,@MealNeeds,@CheckInTime,@HotelLevel,@HotelPosition,@RoomNum,@NeedsRemark,@OPer,@OPdate,@Isdel);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",Dov.Diid), new SqlParameter("@OffActPlace",Dov.OffActPlace), new SqlParameter("@OffActLetter",Dov.OffActLetter), new SqlParameter("@TransNeed",Dov.TransNeed), new SqlParameter("@TranLanguage",Dov.TranLanguage), new SqlParameter("@TranScene",Dov.TranScene), new SqlParameter("@VisaNeeds",Dov.VisaNeeds), new SqlParameter("@Hobby",Dov.Hobby), new SqlParameter("@CarNeeds",Dov.CarNeeds), new SqlParameter("@GuideNeeds",Dov.GuideNeeds), new SqlParameter("@MealNeeds",Dov.MealNeeds), new SqlParameter("@CheckInTime",Dov.CheckInTime), new SqlParameter("@HotelLevel",Dov.HotelLevel), new SqlParameter("@HotelPosition",Dov.HotelPosition), new SqlParameter("@RoomNum",Dov.RoomNum), new SqlParameter("@NeedsRemark",Dov.NeedsRemark), 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(DeleClientNeeds Dov) { string sql = "update DeleClientNeeds set Diid=@Diid,OffActPlace=@OffActPlace,TransNeed=@TransNeed,TranLanguage=@TranLanguage,TranScene=@TranScene," + "OffActLetter=@OffActLetter,VisaNeeds=@VisaNeeds,Hobby=@Hobby,CarNeeds=@CarNeeds," + "GuideNeeds=@GuideNeeds,MealNeeds=@MealNeeds,CheckInTime=@CheckInTime,HotelLevel=@HotelLevel," + "HotelPosition=@HotelPosition,RoomNum=@RoomNum,NeedsRemark=@NeedsRemark,OPer=@OPer,OPdate=@OPdate,Isdel=@Isdel where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",Dov.Diid), new SqlParameter("@OffActPlace",Dov.OffActPlace), new SqlParameter("@OffActLetter",Dov.OffActLetter), new SqlParameter("@TransNeed",Dov.TransNeed), new SqlParameter("@TranLanguage",Dov.TranLanguage), new SqlParameter("@TranScene",Dov.TranScene), new SqlParameter("@VisaNeeds",Dov.VisaNeeds), new SqlParameter("@Hobby",Dov.Hobby), new SqlParameter("@CarNeeds",Dov.CarNeeds), new SqlParameter("@GuideNeeds",Dov.GuideNeeds), new SqlParameter("@MealNeeds",Dov.MealNeeds), new SqlParameter("@CheckInTime",Dov.CheckInTime), new SqlParameter("@HotelLevel",Dov.HotelLevel), new SqlParameter("@HotelPosition",Dov.HotelPosition), new SqlParameter("@RoomNum",Dov.RoomNum), new SqlParameter("@NeedsRemark",Dov.NeedsRemark), 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 DeleClientNeeds set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } public List GetByNameAndPhone(string name, string Phone) { return excuteSql("select * from DeleClientNeeds where Isdel=0 and Name='" + name + "' and Phone='" + Phone + "'"); } } }