EnterExitPriceService.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 EnterExitPriceService
  11. {
  12. /// <summary>
  13. /// 查询所有
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<EnterExitPrice> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<EnterExitPrice>.excuteSql(new EnterExitPrice(), "EnterExitPrice", 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. EnterExitPrice excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<EnterExitPrice> 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="cd"></param>
  43. /// <returns></returns>
  44. public bool AddEnterExitPrice(EnterExitPrice hd)
  45. {
  46. string sql = "insert into EnterExitPrice values(@Continent,@Country,@City,@Currency,@RoomCost,@FoodCost,@PublicCost,@Oper,@Opdate,@Isdel)";
  47. SqlParameter[] parameter = new SqlParameter[]{
  48. new SqlParameter("@Continent",hd.Continent),
  49. new SqlParameter("@Country",hd.Country),
  50. new SqlParameter("@City",hd.City),
  51. new SqlParameter("@Currency",hd.Currency),
  52. new SqlParameter("@RoomCost",hd.RoomCost),
  53. new SqlParameter("@FoodCost",hd.FoodCost),
  54. new SqlParameter("@PublicCost",hd.PublicCost),
  55. new SqlParameter("@Oper",hd.Oper),
  56. new SqlParameter("@Opdate",hd.Opdate),
  57. new SqlParameter("@Isdel",hd.Isdel)
  58. };
  59. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  60. return true;
  61. return false;
  62. }
  63. /// <summary>
  64. /// 编辑
  65. /// </summary>
  66. /// <param name="sdt"></param>
  67. /// <returns></returns>
  68. public bool EditEnterExitPrice(EnterExitPrice hd)
  69. {
  70. string sql = "update EnterExitPrice set Continent=@Continent,Country=@Country,City=@City,Currency=@Currency,"
  71. + "RoomCost=@RoomCost,FoodCost=@FoodCost,PublicCost=@PublicCost,Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id";
  72. SqlParameter[] parameter = new SqlParameter[]{
  73. new SqlParameter("@Continent",hd.Continent),
  74. new SqlParameter("@Country",hd.Country),
  75. new SqlParameter("@City",hd.City),
  76. new SqlParameter("@Currency",hd.Currency),
  77. new SqlParameter("@RoomCost",hd.RoomCost),
  78. new SqlParameter("@FoodCost",hd.FoodCost),
  79. new SqlParameter("@PublicCost",hd.PublicCost),
  80. new SqlParameter("@Oper",hd.Oper),
  81. new SqlParameter("@Opdate",hd.Opdate),
  82. new SqlParameter("@Isdel",hd.Isdel),
  83. new SqlParameter("@Id",hd.Id)
  84. };
  85. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  86. return true;
  87. return false;
  88. }
  89. /// <summary>
  90. /// 删除
  91. /// </summary>
  92. /// <param name="id"></param>
  93. /// <returns></returns>
  94. public bool DelEnterExitPrice(int id)
  95. {
  96. if (SqlHelper.ExecuteNonQuery("update EnterExitPrice set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  97. return true;
  98. return false;
  99. }
  100. /// <summary>
  101. /// 查询所有
  102. /// </summary>
  103. /// <returns></returns>
  104. public List<EnterExitPrice> GetByPlace(string City)
  105. {
  106. return excuteSql("SELECT * FROM EnterExitPrice where Isdel=0 AND (Country LIKE '%" + City + "%' OR City LIKE '%" + City + "%')");
  107. }
  108. /// <summary>
  109. /// 雷怡 2021-08-23 10:32
  110. /// 查询所有
  111. /// </summary>
  112. /// <returns></returns>
  113. public List<EnterExitPrice> GetByAll()
  114. {
  115. return excuteSql("SELECT * FROM EnterExitPrice where Isdel=0 ");
  116. }
  117. /// <summary>
  118. /// 查询所有
  119. /// </summary>
  120. /// <returns></returns>
  121. public EnterExitPrice GetById(string ID)
  122. {
  123. return excuteType("SELECT * FROM EnterExitPrice where Isdel=0 AND Id=" + ID);
  124. }
  125. /// <summary>
  126. /// 查询所有
  127. /// </summary>
  128. /// <returns></returns>
  129. public EnterExitPrice GetByCity(string City)
  130. {
  131. return excuteType("SELECT * FROM EnterExitPrice where Isdel=0 AND (Country LIKE '%" + City + "%' OR City LIKE '%" + City + "%')");
  132. }
  133. public EnterExitPrice NewGetByCity(string City)
  134. {
  135. return excuteType("SELECT * FROM EnterExitPrice where Isdel=0 AND City = '"+ City+"'");
  136. }
  137. /// <summary>
  138. /// 查找所有数据 - 分页
  139. /// </summary>
  140. /// <returns></returns>
  141. public List<EnterExitPrice> GetAll(int pageIndex, out int sumPage, out int totalRecord, string Job)
  142. {
  143. string sqlwhere = "IsDel = 0 and City like '%" + Job + "%'";
  144. return PageBase<EnterExitPrice>.excutePageSql(new EnterExitPrice(), "EnterExitPrice", "EnterExitPrice", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  145. }
  146. // <summary>
  147. /// 查找所有数据 - 分页
  148. /// </summary>
  149. /// <returns></returns>
  150. public List<EnterExitPrice> GetAll(int pageIndex, out int sumPage, out int totalRecord, string country, string city)
  151. {
  152. string sqlwhere = "IsDel = 0 and City like '%" + city + "%' and Country like '%" + country + "%' ";
  153. return PageBase<EnterExitPrice>.excutePageSql(new EnterExitPrice(), "EnterExitPrice", "EnterExitPrice", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  154. }
  155. }
  156. }