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 VisaChekOutTimeService { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new VisaCheckOutTime(), "VisaCheckOutTime", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 VisaCheckOutTime excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } /// /// 根据编号查询对象信息 /// /// 对象编号 /// 返回空或者单个对象信息 public VisaCheckOutTime GetVisaChekOutTimeByID(int id) { //调用获取单个对象的方法 return excuteType("select * from VisaChekOutTime where Id = @id and IsDel = 0", new SqlParameter("@id", id)); } /// /// 查询信息 /// /// 返回空或者对象信息 public VisaCheckOutTime GetVisaChekOutTimeName(string name) { //调用获取单个对象的方法 return excuteType("select * from VisaChekOutTime where Country like '%" + name + "%'"); } /// /// 查询信息 /// /// 返回空或者对象信息 public List getByCountry(string name) { //调用获取单个对象的方法 return excuteSql("select * from VisaChekOutTime where Isdel=0 and Country ='" + name + "'"); } /// /// 查询所有 /// /// public List GetAll() { return excuteSql("select * from VisaChekOutTime where IsDel=0", null); } /// /// 增加 /// /// /// public bool AddVisaChekOutTime(VisaCheckOutTime hd) { string sql = "insert into VisaChekOutTime values(@Contient,@Country,@VisaPlace,@Time,@RushTime,@Remark,@Oper,@Opdate,@Isdel)"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Contient",hd.Contient), new SqlParameter("@Country",hd.Country), new SqlParameter("@VisaPlace",hd.VisaPlace), new SqlParameter("@Time",hd.Time), new SqlParameter("@RushTime",hd.RushTime), new SqlParameter("@Remark",hd.Remark), new SqlParameter("@Oper",hd.Oper), new SqlParameter("@Opdate",hd.Opdate), new SqlParameter("@Isdel",hd.Isdel) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 编辑 /// /// /// public bool EditVisaChekOutTime(VisaCheckOutTime hd) { string sql = "update VisaChekOutTime set Contient=@Contient,Country=@Country,VisaPlace=@VisaPlace,Time=@Time,RushTime=@RushTime,Remark=@Remark,Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Contient",hd.Contient), new SqlParameter("@Country",hd.Country), new SqlParameter("@VisaPlace",hd.VisaPlace), new SqlParameter("@Time",hd.Time), new SqlParameter("@RushTime",hd.RushTime), new SqlParameter("@Remark",hd.Remark), new SqlParameter("@Oper",hd.Oper), new SqlParameter("@Opdate",hd.Opdate), new SqlParameter("@Isdel",hd.Isdel), new SqlParameter("@Id",hd.Id) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 删除 /// /// /// public bool DelVisaChekOutTime(int id) { if (SqlHelper.ExecuteNonQuery("update VisaChekOutTime set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } } }