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 YearMonthService { // /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new YearMonth(), "YearMonth", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 YearMonth excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List ymList = excuteSql(sql, param); //判断集合是否为空 if (ymList == null || ymList.Count == 0) //返回null return null; //返回单个对象 return ymList[0]; } /// /// 查询年月 /// /// public List GetYearMonth() { return excuteSql("select DISTINCT SubString(SwipeDate,0,8) as YearMonths from attendanceData order by SubString(SwipeDate,0,8) desc"); } /// /// 获取工作日 /// /// /// /// public List GetCalendarWeekCount(string starDate, string endDate) { string sql = "select distinct calendarDate as YearMonths from Calendar where ctid = 0 and (calendardate between '" + starDate + "' and '" + endDate + "')"; return excuteSql(sql); } /// /// 在考核表里查询年月 /// /// public List GetYearMonthOnMonthKpiItemScore() { return excuteSql("select distinct YearMonth as YearMonths from MonthKpiItemScore order by YearMonth asc"); } /// /// 判断考勤是否有大于28日但是月份没有+1时的情况 /// /// public YearMonth GetLastDate() { return excuteType("select DISTINCT(SwipeDate) as YearMonths from attendanceData order by SwipeDate desc"); } } }