OtherPriceOPService.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 OtherPriceOPService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<OtherPriceOP> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<OtherPriceOP>.excuteSql(new OtherPriceOP(), "OtherPriceOP", 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. OtherPriceOP excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<OtherPriceOP> 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 OtherPriceOP GetOtherPriceOfOPByID(int id)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteType("select * from OtherPriceOP where Id = @id and isdel=0", new SqlParameter("@id", id));
  51. }
  52. public float GetSKTH(int diid)
  53. {
  54. string sql = "select sum(Price) from OtherPriceOP where Diid=@diid and IsDel=0 and PriceType =1 and PayType='1' ";
  55. SqlParameter[] parameter = new SqlParameter[]{
  56. new SqlParameter("@DIId",diid)
  57. };
  58. object obj = SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter);
  59. try
  60. {
  61. return float.Parse(obj == null ? "0" : obj.ToString());
  62. }
  63. catch
  64. {
  65. return 0;
  66. }
  67. }
  68. /// <summary>
  69. /// 获取全部 - 分页
  70. /// </summary>
  71. /// <returns></returns>
  72. public List<OtherPriceOP> GetOtherPriceOfOP(int pageIndex, out int sumPage, out int totalRecord, string tourCode)
  73. {
  74. string sqlwhere = "IsDel = 0 and DIId = " + tourCode;
  75. return PageBase<OtherPriceOP>.excutePageSql(new OtherPriceOP(), "OtherPriceOP", "OtherPriceOP", "*", "OperatorDate desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  76. }
  77. public List<OtherPriceOP> GetOtherPrice(int diid)
  78. {
  79. //调用获取单个对象的方法
  80. return excuteSql("select * from OtherPriceOP where diid = " + diid + " and isdel = 0 and PriceType = 1 and PayType='" + "1' ");
  81. }
  82. /// 增加
  83. /// </summary>
  84. /// <returns></returns>
  85. public bool AddOtherPriceOfOP(OtherPriceOP gpd, out int id)
  86. {
  87. string sql = "insert into OtherPriceOP values(@DIID,@PriceName,@Price,@Currency,@Remark,@Operator,@OperatorDate,@IsDel,@PayType,@PriceType);SELECT @@IDENTITY";
  88. SqlParameter[] parameter = new SqlParameter[]{
  89. new SqlParameter("@DIId",gpd.DIID),
  90. new SqlParameter("@PriceName",gpd.PriceName),
  91. new SqlParameter("@Price",gpd.Price),
  92. new SqlParameter("@Currency",gpd.Currency),
  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("@PayType",gpd.PayType),
  98. new SqlParameter("@PriceType",gpd.PriceType)
  99. };
  100. int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
  101. if (obj > 0)
  102. {
  103. id = obj;
  104. return true;
  105. }
  106. id = 0;
  107. return false;
  108. }
  109. /// <summary>
  110. /// 编辑
  111. /// </summary>
  112. /// <returns></returns>
  113. public bool EditOtherPriceOfOP(OtherPriceOP gpd)
  114. {
  115. string sql = "update OtherPriceOP set DIID = @DIID,PriceName = @PriceName,Price = @Price,Currency = @Currency,Remark = @Remark ,Operator = @Operator,OperatorDate = @OperatorDate,PayType=@PayType,PriceType=@PriceType where Id = @Id";
  116. SqlParameter[] parameter = new SqlParameter[]{
  117. new SqlParameter("@DIId",gpd.DIID),
  118. new SqlParameter("@PriceName",gpd.PriceName),
  119. new SqlParameter("@Price",gpd.Price),
  120. new SqlParameter("@Currency",gpd.Currency),
  121. new SqlParameter("@Remark",gpd.Remark),
  122. new SqlParameter("@Operator",gpd.Operators),
  123. new SqlParameter("@OperatorDate",gpd.OperatorsDate),
  124. new SqlParameter("@Id",gpd.Id),
  125. new SqlParameter("@PayType",gpd.PayType),
  126. new SqlParameter("@PriceType",gpd.PriceType)
  127. };
  128. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  129. return true;
  130. return false;
  131. }
  132. /// <summary>
  133. /// 删除
  134. /// </summary>
  135. /// <returns></returns>
  136. public bool DelOtherPriceOfOP(int id)
  137. {
  138. string sql = "update OtherPriceOP set IsDel = 1 where Id = @Id";
  139. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, new SqlParameter("@Id", id)) > 0)
  140. return true;
  141. return false;
  142. }
  143. /// <summary>
  144. /// 查询退多付款的其他款项
  145. /// </summary>
  146. /// <param name="diid"></param>
  147. /// <returns></returns>
  148. public DataTable GetOtherPriceOfOPByDiiD(int diid)
  149. {
  150. //调用获取单个对象的方法
  151. return SqlHelper.TransferProcedure("exec_OtherPriceOP_QueryByPayType", CommandType.StoredProcedure, new SqlParameter("@diid", diid));
  152. }
  153. }
  154. }