VisaChekOutTimeService.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 VisaChekOutTimeService
  11. {
  12. /// <summary>
  13. /// 查询所有
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<VisaCheckOutTime> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<VisaCheckOutTime>.excuteSql(new VisaCheckOutTime(), "VisaCheckOutTime", 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. VisaCheckOutTime excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<VisaCheckOutTime> 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 VisaCheckOutTime GetVisaChekOutTimeByID(int id)
  45. {
  46. //调用获取单个对象的方法
  47. return excuteType("select * from VisaChekOutTime where Id = @id and IsDel = 0", new SqlParameter("@id", id));
  48. }
  49. /// <summary>
  50. /// 查询信息
  51. /// </summary>
  52. /// <returns>返回空或者对象信息</returns>
  53. public VisaCheckOutTime GetVisaChekOutTimeName(string name)
  54. {
  55. //调用获取单个对象的方法
  56. return excuteType("select * from VisaChekOutTime where Country like '%" + name + "%'");
  57. }
  58. /// <summary>
  59. /// 查询信息
  60. /// </summary>
  61. /// <returns>返回空或者对象信息</returns>
  62. public List<VisaCheckOutTime> getByCountry(string name)
  63. {
  64. //调用获取单个对象的方法
  65. return excuteSql("select * from VisaChekOutTime where Isdel=0 and Country ='" + name + "'");
  66. }
  67. /// <summary>
  68. /// 查询所有
  69. /// </summary>
  70. /// <returns></returns>
  71. public List<VisaCheckOutTime> GetAll()
  72. {
  73. return excuteSql("select * from VisaChekOutTime where IsDel=0", null);
  74. }
  75. /// <summary>
  76. /// 增加
  77. /// </summary>
  78. /// <param name="cd"></param>
  79. /// <returns></returns>
  80. public bool AddVisaChekOutTime(VisaCheckOutTime hd)
  81. {
  82. string sql = "insert into VisaChekOutTime values(@Contient,@Country,@VisaPlace,@Time,@RushTime,@Remark,@Oper,@Opdate,@Isdel)";
  83. SqlParameter[] parameter = new SqlParameter[]{
  84. new SqlParameter("@Contient",hd.Contient),
  85. new SqlParameter("@Country",hd.Country),
  86. new SqlParameter("@VisaPlace",hd.VisaPlace),
  87. new SqlParameter("@Time",hd.Time),
  88. new SqlParameter("@RushTime",hd.RushTime),
  89. new SqlParameter("@Remark",hd.Remark),
  90. new SqlParameter("@Oper",hd.Oper),
  91. new SqlParameter("@Opdate",hd.Opdate),
  92. new SqlParameter("@Isdel",hd.Isdel)
  93. };
  94. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  95. return true;
  96. return false;
  97. }
  98. /// <summary>
  99. /// 编辑
  100. /// </summary>
  101. /// <param name="sdt"></param>
  102. /// <returns></returns>
  103. public bool EditVisaChekOutTime(VisaCheckOutTime hd)
  104. {
  105. 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";
  106. SqlParameter[] parameter = new SqlParameter[]{
  107. new SqlParameter("@Contient",hd.Contient),
  108. new SqlParameter("@Country",hd.Country),
  109. new SqlParameter("@VisaPlace",hd.VisaPlace),
  110. new SqlParameter("@Time",hd.Time),
  111. new SqlParameter("@RushTime",hd.RushTime),
  112. new SqlParameter("@Remark",hd.Remark),
  113. new SqlParameter("@Oper",hd.Oper),
  114. new SqlParameter("@Opdate",hd.Opdate),
  115. new SqlParameter("@Isdel",hd.Isdel),
  116. new SqlParameter("@Id",hd.Id)
  117. };
  118. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  119. return true;
  120. return false;
  121. }
  122. /// <summary>
  123. /// 删除
  124. /// </summary>
  125. /// <param name="id"></param>
  126. /// <returns></returns>
  127. public bool DelVisaChekOutTime(int id)
  128. {
  129. if (SqlHelper.ExecuteNonQuery("update VisaChekOutTime set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  130. return true;
  131. return false;
  132. }
  133. }
  134. }