12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data.SqlClient;
- using System.Data;
- namespace DAL
- {
- /// <summary>
- /// 工资查询考勤多表联查多表联查类 - 用于算迟到、早退、未打卡、旷工
- /// </summary>
- public class ViewWageSelectADService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<ViewWageSelectAD> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<ViewWageSelectAD>.excuteSql(new ViewWageSelectAD(), "ViewWageSelectAD", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- ViewWageSelectAD excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<ViewWageSelectAD> ctggdList = excuteSql(sql, param);
- //判断集合是否为空
- if (ctggdList == null || ctggdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return ctggdList[0];
- }
- /// <summary>
- /// 查询集合 - 获取员工已打卡信息
- /// </summary>
- /// <param name="userNumber"></param>
- /// <param name="startDate"></param>
- /// <param name="endDate"></param>
- /// <returns></returns>
- public List<ViewWageSelectAD> GetAll(string userNumber, string startDate,string endDate)
- {
- //调用获取单个对象的方法
- 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");
- }
- /// <summary>
- /// 查询集合 - 获取财务已打卡信息
- /// </summary>
- /// <param name="userNumber"></param>
- /// <param name="startDate"></param>
- /// <param name="endDate"></param>
- /// <returns></returns>
- public List<ViewWageSelectAD> GetAllZ(string userNumber, string startDate, string endDate)
- {
- //调用获取单个对象的方法
- 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");
- }
- }
- }
|