protected void btn_givesc_Click(object sender, EventArgs e) { if (tb_class.Text == "" || tb_course.Text == "" || tb_teaer.Text == "") { Exception ex = new Exception(); ex.Data["tbnull"] = "数据不完整。"; throw ex; } ASSEntities assen = new ASSEntities(); SetCourses sc = new SetCourses(); int ncint = int.Parse(tb_class.Text); int ncoint = int.Parse(tb_course.Text); int ntint = int.Parse(tb_teaer.Text); var newclass = (from nc in assen.Classes where nc.ClassID == ncint select nc).First(); var newcourse = (from nco in assen.Courses where nco.CourseID == ncoint select nco).First(); var newteacher = (from nt in assen.Teachers where nt.TeaID == ntint select nt).First(); sc.SCID = 1; sc.Classes = newclass; sc.Courses = newcourse; sc.Teachers = newteacher; if (tb_semester.Text != "") { sc.Semester = tb_semester.Text; } else { sc.Semester = Session["schoolsemester"].ToString(); } assen.AddToSetCourses(sc); assen.SaveChanges(); }
public static SetCourses CreateSetCourses(int sCID, string semester) { SetCourses setCourses = new SetCourses(); setCourses.SCID = sCID; setCourses.Semester = semester; return setCourses; }
public void AddToSetCourses(SetCourses setCourses) { base.AddObject("SetCourses", setCourses); }