ViewDelegationInfoAndForeignReceivablesService.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 ViewDelegationInfoAndForeignReceivablesService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<ViewDelegationInfoAndForeignReceivables> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<ViewDelegationInfoAndForeignReceivables>.excuteSql(new ViewDelegationInfoAndForeignReceivables(), "ViewDelegationInfoAndForeignReceivables", 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. ViewDelegationInfoAndForeignReceivables excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<ViewDelegationInfoAndForeignReceivables> adList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (adList == null || adList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return adList[0];
  41. }
  42. /// <summary>
  43. /// 根据出访日期获取数据集合
  44. /// </summary>
  45. /// <param name="userNumber"></param>
  46. /// <param name="swipeDate"></param>
  47. /// <returns></returns>
  48. public List<ViewDelegationInfoAndForeignReceivables> GetByTime(string startTime, string endTime)
  49. {
  50. //return excuteSql("select distinct fr.diid,di.TeamName,di.ClientUnit,di.VisitDate from ForeignReceivables fr join DelegationInfo di on fr.DIID = di.id where di.VisitDate between '" + startTime + "' and '" + endTime + "' and issure=1 and di.isdel=0 ");
  51. return excuteSql("select distinct fr.diid,di.TeamName,di.ClientUnit,di.VisitDate from ForeignReceivables fr join DelegationInfo di on fr.DIID = di.id where di.VisitDate between '" + startTime + "' and '" + endTime + "' and di.isdel=0 order by di.VisitDate asc");
  52. }
  53. /// <summary>
  54. ///
  55. /// </summary>
  56. /// <param name="startTime"></param>
  57. /// <param name="endTime"></param>
  58. /// <param name="Type">(团组收入,会务收入,赛事项目收入,其他非团组收入)</param>
  59. /// <returns></returns>
  60. public List<ViewDelegationInfoAndForeignReceivables> GetByTimeAndType(string startTime, string endTime,string Type)
  61. {
  62. string sql = string.Empty;
  63. switch (Type)
  64. {
  65. case "团组收入":
  66. sql = $@"select distinct a.Id as diid,a.TeamName,a.ClientUnit,a.VisitDate from DelegationInfo a,SetData b ,ForeignReceivables c
  67. where a.TeamDid = b.Id and a.Id = c.DIId and b.id in(38,39,40)
  68. and a.VisitDate between '{startTime}' and '{endTime}' and a.IsDel = 0 ";
  69. break;
  70. case "会务收入":
  71. sql = $@"select distinct a.Id as diid,a.TeamName,a.ClientUnit,a.VisitDate from DelegationInfo a,SetData b ,ForeignReceivables c
  72. where a.TeamDid = b.Id and a.Id = c.DIId and b.id in(691)
  73. and a.VisitDate between '{startTime}' and '{endTime}' and a.IsDel = 0 ";
  74. break;
  75. case "赛事项目收入":
  76. sql = $@" select distinct a.Id as diid,a.TeamName,a.ClientUnit,a.VisitDate from DelegationInfo a,SetData b ,ForeignReceivables c
  77. where a.TeamDid = b.Id and a.Id = c.DIId and b.id in(762)
  78. and a.VisitDate between '{startTime}' and '{endTime}' and a.IsDel = 0 ";
  79. break;
  80. case "其他非团组收入":
  81. sql = $@" select distinct a.Id as diid,a.TeamName,a.ClientUnit,a.VisitDate from DelegationInfo a,SetData b ,ForeignReceivables c
  82. where a.TeamDid = b.Id and a.Id = c.DIId and b.id not in(762,691,38,39,40)
  83. and a.VisitDate between '{startTime}' and '{endTime}' and a.IsDel = 0 ";
  84. break;
  85. }
  86. if (string.IsNullOrEmpty(sql))
  87. {
  88. return new List<ViewDelegationInfoAndForeignReceivables>();
  89. }
  90. return excuteSql(sql);
  91. }
  92. }
  93. }