private void filter_combo_SelectedIndexChanged(object sender, EventArgs e) { string item = filter_combo.Text; if (!item.Trim().Equals("")) { if (item.Trim().ToLower().Equals("all")) { CreateList(); } else { string[] parsed = item.Split('-'); string name = parsed[0]; string level = HelpMe.GetFullForm(parsed[1]); AspireDB db = new AspireDB(); Course c = db.Courses.SingleOrDefault(Course => Course.Name == name && Course.Level == level); CreateList(c); } } else { CreateList(); } }
// Add student method private void addbtn_Click(object sender, EventArgs e) { if (ValidateChildren()) { Student stud = new Student(); stud.Name = student_name.Text; stud.StudentID = student_studentID.Text; stud.Email = student_email.Text; string toparse = course_combo.Text; string[] strs = toparse.Split('-'); string cname = strs[0], clevel = HelpMe.GetFullForm(strs[1]); Course fc = db.Courses.SingleOrDefault(Course => Course.Name == cname && Course.Level == clevel); stud.Course = fc; db.Students.Add(stud); db.SaveChanges(); student_email.Text = ""; student_name.Text = ""; student_studentID.Text = ""; StudentControl.Instance.CreateList(); StudentControl.Instance.FooterMessage("Student Added"); } }