示例#1
0
        public ActionResult Edit(int id = 0)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.ClassAllotStudent.Edit();
                vm.GradeList     = GradeController.SelectList();
                vm.ClassTypeList = ClassTypeController.SelectList();
                vm.YearList      = YearController.SelectList(Code.EnumHelper.YearType.Year);
                if (vm.ClassAllotStudentEdit.YearId == 0 && vm.YearList.Count > 0)
                {
                    vm.ClassAllotStudentEdit.YearId = vm.YearList.OrderByDescending(d => d.Selected).FirstOrDefault().Value.ConvertToInt();
                }

                if (id != 0)
                {
                    vm.ClassAllotStudentEdit = (from p in db.Table <Basis.Entity.tbClassAllotStudent>()
                                                where p.Id == id
                                                select new Dto.ClassAllotStudent.Edit
                    {
                        Id = p.Id,
                        YearId = p.tbYear.Id,
                        ClassTypeId = p.tbClassType.Id,
                        GradeId = p.tbGrade.Id,
                        Score = p.Score,
                        StudentCode = p.tbStudent.StudentCode,
                        StudentName = p.tbStudent.StudentName
                    }).FirstOrDefault();
                }

                return(View(vm));
            }
        }
        public ActionResult ClassStudentList()
        {
            var vm = new Models.ClassStudent.ClassStudentList();

            using (var db = new XkSystem.Models.DbContext())
            {
                vm.ClassTypeList = ClassTypeController.SelectList();
                vm.GradeList     = GradeController.SelectList();
                vm.YearList      = YearController.SelectList(Code.EnumHelper.YearType.Year);
                if (vm.YearId == 0 && vm.YearList.Count > 0)
                {
                    vm.YearId = vm.YearList.OrderByDescending(d => d.Selected).FirstOrDefault().Value.ConvertToInt();
                }

                vm.ClassList = ClassController.SelectList(vm.YearId ?? 0, vm.GradeId);

                var tb = db.Table <Basis.Entity.tbClassStudent>();
                if (vm.ClassTypeId > 0)
                {
                    tb = tb.Where(d => d.tbClass.tbClassType.Id == vm.ClassTypeId);
                }

                if (vm.GradeId > 0)
                {
                    tb = tb.Where(d => d.tbClass.tbGrade.Id == vm.GradeId);
                }

                if (vm.YearId > 0)
                {
                    tb = tb.Where(d => d.tbClass.tbYear.Id == vm.YearId);
                }

                if (vm.ClassId != 0)
                {
                    tb = tb.Where(d => d.tbClass.Id == vm.ClassId);
                }

                if (!string.IsNullOrEmpty(vm.SearchText))
                {
                    tb = tb.Where(d => d.tbStudent.StudentCode.Contains(vm.SearchText) || d.tbStudent.StudentName.Contains(vm.SearchText));
                }

                vm.List = (from p in tb
                           orderby p.tbClass.No, p.tbStudent.StudentCode
                           select new Dto.ClassStudent.ClassStudentList()
                {
                    ClassId = p.tbClass.Id,
                    ClassName = p.tbClass.ClassName,
                    GradeName = p.tbClass.tbGrade.GradeName,
                    Id = p.Id,
                    No = p.No,
                    SexName = p.tbStudent.tbSysUser.tbSex.SexName,
                    StudentCode = p.tbStudent.StudentCode,
                    StudentId = p.tbStudent.Id,
                    StudentName = p.tbStudent.StudentName
                }).ToPageList(vm.Page);
            }

            return(View(vm));
        }
        public ActionResult Batch()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.ClassAllotClass.Batch();
                vm.YearList = YearController.SelectList(Code.EnumHelper.YearType.Year);
                if (vm.BatchEdit.YearId == 0 && vm.YearList.Count > 0)
                {
                    vm.BatchEdit.YearId = vm.YearList.OrderByDescending(d => d.Selected).FirstOrDefault().Value.ConvertToInt();
                }
                vm.GradeList     = GradeController.SelectList();
                vm.ClassTypeList = ClassTypeController.SelectList();

                return(View(vm));
            }
        }
示例#4
0
        public ActionResult List()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.ClassAllotStudent.List();
                vm.YearList = YearController.SelectList(Code.EnumHelper.YearType.Year);
                if (vm.YearId == 0 && vm.YearList.Count > 0)
                {
                    vm.YearId = vm.YearList.OrderByDescending(d => d.Selected).FirstOrDefault().Value.ConvertToInt();
                }
                vm.ClassTypeList = ClassTypeController.SelectList();
                vm.SexList       = Dict.Controllers.DictSexController.SelectList();

                var tb = from p in db.Table <Basis.Entity.tbClassAllotStudent>()
                         where p.tbYear.Id == vm.YearId
                         select p;
                if (!string.IsNullOrEmpty(vm.SearchText))
                {
                    tb = tb.Where(d => d.tbStudent.StudentName.Contains(vm.SearchText) || d.tbStudent.StudentCode.Contains(vm.SearchText));
                }
                if (vm.ClassTypeId != 0)
                {
                    tb = tb.Where(d => d.tbClassType.Id == vm.ClassTypeId);
                }
                if (vm.SexId != 0)
                {
                    tb = tb.Where(d => d.tbStudent.tbSysUser.tbSex.Id == vm.SexId);
                }

                vm.ClassAllotStudentList = (from p in tb
                                            orderby p.tbStudent.StudentCode, p.tbStudent.StudentName
                                            select new Dto.ClassAllotStudent.List
                {
                    Id = p.Id,
                    Score = p.Score,
                    ClassTypeName = p.tbClassType.ClassTypeName,
                    GradeName = p.tbGrade.GradeName,
                    StudentCode = p.tbStudent.StudentCode,
                    StudentName = p.tbStudent.StudentName,
                    Sex = p.tbStudent.tbSysUser.tbSex.SexName
                }).ToPageList(vm.Page);

                return(View(vm));
            }
        }