CarTouristGuideGroundReservationsService.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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 CarTouristGuideGroundReservationsService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<CarTouristGuideGroundReservations> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<CarTouristGuideGroundReservations>.excuteSql(new CarTouristGuideGroundReservations(), "CarTouristGuideGroundReservations", 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. CarTouristGuideGroundReservations excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<CarTouristGuideGroundReservations> ctggrList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (ctggrList == null || ctggrList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return ctggrList[0];
  41. }
  42. /// <summary>
  43. /// 根据编号查询对象信息
  44. /// </summary>
  45. /// <param name="id">对象编号</param>
  46. /// <returns>返回空或者单个对象信息</returns>
  47. public CarTouristGuideGroundReservations GetCarTouristGuideGroundReservationsByID(int id)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteType("select * from CarTouristGuideGroundReservations where Id = @id and isdel=0", new SqlParameter("@id", id));
  51. }
  52. /// <summary>
  53. /// 根据编号查询对象信息
  54. /// </summary>
  55. /// <param name="id">对象编号</param>
  56. /// <returns>返回空或者单个对象信息</returns>
  57. public CarTouristGuideGroundReservations GetCarTouristGuideGroundReservationsByArea(string area)
  58. {
  59. //调用获取单个对象的方法
  60. return excuteType("select * from CarTouristGuideGroundReservations where Area = @area and isdel=0", new SqlParameter("@area", area));
  61. }
  62. /// <summary>
  63. /// 根据团号查询数据
  64. /// </summary>
  65. /// <param name="diid">团号</param>
  66. /// <returns></returns>
  67. public List<CarTouristGuideGroundReservations> GetCarTouristGuideGroundReservationsByDIID(int diid)
  68. {
  69. //调用获取单个对象的方法
  70. return excuteSql("select * from CarTouristGuideGroundReservations where diid = @diid and isdel=0 order by ServiceStartTime", new SqlParameter("@diid", diid));
  71. }
  72. /// <summary>
  73. /// 获取全部 - 分页
  74. /// </summary>
  75. /// <returns></returns>
  76. public List<CarTouristGuideGroundReservations> GetCarTouristGuideGroundReservations(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string arrayUsersId)
  77. {
  78. string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and Operator in (" + arrayUsersId + ")";
  79. return PageBase<CarTouristGuideGroundReservations>.excutePageSql(new CarTouristGuideGroundReservations(), "CarTouristGuideGroundReservations", "CarTouristGuideGroundReservations", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  80. }
  81. /// <summary>
  82. /// 增加
  83. /// </summary>
  84. /// <param name="ctggr"></param>
  85. /// <returns></returns>
  86. public bool AddCarTouristGuideGroundReservations(CarTouristGuideGroundReservations ctggr, out int id)
  87. {
  88. string sql = "insert into CarTouristGuideGroundReservations values(@DIId,@Area,@ServiceCompany,@ServiceGuide,@ServiceTel,@BusName,@BusDescription,@BusTel,@ServiceStartTime,@ServiceEndTime,@ServiceDescription,@ServiceQuotedPrice,@CId,@QuotedPriceExplanation,@Remark,@Operator,@OperatorDate,@IsDel,@OrbitalPrivateTransfer);SELECT @@IDENTITY";
  89. SqlParameter[] parameter = new SqlParameter[]{
  90. new SqlParameter("@DIId",ctggr.DIId),
  91. new SqlParameter("@Area",ctggr.Area),
  92. new SqlParameter("@ServiceCompany",ctggr.ServiceCompany),
  93. new SqlParameter("@ServiceGuide",ctggr.ServiceGuide),
  94. new SqlParameter("@ServiceTel",ctggr.ServiceTel),
  95. new SqlParameter("@BusName",ctggr.BusName),
  96. new SqlParameter("@BusDescription",ctggr.BusDescription),
  97. new SqlParameter("@BusTel",ctggr.BusTel),
  98. new SqlParameter("@ServiceStartTime",ctggr.ServiceStartTime),
  99. new SqlParameter("@ServiceEndTime",ctggr.ServiceEndTime),
  100. new SqlParameter("@ServiceDescription",ctggr.ServiceDescription),
  101. new SqlParameter("@ServiceQuotedPrice",ctggr.ServiceQuotedPrice),
  102. new SqlParameter("@CId",ctggr.CId),
  103. new SqlParameter("@QuotedPriceExplanation",ctggr.QuotedPriceExplanation),
  104. new SqlParameter("@Remark",ctggr.Remark),
  105. new SqlParameter("@Operator",ctggr.Operators),
  106. new SqlParameter("@OperatorDate",ctggr.OperatorsDate),
  107. new SqlParameter("@IsDel",ctggr.IsDel),
  108. new SqlParameter("@OrbitalPrivateTransfer",ctggr.OrbitalPrivateTransfer)
  109. };
  110. int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
  111. if (obj > 0)
  112. {
  113. id = obj;
  114. return true;
  115. }
  116. id = 0;
  117. return false;
  118. }
  119. /// <summary>
  120. /// 编辑
  121. /// </summary>
  122. /// <returns></returns>
  123. public bool EditCarTouristGuideGroundReservations(CarTouristGuideGroundReservations ctggr)
  124. {
  125. string sql = "update CarTouristGuideGroundReservations set DIId = @DIId,Area = @Area,ServiceCompany = @ServiceCompany,ServiceGuide = @ServiceGuide,ServiceTel = @ServiceTel,BusName = @BusName,BusDescription = @BusDescription,BusTel = @BusTel,ServiceStartTime = @ServiceStartTime,ServiceEndTime = @ServiceEndTime,ServiceDescription = @ServiceDescription,ServiceQuotedPrice = @ServiceQuotedPrice,CId = @CId,QuotedPriceExplanation = @QuotedPriceExplanation,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,OrbitalPrivateTransfer = @OrbitalPrivateTransfer where Id = @Id";
  126. SqlParameter[] parameter = new SqlParameter[]{
  127. new SqlParameter("@DIId",ctggr.DIId),
  128. new SqlParameter("@Area",ctggr.Area),
  129. new SqlParameter("@ServiceCompany",ctggr.ServiceCompany),
  130. new SqlParameter("@ServiceGuide",ctggr.ServiceGuide),
  131. new SqlParameter("@ServiceTel",ctggr.ServiceTel),
  132. new SqlParameter("@BusName",ctggr.BusName),
  133. new SqlParameter("@BusDescription",ctggr.BusDescription),
  134. new SqlParameter("@BusTel",ctggr.BusTel),
  135. new SqlParameter("@ServiceStartTime",ctggr.ServiceStartTime),
  136. new SqlParameter("@ServiceEndTime",ctggr.ServiceEndTime),
  137. new SqlParameter("@ServiceDescription",ctggr.ServiceDescription),
  138. new SqlParameter("@ServiceQuotedPrice",ctggr.ServiceQuotedPrice),
  139. new SqlParameter("@CId",ctggr.CId),
  140. new SqlParameter("@QuotedPriceExplanation",ctggr.QuotedPriceExplanation),
  141. new SqlParameter("@Remark",ctggr.Remark),
  142. new SqlParameter("@Operator",ctggr.Operators),
  143. new SqlParameter("@OperatorDate",ctggr.OperatorsDate),
  144. new SqlParameter("@OrbitalPrivateTransfer",ctggr.OrbitalPrivateTransfer),
  145. new SqlParameter("@Id",ctggr.Id)
  146. };
  147. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  148. return true;
  149. return false;
  150. }
  151. /// <summary>
  152. /// 编辑 - 金额和币种
  153. /// </summary>
  154. /// <returns></returns>
  155. public bool EditCarTouristGuideGroundReservationsByPrice(CarTouristGuideGroundReservations ctggr)
  156. {
  157. string sql = "update CarTouristGuideGroundReservations set ServiceQuotedPrice = @ServiceQuotedPrice,CId = @CId,Operator = @Operator,OperatorDate = @OperatorDate where Id = @Id";
  158. SqlParameter[] parameter = new SqlParameter[]{
  159. new SqlParameter("@ServiceQuotedPrice",ctggr.ServiceQuotedPrice),
  160. new SqlParameter("@CId",ctggr.CId),
  161. new SqlParameter("@Operator",ctggr.Operators),
  162. new SqlParameter("@OperatorDate",ctggr.OperatorsDate),
  163. new SqlParameter("@Id",ctggr.Id)
  164. };
  165. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  166. return true;
  167. return false;
  168. }
  169. /// <summary>
  170. /// 删除
  171. /// </summary>
  172. /// <param name="id"></param>
  173. /// <returns></returns>
  174. public bool DelCarTouristGuideGroundReservations(int id)
  175. {
  176. if (SqlHelper.ExecuteNonQuery("update CarTouristGuideGroundReservations set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  177. return true;
  178. return false;
  179. }
  180. }
  181. }