InvitationOfficialActivitiesService.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 InvitationOfficialActivitiesService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<InvitationOfficialActivities> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<InvitationOfficialActivities>.excuteSql(new InvitationOfficialActivities(), "InvitationOfficialActivities", 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. InvitationOfficialActivities excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<InvitationOfficialActivities> ioaList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (ioaList == null || ioaList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return ioaList[0];
  41. }
  42. /// <summary>
  43. /// 根据编号查询对象信息
  44. /// </summary>
  45. /// <param name="id">对象编号</param>
  46. /// <returns>返回空或者单个对象信息</returns>
  47. public InvitationOfficialActivities GetInvitationOfficialActivitiesByID(int id)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteType("select * from InvitationOfficialActivities 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 InvitationOfficialActivities GetInvitationOfficialActivitiesAndDiId(int diid,string Inviter)
  58. {
  59. //调用获取单个对象的方法
  60. return excuteType("select * from InvitationOfficialActivities where DIId = @diid and Inviter="+Inviter+" and isdel=0", new SqlParameter("@diid", diid));
  61. }
  62. public List<InvitationOfficialActivities> GetIByDiid(int diid)
  63. {
  64. //调用获取单个对象的方法
  65. return excuteSql("select * from InvitationOfficialActivities where DIId = @diid and isdel=0", new SqlParameter("@diid", diid));
  66. }
  67. /// <summary>
  68. /// 获取全部 - 分页
  69. /// </summary>
  70. /// <returns></returns>
  71. public List<InvitationOfficialActivities> GetInvitationOfficialActivities(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string inviter, string startTime, string endTime, string arrayUsersId)
  72. {
  73. string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and Inviter like '%" + inviter + "%' and Operator in (" + arrayUsersId + ")";
  74. if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
  75. sqlwhere += " and (InviteTime Between '" + startTime + "' and '" + endTime + "')";
  76. return PageBase<InvitationOfficialActivities>.excutePageSql(new InvitationOfficialActivities(), "InvitationOfficialActivities", "InvitationOfficialActivities", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  77. }
  78. /// <summary>
  79. /// 增加
  80. /// </summary>
  81. /// <returns></returns>
  82. public bool AddInvitationOfficialActivities(InvitationOfficialActivities ioa, out int id)
  83. {
  84. string sql = "insert into InvitationOfficialActivities values(@DIId,@InviterArea,@Inviter,@InviteTime,@Attachment,@InviteCosts,@Currency," +
  85. "@SendCost,@IsGoOfficialBusiness,@Remark,@Operator,@OperatorDate,@IsDel,@EventsCost,@TranslateCost,@SendCurrency,@EventsCurrency,@TranslateCurrency);SELECT @@IDENTITY";
  86. SqlParameter[] parameter = new SqlParameter[]{
  87. new SqlParameter("@DIId",ioa.DIId),
  88. new SqlParameter("@InviterArea",ioa.InviterArea),
  89. new SqlParameter("@Inviter",ioa.Inviter),
  90. new SqlParameter("@InviteTime",ioa.InviteTime),
  91. new SqlParameter("@Attachment",ioa.Attachment),
  92. new SqlParameter("@InviteCosts",ioa.InviteCosts),
  93. new SqlParameter("@Currency",ioa.Currency),
  94. new SqlParameter("@SendCost",ioa.SendCost),
  95. new SqlParameter("@IsGoOfficialBusiness",ioa.IsGoOfficaiaBussiness),
  96. new SqlParameter("@Remark",ioa.Remark),
  97. new SqlParameter("@Operator",ioa.Operators),
  98. new SqlParameter("@OperatorDate",ioa.OperatorsDate),
  99. new SqlParameter("@IsDel",ioa.IsDel),
  100. new SqlParameter("@EventsCost",ioa.EventsCost),
  101. new SqlParameter("@TranslateCost",ioa.TranslateCost),
  102. new SqlParameter("@SendCurrency",ioa.SendCurrency),
  103. new SqlParameter("@EventsCurrency",ioa.EventsCurrency),
  104. new SqlParameter("@TranslateCurrency",ioa.TranslateCurrency),
  105. };
  106. int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
  107. if (obj > 0)
  108. {
  109. id = obj;
  110. return true;
  111. }
  112. id = 0;
  113. return false;
  114. }
  115. /// <summary>
  116. /// 编辑
  117. /// </summary>
  118. /// <returns></returns>
  119. public bool EditInvitationOfficialActivities(InvitationOfficialActivities ioa)
  120. {
  121. string sql = "update InvitationOfficialActivities set DIId = @DIId,InviterArea = @InviterArea,Inviter = @Inviter,InviteTime = @InviteTime," +
  122. "Attachment = @Attachment,InviteCosts = @InviteCosts,Currency = @Currency,SendCost = @SendCost," +
  123. "IsGoOfficialBusiness = @IsGoOfficialBusiness,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,EventsCost=@EventsCost," +
  124. " TranslateCost=@TranslateCost,SendCurrency=@SendCurrency,EventsCurrency=@EventsCurrency,TranslateCurrency=@TranslateCurrency where Id = @Id";
  125. SqlParameter[] parameter = new SqlParameter[]{
  126. new SqlParameter("@DIId",ioa.DIId),
  127. new SqlParameter("@InviterArea",ioa.InviterArea),
  128. new SqlParameter("@Inviter",ioa.Inviter),
  129. new SqlParameter("@InviteTime",ioa.InviteTime),
  130. new SqlParameter("@Attachment",ioa.Attachment),
  131. new SqlParameter("@InviteCosts",ioa.InviteCosts),
  132. new SqlParameter("@Currency",ioa.Currency),
  133. new SqlParameter("@SendCost",ioa.SendCost),
  134. new SqlParameter("@IsGoOfficialBusiness",ioa.IsGoOfficaiaBussiness),
  135. new SqlParameter("@Remark",ioa.Remark),
  136. new SqlParameter("@Operator",ioa.Operators),
  137. new SqlParameter("@OperatorDate",ioa.OperatorsDate),
  138. new SqlParameter("@Id",ioa.Id),
  139. new SqlParameter("@EventsCost",ioa.EventsCost),
  140. new SqlParameter("@TranslateCost",ioa.TranslateCost),
  141. new SqlParameter("@SendCurrency",ioa.SendCurrency),
  142. new SqlParameter("@EventsCurrency",ioa.EventsCurrency),
  143. new SqlParameter("@TranslateCurrency",ioa.TranslateCurrency),
  144. };
  145. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  146. return true;
  147. return false;
  148. }
  149. /// <summary>
  150. /// 删除
  151. /// </summary>
  152. /// <param name="id"></param>
  153. /// <returns></returns>
  154. public bool DelInvitationOfficialActivities(int id)
  155. {
  156. if (SqlHelper.ExecuteNonQuery("update InvitationOfficialActivities set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  157. return true;
  158. return false;
  159. }
  160. }
  161. }