Esempio n. 1
0
        //添加课程信息
        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;
        }
Esempio n. 2
0
        public List <Course> getCourses()
        {
            CourseDBContext coursedb = new CourseDBContext();
            List <Course>   courses  = coursedb.courses.ToList();

            coursedb = null;
            return(courses);
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        //寻找课程
        public Course findCourse(string courseId)
        {
            CourseDBContext cdb  = new CourseDBContext();
            List <Course>   list = cdb.courses.ToList();

            foreach (Course c in list)
            {
                if (c.courseId == courseId)
                {
                    return(c);
                }
            }
            return(null);
        }
Esempio n. 5
0
        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;
        }