VisaCheckTimeForBackService.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. namespace DAL
  9. {
  10. public class VisaCheckTimeForBackService
  11. {
  12. /// <summary>
  13. /// 查询所有
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<VisaCheckTimeForBack> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<VisaCheckTimeForBack>.excuteSql(new VisaCheckTimeForBack(), "VisaCheckTimeForBack", sql, CommandType.Text, param);
  21. }
  22. /// <summary>
  23. /// 获取单个对象
  24. /// </summary>
  25. /// <param name="sql">sql语句</param>
  26. /// <param name="param">可变参数数组</param>
  27. /// <returns>返回空或者单个对象</returns>
  28. VisaCheckTimeForBack excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<VisaCheckTimeForBack> hdList = excuteSql(sql, param);
  32. //判断集合是否为空
  33. if (hdList == null || hdList.Count == 0)
  34. //返回null
  35. return null;
  36. //返回单个对象
  37. return hdList[0];
  38. }
  39. /// <summary>
  40. /// 根据编号查询对象信息
  41. /// </summary>
  42. /// <param name="id">对象编号</param>
  43. /// <returns>返回空或者单个对象信息</returns>
  44. public VisaCheckTimeForBack GetByID(int id)
  45. {
  46. //调用获取单个对象的方法
  47. return excuteType("select * from VisaCheckTimeForBack where Id = @id and IsDel = 0", new SqlParameter("@id", id));
  48. }
  49. /// <summary>
  50. /// 查询所有
  51. /// </summary>
  52. /// <returns></returns>
  53. public List<VisaCheckTimeForBack> GetAll(string diid)
  54. {
  55. return excuteSql("select * from VisaCheckTimeForBack where IsDel=0 and Diid=" + diid);
  56. }
  57. /// <summary>
  58. /// 查询所有
  59. /// </summary>
  60. /// <returns></returns>
  61. public List<VisaCheckTimeForBack> GetAll()
  62. {
  63. return excuteSql("select * from VisaCheckTimeForBack where IsDel=0", null);
  64. }
  65. /// <summary>
  66. /// 按国家名和id查询所有
  67. /// </summary>
  68. /// <param name="country">国家名</param>
  69. /// <param name="id">id</param>
  70. /// <returns></returns>
  71. public VisaCheckTimeForBack GetCountryAndDiid(string country,int diid)
  72. {
  73. return excuteType("select * from VisaCheckTimeForBack where IsDel=0 and Country=@country and Diid=@diid", new SqlParameter("@country", country), new SqlParameter("@diid", diid));
  74. }
  75. /// <summary>
  76. /// 增加
  77. /// </summary>
  78. /// <param name="cd"></param>
  79. /// <returns></returns>
  80. public bool Add(VisaCheckTimeForBack hd)
  81. {
  82. string sql = "insert into VisaCheckTimeForBack values(@Diid,@Country,@Time,@Isdel)";
  83. SqlParameter[] parameter = new SqlParameter[]{
  84. new SqlParameter("@Diid",hd.Diid),
  85. new SqlParameter("@Country",hd.Country),
  86. new SqlParameter("@Time",hd.Time),
  87. new SqlParameter("@Isdel",hd.Isdel)
  88. };
  89. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  90. return true;
  91. return false;
  92. }
  93. /// <summary>
  94. /// 编辑
  95. /// </summary>
  96. /// <param name="sdt"></param>
  97. /// <returns></returns>
  98. public bool Edit(VisaCheckTimeForBack hd)
  99. {
  100. string sql = "update VisaCheckTimeForBack set Diid=@Diid,Country=@Country,Time=@Time,Isdel=@Isdel where Id = @Id";
  101. SqlParameter[] parameter = new SqlParameter[]{
  102. new SqlParameter("@Diid",hd.Diid),
  103. new SqlParameter("@Country",hd.Country),
  104. new SqlParameter("@Time",hd.Time),
  105. new SqlParameter("@Isdel",hd.Isdel),
  106. new SqlParameter("@Id",hd.Id)
  107. };
  108. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  109. return true;
  110. return false;
  111. }
  112. /// <summary>
  113. /// 删除
  114. /// </summary>
  115. /// <param name="id"></param>
  116. /// <returns></returns>
  117. public bool Del(int id)
  118. {
  119. if (SqlHelper.ExecuteNonQuery("update VisaCheckTimeForBack set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  120. return true;
  121. return false;
  122. }
  123. /// <summary>
  124. /// 清空
  125. /// </summary>
  126. /// <param name="id"></param>
  127. /// <returns></returns>
  128. public bool Clean(int id)
  129. {
  130. if (SqlHelper.ExecuteNonQuery("update VisaCheckTimeForBack set Country='" + "',Time='" + "' where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  131. return true;
  132. return false;
  133. }
  134. }
  135. }