Exemple #1
0
        public ActionResult Edit(int id = 0)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.TeacherHonor.Edit();
                vm.TeacherHonorLevelList = TeacherHonorLevelController.SelectList();
                vm.TeacherHonorTypeList  = TeacherHonorTypeController.SelectList();

                if (id > 0)
                {
                    vm.DataEdit = (from p in db.Table <Teacher.Entity.tbTeacherHonor>()
                                   where p.Id == id
                                   select new Dto.TeacherHonor.Edit()
                    {
                        Id = p.Id,
                        No = p.No,
                        TeacherId = p.tbTeacher.Id,
                        TeacherCode = p.tbTeacher.TeacherCode,
                        TeacherName = p.tbTeacher.TeacherName,
                        HonorName = p.HonorName,
                        HonorFile = p.HonorFile,
                        TeacherHonorLevelId = p.tbTeacherHonorLevel.Id,
                        TeacherHonorTypeId = p.tbTeacherHonorType.Id
                    }).FirstOrDefault();
                }

                return(View(vm));
            }
        }
Exemple #2
0
        public ActionResult List()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.TeacherHonor.List();
                //vm.TeacherName = db.Set<Teacher.Entity.tbTeacher>().Find(vm.TeacherId).TeacherName;
                vm.TeacherHonorLevelList = TeacherHonorLevelController.SelectList();
                vm.TeacherHonorTypeList  = TeacherHonorTypeController.SelectList();
                var tb = db.Table <Teacher.Entity.tbTeacherHonor>().Where(d => d.tbTeacher.IsDeleted == false);

                #region 查询条件
                //tb = tb.Where(d => d.tbTeacher.Id == vm.TeacherId);
                if (!string.IsNullOrEmpty(vm.SearchText))
                {
                    tb = tb.Where(d => d.HonorName.Contains(vm.SearchText) ||
                                  d.tbTeacher.TeacherName.Contains(vm.SearchText) ||
                                  d.tbTeacher.TeacherCode.Contains(vm.SearchText));
                }
                if (vm.TeacherHonorLevelId > 0)
                {
                    tb = tb.Where(d => d.tbTeacherHonorLevel.Id == vm.TeacherHonorLevelId);
                }
                if (vm.TeacherHonorTypeId > 0)
                {
                    tb = tb.Where(d => d.tbTeacherHonorType.Id == vm.TeacherHonorTypeId);
                }
                #endregion

                vm.DataList = (from p in tb
                               orderby p.No
                               select new Dto.TeacherHonor.List()
                {
                    Id = p.Id,
                    No = p.No,
                    TeacherId = p.tbTeacher.Id,
                    TeacherCode = p.tbTeacher.TeacherCode,
                    TeacherName = p.tbTeacher.TeacherName,
                    HonorName = p.HonorName,
                    HonorFile = p.HonorFile,
                    TeacherHonorLevelName = p.tbTeacherHonorLevel.TeacherHonorLevelName,
                    TeacherHonorTypeName = p.tbTeacherHonorType.TeacherHonorTypeName
                }).ToList();
                return(View(vm));
            }
        }