YearMonthService.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 YearMonthService
  14. {
  15. // <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<YearMonth> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<YearMonth>.excuteSql(new YearMonth(), "YearMonth", 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. YearMonth excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<YearMonth> ymList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (ymList == null || ymList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return ymList[0];
  41. }
  42. /// <summary>
  43. /// 查询年月
  44. /// </summary>
  45. /// <returns></returns>
  46. public List<YearMonth> GetYearMonth()
  47. {
  48. return excuteSql("select DISTINCT SubString(SwipeDate,0,8) as YearMonths from attendanceData order by SubString(SwipeDate,0,8) desc");
  49. }
  50. /// <summary>
  51. /// 获取工作日
  52. /// </summary>
  53. /// <param name="starDate"></param>
  54. /// <param name="endDate"></param>
  55. /// <returns></returns>
  56. public List<YearMonth> GetCalendarWeekCount(string starDate, string endDate)
  57. {
  58. string sql = "select distinct calendarDate as YearMonths from Calendar where ctid = 0 and (calendardate between '" + starDate + "' and '" + endDate + "')";
  59. return excuteSql(sql);
  60. }
  61. /// <summary>
  62. /// 在考核表里查询年月
  63. /// </summary>
  64. /// <returns></returns>
  65. public List<YearMonth> GetYearMonthOnMonthKpiItemScore()
  66. {
  67. return excuteSql("select distinct YearMonth as YearMonths from MonthKpiItemScore order by YearMonth asc");
  68. }
  69. /// <summary>
  70. /// 判断考勤是否有大于28日但是月份没有+1时的情况
  71. /// </summary>
  72. /// <returns></returns>
  73. public YearMonth GetLastDate()
  74. {
  75. return excuteType("select DISTINCT(SwipeDate) as YearMonths from attendanceData order by SwipeDate desc");
  76. }
  77. }
  78. }