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