OfficialActivitiesService.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. namespace DAL
  9. {
  10. public class OfficialActivitiesService
  11. {
  12. List<OfficialActivities> excuteSql(string sql, params SqlParameter[] param)
  13. {
  14. return ServiceBase<OfficialActivities>.excuteSql(new OfficialActivities(), "OfficalActivities", sql, CommandType.Text, param);
  15. }
  16. OfficialActivities excuteType(string sql, params SqlParameter[] param)
  17. {
  18. //查询结果放入对象集合
  19. List<OfficialActivities> hdList = excuteSql(sql, param);
  20. //判断集合是否为空
  21. if (hdList == null || hdList.Count == 0)
  22. //返回null
  23. return null;
  24. //返回单个对象
  25. return hdList[0];
  26. }
  27. //增Add
  28. public bool Add(OfficialActivities Dov)
  29. {
  30. string sql = "insert into OfficialActivities values(@Diid,@Dovid,@Client,@Date,@Time,@Address,@Contact,@Job,@Tel,@Form,@Setting,@Dresscode,@Attendees,@IsNeedTrans,@Translators,@Language," +
  31. "@Trip,@Oper,@OpDate,@Isdel,@Type,@IsSubmitApproval,@IsPay);SELECT @@IDENTITY";
  32. SqlParameter[] parameter = new SqlParameter[]{
  33. new SqlParameter("@Diid",Dov.Diid),
  34. new SqlParameter("@Dovid",Dov.Dovid),
  35. new SqlParameter("@Client",Dov.Client),
  36. new SqlParameter("@Date",Dov.Date),
  37. new SqlParameter("@Time",Dov.Time),
  38. new SqlParameter("@Address",Dov.Address),
  39. new SqlParameter("@Contact",Dov.Contact),
  40. new SqlParameter("@Job",Dov.Job),
  41. new SqlParameter("@Tel",Dov.Tel),
  42. new SqlParameter("@Form",Dov.Form),
  43. new SqlParameter("@Setting",Dov.Setting),
  44. new SqlParameter("@Dresscode",Dov.Dresscode),
  45. new SqlParameter("@Attendees",Dov.Attendees),
  46. new SqlParameter("@IsNeedTrans",Dov.IsNeedTrans),
  47. new SqlParameter("@Translators",Dov.Translators),
  48. new SqlParameter("@Language",Dov.Language),
  49. new SqlParameter("@Trip",Dov.Trip),
  50. new SqlParameter("@Oper",Dov.Oper),
  51. new SqlParameter("@OpDate",Dov.OpDate),
  52. new SqlParameter("@Isdel",Dov.Isdel),
  53. new SqlParameter("@Type",Dov.Type),
  54. new SqlParameter("@IsSubmitApproval",Dov.IsSubmitApproval),
  55. new SqlParameter("@IsPay",Dov.IsPay),
  56. };
  57. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  58. return true;
  59. return false;
  60. }
  61. //改Update
  62. public bool Edit(OfficialActivities Dov)
  63. {
  64. string sql = "update OfficialActivities set Diid=@Diid,Dovid=@Dovid,Client=@Client,Date=@Date,Time=@Time,Address=@Address,Contact=@Contact,Job=@Job,"
  65. + "Tel=@Tel,Form=@Form,Setting=@Setting,Dresscode=@Dresscode,Attendees=@Attendees,IsNeedTrans=@IsNeedTrans,Translators=@Translators,Language=@Language,"
  66. + "Trip=@Trip,Oper=@Oper,OpDate=@OpDate,Isdel=@Isdel,Type=@Type,IsSubmitApproval=@IsSubmitApproval,IsPay=@IsPay where Id = @Id";
  67. SqlParameter[] parameter = new SqlParameter[]{
  68. new SqlParameter("@Diid",Dov.Diid),
  69. new SqlParameter("@Dovid",Dov.Dovid),
  70. new SqlParameter("@Client",Dov.Client),
  71. new SqlParameter("@Date",Dov.Date),
  72. new SqlParameter("@Time",Dov.Time),
  73. new SqlParameter("@Address",Dov.Address),
  74. new SqlParameter("@Contact",Dov.Contact),
  75. new SqlParameter("@Job",Dov.Job),
  76. new SqlParameter("@Tel",Dov.Tel),
  77. new SqlParameter("@Form",Dov.Form),
  78. new SqlParameter("@Setting",Dov.Setting),
  79. new SqlParameter("@Dresscode",Dov.Dresscode),
  80. new SqlParameter("@Attendees",Dov.Attendees),
  81. new SqlParameter("@IsNeedTrans",Dov.IsNeedTrans),
  82. new SqlParameter("@Translators",Dov.Translators),
  83. new SqlParameter("@Language",Dov.Language),
  84. new SqlParameter("@Trip",Dov.Trip),
  85. new SqlParameter("@Oper",Dov.Oper),
  86. new SqlParameter("@OpDate",Dov.OpDate),
  87. new SqlParameter("@Isdel",Dov.Isdel),
  88. new SqlParameter("@Id",Dov.Id),
  89. new SqlParameter("@Type",Dov.Type),
  90. new SqlParameter("@IsSubmitApproval",Dov.IsSubmitApproval),
  91. new SqlParameter("@IsPay",Dov.IsPay),
  92. };
  93. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  94. return true;
  95. return false;
  96. }
  97. //删
  98. public bool delOA(int id)
  99. {
  100. if (SqlHelper.ExecuteNonQuery("update OfficialActivities set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  101. return true;
  102. return false;
  103. }
  104. /// <summary>
  105. /// 根据团组ID查询多个信息
  106. /// </summary>
  107. /// <param name="diid"></param>
  108. /// <returns></returns>
  109. public List<OfficialActivities> getByDiid(int diid)
  110. {
  111. return excuteSql("select * from OfficialActivities where Isdel=0 and Diid=@diid order by Date", new SqlParameter("@diid", diid));
  112. }
  113. /// <summary>
  114. /// 根据团组查询多个信息
  115. /// </summary>
  116. /// <param name="diid"></param>
  117. /// <returns></returns>
  118. public List<OfficialActivities> getByDiidAndDate(int diid,string date)
  119. {
  120. return excuteSql("select * from OfficialActivities where Isdel=0 and Diid=@diid and IsSubmitApproval=0 and Date=@Date order by Date", new SqlParameter("@diid", diid), new SqlParameter("@Date", date));
  121. }
  122. /// <summary>
  123. /// 根据Id查单条信息
  124. /// </summary>
  125. /// <param name="diid"></param>
  126. /// <returns></returns>
  127. public OfficialActivities getById(int id)
  128. {
  129. return excuteType("select * from OfficialActivities where Isdel=0 and Id=@id", new SqlParameter("@id", id));
  130. }
  131. /// <summary>
  132. /// 根据Id查单条信息
  133. /// </summary>
  134. /// <param name="diid"></param>
  135. /// <returns></returns>
  136. public OfficialActivities getBySingleDiid(int diid)
  137. {
  138. return excuteType("select * from OfficialActivities where Isdel=0 and diid=@diid", new SqlParameter("@diid", diid));
  139. }
  140. /// <summary>
  141. /// 根据Id查单条信息
  142. /// </summary>
  143. /// <param name="diid"></param>
  144. /// <returns></returns>
  145. public OfficialActivities getBySingleDiidAndCountry(int diid,string country)
  146. {
  147. return excuteType("select * from OfficialActivities where Isdel=0 and diid=" + diid + " and Client like '%" + country + "%'");
  148. }
  149. /// <summary>
  150. /// 雷怡 2021-08-30 10:20
  151. /// 查询所有
  152. /// </summary>
  153. /// <returns></returns>
  154. public List<OfficialActivities> getAll()
  155. {
  156. return excuteSql("select * from OfficialActivities where Isdel=0 order by Date desc");
  157. }
  158. }
  159. }