/// <summary> /// 删除一条教师授课信息 /// </summary> /// <param name="Teacher_id"></param> /// <param name="course_id"></param> /// <returns></returns> public IActionResult DelTCcourse(string Teacher_id, string course_id) { TCmethod cmethod = new TCmethod(); cmethod.DelTC(Teacher_id, course_id); return(Content("<script>alert('删除成功');window.location.href='../Administrator/ShowTC';</script>", "text/html;charset=UTF-8")); }
/// <summary> /// 教师授课信息变动页面 /// </summary> /// <returns></returns> public IActionResult ModifyTC() { TeacherMethod teacher = new TeacherMethod(); TCmethod cmethod = new TCmethod(); var courses = new List <List <Course> >(); var Allteacher = teacher.ReadDB(); foreach (var infor in Allteacher) { courses.Add(cmethod.GetCourseByTno(infor.Tno)); } ViewBag.courses = courses; ViewBag.teachers = Allteacher; return(View()); }
/// <summary> /// 输出一个老师所教授的所有课程 /// </summary> /// <param name="Teacher_id"></param> /// <returns></returns> public IActionResult ShowTC(string Teacher_id) { TeacherMethod method = new TeacherMethod(); if (method.GetTeacher(Teacher_id) != null) { TCmethod cmethod = new TCmethod(); ViewBag.courses = cmethod.GetCourseByTno(Teacher_id); ViewBag.Tno = Teacher_id; return(View()); } else { return(Content("<script>alert('该教师不存在');history.go(-1);</script>", "text/html;charset=UTF-8")); } }
public IActionResult Input(Student student) { this.Request.Cookies.TryGetValue("Tno", out string Value); var infor = new Student(); using (var dbcontext = new srContext()) { infor = dbcontext.Student.FirstOrDefault(u => u.Sno == student.Sno); } if (infor == null) { return(Content("<script>alert('该学生不存在');history.go(-1);</script>", "text/html;charset=UTF-8")); } else { ScoreMethod method = new ScoreMethod(); CourseMethod course = new CourseMethod(); TCmethod cmethod = new TCmethod(); List <Course> courses = cmethod.GetCourseByTno(Value); var scoreLists = method.GetnullScores(student.Sno); var scores = new List <Score>(); foreach (var temp in courses) { if (scoreLists.FirstOrDefault(s => s.Cno == temp.Cno) != null) { scores.Add(scoreLists.FirstOrDefault(s => s.Cno == temp.Cno)); } } if (scores.Count() != 0) { List <Course> courseLists = new List <Course>(); foreach (var value in scores) { courseLists.Add(course.FindCourse(value.Cno)); } ViewBag.scoreLists = scores; ViewBag.courseLists = courseLists; return(View()); } else { return(Content("<script>alert('暂无成绩可录入');history.go(-1);</script>", "text/html;charset=UTF-8")); } } }
public IActionResult Showstuscore(string stu_id) { using (var dbcontext = new srContext()) { this.Request.Cookies.TryGetValue("Tno", out string Value); TCmethod cmethod = new TCmethod(); List <Course> courseslist = cmethod.GetCourseByTno(Value); var stu = dbcontext.Student.FirstOrDefault(u => u.Sno == stu_id); decimal? credit = 0; if (stu != null) { ScoreMethod method = new ScoreMethod(); List <Score> scores = method.GetScores(stu_id); List <Course> courses = new List <Course>(); var scoreslist = new List <Score>(); foreach (var temp in courseslist) { if (scores.FirstOrDefault(s => s.Cno == temp.Cno) != null) { scoreslist.Add(scores.FirstOrDefault(s => s.Cno == temp.Cno)); } } for (int i = 0; i < scoreslist.Count; i++) { courses.Add(dbcontext.Course.FirstOrDefault(u => u.Cno == scoreslist[i].Cno)); if (scoreslist[i].Grade >= 60 && scoreslist[i].Grade != null) { credit += courses[i].Credit; } } var Crd = credit.ToString(); ViewBag.courses = courses; ViewBag.scores = scoreslist; ViewBag.credit = Crd; return(View()); } else { return(Content("<script>alert('该学生不存在');history.go(-1);</script>", "text/html;charset=UTF-8")); } } }
//增加一条教师授课信息 public IActionResult AddTCcourse(string Teacher_id, string course_id) { TCmethod cmethod = new TCmethod(); CourseMethod course = new CourseMethod(); if (course.FindCourse(course_id) == null) { return(Content("<script>alert('添加失败,不存在这门课程');history.go(-1);</script>", "text/html;charset=UTF-8")); } else { if (cmethod.AddTC(Teacher_id, course_id)) { return(RedirectToAction("ShowTC", "Administrator", new { Teacher_id = Teacher_id })); } else { return(Content("<script>alert('添加失败,请勿重复添加');history.go(-1);</script>", "text/html;charset=UTF-8")); } } }