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 VisaCheckTimeForBackService { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new VisaCheckTimeForBack(), "VisaCheckTimeForBack", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 VisaCheckTimeForBack excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } /// /// 根据编号查询对象信息 /// /// 对象编号 /// 返回空或者单个对象信息 public VisaCheckTimeForBack GetByID(int id) { //调用获取单个对象的方法 return excuteType("select * from VisaCheckTimeForBack where Id = @id and IsDel = 0", new SqlParameter("@id", id)); } /// /// 查询所有 /// /// public List GetAll(string diid) { return excuteSql("select * from VisaCheckTimeForBack where IsDel=0 and Diid=" + diid); } /// /// 查询所有 /// /// public List GetAll() { return excuteSql("select * from VisaCheckTimeForBack where IsDel=0", null); } /// /// 按国家名和id查询所有 /// /// 国家名 /// id /// public VisaCheckTimeForBack GetCountryAndDiid(string country,int diid) { return excuteType("select * from VisaCheckTimeForBack where IsDel=0 and Country=@country and Diid=@diid", new SqlParameter("@country", country), new SqlParameter("@diid", diid)); } /// /// 增加 /// /// /// public bool Add(VisaCheckTimeForBack hd) { string sql = "insert into VisaCheckTimeForBack values(@Diid,@Country,@Time,@Isdel)"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",hd.Diid), new SqlParameter("@Country",hd.Country), new SqlParameter("@Time",hd.Time), new SqlParameter("@Isdel",hd.Isdel) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 编辑 /// /// /// public bool Edit(VisaCheckTimeForBack hd) { string sql = "update VisaCheckTimeForBack set Diid=@Diid,Country=@Country,Time=@Time,Isdel=@Isdel where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Diid",hd.Diid), new SqlParameter("@Country",hd.Country), new SqlParameter("@Time",hd.Time), new SqlParameter("@Isdel",hd.Isdel), new SqlParameter("@Id",hd.Id) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 删除 /// /// /// public bool Del(int id) { if (SqlHelper.ExecuteNonQuery("update VisaCheckTimeForBack set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } /// /// 清空 /// /// /// public bool Clean(int id) { if (SqlHelper.ExecuteNonQuery("update VisaCheckTimeForBack set Country='" + "',Time='" + "' where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } } }