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 VisaFileService { List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new VisaFile(), "VisaFile", sql, CommandType.Text, param); } VisaFile 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(VisaFile Dov) { string sql = "insert into VisaFile values(@Continent,@Country,@Category,@FileName,@FilePath,@Oper,@OpDate,@Isdel);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Continent",Dov.Continent), new SqlParameter("@Country",Dov.Country), new SqlParameter("@Category",Dov.Category), new SqlParameter("@FileName",Dov.FileName), new SqlParameter("@FilePath",Dov.FilePath), 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(VisaFile Dov) { string sql = "update VisaFile set Continent=@Continent,Country=@Country,Category=@Category,FileName=@FileName,FilePath=@FilePath,Oper=@Oper,OpDate=@OpDate,Isdel=@Isdel where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Continent",Dov.Continent), new SqlParameter("@Country",Dov.Country), new SqlParameter("@Category",Dov.Category), new SqlParameter("@FileName",Dov.FileName), new SqlParameter("@FilePath",Dov.FilePath), 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 VisaFile set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } /// /// 查找所有数据 - 分页 /// /// public List GetAllVisaFile(int pageIndex, out int sumPage, out int totalRecord, string Continent, string Country, string Category) { string sqlwhere = "IsDel = 0 and Continent like '%" + Continent + "%' and Country like '%" + Country + "%' and Category like '%" + Category + "%'"; return PageBase.excutePageSql(new VisaFile(), "VisaFile", "VisaFile", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord); } public VisaFile GetVisaFileById(int id) { return excuteType("select * from VisaFile where Isdel=0 and Id=" + id); } public List GetAll() { return excuteSql("select * from VisaFile where Isdel=0 "); } public VisaFile GetVisaFile(string Continent, string Country, string Category) { return excuteType("select * from VisaFile where Isdel=0 and Continent=" + Continent + " and Country=" + Country + " and Category=" + Category); } } }