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