GroupsDecreasePaymentsService.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 GroupsDecreasePaymentsService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<GroupsDecreasePayments> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<GroupsDecreasePayments>.excuteSql(new GroupsDecreasePayments(), "GroupsDecreasePayments", 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. GroupsDecreasePayments excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<GroupsDecreasePayments> gdpList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (gdpList == null || gdpList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return gdpList[0];
  41. }
  42. /// <summary>
  43. /// 根据编号查询对象信息
  44. /// </summary>
  45. /// <param name="id">对象编号</param>
  46. /// <returns>返回空或者单个对象信息</returns>
  47. public GroupsDecreasePayments GetGroupsDecreasePaymentsByID(int id)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteType("select * from GroupsDecreasePayments 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 GroupsDecreasePayments GetGroupsDecreasePaymentsByIDable(int id)
  58. {
  59. //调用获取单个对象的方法
  60. //return excuteType("select * from GroupsDecreasePayments where Id = @id and isdel=0", new SqlParameter("@id", id));
  61. return excuteType("select * from GroupsDecreasePayments gdp join dbo.DelegationInfo di on di.Id = gdp.DIID where (di.TeamDid <> 300 and di.TeamDid <> 320) and gdp.IsDel =0 and gdp.Id = @ID", new SqlParameter("@id", id));
  62. }
  63. /// <summary>
  64. /// 获取全部 - 分页
  65. /// </summary>
  66. /// <returns></returns>
  67. public List<GroupsDecreasePayments> GetGroupsDecreasePayments(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string arrayUsersId)
  68. {
  69. string sqlwhere = "IsDel = 0 and DIId = " + tourCode + " and Operator in (" + arrayUsersId + ")";
  70. return PageBase<GroupsDecreasePayments>.excutePageSql(new GroupsDecreasePayments(), "GroupsDecreasePayments", "GroupsDecreasePayments", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  71. }
  72. /// <summary>
  73. /// 获取增减款项表里的零用金数据
  74. /// </summary>
  75. /// <param name="diid"></param>
  76. /// <returns></returns>
  77. public List<GroupsDecreasePayments> GetCashDataByDiid(int diid)
  78. {
  79. return excuteSql("select * from GroupsDecreasePayments where Diid = @diid and isdel=0 and PriceName like '%零用金%' ", new SqlParameter("@diid", diid));
  80. }
  81. /// 增加
  82. /// </summary>
  83. /// <returns></returns>
  84. public bool AddGroupsDecreasePayments(GroupsDecreasePayments gpd, out int id)
  85. {
  86. string sql = "insert into GroupsDecreasePayments values(@DIID,@PriceName,@Price,@Currency,@FilePath,@Remark,@Operator,@OperatorDate,@IsDel,@PriceType,@coefficient,@PriceTypeDetail);SELECT @@IDENTITY";
  87. SqlParameter[] parameter = new SqlParameter[]{
  88. new SqlParameter("@DIId",gpd.DIID),
  89. new SqlParameter("@PriceName",gpd.PriceName),
  90. new SqlParameter("@Price",gpd.Price),
  91. new SqlParameter("@Currency",gpd.Currency),
  92. new SqlParameter("@FilePath",gpd.FilePath),
  93. new SqlParameter("@Remark",gpd.Remark),
  94. new SqlParameter("@Operator",gpd.Operators),
  95. new SqlParameter("@OperatorDate",gpd.OperatorsDate),
  96. new SqlParameter("@IsDel",gpd.IsDel),
  97. new SqlParameter("@PriceType",gpd.PriceType),
  98. new SqlParameter("@coefficient",gpd.coefficient),
  99. new SqlParameter("@PriceTypeDetail",gpd.PriceTypeDetail)
  100. };
  101. int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
  102. if (obj > 0)
  103. {
  104. id = obj;
  105. return true;
  106. }
  107. id = 0;
  108. return false;
  109. }
  110. /// <summary>
  111. /// 编辑
  112. /// </summary>
  113. /// <returns></returns>
  114. public bool EditGroupsDecreasePayments(GroupsDecreasePayments gpd)
  115. {
  116. string sql = "update GroupsDecreasePayments set DIID = @DIID,PriceName = @PriceName,Price = @Price,Currency = @Currency,FilePath = @FilePath,Remark = @Remark ,Operator = @Operator,OperatorDate = @OperatorDate,PriceType = @PriceType,coefficient= @coefficient,PriceTypeDetail=@PriceTypeDetail where Id = @Id";
  117. SqlParameter[] parameter = new SqlParameter[]{
  118. new SqlParameter("@DIId",gpd.DIID),
  119. new SqlParameter("@PriceName",gpd.PriceName),
  120. new SqlParameter("@Price",gpd.Price),
  121. new SqlParameter("@Currency",gpd.Currency),
  122. new SqlParameter("@FilePath",gpd.FilePath),
  123. new SqlParameter("@Remark",gpd.Remark),
  124. new SqlParameter("@Operator",gpd.Operators),
  125. new SqlParameter("@OperatorDate",gpd.OperatorsDate),
  126. new SqlParameter("@Id",gpd.Id),
  127. new SqlParameter("@PriceType",gpd.PriceType),
  128. new SqlParameter("@coefficient",gpd.coefficient),
  129. new SqlParameter("@PriceTypeDetail",gpd.PriceTypeDetail)
  130. };
  131. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  132. return true;
  133. return false;
  134. }
  135. /// <summary>
  136. /// 删除
  137. /// </summary>
  138. /// <returns></returns>
  139. public bool DelGroupsDecreasePayments(int id)
  140. {
  141. string sql = "update GroupsDecreasePayments set IsDel = 1 where Id = @Id";
  142. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, new SqlParameter("@Id", id)) > 0)
  143. return true;
  144. return false;
  145. }
  146. }
  147. }