CarTouristGuideGroundReservationsContentService.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. /// <summary>
  11. /// 车/导游地接预订详细数据访问类
  12. /// </summary>
  13. public class CarTouristGuideGroundReservationsContentService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<CarTouristGuideGroundReservationsContent> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<CarTouristGuideGroundReservationsContent>.excuteSql(new CarTouristGuideGroundReservationsContent(), "CarTouristGuideGroundReservationsContent", sql, CommandType.Text, param);
  24. }
  25. /// <summary>
  26. /// 获取单个对象
  27. /// </summary>
  28. /// <param name="sql">sql语句</param>
  29. /// <param name="param">可变参数数组</param>
  30. /// <returns>返回空或者单个对象</returns>
  31. CarTouristGuideGroundReservationsContent excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<CarTouristGuideGroundReservationsContent> cList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (cList == null || cList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return cList[0];
  41. }
  42. /// <summary>
  43. /// 根据编号查询对象信息
  44. /// </summary>
  45. /// <param name="id">对象编号</param>
  46. /// <returns>返回空或者单个对象信息</returns>
  47. public CarTouristGuideGroundReservationsContent GetCarTouristGuideGroundReservationsContentByID(int id)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteType("select * from CarTouristGuideGroundReservationsContent where Id = @id", new SqlParameter("@id", id));
  51. }
  52. public List<CarTouristGuideGroundReservationsContent> GetByDiid(int Diid)
  53. {
  54. //调用获取单个对象的方法
  55. return excuteSql("select * from CarTouristGuideGroundReservationsContent where Diid = @Diid", new SqlParameter("@Diid", Diid));
  56. }
  57. /// <summary>
  58. /// 查询所有
  59. /// </summary>
  60. /// <param name="Stable"></param>
  61. /// <returns></returns>
  62. public List<CarTouristGuideGroundReservationsContent> GetAll(int CTGGRId)
  63. {
  64. return excuteSql("select * from CarTouristGuideGroundReservationsContent where isdel=0 and CTGGRId = @CTGGRId", new SqlParameter("@CTGGRId", CTGGRId));
  65. }
  66. /// <summary>
  67. /// 增加
  68. /// </summary>
  69. /// <param name="c"></param>
  70. public bool AddCarTouristGuideGroundReservationsContent(List<CarTouristGuideGroundReservationsContent> list)
  71. {
  72. SqlCommand cmd = SqlHelper.createCon().CreateCommand();
  73. cmd.Connection.Open();
  74. SqlTransaction trans = cmd.Connection.BeginTransaction();
  75. try
  76. {
  77. cmd.Transaction = trans;//将事务赋值给command就可以了
  78. foreach (CarTouristGuideGroundReservationsContent c in list)
  79. {
  80. cmd.CommandText = "insert into CarTouristGuideGroundReservationsContent values(" + c.DIId + "," + c.CTGGRId + "," + c.SId + "," + c.Price + "," + c.Currency + ",'" + c.PriceContent + "','" + c.Remark + "'," + c.Operators + ",'" + c.OperatorsDate + "'," + c.IsDel + ")";
  81. cmd.ExecuteNonQuery();
  82. }
  83. trans.Commit();
  84. cmd.Connection.Close();
  85. return true;
  86. }
  87. catch (Exception ex)
  88. {
  89. trans.Rollback();
  90. cmd.Connection.Close();
  91. return false;
  92. }
  93. }
  94. /// <summary>
  95. /// 删除用户对应页面权限
  96. /// </summary>
  97. /// <param name="CTGGRId"></param>
  98. /// <returns></returns>
  99. public bool DelCarTouristGuideGroundReservationsContent(int CTGGRId)
  100. {
  101. if (SqlHelper.ExecuteNonQuery("delete CarTouristGuideGroundReservationsContent where CTGGRId =@CTGGRId", CommandType.Text, new SqlParameter("@CTGGRId", CTGGRId)) > 0)
  102. return true;
  103. return false;
  104. }
  105. /// <summary>
  106. /// 删除用户对应页面权限
  107. /// </summary>
  108. /// <param name="sid"></param>
  109. /// <param name="STable"></param>
  110. /// <returns></returns>
  111. public bool DelCarTouristGuideGroundReservationsContentBySid(int sid, int STable)
  112. {
  113. if (SqlHelper.ExecuteNonQuery("delete CarTouristGuideGroundReservationsContent where Sid =@Sid and STable = @STable", CommandType.Text, new SqlParameter("@Sid", sid), new SqlParameter("@STable", STable)) > 0)
  114. return true;
  115. return false;
  116. }
  117. /// <summary>
  118. /// 删除用户对应页面权限
  119. /// </summary>
  120. /// <param name="sid"></param>
  121. /// <param name="STable"></param>
  122. /// <returns></returns>
  123. public bool DelCarTouristGuideGroundReservationsContentByUIdAndSIdAndSTable(int uid, int sid, int stable)
  124. {
  125. if (SqlHelper.ExecuteNonQuery("delete CarTouristGuideGroundReservationsContent where UId =@UId and SId = @SId and STable=@STable", CommandType.Text, new SqlParameter("@UId", uid), new SqlParameter("@SId", sid), new SqlParameter("@STable", stable)) > 0)
  126. return true;
  127. return false;
  128. }
  129. }
  130. }