/// <summary>
        /// 从数据源刷新学生志愿
        /// </summary>
        public void RefreshStudentPreselections()
        {
            var cl = base.GetClCase(base.LocalID);

            int no       = 0;
            var students = (from s in cl.Students
                            select new UIStudent()
            {
                NO = ++no,
                ID = s.ID,
                Name = s.Name,
                Preselections = s.Preselections.Select(p =>
                {
                    UIPreselection preselection = new UIPreselection();
                    preselection.CourseID = p.CourseID;
                    preselection.LevelID = p.LevelID;

                    var course = cl.Courses.FirstOrDefault(c => c.ID.Equals(p.CourseID));
                    if (course != null)
                    {
                        var level = course.Levels?.FirstOrDefault(cll => cll.ID.Equals(p.LevelID));
                        preselection.Course = course.Name;
                        preselection.Level = level?.Name;
                    }

                    return(preselection);
                })?.ToList()
            })?.ToList();

            this.BindData(students, cl);
        }
예제 #2
0
        void save(object obj)
        {
            var group = this.Preselections.Where(p => p.IsChecked).GroupBy(p => p.CourseID);

            var isSelectMoreLevel = group.Any(g => g.Count() > 1);

            if (isSelectMoreLevel)
            {
                this.ShowDialog("提示信息", "每个科目只能选择一个层!", CustomControl.Enums.DialogSettingType.OnlyOkButton, CustomControl.Enums.DialogType.Warning);
                return;
            }

            SetStudentPreselectionWindow window = obj as SetStudentPreselectionWindow;

            // 清除
            window.Preselections = new List <UIPreselection>();

            // 添加
            this.Preselections.Where(p => p.IsChecked)?.ToList()?.ForEach(p =>
            {
                UIPreselection uiPreselection = new UIPreselection()
                {
                    Course    = p.Course,
                    CourseID  = p.CourseID,
                    IsChecked = p.IsChecked,
                    Level     = p.Level,
                    LevelID   = p.LevelID
                };
                window.Preselections.Add(uiPreselection);
            });

            window.DialogResult = true;
        }
        public void Initilize()
        {
            Messenger.Default.Register <string>(this, Receive);

            var cl = base.GetClCase(base.LocalID);

            // 学生列表
            int no = 0;

            this.ShowLoading = true;

            Task.Run(() =>
            {
                var students = (from s in cl.Students
                                select new UIStudent()
                {
                    NO = ++no,
                    ID = s.ID,
                    Name = s.Name,
                    Preselections = s.Preselections.Select(p =>
                    {
                        UIPreselection preselection = new UIPreselection();
                        preselection.CourseID = p.CourseID;
                        preselection.LevelID = p.LevelID;

                        var course = cl.Courses.FirstOrDefault(c => c.ID.Equals(p.CourseID));
                        if (course != null)
                        {
                            var level = course.Levels?.FirstOrDefault(cll => cll.ID.Equals(p.LevelID));
                            preselection.Course = course.Name;
                            preselection.Level = level?.Name;
                        }

                        return(preselection);
                    })?.ToList()
                })?.ToList();

                if (students != null)
                {
                    GalaSoft.MvvmLight.Threading.DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        this.Students                 = new ObservableCollection <UIStudent>(students);
                        _studentCollectionView        = (ListCollectionView)CollectionViewSource.GetDefaultView(this.Students);
                        _studentCollectionView.Filter = StudentContains;
                    });

                    this.ShowLoading = false;
                }
            });
        }
예제 #4
0
        public void Initilize()
        {
            var cl = CommonDataManager.GetCLCase(base.LocalID);

            var preselections = new List <UIPreselection>();

            cl.Courses.ForEach(course =>
            {
                if (course.Levels.Count > 0)
                {
                    course.Levels.ForEach(l =>
                    {
                        UIPreselection preselection = new UIPreselection()
                        {
                            LevelID   = l.ID,
                            Level     = l.Name,
                            CourseID  = course.ID,
                            Course    = course.Name,
                            IsChecked = false
                        };
                        preselections.Add(preselection);
                    });
                }
                else
                {
                    UIPreselection preselection = new UIPreselection()
                    {
                        CourseID  = course.ID,
                        Course    = course.Name,
                        IsChecked = false
                    };
                    preselections.Add(preselection);
                }
            });

            this.Preselections = preselections;
        }