//添加课程信息 public void addCourse(string name, string start, string end, string address, string teacher) { CourseDBContext db = new CourseDBContext(); DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo(); dtFormat.ShortDatePattern = "yyyy/MM/dd"; DateTime dt1 = Convert.ToDateTime(start, dtFormat); DateTime dt2 = Convert.ToDateTime(end, dtFormat); Course course = new Course(); string coursesId = System.DateTime.Now.ToLongDateString(); course.courseId = coursesId; course.courseName = name; course.courseStartTime = dt1; course.courseEndTime = dt2; course.coursePlace = address; course.courseTeacherName = teacher; course.courseCredit = 5; course.courseOutlineURL = ""; course.courseRequireURL = ""; course.courseTime = 0; course.maxNumPerGroup = 0; course.minNumPerGroup = 0; course.isEnd = false; db.courses.Add(course); db.SaveChanges(); db = null; }
internal void addCourse(string courseName, string courseStartTime, string courseEndTime, string coursePlace, string courseTeacherName, string courseCredit, string courseTime) { CourseDBContext db = new CourseDBContext(); DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo(); dtFormat.ShortDatePattern = "yyyy/MM/dd"; DateTime dt1 = Convert.ToDateTime(courseStartTime, dtFormat); DateTime dt2 = Convert.ToDateTime(courseEndTime, dtFormat); Course course = new Course(); string coursesId = System.DateTime.Now.ToString(); course.courseId = coursesId; course.courseName = courseName; course.courseStartTime = dt1; course.courseEndTime = dt2; course.coursePlace = coursePlace; course.courseTeacherName = courseTeacherName; /* * int coursecredit = 0; * try * { * coursecredit = Convert.ToInt32(courseCredit); * } * catch (Exception) * { * coursecredit = 0; * } * course.courseCredit = coursecredit; * int coursetime = 0; * try * { * coursetime = Convert.ToInt32(courseTime); * * } * catch (Exception) * { * coursetime = 0; * } * course.courseTime = coursetime; */ course.courseCredit = Convert.ToInt32(courseCredit); course.courseTime = Convert.ToInt32(courseTime); course.courseOutlineURL = ""; course.courseRequireURL = ""; course.maxNumPerGroup = 0; course.minNumPerGroup = 0; course.isEnd = false; db.courses.Add(course); db.SaveChanges(); db = null; }
public void addRequire(string courseid, string require) { CourseDBContext db = new CourseDBContext(); List <Course> clist = db.courses.ToList(); foreach (Course course in clist) { if (course.courseId == courseid) { course.courseRequireURL = require; } } int num = db.SaveChanges(); db = null; }