public ActionResult Index(int?page)
        {
            int pageIndex = PagingHelper.GetPageIndex(page);
            AttendanceRecordDetailSearchModel q  = new AttendanceRecordDetailSearchModel();
            IAttendanceRecordDetailService    ss = new AttendanceRecordDetailService(Settings.Default.db);

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

            ViewBag.Query = q;
            SetShiftList();
            return(View(records));
        }
        public ActionResult Search([Bind(Include = "CompanyId,DepartmentId,StaffNr,RecordAtFrom,RecordAtEnd")] AttendanceRecordDetailSearchModel q)
        {
            int pageIndex = 0;

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

            IAttendanceRecordDetailService ss = new AttendanceRecordDetailService(Settings.Default.db);

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

            ViewBag.Query = q;
            SetShiftList();
            return(View("Index", records));
        }
        public IQueryable <AttendanceRecordDetailView> Search(AttendanceRecordDetailSearchModel searchModel)
        {
            IQueryable <AttendanceRecordDetailView> q = this.context.AttendanceRecordDetailView;

            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.RecordAtFrom.HasValue)
            {
                q = q.Where(s => s.recordAt >= searchModel.RecordAtFrom);
            }

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

            //   AS[t0] ORDER BY[t0].[staffNr], [t0].[recordAt] DESC
            // 因为建立了staffnr asc + recordat desc 的索引
            return(q.OrderByDescending(s => s.recordAt).OrderBy(s => s.staffNr));
        }
示例#4
0
        /// <summary>
        /// 搜索详细考勤信息视图, 包含员工的信息
        /// </summary>
        /// <param name="searchModel"></param>
        /// <returns></returns>
        public IQueryable <AttendanceRecordDetailView> SearchDetailView(AttendanceRecordDetailSearchModel searchModel)
        {
            IAttendanceRecordDetailViewRepository rep = new AttendanceRecordDetailViewRepository(new DataContext(this.DbString));

            return(rep.Search(searchModel));
        }