ViewWageSelectADService.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 ViewWageSelectADService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<ViewWageSelectAD> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<ViewWageSelectAD>.excuteSql(new ViewWageSelectAD(), "ViewWageSelectAD", 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. ViewWageSelectAD excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<ViewWageSelectAD> ctggdList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (ctggdList == null || ctggdList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return ctggdList[0];
  41. }
  42. /// <summary>
  43. /// 查询集合 - 获取员工已打卡信息
  44. /// </summary>
  45. /// <param name="userNumber"></param>
  46. /// <param name="startDate"></param>
  47. /// <param name="endDate"></param>
  48. /// <returns></returns>
  49. public List<ViewWageSelectAD> GetAll(string userNumber, string startDate,string endDate)
  50. {
  51. //调用获取单个对象的方法
  52. return excuteSql("select SwipeDate,UserNumber,max(case when SwipeTime > '00:00' and SwipeTime < '12:00' then SwipeTime else null end) A,max(case when SwipeTime >= '12:00' and SwipeTime < '13:00' then SwipeTime else null end) B,max(case when SwipeTime >= '13:00' and SwipeTime < ='13:30' then SwipeTime else null end) C,max(case when SwipeTime >= '14:00' and SwipeTime <= '23:59' then SwipeTime else null end) D from AttendanceData where userNumber = '"+userNumber+"' and (SwipeDate between '"+startDate+"' and '"+endDate+"') group by SwipeDate,userNumber order by SwipeDate asc");
  53. }
  54. /// <summary>
  55. /// 查询集合 - 获取财务已打卡信息
  56. /// </summary>
  57. /// <param name="userNumber"></param>
  58. /// <param name="startDate"></param>
  59. /// <param name="endDate"></param>
  60. /// <returns></returns>
  61. public List<ViewWageSelectAD> GetAllZ(string userNumber, string startDate, string endDate)
  62. {
  63. //调用获取单个对象的方法
  64. return excuteSql("select SwipeDate,UserNumber,max(case when SwipeTime > '00:00' and SwipeTime < '12:00' then SwipeTime else null end) A,max(case when SwipeTime >= '12:00' and SwipeTime < '12:20' then SwipeTime else null end) B,max(case when SwipeTime >= '12:20' and SwipeTime < '14:00' then SwipeTime else null end) C,max(case when SwipeTime >= '14:00' and SwipeTime <= '23:59' then SwipeTime else null end) D from AttendanceData where userNumber = '" + userNumber + "' and (SwipeDate between '" + startDate + "' and '" + endDate + "') group by SwipeDate,userNumber order by SwipeDate asc");
  65. }
  66. }
  67. }