public ActionResult BmListAjax(GridCommand cmd, SerchStudentModel sModel)
        {
            #region 时间初始化
            sModel.sTime = new DateTime(1949, 1, 1, 0, 0, 0);
            sModel.eTime = DateTime.Now;
            if (!string.IsNullOrEmpty(sModel.startTime))
            {
                sModel.sTime = Convert.ToDateTime(sModel.startTime);
            }


            if (!string.IsNullOrEmpty(sModel.endTime))
            {
                sModel.eTime = Convert.ToDateTime(sModel.endTime).AddMinutes(1439);
            }
            #endregion

            var queryData = _iEnrolSysService.getStudentInfoBySearch(sModel, cmd.PageSize, cmd.Page - 1);
            var PageList  = queryData.ToList();

            var result = new GridModel <StudentInfo>()
            {
                Data  = PageList,
                Total = queryData.TotalCount
            };
            //return this.Json()
            //return new JsonResult() { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
            return(new VMEJsonResult()
            {
                Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult ExportStudent(SerchStudentModel sModel)
        {
            #region 时间初始化
            sModel.sTime = new DateTime(1949, 1, 1, 0, 0, 0);
            sModel.eTime = DateTime.Now;
            if (!string.IsNullOrEmpty(sModel.startTime))
            {
                sModel.sTime = Convert.ToDateTime(sModel.startTime);
            }


            if (!string.IsNullOrEmpty(sModel.endTime))
            {
                sModel.eTime = Convert.ToDateTime(sModel.endTime).AddMinutes(1439);
            }
            #endregion

            var studentList = _iEnrolSysService.ExportStudentInfos(sModel);


            string   path        = System.Web.HttpContext.Current.Server.MapPath("~/Excel/StudentInfo.xlsx");
            string   templetPath = System.Web.HttpContext.Current.Server.MapPath("~/Excel/TempStudentInfo.xlsx");
            FileInfo info        = new FileInfo(path);
            FileInfo temp        = new FileInfo(templetPath);
            var      exp         = new HC.Core.Common.ExportExcel.ExportExcel();
            exp.ExportExcelStudentInfo(info, temp, ToDataTable <StudentInfo>(studentList.ToList()));
            return(File(path, "application/octet-stream", "报名学生信息导出.xlsx"));
        }
Пример #3
0
        public IList <StudentInfo> ExportStudentInfos(SerchStudentModel sModel)
        {
            var query = _StudentInfoRepository.Table;


            query = query.Where(x => x.RegisterTime >= sModel.sTime && x.RegisterTime <= sModel.eTime);


            if (!string.IsNullOrEmpty(sModel.StudentName))
            {
                query = query.Where(x => x.StudentName.Contains(sModel.StudentName));
            }
            if (!string.IsNullOrEmpty(sModel.StCardNo))
            {
                query = query.Where(x => x.SelfCardNo == sModel.StCardNo);
            }
            if (!string.IsNullOrEmpty(sModel.StFrom))
            {
                query = query.Where(x => x.Sfrom == sModel.StFrom);
            }

            return(query.ToList());
        }