Example #1
0
        public static List <TStudentCourse> LoadData(int StudentID, TCourse course, out string error)
        {
            List <TStudentCourse> StudentCourses = new List <TStudentCourse>();
            List <TSubject>       Subjects       = new List <TSubject>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    StudentCourses = (from sc in db.StudentCourses where sc.StudentsID == StudentID select new TStudentCourse(sc)).ToList();
                    Subjects       = (from s in db.Subjects where s.CompulsoryDiscipline == false select new TSubject(s)).ToList();

                    var ls = Subjects.Where(i => StudentCourses.Where(p => p.SubjectsID == i.ID).Count() == 0).ToList();

                    var subjCourse = db.SubjectCourses.Where(i => i.CourseiD == course.ID).ToList();
                    ls = ls.Where(i => subjCourse.Select(p => p.SubjectID).Contains(i.ID)).ToList();

                    var specialities = db.SubjectSpecialities.Where(i => ls.Select(k => k.ID).Contains(i.SubjectID)).ToList();
                    var studSpecs    = db.StudentSpecialities.Where(i => i.CourseID == course.ID).ToList();

                    foreach (var l in ls)
                    {
                        var s = new TStudentCourse(l, course);
                        StudentCourses.Add(s);
                    }
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(StudentCourses);
        }
Example #2
0
 public TStudentCourse(TSubject s, TCourse stc)
 {
     this.Subject  = s;
     this.Course   = stc;
     this.Selected = false;
 }