VisaFileService.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data.SqlClient;
  7. using System.Data;
  8. namespace DAL
  9. {
  10. public class VisaFileService
  11. {
  12. List<VisaFile> excuteSql(string sql, params SqlParameter[] param)
  13. {
  14. return ServiceBase<VisaFile>.excuteSql(new VisaFile(), "VisaFile", sql, CommandType.Text, param);
  15. }
  16. VisaFile excuteType(string sql, params SqlParameter[] param)
  17. {
  18. //查询结果放入对象集合
  19. List<VisaFile> hdList = excuteSql(sql, param);
  20. //判断集合是否为空
  21. if (hdList == null || hdList.Count == 0)
  22. //返回null
  23. return null;
  24. //返回单个对象
  25. return hdList[0];
  26. }
  27. //增Add
  28. public bool Add(VisaFile Dov)
  29. {
  30. string sql = "insert into VisaFile values(@Continent,@Country,@Category,@FileName,@FilePath,@Oper,@OpDate,@Isdel);SELECT @@IDENTITY";
  31. SqlParameter[] parameter = new SqlParameter[]{
  32. new SqlParameter("@Continent",Dov.Continent),
  33. new SqlParameter("@Country",Dov.Country),
  34. new SqlParameter("@Category",Dov.Category),
  35. new SqlParameter("@FileName",Dov.FileName),
  36. new SqlParameter("@FilePath",Dov.FilePath),
  37. new SqlParameter("@Oper",Dov.Oper),
  38. new SqlParameter("@OpDate",Dov.OpDate),
  39. new SqlParameter("@Isdel",Dov.Isdel)
  40. };
  41. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  42. return true;
  43. return false;
  44. }
  45. //改Update
  46. public bool Edit(VisaFile Dov)
  47. {
  48. string sql = "update VisaFile set Continent=@Continent,Country=@Country,Category=@Category,FileName=@FileName,FilePath=@FilePath,Oper=@Oper,OpDate=@OpDate,Isdel=@Isdel where Id = @Id";
  49. SqlParameter[] parameter = new SqlParameter[]{
  50. new SqlParameter("@Continent",Dov.Continent),
  51. new SqlParameter("@Country",Dov.Country),
  52. new SqlParameter("@Category",Dov.Category),
  53. new SqlParameter("@FileName",Dov.FileName),
  54. new SqlParameter("@FilePath",Dov.FilePath),
  55. new SqlParameter("@Oper",Dov.Oper),
  56. new SqlParameter("@OpDate",Dov.OpDate),
  57. new SqlParameter("@Isdel",Dov.Isdel),
  58. new SqlParameter("@Id",Dov.Id)
  59. };
  60. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  61. return true;
  62. return false;
  63. }
  64. //删数据
  65. public bool delOA(int id)
  66. {
  67. if (SqlHelper.ExecuteNonQuery("update VisaFile set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  68. return true;
  69. return false;
  70. }
  71. /// <summary>
  72. /// 查找所有数据 - 分页
  73. /// </summary>
  74. /// <returns></returns>
  75. public List<VisaFile> GetAllVisaFile(int pageIndex, out int sumPage, out int totalRecord, string Continent, string Country, string Category)
  76. {
  77. string sqlwhere = "IsDel = 0 and Continent like '%" + Continent + "%' and Country like '%" + Country + "%' and Category like '%" + Category + "%'";
  78. return PageBase<VisaFile>.excutePageSql(new VisaFile(), "VisaFile", "VisaFile", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  79. }
  80. public VisaFile GetVisaFileById(int id)
  81. {
  82. return excuteType("select * from VisaFile where Isdel=0 and Id=" + id);
  83. }
  84. public List<VisaFile> GetAll()
  85. {
  86. return excuteSql("select * from VisaFile where Isdel=0 ");
  87. }
  88. public VisaFile GetVisaFile(string Continent, string Country, string Category)
  89. {
  90. return excuteType("select * from VisaFile where Isdel=0 and Continent=" + Continent + " and Country=" + Country + " and Category=" + Category);
  91. }
  92. }
  93. }