コード例 #1
0
        void batchDeleteCommand()
        {
            var dialog = this.ShowDialog("提示信息", "确认删除?", CustomControl.Enums.DialogSettingType.OkAndCancel, CustomControl.Enums.DialogType.Warning);

            if (dialog == CustomControl.Enums.DialogResultType.OK)
            {
                var cl = base.GetClCase(base.LocalID);

                // 验证是否确认删除?
                var toDeleteTeachers = this.Teachers.Where(t => t.IsChecked)?.ToList();
                if (toDeleteTeachers != null)
                {
                    foreach (var t in toDeleteTeachers)
                    {
                        // 更新UI
                        this.Teachers.Remove(t);
                        // 移除教师
                        cl.Teachers.RemoveAll(teacher => teacher.ID.Equals(t.ID));
                        // 删除基础数据
                        MixedDataHelper.TeacherChanged(t, base.LocalID, CommonDataManager);

                        // 发送消息
                        GalaSoft.MvvmLight.Messaging.Messenger.Default.Send <UITeacher>(t);
                    }

                    base.Serialize(cl, LocalID);
                }
            }
        }
コード例 #2
0
        void deleteAllCourse()
        {
            var confirm = this.ShowDialog("提示信息", "确认删除全部课程?", CustomControl.Enums.DialogSettingType.OkAndCancel, CustomControl.Enums.DialogType.Warning);

            if (confirm == CustomControl.Enums.DialogResultType.OK)
            {
                foreach (var c in this.Courses)
                {
                    _toDeleteCourses.Add(c);
                }
                this.Courses.Clear();

                var rule     = base.GetClRule(base.LocalID);
                var algo     = base.GetCLAlgoRule(base.LocalID);
                var cl       = base.GetClCase(base.LocalID);
                var local    = CommonDataManager.GetLocalCase(base.LocalID);
                var isPatern = local.Pattern != Models.Enums.PatternTypeEnum.None ? true : false;

                MixedDataHelper.CourseChanged(_toDeleteCourses, base.LocalID, rule, algo, cl, isPatern);
            }
        }
コード例 #3
0
        void batchDeleteCommand()
        {
            var hasChecked = this.Teachers.Any(t => t.IsChecked);

            if (!hasChecked)
            {
                this.ShowDialog("提示信息", "没有选中要删除的教师!", CustomControl.Enums.DialogSettingType.OnlyOkButton, CustomControl.Enums.DialogType.Warning);
                return;
            }

            var dialog = this.ShowDialog("提示信息", "确认删除?", CustomControl.Enums.DialogSettingType.OkAndCancel, CustomControl.Enums.DialogType.Warning);

            if (dialog == CustomControl.Enums.DialogResultType.OK)
            {
                var rule      = base.GetClRule(base.LocalID);
                var algo      = base.GetCLAlgoRule(base.LocalID);
                var cl        = base.GetClCase(base.LocalID);
                var hasPatern = base.HasPatern();

                // 验证是否确认删除?
                var toDeleteTeachers = _toDeleteTeachers?.Count == 0 ? this.Teachers.Where(t => t.IsChecked)?.ToList() : _toDeleteTeachers?.Where(t => t.IsChecked);
                if (toDeleteTeachers != null)
                {
                    foreach (var t in toDeleteTeachers)
                    {
                        // 更新UI
                        this.Teachers.Remove(t);
                        // 移除教师
                        cl.Teachers.RemoveAll(teacher => teacher.ID.Equals(t.ID));
                        // 删除基础数据
                        MixedDataHelper.TeacherChanged(t, base.LocalID, rule, algo, cl, hasPatern);

                        // 发送消息
                        GalaSoft.MvvmLight.Messaging.Messenger.Default.Send <UITeacher>(t);
                    }

                    base.Serialize(cl, LocalID);
                }
            }
        }
コード例 #4
0
        void saveCommand()
        {
            var cl       = base.GetClCase(base.LocalID);
            var rule     = base.GetClRule(base.LocalID);
            var algo     = base.GetCLAlgoRule(base.LocalID);
            var local    = CommonDataManager.GetLocalCase(base.LocalID);
            var isPatern = local.Pattern != Models.Enums.PatternTypeEnum.None ? true : false;

            if (_toDeleteCourses.Count > 0)
            {
                MixedDataHelper.CourseChanged(_toDeleteCourses, base.LocalID, rule, algo, cl, isPatern);
                _toDeleteCourses.Clear();
                GalaSoft.MvvmLight.Messaging.Messenger.Default.Send("clearPreselections");
            }
            if (_toDeleteLevels.Count > 0)
            {
                MixedDataHelper.LevelChanged(_toDeleteLevels, base.LocalID, rule, algo, cl, isPatern);
                _toDeleteLevels.Clear();
                GalaSoft.MvvmLight.Messaging.Messenger.Default.Send("clearPreselections");
            }

            var has = this.Courses.Any(c =>
            {
                var groups = c.Levels.GroupBy(l => l.Name);

                if (groups != null)
                {
                    if (groups.Any(g => g.Count() > 1))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            });

            if (has)
            {
                var result = this.ShowDialog("提示信息", "同科目下存在相同的名称的层,是否确认继续?", CustomControl.Enums.DialogSettingType.OkAndCancel, CustomControl.Enums.DialogType.Warning);
                if (result != CustomControl.Enums.DialogResultType.OK)
                {
                    return;
                }
            }

            cl.Courses.Clear();

            foreach (var c in this.Courses)
            {
                var model = new XYKernel.OS.Common.Models.Mixed.CourseModel()
                {
                    ID     = c.ID,
                    Name   = c.Name,
                    Levels = new List <XYKernel.OS.Common.Models.Mixed.LevelModel>()
                };

                if (c.Levels.Count > 0)
                {
                    model.Levels = c.Levels.Select(sl =>
                    {
                        return(new XYKernel.OS.Common.Models.Mixed.LevelModel()
                        {
                            ID = sl.ID,
                            Lessons = sl.Lessons,
                            Name = sl.Name
                        });
                    })?.ToList();
                }
                else
                {
                    var classCount     = cl.Classes.Count(cc => cc.CourseID.Equals(model.ID) && cc.LevelID.Equals("0"));
                    var classHourCount = classCount == 0 ? 0 : cl.GetClassHoursByCouresAndLevel(model.ID, "0").Count / classCount;

                    model.Levels.Add(new XYKernel.OS.Common.Models.Mixed.LevelModel()
                    {
                        // 插入空层
                        ID      = "0",
                        Name    = string.Empty,
                        Lessons = classHourCount == 0 ? 5 : classHourCount,
                    });
                }

                cl.Courses.Add(model);
            }

            // 3.保存
            base.Serialize(cl, LocalID);
            local.Serialize();

            this.ShowDialog("提示信息", "保存成功!", CustomControl.Enums.DialogSettingType.NoButton, CustomControl.Enums.DialogType.None);
        }
コード例 #5
0
        void saveCommand()
        {
            var cl = base.GetClCase(base.LocalID);

            if (hasChanged())
            {
                var rule = base.GetClRule(base.LocalID);
                var algo = base.GetCLAlgoRule(base.LocalID);

                var local = CommonDataManager.GetLocalCase(base.LocalID);

                bool isPatern = local.Pattern != Models.Enums.PatternTypeEnum.None ? true : false;

                MixedDataHelper.ClassHourChanged(base.LocalID, rule, algo, cl, isPatern);
            }

            // 层下是否存在重复班级
            var has = this.CourseLevels.Any(courseLevel =>
            {
                var groups = courseLevel.Classes.GroupBy(c => c.Name);
                if (groups.Any(g => g.Count() > 1))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            if (has)
            {
                this.ShowDialog("提示信息", "同科同层下不能存在相同班级", CustomControl.Enums.DialogSettingType.OnlyOkButton, CustomControl.Enums.DialogType.Warning);
                return;
            }

            var filters = this.CourseLevels.Where(c => c.Classes.Count > 0);

            if (filters != null)
            {
                // 清除班级信息
                cl.Classes.Clear();
                cl.ClassHours.Clear();

                int no = 0;
                foreach (var l in filters)
                {
                    if (l.Classes != null)
                    {
                        foreach (var c in l.Classes)
                        {
                            // 添加班级
                            cl.Classes.Add(new XYKernel.OS.Common.Models.Mixed.ClassModel()
                            {
                                Capacity   = c.Capacity,
                                CourseID   = c.CourseID,
                                ID         = c.ID,
                                LevelID    = c.LevelID,
                                Name       = c.Name,
                                StudentIDs = c.StudentIDs,
                                TeacherIDs = c.TeacherIDs
                            });

                            for (int i = 0; i < l.Lessons; i++)
                            {
                                // 添加课时
                                var clasHour = new XYKernel.OS.Common.Models.Mixed.ClassHourModel()
                                {
                                    ID         = ++no,
                                    CourseID   = l.CourseID,
                                    ClassID    = c.ID,
                                    LevelID    = l.LevelID,
                                    TeacherIDs = c.TeacherIDs
                                };
                                cl.ClassHours.Add(clasHour);
                            }
                        }
                    }
                }

                // 4.序列化规则
                var serialize = this.CourseLevels.Select(l =>
                {
                    return(new SaveCourseLevel()
                    {
                        CourseID = l.CourseID,
                        LevelID = l.LevelID,
                        Lessons = l.Lessons
                    });
                })?.ToList();

                //base.LocalID.MixedClassFile().SerializeObjectToJson(serialize);

                // 更改层下课时
                if (this.CourseLevels != null)
                {
                    foreach (var courseLevel in this.CourseLevels)
                    {
                        var scourse = cl.Courses.FirstOrDefault(cc => cc.ID.Equals(courseLevel.CourseID));
                        if (scourse != null)
                        {
                            var slevel = scourse.Levels.FirstOrDefault(ssl => ssl.ID.Equals(courseLevel.LevelID));
                            if (slevel != null)
                            {
                                slevel.Lessons = courseLevel.Lessons;
                            }
                        }
                    }
                }

                base.Serialize(cl, LocalID);
                this.ShowDialog("提示信息", "保存成功!", CustomControl.Enums.DialogSettingType.NoButton, CustomControl.Enums.DialogType.None);
            }
        }