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 VisaProgressService { /// /// 查询所有数据 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new VisaProgress(), "VisaProgress", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 VisaProgress excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List ctggdList = excuteSql(sql, param); //判断集合是否为空 if (ctggdList == null || ctggdList.Count == 0) //返回null return null; //返回单个对象 return ctggdList[0]; } //增Add public bool AddDeleQZ(VisaProgress Dov) { string sql = "insert into VisaProgress values(@Diid,@Country,@GetData,@GetDataTime,@GetPassport,@GetPassportTime," + "@FillData,@FillDataTime,@SendVisa,@SendVisaTime,@SignOut,@SignOutTime,@SendBackPassport,@SendBackPassporTime," + "@Receiver,@Oper,@Opdate,@IsDel);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",Dov.Diid), new SqlParameter("@Country",Dov.Country), new SqlParameter("@GetData",Dov.GetData), new SqlParameter("@GetDataTime",Dov.GetDataTime), new SqlParameter("@GetPassport",Dov.GetPassport), new SqlParameter("@GetPassportTime",Dov.GetPassportTime), new SqlParameter("@FillData",Dov.FillData), new SqlParameter("@FillDataTime",Dov.FillDataTime), new SqlParameter("@SendVisa",Dov.SendVisa), new SqlParameter("@SendVisaTime",Dov.SendVisaTime), new SqlParameter("@SignOut",Dov.SignOut), new SqlParameter("@SignOutTime",Dov.SignOutTime), new SqlParameter("@SendBackPassport",Dov.SendBackPassport), new SqlParameter("@SendBackPassporTime",Dov.SendBackPassporTime), new SqlParameter("@Receiver",Dov.Receiver), 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; } //删Delete public bool DelDeleQZ(int id) { if (SqlHelper.ExecuteNonQuery("update VisaProgress set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } //改Update public bool EditDeleQZ(VisaProgress Dov) { string sql = "update VisaProgress set Diid=@Diid,Country=@Country,GetData=@GetData,GetDataTime=@GetDataTime,GetPassport=@GetPassport," + "GetPassportTime=@GetPassportTime,FillData=@FillData,FillDataTime=@FillDataTime,SendVisa=@SendVisa,SendVisaTime=@SendVisaTime," + "SignOut=@SignOut,SignOutTime=@SignOutTime,SendBackPassport=@SendBackPassport,SendBackPassporTime=@SendBackPassporTime," + "Receiver=@Receiver,Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",Dov.Diid), new SqlParameter("@Country",Dov.Country), new SqlParameter("@GetData",Dov.GetData), new SqlParameter("@GetDataTime",Dov.GetDataTime), new SqlParameter("@GetPassport",Dov.GetPassport), new SqlParameter("@GetPassportTime",Dov.GetPassportTime), new SqlParameter("@FillData",Dov.FillData), new SqlParameter("@FillDataTime",Dov.FillDataTime), new SqlParameter("@SendVisa",Dov.SendVisa), new SqlParameter("@SendVisaTime",Dov.SendVisaTime), new SqlParameter("@SignOut",Dov.SignOut), new SqlParameter("@SignOutTime",Dov.SignOutTime), new SqlParameter("@SendBackPassport",Dov.SendBackPassport), new SqlParameter("@SendBackPassporTime",Dov.SendBackPassporTime), new SqlParameter("@Receiver",Dov.Receiver), 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; } //查Select /// /// 根据ID查询数据 /// /// 根据ID /// 返回空或者单个对象信息 public VisaProgress GetById(int Id) { //调用获取单个对象的方法 return excuteType("select * from VisaProgress where IsDel=0 and Id=@Id", new SqlParameter("@Id", Id)); } /// /// /// /// 根据团组ID /// public List GetAllByDiid(int diid) { //调用获取单个对象的方法 return excuteSql("select * from VisaProgress where IsDel=0 and Diid=@diid", new SqlParameter("@diid", diid)); } List excuteUserSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new Users(), "Users", sql, CommandType.Text, param); } public List GetByUser() { return excuteUserSql(" select * from Users where Post like '%酒店%' and IsDel=@isDel or Post like '%机票%' or Id=149", new SqlParameter("@isDel", 0)); //return null; } } }