コード例 #1
0
        /// <summary>
        /// 根据课程选择教师
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="courseID">科目ID</param>
        /// <returns>教师</returns>
        public static List <UITeacher> GetTeachers(this CLCase cp, string courseID)
        {
            List <UITeacher> teachers = new List <UITeacher>();

            var classhours = (from c in cp.ClassHours
                              from tid in c.TeacherIDs
                              from t in cp.Teachers
                              where tid.Equals(t.ID)
                              select new
            {
                c.CourseID,
                t
            });

            var results = classhours.Where(c => c.CourseID.Equals(courseID));

            if (results != null)
            {
                var groups = results.GroupBy(r => r.t);
                foreach (var g in groups)
                {
                    UITeacher uiTeacher = new UITeacher()
                    {
                        ID   = g.Key.ID,
                        Name = g.Key.Name
                    };
                    teachers.Add(uiTeacher);
                }
            }
            return(teachers);
        }
コード例 #2
0
        public void Initilize()
        {
            var cp = CommonDataManager.GetCPCase(base.LocalID);

            if (cp != null)
            {
                _cpcase = cp;

                if (cp.Teachers != null)
                {
                    List <UITeacher> teachers = new List <UITeacher>();
                    cp.Teachers.ForEach(t =>
                    {
                        UITeacher teacher = new UITeacher()
                        {
                            ID   = t.ID,
                            Name = t.Name,
                        };
                        teachers.Add(teacher);
                    });
                    this.Teachers = new ObservableCollection <UITeacher>(teachers);

                    _teacherCollectionView        = (ListCollectionView)CollectionViewSource.GetDefaultView(this.Teachers);
                    _teacherCollectionView.Filter = TeacherContains;
                }
            }
            else
            {
                _cpcase = new CPCase();
            }
        }
コード例 #3
0
 void bind(UITeacherRule receive)
 {
     this.UID           = receive.UID;
     this.Weight        = receive.Weight;
     this.IsActive      = receive.IsActive;
     this.SelectTeacher = this.Teachers.FirstOrDefault(t => t.ID.Equals(receive.TeacherID));
     this.MaxGaps       = receive.Value;
 }
コード例 #4
0
        private void Dg_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            UITeacher ampm = e.Row.DataContext as UITeacher;

            if (ampm != null)
            {
                ampm.IsChecked = true;
            }
        }
コード例 #5
0
 void ReceiveTeacher(UITeacher teacher)
 {
     foreach (var c in this.Classes)
     {
         if (c.Courses != null)
         {
             foreach (var course in c.Courses)
             {
                 course.Teachers?.RemoveAll(t => t.ID.Equals(teacher.ID));
                 course.RaiseChanged();
             }
         }
     }
 }
コード例 #6
0
        public void Initilize()
        {
            Messenger.Default.Register <HostView>(this, save);

            this.Comments = CommonDataManager.GetAdminRuleComments(AdministrativeRuleEnum.TeacherAmPmNoContinues);

            #region 加载教师

            var cp = CommonDataManager.GetCPCase(base.LocalID);

            List <UITeacher> teachers = new List <UITeacher>();
            cp.Teachers.ForEach(t =>
            {
                UITeacher teacher = new UITeacher()
                {
                    ID   = t.ID,
                    Name = t.Name,
                };
                teachers.Add(teacher);
            });
            this.Teachers = teachers;

            _teacherCollectionView        = (ListCollectionView)CollectionViewSource.GetDefaultView(this.Teachers);
            _teacherCollectionView.Filter = TeacherContains;

            #endregion

            #region 绑定

            var rule = CommonDataManager.GetAminRule(base.LocalID);
            if (rule != null)
            {
                rule.AmPmNoContinues.ForEach(rc =>
                {
                    var teacher = this.Teachers.FirstOrDefault(t => t.ID.Equals(rc.TeacherID));

                    if (teacher != null)
                    {
                        teacher.IsChecked = true;
                        teacher.Weight    = (WeightTypeEnum)rc.Weight;
                    }
                });
            }

            #endregion
        }
コード例 #7
0
        bool TeacherContains(object contain)
        {
            UITeacher teacher = contain as UITeacher;

            if (string.IsNullOrEmpty(this.SearchTeacher))
            {
                return(true);
            }

            if (teacher.Name.IndexOf(this.SearchTeacher) != -1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #8
0
        void bind(UITeacherRule receive)
        {
            this.UID           = receive.UID;
            this.Weight        = receive.Weight;
            this.IsActive      = receive.IsActive;
            this.SelectTeacher = this.Teachers.FirstOrDefault(t => t.ID.Equals(receive.TeacherID));

            receive.ForbidTimes.ForEach(t =>
            {
                var period = this.Periods.First(p => p.Period.Period == t.Period);
                if (period != null)
                {
                    if (t.Day == DayOfWeek.Monday)
                    {
                        period.Monday.IsChecked = false;
                    }
                    else if (t.Day == DayOfWeek.Tuesday)
                    {
                        period.Tuesday.IsChecked = false;
                    }
                    else if (t.Day == DayOfWeek.Wednesday)
                    {
                        period.Wednesday.IsChecked = false;
                    }
                    else if (t.Day == DayOfWeek.Thursday)
                    {
                        period.Thursday.IsChecked = false;
                    }
                    else if (t.Day == DayOfWeek.Friday)
                    {
                        period.Friday.IsChecked = false;
                    }
                    else if (t.Day == DayOfWeek.Saturday)
                    {
                        period.Saturday.IsChecked = false;
                    }
                    else if (t.Day == DayOfWeek.Sunday)
                    {
                        period.Sunday.IsChecked = false;
                    }
                }
            });
        }
コード例 #9
0
        public static List <UITeacher> GetTeachersByTeacherIDs(this ResultModel r, List <string> teacherIDs)
        {
            List <UITeacher> teachers = new List <UITeacher>();

            teacherIDs?.ForEach(t =>
            {
                var teacher = r.Teachers.FirstOrDefault(tt => tt.ID.Equals(t));
                if (teacher != null)
                {
                    UITeacher newTeacher = new UITeacher()
                    {
                        ID   = teacher.ID,
                        Name = teacher.Name
                    };
                    teachers.Add(newTeacher);
                }
            });

            return(teachers);
        }
コード例 #10
0
        public void Initilize()
        {
            var cl = base.GetClCase(base.LocalID);

            List <UITeacher> teachers = new List <UITeacher>();

            cl.Teachers.ForEach(t =>
            {
                UITeacher teacher = new UITeacher()
                {
                    ID   = t.ID,
                    Name = t.Name,
                };
                teachers.Add(teacher);
            });
            this.Teachers = new ObservableCollection <UITeacher>(teachers);

            _teacherCollectionView        = (ListCollectionView)CollectionViewSource.GetDefaultView(this.Teachers);
            _teacherCollectionView.Filter = TeacherContains;
        }
コード例 #11
0
        void getBase(OperatorEnum opratorEnum, MixedAlgoRuleEnum timeRule)
        {
            base.OpratorEnum = opratorEnum;
            this._timeRule   = timeRule;
            this.TitleString = $"{ opratorEnum.GetLocalDescription()}-{timeRule.GetLocalDescription()}";
            this.RaisePropertyChanged(() => ShowRead);
            this.RaisePropertyChanged(() => ShowEdit);

            //this.MaxTips = $"(1-{CommonDataManager.Hours})";

            if (timeRule == MixedAlgoRuleEnum.TeachersMaxGapsPerDay)
            {
                this.Teachers = new List <UITeacher>()
                {
                    new UITeacher
                    {
                        ID   = string.Empty,
                        Name = "所有教师"
                    }
                };

                this.SelectTeacher = this.Teachers.First();
            }
            else
            {
                var cl = base.GetClCase(base.LocalID);

                this.Teachers = cl.Teachers.Select(t =>
                {
                    return(new UITeacher()
                    {
                        ID = t.ID,
                        Name = t.Name
                    });
                })?.ToList();
            }

            this.SelectTeacher = this.Teachers.FirstOrDefault();
        }
コード例 #12
0
        void getBase(OperatorEnum opratorEnum, AdministrativeAlgoRuleEnum timeRule)
        {
            base.OpratorEnum = opratorEnum;
            this.TitleString = $"{ opratorEnum.GetLocalDescription()}-{timeRule.GetLocalDescription()}";
            this.RaisePropertyChanged(() => ShowRead);
            this.RaisePropertyChanged(() => ShowEdit);

            var cp = CommonDataManager.GetCPCase(base.LocalID);

            this.Teachers = cp.Teachers.Select(t =>
            {
                return(new UITeacher()
                {
                    ID = t.ID,
                    Name = t.Name
                });
            })?.ToList();

            this.SelectTeacher = this.Teachers.FirstOrDefault();

            var results = new List <UITwoStatusWeek>();
            var groups  = cp.Positions.GroupBy(p => p.DayPeriod.Period);

            if (groups != null)
            {
                foreach (var g in groups)
                {
                    var             first = g.First();
                    UITwoStatusWeek week  = new UITwoStatusWeek()
                    {
                        Period       = first.DayPeriod,
                        PositionType = first.Position,
                    };
                    week.SetStatus(true);
                    results.Add(week);
                }
            }
            this.Periods = results;
        }
コード例 #13
0
        void getBase(OperatorEnum opratorEnum, AdministrativeAlgoRuleEnum timeRule)
        {
            base.OpratorEnum = opratorEnum;
            this._timeRule   = timeRule;
            this.TitleString = $"{ opratorEnum.GetLocalDescription()}-{timeRule.GetLocalDescription()}";
            this.RaisePropertyChanged(() => ShowRead);
            this.RaisePropertyChanged(() => ShowEdit);


            if (timeRule == AdministrativeAlgoRuleEnum.TeachersMaxDaysPerWeek)
            {
                this.Teachers = new List <UITeacher>()
                {
                    new UITeacher
                    {
                        ID   = string.Empty,
                        Name = "所有教师"
                    }
                };

                this.SelectTeacher = this.Teachers.First();
            }
            else
            {
                var cp = CommonDataManager.GetCPCase(base.LocalID);

                this.Teachers = cp.Teachers.Select(t =>
                {
                    return(new UITeacher()
                    {
                        ID = t.ID,
                        Name = t.Name
                    });
                })?.ToList();
            }

            this.SelectTeacher = this.Teachers.FirstOrDefault();
        }
コード例 #14
0
        public static List <UITeacher> GetTeachers(this ResultModel r)
        {
            List <UITeacher> teachers = new List <UITeacher>();

            var details = (from c in r.ResultClasses
                           from rc in c.ResultDetails
                           select new
            {
                rc.ClassHourId,
                rc.Teachers,
            });

            r.Teachers?.ToList()?.ForEach(t =>
            {
                UITeacher teacher    = new UITeacher();
                teacher.ID           = t.ID;
                teacher.Name         = t.Name;
                teacher.ClassHourIDs = details.Where(d => d.Teachers.Contains(t.ID))?.Select(s => s.ClassHourId)?.ToList();
                teachers.Add(teacher);
            });

            return(teachers);
        }
コード例 #15
0
        void bindData(UITeacher teacher)
        {
            this.Teachers.ForEach(t =>
            {
                t.IsChecked = false;
            });
            teacher.IsChecked = true;

            this.Periods.ForEach(p =>
            {
                p.ClearStatus();
            });

            var rule = CommonDataManager.GetAminRule(base.LocalID);

            if (rule != null)
            {
                var teacherTime = rule.TeacherTimes.FirstOrDefault(t => t.TeacherID.Equals(teacher.ID));
                if (teacherTime != null)
                {
                    teacherTime.ForbidTimes.ForEach(t =>
                    {
                        var period = this.Periods.First(p => p.Period.Period == t.Period);
                        if (period != null)
                        {
                            if (t.Day == DayOfWeek.Monday)
                            {
                                period.Monday.IsChecked   = true;
                                period.Monday.IsMouseLeft = true;
                            }
                            else if (t.Day == DayOfWeek.Tuesday)
                            {
                                period.Tuesday.IsChecked   = true;
                                period.Tuesday.IsMouseLeft = true;
                            }
                            else if (t.Day == DayOfWeek.Wednesday)
                            {
                                period.Wednesday.IsChecked   = true;
                                period.Wednesday.IsMouseLeft = true;
                            }
                            else if (t.Day == DayOfWeek.Thursday)
                            {
                                period.Thursday.IsChecked   = true;
                                period.Thursday.IsMouseLeft = true;
                            }
                            else if (t.Day == DayOfWeek.Friday)
                            {
                                period.Friday.IsChecked   = true;
                                period.Friday.IsMouseLeft = true;
                            }
                            else if (t.Day == DayOfWeek.Saturday)
                            {
                                period.Saturday.IsChecked   = true;
                                period.Saturday.IsMouseLeft = true;
                            }
                            else if (t.Day == DayOfWeek.Sunday)
                            {
                                period.Sunday.IsChecked   = true;
                                period.Sunday.IsMouseLeft = true;
                            }
                        }
                    });

                    teacherTime.MustTimes.ForEach(t =>
                    {
                        var period = this.Periods.First(p => p.Period.Period == t.Period);
                        if (period != null)
                        {
                            if (t.Day == DayOfWeek.Monday)
                            {
                                period.Monday.IsChecked = true;
                            }
                            else if (t.Day == DayOfWeek.Tuesday)
                            {
                                period.Tuesday.IsChecked = true;
                            }
                            else if (t.Day == DayOfWeek.Wednesday)
                            {
                                period.Wednesday.IsChecked = true;
                            }
                            else if (t.Day == DayOfWeek.Thursday)
                            {
                                period.Thursday.IsChecked = true;
                            }
                            else if (t.Day == DayOfWeek.Friday)
                            {
                                period.Friday.IsChecked = true;
                            }
                            else if (t.Day == DayOfWeek.Saturday)
                            {
                                period.Saturday.IsChecked = true;
                            }
                            else if (t.Day == DayOfWeek.Sunday)
                            {
                                period.Sunday.IsChecked = true;
                            }
                        }
                    });
                }
            }
        }
コード例 #16
0
        void getBase(OperatorEnum opratorEnum, MixedAlgoRuleEnum timeRule)
        {
            base.OpratorEnum = opratorEnum;
            this.TitleString = $"{ opratorEnum.GetLocalDescription()}-{timeRule.GetLocalDescription()}";
            this.RaisePropertyChanged(() => ShowRead);
            this.RaisePropertyChanged(() => ShowEdit);

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

            this.Teachers = cl.Teachers.Select(t =>
            {
                return(new UITeacher()
                {
                    ID = t.ID,
                    Name = t.Name
                });
            })?.ToList();

            this.SelectTeacher = this.Teachers.FirstOrDefault();

            var results = new List <UITwoStatusWeek>();
            var groups  = cl.Positions.GroupBy(p => p.DayPeriod.Period);

            if (groups != null)
            {
                foreach (var g in groups)
                {
                    var             first = g.First();
                    UITwoStatusWeek week  = new UITwoStatusWeek()
                    {
                        Period       = first.DayPeriod,
                        PositionType = first.Position,
                    };
                    week.SetStatus(true);

                    if (first.Position != XYKernel.OS.Common.Enums.Position.AB &&
                        first.Position != XYKernel.OS.Common.Enums.Position.PB &&
                        first.Position != XYKernel.OS.Common.Enums.Position.Noon)
                    {
                        g.ToList().ForEach(gg =>
                        {
                            if (gg.DayPeriod.Day == DayOfWeek.Monday)
                            {
                                week.Monday.IsChecked = gg.IsSelected;
                            }
                            else if (gg.DayPeriod.Day == DayOfWeek.Tuesday)
                            {
                                week.Tuesday.IsChecked = gg.IsSelected;
                            }
                            else if (gg.DayPeriod.Day == DayOfWeek.Wednesday)
                            {
                                week.Wednesday.IsChecked = gg.IsSelected;
                            }
                            else if (gg.DayPeriod.Day == DayOfWeek.Thursday)
                            {
                                week.Thursday.IsChecked = gg.IsSelected;
                            }
                            else if (gg.DayPeriod.Day == DayOfWeek.Friday)
                            {
                                week.Friday.IsChecked = gg.IsSelected;
                            }
                            else if (gg.DayPeriod.Day == DayOfWeek.Saturday)
                            {
                                week.Saturday.IsChecked = gg.IsSelected;
                            }
                            else if (gg.DayPeriod.Day == DayOfWeek.Sunday)
                            {
                                week.Sunday.IsChecked = gg.IsSelected;
                            }
                        });
                    }

                    results.Add(week);
                }
            }
            this.Periods = results;
        }
コード例 #17
0
        void modifyCommand(object obj)
        {
            UITeacher teacher = obj as UITeacher;

            this.bindData(teacher);
        }
コード例 #18
0
 void weightChanged(UITeacher course)
 {
     course.IsChecked = true;
 }