Esempio n. 1
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);
            }
        }
Esempio n. 2
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);
        }