InvitationOfficialActivitiesService.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. public List<InvitationOfficialActivities> GetIByDiid(int diid)
  53. {
  54. //调用获取单个对象的方法
  55. return excuteSql("select * from InvitationOfficialActivities where DIId = @diid and isdel=0", new SqlParameter("@diid", diid));
  56. }
  57. /// <summary>
  58. /// 获取全部 - 分页
  59. /// </summary>
  60. /// <returns></returns>
  61. public List<InvitationOfficialActivities> GetInvitationOfficialActivities(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string inviter, string startTime, string endTime, string arrayUsersId)
  62. {
  63. string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and Inviter like '%" + inviter + "%' and Operator in (" + arrayUsersId + ")";
  64. if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
  65. sqlwhere += " and (InviteTime Between '" + startTime + "' and '" + endTime + "')";
  66. return PageBase<InvitationOfficialActivities>.excutePageSql(new InvitationOfficialActivities(), "InvitationOfficialActivities", "InvitationOfficialActivities", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  67. }
  68. /// <summary>
  69. /// 增加
  70. /// </summary>
  71. /// <returns></returns>
  72. public bool AddInvitationOfficialActivities(InvitationOfficialActivities ioa, out int id)
  73. {
  74. string sql = "insert into InvitationOfficialActivities values(@DIId,@InviterArea,@Inviter,@InviteTime,@Attachment,@InviteCosts,@Currency," +
  75. "@SendCost,@IsGoOfficialBusiness,@Remark,@Operator,@OperatorDate,@IsDel,@EventsCost,@TranslateCost,@SendCurrency,@EventsCurrency,@TranslateCurrency);SELECT @@IDENTITY";
  76. SqlParameter[] parameter = new SqlParameter[]{
  77. new SqlParameter("@DIId",ioa.DIId),
  78. new SqlParameter("@InviterArea",ioa.InviterArea),
  79. new SqlParameter("@Inviter",ioa.Inviter),
  80. new SqlParameter("@InviteTime",ioa.InviteTime),
  81. new SqlParameter("@Attachment",ioa.Attachment),
  82. new SqlParameter("@InviteCosts",ioa.InviteCosts),
  83. new SqlParameter("@Currency",ioa.Currency),
  84. new SqlParameter("@SendCost",ioa.SendCost),
  85. new SqlParameter("@IsGoOfficialBusiness",ioa.IsGoOfficaiaBussiness),
  86. new SqlParameter("@Remark",ioa.Remark),
  87. new SqlParameter("@Operator",ioa.Operators),
  88. new SqlParameter("@OperatorDate",ioa.OperatorsDate),
  89. new SqlParameter("@IsDel",ioa.IsDel),
  90. new SqlParameter("@EventsCost",ioa.EventsCost),
  91. new SqlParameter("@TranslateCost",ioa.TranslateCost),
  92. new SqlParameter("@SendCurrency",ioa.SendCurrency),
  93. new SqlParameter("@EventsCurrency",ioa.EventsCurrency),
  94. new SqlParameter("@TranslateCurrency",ioa.TranslateCurrency),
  95. };
  96. int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
  97. if (obj > 0)
  98. {
  99. id = obj;
  100. return true;
  101. }
  102. id = 0;
  103. return false;
  104. }
  105. /// <summary>
  106. /// 编辑
  107. /// </summary>
  108. /// <returns></returns>
  109. public bool EditInvitationOfficialActivities(InvitationOfficialActivities ioa)
  110. {
  111. string sql = "update InvitationOfficialActivities set DIId = @DIId,InviterArea = @InviterArea,Inviter = @Inviter,InviteTime = @InviteTime," +
  112. "Attachment = @Attachment,InviteCosts = @InviteCosts,Currency = @Currency,SendCost = @SendCost," +
  113. "IsGoOfficialBusiness = @IsGoOfficialBusiness,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,EventsCost=@EventsCost," +
  114. " TranslateCost=@TranslateCost,SendCurrency=@SendCurrency,EventsCurrency=@EventsCurrency,TranslateCurrency=@TranslateCurrency where Id = @Id";
  115. SqlParameter[] parameter = new SqlParameter[]{
  116. new SqlParameter("@DIId",ioa.DIId),
  117. new SqlParameter("@InviterArea",ioa.InviterArea),
  118. new SqlParameter("@Inviter",ioa.Inviter),
  119. new SqlParameter("@InviteTime",ioa.InviteTime),
  120. new SqlParameter("@Attachment",ioa.Attachment),
  121. new SqlParameter("@InviteCosts",ioa.InviteCosts),
  122. new SqlParameter("@Currency",ioa.Currency),
  123. new SqlParameter("@SendCost",ioa.SendCost),
  124. new SqlParameter("@IsGoOfficialBusiness",ioa.IsGoOfficaiaBussiness),
  125. new SqlParameter("@Remark",ioa.Remark),
  126. new SqlParameter("@Operator",ioa.Operators),
  127. new SqlParameter("@OperatorDate",ioa.OperatorsDate),
  128. new SqlParameter("@Id",ioa.Id),
  129. new SqlParameter("@EventsCost",ioa.EventsCost),
  130. new SqlParameter("@TranslateCost",ioa.TranslateCost),
  131. new SqlParameter("@SendCurrency",ioa.SendCurrency),
  132. new SqlParameter("@EventsCurrency",ioa.EventsCurrency),
  133. new SqlParameter("@TranslateCurrency",ioa.TranslateCurrency),
  134. };
  135. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  136. return true;
  137. return false;
  138. }
  139. /// <summary>
  140. /// 删除
  141. /// </summary>
  142. /// <param name="id"></param>
  143. /// <returns></returns>
  144. public bool DelInvitationOfficialActivities(int id)
  145. {
  146. if (SqlHelper.ExecuteNonQuery("update InvitationOfficialActivities set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  147. return true;
  148. return false;
  149. }
  150. }
  151. }