/// <summary> /// 插入选课信息 /// </summary> /// <param name="courseNum">课程号</param> /// <param name="teacherNum">教师编号</param> /// <returns></returns> public ActionResult InsertSelectClass(string courseNum, string teacherNum) { if (Session["UserType"] != null && Session["UserType"].ToString() == "Student") { if (Session["UserNum"] != null) { int k = SelectClassInfo.ExecuteSelelctClass(Session["UserNum"].ToString(), courseNum, teacherNum); if (k > 0) { //return Content("选课成功!"); return(Content("Success")); } else if (k == -1)//已存在的选课信息 { //return Content("课程已经选过了"); return(Content("Error1")); } else// k == 0,选课失败或者插入异常 { //return Content("选课失败"); return(Content("Error2")); } } else { return(RedirectToAction("../Home/Login")); } } else { return(RedirectToAction("../Home/Login")); } }
/// <summary> /// 退选 /// </summary> /// <param name="courseNum">课程编号</param> /// <returns></returns> public ActionResult DeleteSelectClass(string courseNum) { if (Session["UserType"] != null && Session["UserType"].ToString() == "Student") { if (Session["UserNum"] != null) { if (SelectClassInfo.DeleteSelectClassByCourseNum(Session["UserNum"].ToString(), courseNum) > 0) { //return RedirectToAction("ShowSelectClassInfo"); return(Content("Success")); } else { return(Content("Error")); } } else { return(RedirectToAction("../Home/Login")); } } else { return(RedirectToAction("../Home/Login")); } }
/// <summary> /// 【教师】获取学生当前的成绩 /// </summary> /// <param name="stuNum"></param> /// <param name="coureNum"></param> /// <returns></returns> public ActionResult TGetStuScoreInfo(string stuNum, string courseNum) { if (Session["UserType"] != null && Session["UserType"].ToString() == "Teacher") { if (Session["UserNum"] != null) { SelectClassInfo sc = SelectClassInfo.TGetStuScoreInfo(stuNum, courseNum); var json = new { Grade1 = sc.Grade1, Grade2 = sc.Grade2, Grade3 = sc.Grade3, Grade4 = sc.Grade4, Grade = sc.Grade }; return(Json(json, JsonRequestBehavior.DenyGet)); } else { return(RedirectToAction("../Home/Login")); } } else { return(RedirectToAction("../Home/Login")); } }
/// <summary> /// 【教师】获取选课的详细的【学生的信息】 /// </summary /// <returns></returns> public ActionResult GetStudentInfoInSelectClass(string courseNum) { if (Session["UserType"] != null && Session["UserType"].ToString() == "Teacher") { if (Session["UserNum"] != null) { List <StuInfo> list = SelectClassInfo.GetStuInfoByCourseNumAndTeacherNum(courseNum, Session["UserNum"].ToString()); var json = new { total = list.Count, Row = list.ToArray() }; return(Json(json, JsonRequestBehavior.DenyGet)); } else { return(RedirectToAction("../Home/Login")); } } else { return(RedirectToAction("../Home/Login")); } }
/// <summary> /// 选课课程信息展示 /// </summary> /// <returns></returns> public ActionResult ShowSelectClassInfo() { if (Session["UserType"] != null && Session["UserType"].ToString() == "Student") { if (Session["UserNum"] != null) { //学生信息展示 StuInfo s1 = new StuInfo(); s1 = StuInfo.GetStuInfo(Session["UserNum"].ToString()); ViewBag.Stu = s1; //①展示选课课程信息 List <CourseInfo> list = null; list = CourseInfo.ShowCourseInfo(); //②展示学生已经选好的课程信息 List <SelectClassInfo> list2 = null; list2 = SelectClassInfo.GetStuSelectClassInfoByStuNum(Session["UserNum"].ToString()); if (list != null && list2 != null) { ViewBag.CourseInfo = list; //选课课程信息 ViewBag.SelectClassInfo = list2; //学生已选课程信息 return(View()); } else { return(RedirectToAction("../Home/Error404")); } } else { return(RedirectToAction("../Home/Login")); } } else { return(RedirectToAction("../Home/Login")); } }
/// <summary> /// 【教师】提交学生成绩 /// </summary> /// <param name="stuNum">学号</param> /// <returns></returns> public ActionResult TSvaeStuScore(string stuNum, string courseNum, string grade1, string grade2, string grade3, string grade4, string grade) { if (Session["UserType"] != null && Session["UserType"].ToString() == "Teacher") { if (Session["UserNum"] != null) { //数据填充 SelectClassInfo sc = new SelectClassInfo(); sc.StuNum = stuNum; sc.CourseNum = courseNum; sc.Grade1 = Convert.ToInt32(grade1); sc.Grade2 = Convert.ToInt32(grade2); sc.Grade3 = Convert.ToInt32(grade3); sc.Grade4 = Convert.ToInt32(grade4); sc.Grade = Convert.ToInt32(grade); //执行 int result = SelectClassInfo.TSvaeStuScore(sc); //比较执行结果 if (result > 0) { return(Content("Success")); } else { return(Content("Error")); } } else { return(RedirectToAction("../Home/Login")); } } else { return(RedirectToAction("../Home/Login")); } }