Exemplo n.º 1
0
 public void Fill(lesson l)
 {
     
     if (l.LessonNum == 0)
     {
         this.Lesson = l;
         this.LessonOne = null;
         this.LessonTwo = null;
         this.IsDoubledLesson = false;
     }
     else if (l.LessonNum == 1)
     {
         this.IsDoubledLesson = true;
         this.Lesson = null;
         this.LessonOne = l;
         if (LessonTwo == null)
         {
             this.LessonTwo = DBModel.Instance.EmptyLesson;
         }
     }
     else if (l.LessonNum == 2)
     {
         this.IsDoubledLesson = true;
         this.Lesson = null;
         if (this.LessonOne == null)
         {
             this.LessonOne = DBModel.Instance.EmptyLesson;
         }
         this.LessonTwo = l;
     }
 }
Exemplo n.º 2
0
 public void LessonToLessonarchive(lesson l)
 {
     this.Model.LessonToLessonarchive(l);
 }
Exemplo n.º 3
0
 public void EditLesson(lesson l, long subId, long teacherId, bool isSubst, bool isCanceled, string cl)
 {
     this.Model.EditLesson(l, subId, teacherId, isSubst, isCanceled, cl);
 }
Exemplo n.º 4
0
 public void AddLesson(long subjectId,long teacherId,long groupId , DateTime date , bool isSubstitution,bool isCanceled,string cl,long lessonIndex , long lessonNum)
 {
     lesson le = new lesson
                     {
                         SubjectId = subjectId,
                         TeacherId = teacherId,
                         GroupId = groupId,
                         Date = date,
                         IsSubstitution = isSubstitution,
                         IsCanceled = isCanceled,
                         Class = cl,
                         LessonIndex = lessonIndex,
                         LessonNum = lessonNum
                     };
     lesson less = this.Model.FindLesson(date, lessonIndex, lessonNum);
     if (less != null)
     {
         this.Model.DeleteLesson(less);
     }
     this.Model.AddLesson(le);
 }
Exemplo n.º 5
0
        void SetLessonInfo(lesson lesson)
        {
            if (lesson == null || lesson == DBModel.Instance.EmptyLesson)
            {
                this.bOK.Content = "Добавить";

                this.cbiLesson.IsEnabled = false;
                this.cbClear.SelectedIndex = 1;

                this.dgSubjects.ItemsSource = null;
                this.dgTeachers.ItemsSource = null;
                this.chbRefused.IsChecked = false;
                this.chbSubst.IsChecked = false;
                this.tbClass.Text = "";

                List<dynamic> subs = DBModel.Instance.GetSubjectsByGroup(this.currentGroup.Name);
                this.dgSubjects.ItemsSource = subs;

            }
            else
            {
                this.bOK.Content = "Изменить";

                this.cbiLesson.IsEnabled = true;
                this.cbClear.SelectedIndex = 0;

                try
                {
                    List<dynamic> subs = DBModel.Instance.GetSubjectsByGroup(this.currentGroup.Name);
                    if (subs.Contains(lesson.subject) == false)
                    {
                        subs.Add(lesson.subject);
                    }
                    this.dgSubjects.ItemsSource = subs;

                    List<dynamic> teas = null;

                    if (lesson.IsSubstitution)
                    {
                        this.chbSubst.IsChecked = true;
                        teas = DBModel.Instance.GetAllTeachers();
                    }
                    else
                    {
                        this.chbSubst.IsChecked = false;
                        teas = DBModel.Instance.GetTeachersBySubject(lesson.subject);
                    }

                    if (teas.Contains(lesson.teacher) == false)
                    {
                        teas.Add(lesson.teacher);
                    }

                    this.dgTeachers.ItemsSource = teas;

                    if (lesson.IsCanceled)
                    {
                        this.chbRefused.IsChecked = true;
                    }

                    this.tbClass.Text = lesson.Class;

                    int ind = -1;
                    foreach (var i in this.dgSubjects.Items)
                    {
                        ++ind;
                        subject su = i as subject;
                        if (su != null && su == lesson.subject)
                        {
                            this.dgSubjects.SelectedIndex = ind;
                            break;
                        }
                    }

                    ind = -1;
                    foreach (var i in this.dgTeachers.Items)
                    {
                        ++ind;
                        teacher te = i as teacher;
                        if (te == null || te != lesson.teacher) continue;
                        this.dgTeachers.SelectedIndex = ind;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Message.Show(ex.Message, MessageTypes.Error);
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Create a new lesson object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="subjectId">Initial value of the SubjectId property.</param>
 /// <param name="teacherId">Initial value of the TeacherId property.</param>
 /// <param name="groupId">Initial value of the GroupId property.</param>
 /// <param name="lessonIndex">Initial value of the LessonIndex property.</param>
 /// <param name="weekDay">Initial value of the WeekDay property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="isSubstitution">Initial value of the IsSubstitution property.</param>
 /// <param name="isCanceled">Initial value of the IsCanceled property.</param>
 /// <param name="lessonNum">Initial value of the LessonNum property.</param>
 public static lesson Createlesson(global::System.Int64 id, global::System.Int64 subjectId, global::System.Int64 teacherId, global::System.Int64 groupId, global::System.Int64 lessonIndex, global::System.Int64 weekDay, global::System.DateTime date, global::System.Boolean isSubstitution, global::System.Boolean isCanceled, global::System.Int64 lessonNum)
 {
     lesson lesson = new lesson();
     lesson.Id = id;
     lesson.SubjectId = subjectId;
     lesson.TeacherId = teacherId;
     lesson.GroupId = groupId;
     lesson.LessonIndex = lessonIndex;
     lesson.WeekDay = weekDay;
     lesson.Date = date;
     lesson.IsSubstitution = isSubstitution;
     lesson.IsCanceled = isCanceled;
     lesson.LessonNum = lessonNum;
     return lesson;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the lessons EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTolessons(lesson lesson)
 {
     base.AddObject("lessons", lesson);
 }
Exemplo n.º 8
0
 public void SetData(lesson less)
 {
     this.Lesson = less;
     this.Topic = less.Theme;
     this.Task = less.Task;
 }
Exemplo n.º 9
0
        public void LessonToLessonarchive(lesson l)
        {
            CheckConnection();
            try
            {
                lock (locker)
                {
                    lessonsarchive la = new lessonsarchive();
                    la.Date = l.Date;
                    la.GroupId = l.GroupId;
                    la.LessonIndex = l.LessonIndex;
                    la.SubjectId = l.SubjectId;
                    la.TeacherId = l.TeacherId;
                    la.WeekDay = l.WeekDay;
                    la.IsSubstitution = l.IsSubstitution;
                    la.IsCanceled = l.IsCanceled;

                    this.db.lessonsarchives.AddObject(la);
                    this.db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new DBException(ErrorTypes.UnexpectedException, ex);
            }
        }
Exemplo n.º 10
0
 public void EditLesson(lesson l, long subId, long teacherId, bool isSubst, bool isCanceled, string cl)
 {
     this.CheckConnection();
     try
     {
         lock (locker)
         {
             l.SubjectId = subId;
             l.TeacherId = teacherId;
             l.IsSubstitution = isSubst;
             l.IsCanceled = isCanceled;
             l.Class = cl;
             this.db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
Exemplo n.º 11
0
 public void AddLesson(lesson l)
 {
     this.CheckConnection();
     try
     {
         lock (locker)
         {
             //lesson le = lesson.Createlesson(0, l.SubjectId, l.TeacherId, l.GroupId, l.LessonIndex, 0, l.Date, l.IsSubstitution, l.IsCanceled);
             lesson le = this.db.lessons.CreateObject();
             le.SubjectId = l.SubjectId;
             le.TeacherId = l.TeacherId;
             le.GroupId = l.GroupId;
             le.Date = l.Date;
             le.IsSubstitution = l.IsSubstitution;
             le.IsCanceled = l.IsCanceled;
             le.Class = l.Class;
             le.LessonIndex = l.LessonIndex;
             le.LessonNum = l.LessonNum;
             this.db.lessons.AddObject(le);
             this.db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
Exemplo n.º 12
0
 public void DeleteLesson(lesson l)
 {
     this.CheckConnection();
     try
     {
         lock (locker)
         {
             this.db.lessons.DeleteObject(l);
             this.db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }