InvitingPartyInfoService.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Text;
  7. using Models;
  8. namespace DAL
  9. {
  10. public class InvitingPartyInfoService
  11. {
  12. List<InvitingPartyInfo> excuteSql(string sql, params SqlParameter[] param)
  13. {
  14. return ServiceBase<InvitingPartyInfo>.excuteSql(new InvitingPartyInfo(), "InvitingPartyInfo", sql, CommandType.Text, param);
  15. }
  16. List<InvitationOfficialActivityData> excuteSql2(string sql, params SqlParameter[] param)
  17. {
  18. return ServiceBase<InvitationOfficialActivityData>.excuteSql(new InvitationOfficialActivityData(), "InvitationOfficialActivityData", sql, CommandType.Text, param);
  19. }
  20. InvitingPartyInfo excuteType(string sql, params SqlParameter[] param)
  21. {
  22. //查询结果放入对象集合
  23. List<InvitingPartyInfo> hdList = excuteSql(sql, param);
  24. //判断集合是否为空
  25. if (hdList == null || hdList.Count == 0)
  26. //返回null
  27. return null;
  28. //返回单个对象
  29. return hdList[0];
  30. }
  31. InvitationOfficialActivityData excuteTypeActivityData(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<InvitationOfficialActivityData> hdList = excuteSql2(sql, param);
  35. //判断集合是否为空
  36. if (hdList == null || hdList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return hdList[0];
  41. }
  42. public List<InvitingPartyInfo> GetAllByDiid(int diid)
  43. {
  44. return excuteSql("select * from InvitingPartyInfo Where IsDel = 0 and Diid=" + diid+" order by Id desc");
  45. }
  46. /// <summary>
  47. /// 根据 团组编号 国家 城市 查询 信息
  48. /// </summary>
  49. /// <param name="diid">团组编号</param>
  50. /// <param name="Country">国家</param>
  51. /// <param name="City">城市</param>
  52. /// <returns></returns>
  53. public InvitingPartyInfo GetAddSelect(int diid,string Country,string City)
  54. {
  55. //调用获取单个对象的方法
  56. return excuteType("select * from InvitingPartyInfo where Isdel=0 and diid =" + diid + " and Country='"+ Country + "' and city='"+City+"';");
  57. }
  58. /// <summary>
  59. /// 根据 团组编号 国家 城市 查询 信息
  60. /// </summary>
  61. /// <param name="diid">团组编号</param>
  62. /// <param name="Country">国家</param>
  63. /// <param name="City">城市</param>
  64. /// <returns></returns>
  65. public InvitationOfficialActivityData GetActivityDataAddSelect(string Country, string City, string Address,string Field)
  66. {
  67. //调用获取单个对象的方法
  68. return excuteTypeActivityData("select * from InvitationOfficialActivityData where Country='"+ Country + "'and City='"+City+"' and Address='"+Address+"' and Field='"+Field+"';");
  69. }
  70. /// <summary>
  71. /// 查询单个信息
  72. /// </summary>
  73. /// <param name="diid"></param>
  74. /// <param name="Country"></param>
  75. /// <param name="City"></param>
  76. /// <returns></returns>
  77. public InvitingPartyInfo GetById(int id)
  78. {
  79. //调用获取单个对象的方法
  80. return excuteType("select * from InvitingPartyInfo where Id=" + id);
  81. }
  82. //增Add
  83. public bool Add(InvitingPartyInfo ip)
  84. {
  85. string sql = "insert into InvitingPartyInfo values(@Diid,@Country,@City,@InvitingUnit,@InvitingAddress,@Contacts,@ContactsJob,@ContactsTel,"
  86. + "@ContactsEmail,@ContactsFax,@InvitingUrl,@Oper,@Opdate,@Isdel,@UnitWeb,@Field);SELECT @@IDENTITY";
  87. SqlParameter[] parameter = new SqlParameter[]{
  88. new SqlParameter("@Diid",ip.Diid),
  89. new SqlParameter("@Country",ip.Country),
  90. new SqlParameter("@City",ip.City),
  91. new SqlParameter("@InvitingUnit",ip.InvitingUnit),
  92. new SqlParameter("@InvitingAddress",ip.InvitingAddress),
  93. new SqlParameter("@Contacts",ip.Contacts),
  94. new SqlParameter("@ContactsJob",ip.ContactsJob),
  95. new SqlParameter("@ContactsTel",ip.ContactsTel),
  96. new SqlParameter("@ContactsEmail",ip.ContactsEmail),
  97. new SqlParameter("@ContactsFax",ip.ContactsFax),
  98. new SqlParameter("@InvitingUrl",ip.InvitingUrl),
  99. new SqlParameter("@Oper",ip.Oper),
  100. new SqlParameter("@Opdate",ip.Opdate),
  101. new SqlParameter("@Isdel",ip.Isdel),
  102. new SqlParameter("@UnitWeb",ip.UnitWeb),
  103. new SqlParameter("@Field",ip.Field)
  104. };
  105. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  106. return true;
  107. return false;
  108. }
  109. //改Update
  110. public bool Edit(InvitingPartyInfo ip)
  111. {
  112. string sql = "update InvitingPartyInfo set Diid=@Diid,Country=@Country,City=@City,InvitingUnit=@InvitingUnit,InvitingAddress=@InvitingAddress,Contacts=@Contacts,"
  113. + "ContactsJob=@ContactsJob,ContactsTel=@ContactsTel,ContactsEmail=@ContactsEmail,ContactsFax=@ContactsFax,InvitingUrl=@InvitingUrl,Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel," +
  114. "UnitWeb=@UnitWeb,Field=@Field where Id=@Id";
  115. SqlParameter[] parameter = new SqlParameter[]{
  116. new SqlParameter("@Diid",ip.Diid),
  117. new SqlParameter("@Country",ip.Country),
  118. new SqlParameter("@City",ip.City),
  119. new SqlParameter("@InvitingUnit",ip.InvitingUnit),
  120. new SqlParameter("@InvitingAddress",ip.InvitingAddress),
  121. new SqlParameter("@Contacts",ip.Contacts),
  122. new SqlParameter("@ContactsJob",ip.ContactsJob),
  123. new SqlParameter("@ContactsTel",ip.ContactsTel),
  124. new SqlParameter("@ContactsEmail",ip.ContactsEmail),
  125. new SqlParameter("@ContactsFax",ip.ContactsFax),
  126. new SqlParameter("@InvitingUrl",ip.InvitingUrl),
  127. new SqlParameter("@Oper",ip.Oper),
  128. new SqlParameter("@Opdate",ip.Opdate),
  129. new SqlParameter("@Isdel",ip.Isdel),
  130. new SqlParameter("@Id",ip.Id),
  131. new SqlParameter("@UnitWeb",ip.UnitWeb),
  132. new SqlParameter("@Field",ip.Field)
  133. };
  134. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  135. return true;
  136. return false;
  137. }
  138. //删
  139. public bool delIP(int id)
  140. {
  141. if (SqlHelper.ExecuteNonQuery("update InvitingPartyInfo set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  142. return true;
  143. return false;
  144. }
  145. public List<InvitationOfficialActivityData> ActivityDataQurey(string ddlTeamName)
  146. {
  147. return excuteSql2("select * from InvitationOfficialActivityData Where IsDel = 0 and Delegation='"+ ddlTeamName + "' order by OperatorDate desc");
  148. }
  149. }
  150. }