ViewUpCardAuditService.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 ViewUpCardAuditService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<ViewUpCardAudit> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<ViewUpCardAudit>.excuteSql(new ViewUpCardAudit(), "ViewUpCardAudit", 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. ViewUpCardAudit excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<ViewUpCardAudit> cdList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (cdList == null || cdList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return cdList[0];
  41. }
  42. /// <summary>
  43. /// 查询信息
  44. /// </summary>
  45. /// <returns>返回空或者对象信息</returns>
  46. public List<ViewUpCardAudit> GetViewUpCardAudit(int uid, string yearMonth)
  47. {
  48. //调用获取单个对象的方法
  49. return excuteSql("select uca.Uid,uca.YearMonth,uca.IsAudit,ucac.upcardHours from UpCardAudit uca join UpCardAuditContent ucac on uca.id = ucac.UCAid where uca.isDel = 0 and ucac.isdel=0 and did = 31 and isAudit = 1 and uid = " + uid + " and yearMonth='" + yearMonth + "'");
  50. }
  51. /// <summary>
  52. /// 查询信息
  53. /// </summary>
  54. /// <returns>返回空或者对象信息</returns>
  55. public double GetViewUpCardAuditSumHours(int uid, string yearMonth)
  56. {
  57. object obj = SqlHelper.ExecuteScalar("select sum(ucac.upcardHours) from UpCardAudit uca join UpCardAuditContent ucac on uca.id = ucac.UCAid where uca.isDel = 0 and ucac.isdel=0 and did = 31 and isAudit = 1 and uid = " + uid + " and yearMonth='" + yearMonth + "'", CommandType.Text);
  58. double sumHours = 0;
  59. if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
  60. sumHours = Convert.ToDouble(obj);
  61. //调用获取单个对象的方法
  62. return sumHours;
  63. }
  64. /// <summary>
  65. /// 查询信息
  66. /// </summary>
  67. /// <returns>返回空或者对象信息</returns>
  68. public double GetViewUpCardAuditSumHoursBingJia(int uid, string yearMonth)
  69. {
  70. object obj = SqlHelper.ExecuteScalar("select sum(ucac.upcardHours) from UpCardAudit uca join UpCardAuditContent ucac on uca.id = ucac.UCAid where uca.isDel = 0 and ucac.isdel=0 and did = 32 and isAudit = 1 and uid = " + uid + " and yearMonth='" + yearMonth + "'", CommandType.Text);
  71. double sumHours = 0;
  72. if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
  73. sumHours = Convert.ToDouble(obj);
  74. //调用获取单个对象的方法
  75. return sumHours;
  76. }
  77. /// <summary>
  78. /// 查询员工加班抵休小时数
  79. /// </summary>
  80. /// <returns>返回空或者对象信息</returns>
  81. public double GetViewUpCardAuditSumHour(int uid, string yearMonth)
  82. {
  83. object obj = SqlHelper.ExecuteScalar("select sum(ucac.upcardHours) from UpCardAudit uca join UpCardAuditContent ucac on uca.id = ucac.UCAid where uca.isDel = 0 and ucac.isdel=0 and did = 31 and isAudit = 1 and uid = " + uid + " and yearMonth='" + yearMonth + "'", CommandType.Text);
  84. double sumHours = 0;
  85. if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
  86. sumHours = Convert.ToDouble(obj);
  87. //调用获取单个对象的方法
  88. return sumHours;
  89. }
  90. /// <summary>
  91. /// 根据年月和员工id查询该员工事假信息
  92. /// </summary>
  93. /// <param name="uid"></param>
  94. /// <param name="yearMonth"></param>
  95. /// <returns></returns>
  96. public DataTable GetUpcardHoursByUidAndTime(int uid, string yearMonth, string startDate, string endDate)
  97. {
  98. return SqlHelper.TransferProcedure("Wage_QueryByUidAndMonth", CommandType.StoredProcedure, new SqlParameter("@uid", uid), new SqlParameter("@yearMonth", yearMonth), new SqlParameter("@startDate", startDate), new SqlParameter("@endDate", endDate));
  99. }
  100. /// <summary>
  101. /// 查询已审核的事假,年假,病假,加班抵修的日期
  102. /// </summary>
  103. /// <returns>返回空或者对象信息</returns>
  104. public List<ViewUpCardAudit> GetViewUpCardAuditDelMeal(int uid, string yearMonth)
  105. {
  106. //调用获取单个对象的方法
  107. return excuteSql("select uca.Uid,uca.YearMonth,uca.IsAudit,ucac.upcardHours,ucac.Did from UpCardAudit uca join UpCardAuditContent ucac on uca.id = ucac.UCAid where uca.isDel = 0 and ucac.isdel=0 and did in(31,32,33,281,340,293,299,568) and isAudit = 1 and uid = " + uid + " and yearMonth='" + yearMonth + "'");
  108. }
  109. /// <summary>
  110. /// 查询指定时间段已审核的事假,年假,病假,加班抵修的日期
  111. /// </summary>
  112. /// <returns>返回空或者对象信息</returns>
  113. public List<ViewUpCardAudit> GetViewUpCardAuditDelMeal(int uid, string yearMonth, string start, string end)
  114. {
  115. //调用获取单个对象的方法
  116. return excuteSql("select uca.Uid,uca.YearMonth,uca.IsAudit,ucac.upcardHours,ucac.Did from UpCardAudit uca join UpCardAuditContent ucac on uca.id = ucac.UCAid where uca.isDel = 0 and ucac.isdel=0 and did in(31,32,33,281,340,293,299,568) and isAudit = 1 and uid = " + uid + " and yearMonth='" + yearMonth + "' and (ucac.UpCardDate BETWEEN '" + start + "' and '" + end + "')");
  117. }
  118. }
  119. }