コード例 #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));
            }
        }
コード例 #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));
        }
コード例 #3
0
        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));
            }
        }
コード例 #5
0
        public ActionResult List()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.ClassAllotClass.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();
                }

                var tb = from p in db.Table <Basis.Entity.tbClassAllotClass>()
                         select p;
                if (!string.IsNullOrEmpty(vm.SearchText))
                {
                    tb = tb.Where(d => d.ClassName.Contains(vm.SearchText));
                }
                if (vm.YearId > 0)
                {
                    tb = tb.Where(d => d.tbYear.Id == vm.YearId);
                }

                vm.ClassAllotClassList = (from p in tb
                                          orderby p.No, p.ClassName
                                          select new Dto.ClassAllotClass.List
                {
                    Id = p.Id,
                    No = p.No,
                    ClassName = p.ClassName,
                    ClassTypeName = p.tbClassType.ClassTypeName,
                    GradeName = p.tbGrade.GradeName,
                    YearName = p.tbYear.YearName
                }).ToList();

                return(View(vm));
            }
        }
コード例 #6
0
        public ActionResult List()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.Calendar.List();
                vm.WeekList = WeekController.SelectList();

                vm.YearList = YearController.SelectList(Code.EnumHelper.YearType.Section);
                if (vm.YearId > 0 && vm.YearList.Exists(p => int.Parse(p.Value) == vm.YearId.Value))
                {
                    vm.YearList.ForEach(p => {
                        p.Selected = int.Parse(p.Value) == vm.YearId;
                    });
                }
                //获取当前激活学段的起始日期
                if (vm.FromDate == Code.DateHelper.MinDate || vm.ToDate.Value == Code.DateHelper.MinDate || vm.ToDate.Value < vm.FromDate.Value)
                {
                    var yearId = vm.YearId.HasValue ? vm.YearId.Value : 0;
                    if (yearId == 0)
                    {
                        yearId = vm.YearList.Where(p => p.Selected).Select(p => p.Value).FirstOrDefault().ConvertToInt();
                    }

                    var tbYear = YearController.SelectInfo(yearId);
                    if (tbYear != null)
                    {
                        vm.FromDate = tbYear.FromDate.HasValue ? tbYear.FromDate.Value : Code.DateHelper.MonthFirstDay;
                        vm.ToDate   = tbYear.ToDate.HasValue ? tbYear.ToDate.Value : DateTime.Now;
                    }
                    else
                    {
                        vm.FromDate = Code.DateHelper.MonthFirstDay;
                        vm.ToDate   = DateTime.Now;
                    }
                }
                vm.ToDate = vm.ToDate.Value.AddDays(1).AddSeconds(-1);

                if (vm.YearId == 0 && vm.YearList.Count > 0)
                {
                    vm.YearId = vm.YearList.OrderByDescending(d => d.Selected).FirstOrDefault().Value.ConvertToInt();
                }


                vm.DataList = (from p in db.Table <Entity.tbCalendar>()
                               where p.tbYear.Id == vm.YearId && p.CalendarDate >= vm.FromDate && p.CalendarDate <= vm.ToDate
                               select new Dto.Calendar.List()
                {
                    Id = p.Id,
                    tbWeekId = p.tbWeek.Id,
                    tbWeekName = p.tbWeek.WeekName,
                    tbYear = p.tbYear.YearName,
                    CalendarDate = p.CalendarDate,
                    Remark = p.Remark
                }).ToList();
                vm.DataList.ForEach(p =>
                {
                    p.tbWeekName = TbWeek[p.tbWeekId - 1];
                });
                return(View(vm));
            }
        }