Beispiel #1
0
        /// <summary>
        /// 培训机构正式开班
        /// 设置课程和指定教师
        /// </summary>
        /// <param name="planClassID">计划班级ID</param>
        public ActionResult SetCourse(int id)
        {
            TrainSetCourseViewData viewData = new TrainSetCourseViewData();

            Classes classes = (from c in CQGJ.Classes
                               where c.ClassID == id
                               select c).First();
            viewData.Teachers = (from t in CQGJ.Teacher
                                 from c in CQGJ.Classes
                                 where c.ClassID == id
                                 where t.Org == c.Org
                                 select t).ToList();

            if (Request.RequestType == "POST")
            {
                try
                {
                    Course course = new Course();
                    course.CourseName = GetString("coursename");
                    course.CourseTime = GetInt("CourseTime");
                    course.Remark = GetString("Remark");
                    course.Classes = classes;
                    int teacherID = GetInt("TeacherID");
                    Teacher teacher = (from t in CQGJ.Teacher
                                       where t.TeacherID == teacherID
                                       select t).First();
                    course.Teacher = teacher;
                    CQGJ.AddToCourse(course);
                    CQGJ.SaveChanges();
                    return RedirectToAction("assignbook/" + course.CourseID, "train");
                }
                catch { TempData["Error"] = "请先添加老师!"; }
            }

            viewData.Classes = classes;
            return View("SetCourse", viewData);
        }
Beispiel #2
0
        public ActionResult AddCourse(int id)
        {
            TrainCourseListViewData viewData = new TrainCourseListViewData();
            Classes classes = (from c in CQGJ.Classes
                               where c.ClassID == id
                               select c).First();
            viewData.Classes = classes;
            if (Request.RequestType == "POST")
            {

                Course course = new Course();
                course.Classes = classes;
                course.CourseName = GetString("coursename");
                course.CourseTime = GetInt("time");
                course.TeacherName = GetString("teacher");
                course.Remark = GetString("remark");
                CQGJ.AddToCourse(course);
                CQGJ.SaveChanges();
                return RedirectToAction("courselist/" + id);
            }
            return View("AddCourse", viewData);
        }