InvitationOfficialActivityDataService.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using Models;
  8. namespace DAL
  9. {
  10. /// <summary>
  11. /// 公务活动资料数据访问类
  12. /// </summary>
  13. public class InvitationOfficialActivityDataService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<InvitationOfficialActivityData> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<InvitationOfficialActivityData>.excuteSql(new InvitationOfficialActivityData(), "InvitationOfficialActivityData", 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. List<AssociationGroup> excuteSql1(string sql, params SqlParameter[] param)
  32. {
  33. return ServiceBase<AssociationGroup>.excuteSql(new AssociationGroup(), "AssociationGroup", sql, CommandType.Text, param);
  34. }
  35. /// <summary>
  36. /// 查询所有团组名称
  37. /// </summary>
  38. /// <param name="sql">sql语句</param>
  39. /// <param name="param">可变参数数组</param>
  40. /// <returns>返回集合</returns>
  41. List<DelegationInfo> excuteDelegationSql(string sql, params SqlParameter[] param)
  42. {
  43. return ServiceBase<DelegationInfo>.excuteSql(new DelegationInfo(), "DelegationInfo", sql, CommandType.Text, param);
  44. }
  45. /// <summary>
  46. /// 获取单个对象
  47. /// </summary>
  48. /// <param name="sql">sql语句</param>
  49. /// <param name="param">可变参数数组</param>
  50. /// <returns>返回空或者单个对象</returns>
  51. InvitationOfficialActivityData excuteType(string sql, params SqlParameter[] param)
  52. {
  53. //查询结果放入对象集合
  54. List<InvitationOfficialActivityData> ioadList = excuteSql(sql, param);
  55. //判断集合是否为空
  56. if (ioadList == null || ioadList.Count == 0)
  57. //返回null
  58. return null;
  59. //返回单个对象
  60. return ioadList[0];
  61. }
  62. /// <summary>
  63. /// 获取单个对象
  64. /// </summary>
  65. /// <param name="sql">sql语句</param>
  66. /// <param name="param">可变参数数组</param>
  67. /// <returns>返回空或者单个对象</returns>
  68. AssociationGroup excuteType2(string sql, params SqlParameter[] param)
  69. {
  70. //查询结果放入对象集合
  71. List<AssociationGroup> ioadList = excuteSql1(sql, param);
  72. //判断集合是否为空
  73. if (ioadList == null || ioadList.Count == 0)
  74. //返回null
  75. return null;
  76. //返回单个对象
  77. return ioadList[0];
  78. }
  79. /// <summary>
  80. /// 根据编号查询对象信息
  81. /// </summary>
  82. /// <param name="id">对象编号</param>
  83. /// <returns>返回空或者单个对象信息</returns>
  84. public InvitationOfficialActivityData GetInvitationOfficialActivityDataByID(int id)
  85. {
  86. //调用获取单个对象的方法
  87. return excuteType("select * from InvitationOfficialActivityData where Id = @id and IsDel = 0", new SqlParameter("@id", id));
  88. }
  89. /// <summary>
  90. /// 根据国家 城市 团组名 查询 邀请方信息
  91. /// </summary>
  92. /// <param name="country">国家</param>
  93. /// <param name="city">城市</param>
  94. /// <param name="teamName">团组名</param>
  95. /// <returns></returns>
  96. public InvitationOfficialActivityData GetByCountryAndCity(string country,string city)
  97. {
  98. string sql = "select * from InvitationOfficialActivityData where IsDel = 0 and Country=@Country and City=@City ";
  99. SqlParameter[] pars = new SqlParameter[] {
  100. new SqlParameter("Country",country),
  101. new SqlParameter("City",city)
  102. };
  103. //调用获取单个对象的方法
  104. return excuteType(sql,pars);
  105. }
  106. /// <summary>
  107. /// 获取全部
  108. /// </summary>
  109. /// <returns></returns>
  110. public List<InvitationOfficialActivityData> GetAll()
  111. {
  112. return excuteSql("select * from InvitationOfficialActivityData where IsDel = 0");
  113. }
  114. /// <summary>
  115. /// 获取团组名称
  116. /// </summary>
  117. /// <returns></returns>
  118. public List<DelegationInfo> GetAllDelegationI()
  119. {
  120. return excuteDelegationSql("select * from DelegationInfo Where IsDel = 0 order by Id desc");
  121. }
  122. /// <summary>
  123. /// 查询信息
  124. /// </summary>
  125. /// <returns>返回空或者单个对象信息</returns>
  126. public List<InvitationOfficialActivityData> GetInvitationOfficialActivityDataUnitArea(string Country)
  127. {
  128. //调用获取单个对象的方法
  129. return excuteSql("select * from InvitationOfficialActivityData where Country like '%" + Country + "%'");
  130. }
  131. /// <summary>
  132. /// 查询对象信息
  133. /// </summary>
  134. /// <param name="city">所在城市</param>
  135. /// <param name="name">酒店名称</param>
  136. /// <returns>返回空或者单个对象信息</returns>
  137. public InvitationOfficialActivityData GetInvitationOfficialActivityData(string Country, string unitName)
  138. {
  139. //调用获取单个对象的方法
  140. return excuteType("select * from InvitationOfficialActivityData where Country = @Country and UnitName = @UnitName and IsDel = 0 ", new SqlParameter("@Country", Country), new SqlParameter("@UnitName", unitName));
  141. }
  142. /// <summary>
  143. /// 查询对象信息
  144. /// </summary>
  145. /// <param name="city">所在城市</param>
  146. /// <param name="name">酒店名称</param>
  147. /// <returns>返回空或者单个对象信息</returns>
  148. public InvitationOfficialActivityData GetInvitationOfficialActivityData(string Country, string unitName, string Delegation)
  149. {
  150. //调用获取单个对象的方法
  151. return excuteType("select * from InvitationOfficialActivityData where Country = @Country and UnitName = @UnitName and IsDel = 0 and Delegation=@Delegation", new SqlParameter("@Country", Country), new SqlParameter("@UnitName", unitName), new SqlParameter("@Delegation", Delegation));
  152. }
  153. public AssociationGroup GetAssociationGroup(int id)
  154. {
  155. //调用获取单个对象的方法
  156. return excuteType2("select * from AssociationGroup where Ipid='"+id+"'");
  157. }
  158. /// <summary>
  159. /// 获取全部 - 分页
  160. /// </summary>
  161. /// <param name="pageIndex">当前页</param>
  162. /// <param name="sumPage">总页数</param>
  163. /// <param name="totalRecord">总条数</param>
  164. /// <param name="Country">国家</param>
  165. /// <param name="unitName">邀请方</param>
  166. /// <param name="contact">联系人</param>
  167. /// <param name="delegation">团名</param>
  168. /// <param name="domain">涉及领域</param>
  169. /// <returns></returns>
  170. public List<InvitationOfficialActivityData> GetInvitationOfficialActivityData(int pageIndex, out int sumPage, out int totalRecord, string Country, string unitName, string contact, string delegation,string domain,string ddlOP)
  171. {
  172. string sqlwhere = "IsDel = 0 ";
  173. if (!string.IsNullOrWhiteSpace(Country))
  174. {
  175. if (Country.Contains(','))
  176. Country = Country.Replace(',', ' ');
  177. else if (Country.Contains(','))
  178. Country = Country.Replace(',', ' ');
  179. else if (Country.Contains('、'))
  180. Country = Country.Replace('、', ' ');
  181. if (Country.Contains(" "))
  182. {
  183. string sqlCity = " and (";
  184. string[] sqlName = Country.Split(' ');
  185. for (int i = 0, len = sqlName.Length; i < len; i++)
  186. if (sqlName[i] != "")
  187. if (i == len - 1)
  188. sqlCity += " City like '%" + sqlName[i] + "%') ";
  189. else
  190. sqlCity += " City like '%" + sqlName[i] + "%' or";
  191. sqlwhere += sqlCity;
  192. }
  193. else sqlwhere += " and Country like '%" + Country + "%' ";
  194. }
  195. if (!string.IsNullOrWhiteSpace(unitName)) sqlwhere += " and UnitName like '%" + unitName + "%' ";
  196. if (!string.IsNullOrWhiteSpace(ddlOP)) sqlwhere += " and Operator ="+ ddlOP + "";
  197. if (!string.IsNullOrWhiteSpace(contact)) {
  198. if (contact == "未设置") sqlwhere += " and Contact = '' ";
  199. else sqlwhere += " and Contact like '%" + contact + "%' ";
  200. }
  201. if (!string.IsNullOrWhiteSpace(delegation)) {
  202. if (delegation == "未设置") sqlwhere += " and Delegation = '' ";
  203. else sqlwhere += " and Delegation like '%" + delegation + "%' ";
  204. }
  205. if (!string.IsNullOrWhiteSpace(domain)) {
  206. if (domain == "未设置") sqlwhere += " and Field = '' ";
  207. else sqlwhere += " and Field like '%" + domain + "%' ";
  208. }
  209. return PageBase<InvitationOfficialActivityData>.excutePageSql(new InvitationOfficialActivityData(), "InvitationOfficialActivityData", "InvitationOfficialActivityData", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  210. }
  211. /// <summary>
  212. /// 增加
  213. /// </summary>
  214. /// <param name="cd"></param>
  215. /// <returns></returns>
  216. public bool AddInvitationOfficialActivityData(InvitationOfficialActivityData ctggd)
  217. {
  218. string sql = "insert into InvitationOfficialActivityData values(@Country,@City,@UnitName,@UnitWeb,@Field,@Address,@UnitInfo,"
  219. + "@Contact,@Job,@Tel,@Email,@WeChat,@FaceBook,@Ins,@Delegation,@FileName,@FilePath,@SndFileName,@SndFilePath,@OtherInformation,"
  220. + "@Fax,@Operator,@OperatorDate,@IsDel,@Backdrop)";
  221. SqlParameter[] parameter = new SqlParameter[]{
  222. new SqlParameter("@Country",ctggd.Country),
  223. new SqlParameter("@City",ctggd.City),
  224. new SqlParameter("@UnitName",ctggd.UnitName),
  225. new SqlParameter("@UnitWeb",ctggd.UnitWeb),
  226. new SqlParameter("@Field",ctggd.Field),
  227. new SqlParameter("@Address",ctggd.Address),
  228. new SqlParameter("@UnitInfo",ctggd.UnitInfo),
  229. new SqlParameter("@Contact",ctggd.Contact),
  230. new SqlParameter("@Job",ctggd.Job),
  231. new SqlParameter("@Tel",ctggd.Tel),
  232. new SqlParameter("@Email",ctggd.Email),
  233. new SqlParameter("@WeChat",ctggd.WeChat),
  234. new SqlParameter("@FaceBook",ctggd.FaceBook),
  235. new SqlParameter("@Ins",ctggd.Ins),
  236. new SqlParameter("@Delegation",ctggd.Delegation),
  237. new SqlParameter("@FileName",ctggd.FileName),
  238. new SqlParameter("@FilePath",ctggd.FilePath),
  239. new SqlParameter("@SndFileName",ctggd.SndFileName),
  240. new SqlParameter("@SndFilePath",ctggd.SndFilePath),
  241. new SqlParameter("@OtherInformation",ctggd.OtherInformation),
  242. new SqlParameter("@Fax",ctggd.Fax),
  243. new SqlParameter("@Operator",ctggd.Operators),
  244. new SqlParameter("@OperatorDate",ctggd.OperatorsDate),
  245. new SqlParameter("@IsDel",ctggd.IsDel),
  246. new SqlParameter("@Backdrop",ctggd.Backdrop)
  247. };
  248. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  249. return true;
  250. return false;
  251. }
  252. /// <summary>
  253. /// 编辑
  254. /// </summary>
  255. /// <param name="sdt"></param>
  256. /// <returns></returns>
  257. public bool EditInvitationOfficialActivityData(InvitationOfficialActivityData ctggd)
  258. {
  259. string sql = "update InvitationOfficialActivityData set Country=@Country,City=@City,UnitName=@UnitName,UnitWeb=@UnitWeb,"
  260. + "Field=@Field,Address=@Address,UnitInfo=@UnitInfo,Contact=@Contact,Job=@Job,Tel=@Tel,Email=@Email,WeChat=@WeChat,"
  261. + "FaceBook=@FaceBook,Ins=@Ins,Delegation=@Delegation,FileName=@FileName,FilePath=@FilePath,SndFileName=@SndFileName,SndFilePath=@SndFilePath,OtherInformation=@OtherInformation,Fax=@Fax,Operator=@Operator,"
  262. + "OperatorDate=@OperatorDate,IsDel=@IsDel,Backdrop=@Backdrop where Id = @Id";
  263. SqlParameter[] parameter = new SqlParameter[]{
  264. new SqlParameter("@Country",ctggd.Country),
  265. new SqlParameter("@City",ctggd.City),
  266. new SqlParameter("@UnitName",ctggd.UnitName),
  267. new SqlParameter("@UnitWeb",ctggd.UnitWeb),
  268. new SqlParameter("@Field",ctggd.Field),
  269. new SqlParameter("@Address",ctggd.Address),
  270. new SqlParameter("@UnitInfo",ctggd.UnitInfo),
  271. new SqlParameter("@Contact",ctggd.Contact),
  272. new SqlParameter("@Job",ctggd.Job),
  273. new SqlParameter("@Tel",ctggd.Tel),
  274. new SqlParameter("@Email",ctggd.Email),
  275. new SqlParameter("@WeChat",ctggd.WeChat),
  276. new SqlParameter("@FaceBook",ctggd.FaceBook),
  277. new SqlParameter("@Ins",ctggd.Ins),
  278. new SqlParameter("@Delegation",ctggd.Delegation),
  279. new SqlParameter("@FileName",ctggd.FileName),
  280. new SqlParameter("@FilePath",ctggd.FilePath),
  281. new SqlParameter("@SndFileName",ctggd.SndFileName),
  282. new SqlParameter("@SndFilePath",ctggd.SndFilePath),
  283. new SqlParameter("@OtherInformation",ctggd.OtherInformation),
  284. new SqlParameter("@Fax",ctggd.Fax),
  285. new SqlParameter("@Operator",ctggd.Operators),
  286. new SqlParameter("@OperatorDate",ctggd.OperatorsDate),
  287. new SqlParameter("@IsDel",ctggd.IsDel),
  288. new SqlParameter("@Id",ctggd.Id),
  289. new SqlParameter("@Backdrop",ctggd.Backdrop)
  290. };
  291. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  292. return true;
  293. return false;
  294. }
  295. public bool AddAssociationGroup(int id1, int id2,int Diid)
  296. {
  297. string sql = "insert into AssociationGroup values(@id1,@id2,@Diid)";
  298. SqlParameter[] parameter = new SqlParameter[]{
  299. new SqlParameter("@id1",id1),
  300. new SqlParameter("@id2",id2),
  301. new SqlParameter("@Diid",Diid)
  302. };
  303. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  304. return true;
  305. return false;
  306. }
  307. /// <summary>
  308. /// 删除
  309. /// </summary>
  310. /// <param name="id"></param>
  311. /// <returns></returns>
  312. public bool DelInvitationOfficialActivityData(int id)
  313. {
  314. if (SqlHelper.ExecuteNonQuery("update InvitationOfficialActivityData set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  315. return true;
  316. return false;
  317. }
  318. /// <summary>
  319. /// 查询某时间段的录入数量
  320. /// </summary>
  321. /// <param name="op"></param>
  322. /// <param name="start"></param>
  323. /// <param name="end"></param>
  324. /// <returns></returns>
  325. public List<InvitationOfficialActivityData> getBYOP(string op, string start, string end)
  326. {
  327. //调用获取单个对象的方法
  328. return excuteSql("select * from InvitationOfficialActivityData where Isdel=0 and Operator=" + op + " and ( OperatorDate between '" + start + "' and '" + end + "')");
  329. }
  330. /// <summary>
  331. /// 查找录入者
  332. /// </summary>
  333. /// <returns></returns>
  334. public DataTable getOP()
  335. {
  336. DataTable dt = SqlHelper.TransferProcedure("OP_SELECT", CommandType.StoredProcedure);
  337. if (dt != null && dt.Rows.Count > 0)
  338. {
  339. try
  340. {
  341. return dt;
  342. }
  343. catch
  344. {
  345. return null;
  346. }
  347. }
  348. else
  349. return null;
  350. }
  351. }
  352. }