Ejemplo n.º 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));
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }