123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- 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<VisaFile> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<VisaFile>.excuteSql(new VisaFile(), "VisaFile", sql, CommandType.Text, param);
- }
- VisaFile excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<VisaFile> 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;
- }
- /// <summary>
- /// 查找所有数据 - 分页
- /// </summary>
- /// <returns></returns>
- public List<VisaFile> 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<VisaFile>.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<VisaFile> 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);
- }
- }
- }
|