public IQueryable <AttendanceRecordCalView> Search(AttendanceRecordCalSearchModel searchModel)
        {
            IQueryable <AttendanceRecordCalView> q = this.context.AttendanceRecordCalView;

            if (!string.IsNullOrEmpty(searchModel.StaffNr))
            {
                q = q.Where(s => s.staffNr.Contains(searchModel.StaffNr));
            }

            if (!string.IsNullOrEmpty(searchModel.StaffNrAct))
            {
                q = q.Where(s => s.staffNr.Equals(searchModel.StaffNrAct));
            }

            if (searchModel.companyId.HasValue)
            {
                q = q.Where(s => s.companyId.Equals(searchModel.companyId.Value));
            }


            if (searchModel.departmentId.HasValue)
            {
                q = q.Where(s => s.departmentId.Equals(searchModel.departmentId.Value));
            }

            if (searchModel.AttendanceDateFrom.HasValue)
            {
                q = q.Where(s => s.attendanceDate >= searchModel.AttendanceDateFrom);
            }

            if (searchModel.AttendanceDateEnd.HasValue)
            {
                q = q.Where(s => s.attendanceDate <= searchModel.AttendanceDateEnd);
            }

            if (searchModel.IsException.HasValue)
            {
                q = q.Where(s => s.isException.Equals(searchModel.IsException.Value));
            }

            if (searchModel.IsExceptionHandled.HasValue)
            {
                q = q.Where(s => s.isExceptionHandled.Equals(searchModel.IsExceptionHandled.Value));
            }
            // AS [t0] ORDER BY [t0].[recordAt] DESC, [t0].[attendanceDate]
            //return q.OrderBy(s => s.staffNr).OrderByDescending(s => s.attendanceDate);

            //   AS[t0] ORDER BY[t0].[staffNr], [t0].[attendanceDate] DESC
            // 因为建立了staffnr asc + recordat desc 的索引
            return(q.OrderByDescending(s => s.attendanceDate).OrderBy(s => s.staffNr));
        }
Esempio n. 2
0
        public ActionResult Index(int?page)
        {
            int pageIndex = PagingHelper.GetPageIndex(page);
            AttendanceRecordCalSearchModel q  = new AttendanceRecordCalSearchModel();
            IAttendanceRecordCalService    ss = new AttendanceRecordCalService(Settings.Default.db);

            IPagedList <AttendanceRecordCalView> records = ss.SearchCalView(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            SetExtraWorkTypeList(null);

            return(View(records));
        }
Esempio n. 3
0
        public ActionResult Search([Bind(Include = "CompanyId,DepartmentId,StaffNr,IsException,IsExceptionHandled,AttendanceDateFrom,AttendanceDateEnd")] AttendanceRecordCalSearchModel q)
        {
            int pageIndex = 0;

            int.TryParse(Request.QueryString.Get("page"), out pageIndex);
            pageIndex = PagingHelper.GetPageIndex(pageIndex);

            IAttendanceRecordCalService          ss      = new AttendanceRecordCalService(Settings.Default.db);
            IPagedList <AttendanceRecordCalView> records = ss.SearchCalView(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            SetExtraWorkTypeList(null);

            return(View("Index", records));
        }
Esempio n. 4
0
        /// <summary>
        /// 搜索统计考勤信息视图, 包含员工的信息
        /// </summary>
        /// <param name="searchModel"></param>
        /// <returns></returns>
        public IQueryable <AttendanceRecordCalView> SearchCalView(AttendanceRecordCalSearchModel searchModel)
        {
            IAttendanceRecordCalViewRepository rep = new AttendanceRecordCalViewRepository(new DataContext(this.DbString));

            return(rep.Search(searchModel));
        }