TeamAttachmentService.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Models;
  9. namespace DAL
  10. {
  11. /// <summary>
  12. /// 团组附件下载统计数据访问层
  13. /// </summary>
  14. public class TeamAttachmentService
  15. {
  16. /// <summary>
  17. /// 查询所有数据
  18. /// </summary>
  19. /// <param name="sql">sql语句</param>
  20. /// <param name="param">可变参数数组</param>
  21. /// <returns>返回集合</returns>
  22. List<TeamAttachmentInfo> excuteSql(string sql, params SqlParameter[] param)
  23. {
  24. return ServiceBase<TeamAttachmentInfo>.excuteSql(new TeamAttachmentInfo(), "TeamAttachmentInfo", sql, CommandType.Text, param);
  25. }
  26. /// <summary>
  27. /// 获取单个对象
  28. /// </summary>
  29. /// <param name="sql">sql语句</param>
  30. /// <param name="param">可变参数数组</param>
  31. /// <returns>返回空或者单个对象</returns>
  32. TeamAttachmentInfo excuteType(string sql, params SqlParameter[] param)
  33. {
  34. //查询结果放入对象集合
  35. List<TeamAttachmentInfo> ctggdList = excuteSql(sql, param);
  36. //判断集合是否为空
  37. if (ctggdList == null || ctggdList.Count == 0)
  38. //返回null
  39. return null;
  40. //返回单个对象
  41. return ctggdList[0];
  42. }
  43. //增Add
  44. public bool Add(TeamAttachmentInfo tai)
  45. {
  46. string sql = "insert into TeamAttachment values(@Diid,@AirNumber,@HotelNumber,@VisaNumber,@InvitedNumber,@OfficialNumber,@PickNumber,@Oper,@OperDate,@Isdel);SELECT @@IDENTITY";
  47. SqlParameter[] parameter = new SqlParameter[]{
  48. new SqlParameter("@Diid",tai.Diid),
  49. new SqlParameter("@AirNumber",tai.AirNumber),
  50. new SqlParameter("@HotelNumber",tai.HotelNumber),
  51. new SqlParameter("@VisaNumber",tai.VisaNumber),
  52. new SqlParameter("@InvitedNumber",tai.InvitedNumber),
  53. new SqlParameter("@OfficialNumber",tai.OfficialNumber),
  54. new SqlParameter("@PickNumber",tai.PickNumber),
  55. new SqlParameter("@Oper",tai.Oper),
  56. new SqlParameter("@OperDate",tai.OperDate),
  57. new SqlParameter("@Isdel",tai.Isdel)
  58. };
  59. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  60. return true;
  61. return false;
  62. }
  63. //删Delete
  64. public bool Del(int id)
  65. {
  66. if (SqlHelper.ExecuteNonQuery("update TeamAttachment set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  67. return true;
  68. return false;
  69. }
  70. //改Update
  71. public bool Edit(TeamAttachmentInfo tai)
  72. {
  73. string sql = "update TeamAttachment set AirNumber=@AirNumber,HotelNumber=@HotelNumber,VisaNumber=@VisaNumber,InvitedNumber=@InvitedNumber," +
  74. "OfficialNumber=@OfficialNumber,PickNumber=@PickNumber,Oper=@Oper,OperDate=@OperDate,Isdel=@Isdel where Id = @Id";
  75. SqlParameter[] parameter = new SqlParameter[]{
  76. new SqlParameter("@AirNumber",tai.AirNumber),
  77. new SqlParameter("@HotelNumber",tai.HotelNumber),
  78. new SqlParameter("@VisaNumber",tai.VisaNumber),
  79. new SqlParameter("@InvitedNumber",tai.InvitedNumber),
  80. new SqlParameter("@OfficialNumber",tai.OfficialNumber),
  81. new SqlParameter("@PickNumber",tai.PickNumber),
  82. new SqlParameter("@Oper",tai.Oper),
  83. new SqlParameter("@OperDate",tai.OperDate),
  84. new SqlParameter("@Isdel",tai.Isdel),
  85. new SqlParameter("@Id",tai.Id)
  86. };
  87. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  88. return true;
  89. return false;
  90. }
  91. /// <summary>
  92. /// 根据团组id singer
  93. /// </summary>
  94. /// <param name="diid">团组id</param>
  95. /// <returns></returns>
  96. public TeamAttachmentInfo GetByDiid(int diid)
  97. {
  98. //调用获取单个对象的方法
  99. return excuteType("select * from TeamAttachment where IsDel=0 and Diid=@diid ", new SqlParameter("@diid", diid));
  100. }
  101. /// <summary>
  102. /// 根据团组id
  103. /// </summary>
  104. /// <param name="diid">团组id</param>
  105. /// <returns></returns>
  106. public List<TeamAttachmentInfo> GetByDiids(int diid)
  107. {
  108. //调用获取单个对象的方法
  109. return excuteSql("select * from TeamAttachment where IsDel=0 and Diid=@diid ", new SqlParameter("@diid", diid));
  110. }
  111. }
  112. }