VisaCommissionService.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data.SqlClient;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace DAL
  10. {
  11. public class VisaCommissionService
  12. {
  13. /// <summary>
  14. /// 查询集合
  15. /// </summary>
  16. /// <param name="sql"></param>
  17. /// <param name="param"></param>
  18. /// <returns></returns>
  19. List<VisaCommission> excuteSql(string sql, params SqlParameter[] param)
  20. {
  21. return ServiceBase<VisaCommission>.excuteSql(new VisaCommission(), "VisaCommission", sql, CommandType.Text, param);
  22. }
  23. /// <summary>
  24. /// 查询单个
  25. /// </summary>
  26. /// <param name="sql"></param>
  27. /// <param name="param"></param>
  28. /// <returns></returns>
  29. VisaCommission excuteType(string sql, params SqlParameter[] param)
  30. {
  31. //查询结果放入对象集合
  32. List<VisaCommission> hdList = excuteSql(sql, param);
  33. VisaCommission visa = new VisaCommission();
  34. //判断集合是否为空
  35. if (hdList == null || hdList.Count == 0)
  36. {
  37. //返回null
  38. return null;
  39. }
  40. //返回单个对象
  41. return hdList[0];
  42. }
  43. /// <summary>
  44. /// 根据团组Id和国家查询单条
  45. /// </summary>
  46. /// <param name="ShortCode"></param>
  47. /// <returns></returns>
  48. public VisaCommission getByDiId(int diid,string Nation,int UserId)
  49. {
  50. return excuteType("select * from VisaCommission where Nation='" + Nation + "' and Isdel=0 and DiId=@diid and UId="+ UserId, new SqlParameter("@diid", diid));
  51. }
  52. /// <summary>
  53. /// 增加
  54. /// </summary>
  55. /// <param name="cd"></param>
  56. /// <returns></returns>
  57. public bool Add(VisaCommission Vc)
  58. {
  59. string sql = "insert into VisaCommission values(@DiId,@UId,@Number,@Nation,@CreateUserId,@CreateDateTime,@Remark,@IsDel)";
  60. SqlParameter[] parameter = new SqlParameter[]{
  61. new SqlParameter("@DiId",Vc.DiId),
  62. new SqlParameter("@UId",Vc.UId),
  63. new SqlParameter("@Number",Vc.Number),
  64. new SqlParameter("@Nation",Vc.Nation),
  65. new SqlParameter("@CreateUserId",Vc.CreateUserId),
  66. new SqlParameter("@CreateDateTime",Vc.CreateDateTime),
  67. new SqlParameter("@Remark",Vc.Remark),
  68. new SqlParameter("@IsDel",Vc.IsDel)
  69. };
  70. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  71. return true;
  72. return false;
  73. }
  74. /// <summary>
  75. /// 获取信用卡账单类型费用
  76. /// </summary>
  77. /// <returns></returns>
  78. public List<VisaCommission> GetAll(int diid,int UserId)
  79. {
  80. return excuteSql("select * from VisaCommission where DiId="+diid+ " and isdel = 0 and UId="+UserId);
  81. }
  82. /// <summary>
  83. /// 编辑
  84. /// </summary>
  85. /// <param name="sdt"></param>
  86. /// <returns></returns>
  87. public bool Edit(VisaCommission Vc)
  88. {
  89. string sql = "update VisaCommission set Number=@Number,CreateUserId=@CreateUserId,CreateDateTime=@CreateDateTime,Remark=@Remark where Id = @Id";
  90. SqlParameter[] parameter = new SqlParameter[]{
  91. new SqlParameter("@Id ",Vc.Id ),
  92. new SqlParameter("@Number",Vc.Number),
  93. new SqlParameter("@Remark",Vc.Remark),
  94. new SqlParameter("@CreateUserId",Vc.CreateUserId),
  95. new SqlParameter("@CreateDateTime",Vc.CreateDateTime),
  96. };
  97. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  98. return true;
  99. return false;
  100. }
  101. /// <summary>
  102. /// 删除
  103. /// </summary>
  104. /// <param name="id"></param>
  105. /// <returns></returns>
  106. public bool Del(int id)
  107. {
  108. if (SqlHelper.ExecuteNonQuery("update VisaCommission set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  109. return true;
  110. return false;
  111. }
  112. }
  113. }