TeamRateService.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 TeamRateService
  14. {
  15. /// <summary>
  16. /// 获取全部团组汇率 - 分页
  17. /// </summary>
  18. /// <returns></returns>
  19. public List<TeamRate> GetAll(int pageIndex, out int sumPage, out int totalRecord, int diid, int ctable)
  20. {
  21. string sqlwhere = " Diid=" + diid + " and CTable=" + ctable;
  22. return PageBase<TeamRate>.excutePageSql(new TeamRate(), "TeamRate", "TeamRate", "*", "id desc", sqlwhere, 100, pageIndex, out sumPage, out totalRecord);
  23. }
  24. /// <summary>
  25. /// 获取全部团组汇率
  26. /// </summary>
  27. /// <returns></returns>
  28. public List<TeamRate> GetAll(int diid)
  29. {
  30. return excuteSql("select * from TeamRate where diid = '" + diid + "'");
  31. }
  32. /// <summary>
  33. /// 根据团组号和团组指向分类查询汇率信息
  34. /// </summary>
  35. /// <param name="p"></param>
  36. /// <param name="ctable"></param>
  37. /// <returns></returns>
  38. public TeamRate GetByDiidAndCtable(int diid, int ctable)
  39. {
  40. //调用获取单个对象的方法
  41. return excuteType("select * from TeamRate where Diid=" + diid + " and CTable=" + ctable, null);
  42. }
  43. /// <summary>
  44. /// 获取单个对象
  45. /// </summary>
  46. /// <param name="sql">sql语句</param>
  47. /// <param name="param">可变参数数组</param>
  48. /// <returns>返回空或者单个对象</returns>
  49. TeamRate excuteType(string sql, params SqlParameter[] param)
  50. {
  51. //查询结果放入对象集合
  52. List<TeamRate> cList = excuteSql(sql, param);
  53. //判断集合是否为空
  54. if (cList == null || cList.Count == 0)
  55. //返回null
  56. return null;
  57. //返回单个对象
  58. return cList[0];
  59. }
  60. /// <summary>
  61. /// 查询所有
  62. /// </summary>
  63. /// <param name="sql">sql语句</param>
  64. /// <param name="param">可变参数数组</param>
  65. /// <returns>返回集合</returns>
  66. List<TeamRate> excuteSql(string sql, params SqlParameter[] param)
  67. {
  68. return ServiceBase<TeamRate>.excuteSql(new TeamRate(), "TeamRate", sql, CommandType.Text, param);
  69. }
  70. /// <summary>
  71. /// 新增团组汇率
  72. /// </summary>
  73. /// <param name="tr"></param>
  74. /// <returns></returns>
  75. public bool AddTeamRate(TeamRate tr)
  76. {
  77. //if (SqlHelper.ExecuteNonQuery("insert into TeamRate values(@Diid,@CTable,@RateU,@RateE,@OtherRate,@OtherPrice)",
  78. // CommandType.Text,
  79. // new SqlParameter("@Diid", tr.Diid),
  80. // new SqlParameter("@CTable", tr.CTable),
  81. // new SqlParameter("@RateU", tr.RateU),
  82. // new SqlParameter("@RateE", tr.RateE),
  83. // new SqlParameter("@OtherRate", tr.OtherRate),
  84. // new SqlParameter("@OtherPrice", tr.OtherPrice)) > 0)
  85. // RateJ RateH RateN RateS RateA RateC
  86. if (SqlHelper.ExecuteNonQuery("insert into TeamRate values(@Diid,@CTable,@OPer,@OPDate,@OtherRate,@OtherPrice,@RateU,@RateE," +
  87. "@RateJ,@RateH,@RateN,@RateS,@RateA,@RateC,@RateT,@RateBL,@RateHB,@RateFJD,@RateTL,@RateRP,@RatePeso,@RateMYR," +
  88. "@RateCZK,@RateMXN,@RateMOP,@RateARS,@RateHUF,@RateRUB)",
  89. CommandType.Text,
  90. new SqlParameter("@Diid", tr.Diid),
  91. new SqlParameter("@CTable", tr.CTable),
  92. new SqlParameter("@OPer", tr.OPer),
  93. new SqlParameter("@OPDate", tr.OPDate),
  94. new SqlParameter("@OtherRate", tr.OtherRate),
  95. new SqlParameter("@OtherPrice", tr.OtherPrice),
  96. new SqlParameter("@RateU", tr.RateU),
  97. new SqlParameter("@RateE", tr.RateE),
  98. new SqlParameter("@RateJ", tr.RateJ),
  99. new SqlParameter("@RateH", tr.RateH),
  100. new SqlParameter("@RateN", tr.RateN),
  101. new SqlParameter("@RateS", tr.RateS),
  102. new SqlParameter("@RateA", tr.RateA),
  103. new SqlParameter("@RateC", tr.RateC),
  104. new SqlParameter("@RateT", tr.RateT),
  105. new SqlParameter("@RateBL", tr.RateBL),
  106. new SqlParameter("@RateHB", tr.RateHB),
  107. new SqlParameter("@RateFJD", tr.RateFJD),
  108. new SqlParameter("@RateTL", tr.RateTL),
  109. new SqlParameter("@RateRP", tr.RateRP),
  110. new SqlParameter("@RatePeso", tr.RatePeso),
  111. new SqlParameter("@RateMYR", tr.RateMYR),
  112. new SqlParameter("@RateCZK", tr.RateCZK),
  113. new SqlParameter("@RateMXN", tr.RateMXN),
  114. new SqlParameter("@RateMOP", tr.RateMOP),
  115. new SqlParameter("@RateARS", tr.RateARS),
  116. new SqlParameter("@RateHUF", tr.RateHUF),
  117. new SqlParameter("@RateRUB", tr.RateRUB)) > 0)
  118. return true;
  119. return false;
  120. }
  121. /// <summary>
  122. /// 修改团组汇率
  123. /// </summary>
  124. /// <param name="tr"></param>
  125. /// <returns></returns>
  126. public bool EditTeamRate(TeamRate tr)
  127. {
  128. // if (SqlHelper.ExecuteNonQuery("update TeamRate set RateU = @RateU,RateE = @RateE,OtherRate=@OtherRate,OtherPrice=@OtherPrice where ID=@ID", CommandType.Text, new SqlParameter("@RateU", tr.RateU), new SqlParameter("@RateE", tr.RateE), new SqlParameter("@OtherRate", tr.OtherRate), new SqlParameter("@OtherPrice", tr.OtherPrice), new SqlParameter("@ID", tr.ID)) > 0)
  129. if (SqlHelper.ExecuteNonQuery("update TeamRate set OPer=@OPer,OPDate=@OPDate,OtherRate=@OtherRate,OtherPrice=@OtherPrice,RateU = @RateU,RateE = @RateE,RateJ = @RateJ," +
  130. "RateH =@RateH,RateN = @RateN,RateS = @RateS,RateA = @RateA,RateC = @RateC,RateT = @RateT,RateBL=@RateBL,RateHB = @RateHB," +
  131. "RateFJD = @RateFJD,RateTL =@RateTL,RateRP =@RateRP,RatePeso=@RatePeso,RateMYR =@RateMYR,RateCZK =@RateCZK ,RateMXN=@RateMXN," +
  132. "RateMOP=@RateMOP,RateARS=@RateARS,RateHUF=@RateHUF,RateRUB=@RateRUB where ID=@ID",
  133. CommandType.Text,
  134. new SqlParameter("@OPer", tr.OPer),
  135. new SqlParameter("@OPDate", tr.OPDate),
  136. new SqlParameter("@OtherRate", tr.OtherRate),
  137. new SqlParameter("@OtherPrice", tr.OtherPrice),
  138. new SqlParameter("@RateU", tr.RateU),
  139. new SqlParameter("@RateE", tr.RateE),
  140. new SqlParameter("@RateJ", tr.RateJ),
  141. new SqlParameter("@RateH", tr.RateH),
  142. new SqlParameter("@RateN", tr.RateN),
  143. new SqlParameter("@RateS", tr.RateS),
  144. new SqlParameter("@RateA", tr.RateA),
  145. new SqlParameter("@RateC", tr.RateC),
  146. new SqlParameter("@RateT", tr.RateT),
  147. new SqlParameter("@RateBL", tr.RateBL),
  148. new SqlParameter("@RateHB", tr.RateHB),
  149. new SqlParameter("@RateFJD", tr.RateFJD),
  150. new SqlParameter("@RateTL", tr.RateTL),
  151. new SqlParameter("@RateRP", tr.RateRP),
  152. new SqlParameter("@RatePeso", tr.RatePeso),
  153. new SqlParameter("@RateMYR", tr.RateMYR),
  154. new SqlParameter("@RateCZK", tr.RateCZK),
  155. new SqlParameter("@RateMXN", tr.RateMXN),
  156. new SqlParameter("@RateMOP", tr.RateMOP),
  157. new SqlParameter("@RateARS", tr.RateARS),
  158. new SqlParameter("@RateHUF", tr.RateHUF),
  159. new SqlParameter("@RateRUB", tr.RateRUB),
  160. new SqlParameter("@ID", tr.ID)) > 0)
  161. return true;
  162. return false;
  163. }
  164. }
  165. }