예제 #1
0
 private void dgSubjects_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.dgSubjects.SelectedItem != null)
     {
         this.currentSubject = this.dgSubjects.SelectedItem as subject;
         List<dynamic> teas = null;
         if (this.chbSubst.IsChecked.HasValue && this.chbSubst.IsChecked.Value)
         {
             teas = DBModel.Instance.GetAllTeachers();
         }
         else
         {
             teas = DBModel.Instance.GetTeachersBySubject(this.currentSubject);
         }
         this.dgTeachers.ItemsSource = teas;
     }
     else
     {
         this.currentSubject = null;
         this.dgTeachers.ItemsSource = null;
     }
 }
예제 #2
0
 /// <summary>
 /// Create a new subject object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="fullName">Initial value of the FullName property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static subject Createsubject(global::System.Int64 id, global::System.String fullName, global::System.Boolean isDeleted)
 {
     subject subject = new subject();
     subject.Id = id;
     subject.FullName = fullName;
     subject.IsDeleted = isDeleted;
     return subject;
 }
예제 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the subjects EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTosubjects(subject subject)
 {
     base.AddObject("subjects", subject);
 }
예제 #4
0
파일: DBModel.cs 프로젝트: Deiwos3/IMS
 public List<dynamic> GetTeachersBySubject(subject s, bool includeDeleted = false)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             return s.ref_teacher_subject.Where(x => x.teacher.person.IsDeleted == includeDeleted).Select(t => t.teacher).ToList<dynamic>();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     } 
 }
예제 #5
0
파일: DBModel.cs 프로젝트: Deiwos3/IMS
 public void DeleteSubject(subject s)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             s.IsDeleted = true;
             ref_subject_department d = s.ref_subject_department.FirstOrDefault();
             while(d != null)
             {
                 db.ref_subject_department.DeleteObject(d);
                 d = s.ref_subject_department.FirstOrDefault();
             }
             ref_subject_group g = s.ref_subject_group.FirstOrDefault();
             while (g != null)
             {
                 db.ref_subject_group.DeleteObject(g);
                 g = s.ref_subject_group.FirstOrDefault();
             }
             ref_teacher_subject t = s.ref_teacher_subject.FirstOrDefault();
             while (t != null)
             {
                 db.ref_teacher_subject.DeleteObject(t);
                 t = s.ref_teacher_subject.FirstOrDefault();
             }
             //    foreach (var i in s.ref_subject_department)
             //        db.ref_subject_department.DeleteObject(i);
             //foreach (var i in s.ref_subject_group)
             //    db.ref_subject_group.DeleteObject(i);
             //foreach (var i in s.ref_teacher_subject)
             //    db.ref_teacher_subject.DeleteObject(i);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
예제 #6
0
파일: DBModel.cs 프로젝트: Deiwos3/IMS
 public void EditSubject(subject s, string newShortName, string newFullName)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             s.ShortName = newShortName;
             s.FullName = newFullName;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
예제 #7
0
파일: DBModel.cs 프로젝트: Deiwos3/IMS
 public ref_subject_group FindSubjectOfGroup(studentsgroup gr, subject s)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             return db.ref_subject_group.FirstOrDefault(i => i.GroupId == gr.Id && i.SubjectId == s.Id);
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
예제 #8
0
파일: DBModel.cs 프로젝트: Deiwos3/IMS
 public void AddSubjectToGroup(studentsgroup gr, subject s)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             ref_subject_group r = ref_subject_group.Createref_subject_group(0, gr.Id, s.Id);
             db.ref_subject_group.AddObject(r);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     } 
 }