예제 #1
0
        public void CreateList()
        {
            string lvl = LevelChoser.GetItemText(LevelChoser.SelectedItem);

            if (lvl.Equals("All"))
            {
                if (courses_layout.Controls.Count > 0)
                {
                    courses_layout.Controls.Clear();
                }
                AspireDB      db    = new AspireDB();
                List <Course> clist = db.Courses.ToList();
                foreach (Course c in clist)
                {
                    CoursesView cv = new CoursesView(c);
                    courses_layout.Controls.Add(cv);
                }
                db.Database.Connection.Close();
            }
            else
            {
                if (courses_layout.Controls.Count > 0)
                {
                    courses_layout.Controls.Clear();
                }
                AspireDB      db    = new AspireDB();
                List <Course> clist = db.Courses.Where(x => x.Level == lvl).ToList();
                foreach (Course c in clist)
                {
                    CoursesView cv = new CoursesView(c);
                    courses_layout.Controls.Add(cv);
                }
                db.Database.Connection.Close();
            }
        }
예제 #2
0
 public void CreateList()
 {
     if(courses_layout.Controls.Count>0)
     {
         courses_layout.Controls.Clear();
     }
     AspireDB db = new AspireDB();
     List<Course> clist = db.Courses.ToList();
     foreach (Course c in clist)
     {
         CoursesView cv = new CoursesView(c);
         courses_layout.Controls.Add(cv);
     }
     db.Database.Connection.Close();
 }