Пример #1
0
 public sClassRecord(ClassRecord classRecord, sSchedule schedule) : base(classRecord)
 {
     if (classRecord == null)
     {
         return;
     }
     Subject   = classRecord.Subject == null ? null : schedule.sDictionaries.Subjects[classRecord.Subject.GetHashCode()];
     Lecturer  = classRecord.Lecturer == null ? null : schedule.sDictionaries.Lecturers[classRecord.Lecturer.GetHashCode()];
     Classroom = classRecord.Classroom == null ? null : schedule.sDictionaries.Classrooms[classRecord.Classroom.GetHashCode()];
     ClassTime = classRecord.ClassTime == null ? null : schedule.sDictionaries.TimeLine[classRecord.ClassTime.GetHashCode()];
     Group     = classRecord.Group == null ? null : schedule.sDictionaries.Groups[classRecord.Group.GetHashCode()];
 }
Пример #2
0
 public static void Copy(ClassRecord from, ClassRecord to)
 {
     if (from == null || to == null)
     {
         return;
     }
     to.Subject   = from.Subject;
     to.Group     = from.Group;
     to.Lecturer  = from.Lecturer;
     to.Classroom = from.Classroom;
     to.ClassTime = from.ClassTime;
 }
Пример #3
0
        public ClassRecord SetClass(int timeIndex, int subjectIndex, ClassRecord classRecord)
        {
            if (!AreIndexesCorrect(timeIndex, subjectIndex))
            {
                return(null);
            }
            var subject = Subjects[subjectIndex];
            var time    = Schedule.TimeLine[timeIndex];

            if (TableDictionary[subject].ContainsKey(time))
            {
                Schedule.RemoveClass(TableDictionary[subject][time]);
            }
            SetSubject(classRecord, subject);
            classRecord.ClassTime = time;
            Schedule.AddClass(classRecord);
            TableDictionary[subject][time] = classRecord;
            return(classRecord);
        }
Пример #4
0
 //        private void InitClasses()
 //        {
 //            Schedule.CreateNewTables();
 //            foreach (var classesTable in Schedule.Tables)
 //            {
 //                int classCount = classesTable.Groups.Count() * Schedule.TimeLine.Count;
 //                for (int i = 0; i < classCount; i++)
 //                {
 //                    Subject s = Schedule.Subjects[Rnd.Next(Schedule.Subjects.Count)];
 //                    Lecturer l = Schedule.Lecturers[Rnd.Next(Schedule.Lecturers.Count)];
 //                    Classroom c = Schedule.Classrooms[Rnd.Next(Schedule.Classrooms.Count)];
 //
 //                    var timeIndex = Rnd.Next(Schedule.TimeLine.Count);
 //                    var groupIndex = Rnd.Next(classesTable.Groups.Count());
 //
 //                    if (classesTable.Table[timeIndex][groupIndex] == null)
 //                    {
 //                        classesTable.Table[timeIndex][groupIndex] = new ClassRecord
 //                        {
 //                            Subject = s,
 //                            Lecturer = l,
 //                            Classroom = c
 //                        };
 //                    }
 //
 //                }
 //            }
 //            
 //        }
 private void InitClasses()
 {
     //int classCount = Schedule.Groups.Count() * Schedule.TimeLine.Count;
     foreach (var classTime in Schedule.TimeLine)
     {
         foreach (var @group in Schedule.Groups)
         {
             Subject s = Schedule.Subjects[Rnd.Next(Schedule.Subjects.Count)];
             Lecturer l = Schedule.Lecturers[Rnd.Next(Schedule.Lecturers.Count)];
             Classroom c = Schedule.Classrooms[Rnd.Next(Schedule.Classrooms.Count)];
             if (Rnd.Next(100) < 40) continue;
                 var @class = new ClassRecord
                 {
                     Classroom = c,
                 Group = @group,
                     Subject = s,
                     Lecturer = l,
                     ClassTime = classTime
                 };
                 Schedule.ClassRecords.Add(@class);
         }
     }
 }
Пример #5
0
 public void RemoveClass(ClassRecord classRecord)
 {
     ClassRecords.Remove(classRecord);
 }
Пример #6
0
 public void AddClass(ClassRecord classRecord)
 {
     ClassRecords.Add(classRecord);
 }
Пример #7
0
 protected bool Equals(ClassRecord other)
 {
     return Equals(_subject, other._subject) && Equals(_group, other._group) && Equals(_lecturer, other._lecturer) && Equals(_classroom, other._classroom) && Equals(_classTime, other._classTime);
 }
Пример #8
0
 public static void Copy(ClassRecord from, ClassRecord to)
 {
     if (from == null || to == null) return;
     to.Subject = from.Subject;
     to.Group = from.Group;
     to.Lecturer = from.Lecturer;
     to.Classroom = from.Classroom;
     to.ClassTime = from.ClassTime;
 }
Пример #9
0
 public void RemoveClass(ClassRecord classRecord)
 {
     ClassRecords.Remove(classRecord);
 }
Пример #10
0
        private void OnCutClass()
        {
            if (_selectedCard == null || _selectedCard.Class == null) return;
            var classCard = ClassesCards[_selectedRow][_selectedColumn];
            if (classCard == null) return;
            var row = Grid.GetRow(classCard) - TitleRowsCount;
            var col = Grid.GetColumn(classCard) - TimeColumnsCount;

            var @class = new ClassRecord();
            ClassRecord.Copy(_groupClasses.GetClass(row, col), @class);
            ClipboardService.SetData(@class);

            var vmodel = classCard.DataContext as ClassCardViewModel;
            if (vmodel == null) return;

            vmodel.Class = null;
            _groupClasses.RemoveClass(row, col);
        }
Пример #11
0
 protected override void SetSubject(ClassRecord classRecord, Group subject)
 {
     classRecord.Group = subject;
 }
Пример #12
0
//        public void AddGroup(Group group)
//        {
//            if (group == null || group.YearOfStudy != YearOfStudy || Subjects.Contains(group)) return;
//
//            var oldGroups = Subjects.ToList();
//            oldGroups.Add(group);
//            Subjects = sortGroups(oldGroups);
//            SetSubjectIndexes();
//
//            if (group.Specialization == null) return;
//
//            var countGroups = Subjects.Length;
//            var countTime = TimeIndexes.Count;
//            var indexOfNewGroup = SubjectIndexes[group];
//            var newTable = new ClassRecord[countTime][];
//
//            for (int i = 0; i < countTime; ++i)
//            {
//                newTable[i] = new ClassRecord[countGroups];
//                for (int j = 0; j < countGroups; ++j)
//                    if (j != indexOfNewGroup)
//                        newTable[i][j] = Table[i][j < indexOfNewGroup ? j : j - 1];
//            }
//            Table = newTable;
//        }
//
//        public void AddGroup(Group group, ClassRecord[] classes)
//        {
//            AddGroup(group);
//            var countTime = TimeIndexes.Count;
//            var indexOfGroup = SubjectIndexes[group];
//            for (int i = 0; i < countTime; ++i)
//                Table[i][indexOfGroup] = classes[i];
//        }
//
//        public void RemoveGroup(Group group)
//        {
//            if (group == null || Subjects.All(g => g != group)) return;
//
//            var indexOfGroup = SubjectIndexes[group];
//            var countTime = TimeIndexes.Count;
//            var newCountGroups = Subjects.Length - 1;
//            var newGroups = new Group[newCountGroups];
//
//            for (int j = 0; j < newCountGroups + 1; ++j)
//                if (j != indexOfGroup)
//                    newGroups[j < indexOfGroup ? j : j - 1] = Subjects[j];
//
//            Subjects = newGroups;
//            SetSubjectIndexes();
//
//            var newTable = new ClassRecord[countTime][];
//
//            if (countTime != 0 && indexOfGroup < Table[0].Length)
//            {
//                for (int i = 0; i < countTime; ++i)
//                {
//                    newTable[i] = new ClassRecord[newCountGroups];
//                    for (int j = 0; j < newCountGroups + 1; ++j)
//                        if (j != indexOfGroup)
//                            newTable[i][j < indexOfGroup ? j : j - 1] = Table[i][j];
//                }
//
//                Table = newTable;
//            }
//        }
//
//        public ClassRecord[] AllClassesOfGroup(Group group)
//        {
//            if (group == null || Subjects.All(g => g != group)) return null;
//
//            var indexOfGroup = SubjectIndexes[group];
//            var countTime = TimeIndexes.Count;
//            var classes = new ClassRecord[countTime];
//
//            if (countTime != 0 && indexOfGroup < Table[0].Length)
//                for (int i = 0; i < countTime; ++i)
//                    classes[i] = Table[i][indexOfGroup];
//
//            return classes;
//        }

        protected override Group GetSubject(ClassRecord classRecord)
        {
            return(classRecord.Group);
        }
Пример #13
0
 protected bool Equals(ClassRecord other)
 {
     return(Equals(_subject, other._subject) && Equals(_group, other._group) && Equals(_lecturer, other._lecturer) && Equals(_classroom, other._classroom) && Equals(_classTime, other._classTime));
 }
Пример #14
0
 protected abstract void SetSubject(ClassRecord classRecord, TSubject subject);
Пример #15
0
 protected abstract TSubject GetSubject(ClassRecord classRecord);
Пример #16
0
 public ClassCardViewModel(ClassRecord @class)
 {
     Class = @class;
     PropertyChanged += OnPropertyChanged;
 }
Пример #17
0
 private void OnCopyClassCommand()
 {
     if (_selectedCard == null || _selectedCard.Class == null) return;
     var @class = new ClassRecord();
     ClassRecord.Copy(_selectedCard.Class, @class);
     ClipboardService.SetData(@class);
 }
Пример #18
0
 public void AddClassRecord(ClassRecord classRecord)
 {
 }
Пример #19
0
        private static void LoadRecords(Schedule schedule, SQLiteCommand command)
        {
            command.CommandText = "select * from records";

            var reader = command.ExecuteReader();
            while (reader.Read())
            {
                var record = new ClassRecord
                {
                    Subject = schedule.Subjects[(int) reader["sub"]],
                    Group = schedule.Groups[(int) reader["grp"]],
                    Lecturer = schedule.Lecturers[(int) reader["lect"]],
                    Classroom = schedule.Classrooms[(int) reader["room"]],
                    ClassTime = schedule.TimeLine[(int) reader["time"]]
                };
                schedule.ClassRecords.Add(record);
            }
            reader.Close();
        }
Пример #20
0
 public void AddClass(ClassRecord classRecord)
 {
     ClassRecords.Add(classRecord);
 }