コード例 #1
0
        public ActionResult TeachQueryTable(string tname)
        {
            int                   i           = 0;
            GradeDBContext        grade       = new GradeDBContext();
            SelectCourseDBContext selectCname = new SelectCourseDBContext();
            List <SelectCourse>   cname       = selectCname.SelectCourses.Where(u => u.TNAME == tname).ToList();

            foreach (var u in cname)
            {
                @TempData[i.ToString()] = u.CNAME;
                i++;
            }
            @ViewBag.count = i;
            return(View());
        }
コード例 #2
0
        public ActionResult StudentGrade2(string tname)
        {
            int i = 0;
            SelectedCourseDBContext selectSno      = new SelectedCourseDBContext();
            BasicInfoDBContext      studentMessage = new BasicInfoDBContext();
            SelectCourseDBContext   selectCname    = new SelectCourseDBContext();
            List <BasicInfo>        studentName    = new List <BasicInfo>();
            StudentGrade            result         = null;
            List <StudentGrade>     resultGrade    = new List <StudentGrade>();
            GradeDBContext          grade          = new GradeDBContext();
            List <SelectedCourse>   studentSno     = selectSno.SelectedCourses.Where(u => u.TNAME == tname.Replace(" ", "")).ToList();
            List <SelectCourse>     cname          = selectCname.SelectCourses.Where(u => u.TNAME == tname.Replace(" ", "")).ToList();

            string[] className = new string[10];
            foreach (var n in cname)
            {
                className[i] = n.CNAME.ToString().Replace(" ", "");
                i++;
            }
            foreach (var u in studentSno)
            {
                string name = className[1];
                if (name == u.CNAME.Replace(" ", "") && u.SEMESTER == "15-16春")
                {
                    var message      = studentMessage.Basics.Where(m => m.ID == u.SNO).FirstOrDefault();
                    var gradeStudent = grade.Grades.Where(n => n.SNO == u.SNO && n.CNO == u.CNO && n.SEMESTER == "15-16春").FirstOrDefault();
                    if (gradeStudent != null)
                    {
                        result = new StudentGrade()
                        {
                            SNO = message.ID, SNAME = message.NAME, GRADE = gradeStudent.GRADE
                        };
                    }
                    else
                    {
                        result = new StudentGrade()
                        {
                            SNO = message.ID, SNAME = message.NAME, GRADE = null
                        };
                    }
                    resultGrade.Add(result);
                }
            }
            return(View(resultGrade));
        }
コード例 #3
0
        public ActionResult Index()
        {
            @ViewBag.tno   = TempData["tno"];
            @ViewBag.tname = TempData["name"];
            string                tname       = TempData["name"].ToString();
            int                   i           = 0;
            GradeDBContext        grade       = new GradeDBContext();
            SelectCourseDBContext selectCname = new SelectCourseDBContext();
            List <SelectCourse>   cname       = selectCname.SelectCourses.Where(u => u.TNAME == tname).ToList();

            foreach (var u in cname)
            {
                Session[i.ToString()] = u.CNAME;
                i++;
            }

            return(View());
        }
コード例 #4
0
        public string UpdateGrade(List <InsertStusentGrade> models)
        {
            //不知道怎么将json传递过来,先放着吧,不干了,等以后再弄到再搞,现在宣布此项目暂时停住
            Grade                 grade          = null;
            GradeDBContext        gradeDbContext = new GradeDBContext();
            SelectCourseDBContext course         = new SelectCourseDBContext();
            SelectCourse          select         = new SelectCourse();
            string                result         = null;

            if (models != null)
            {
                foreach (var n in models)
                {
                    var    cNo      = course.SelectCourses.SingleOrDefault(u => u.CNAME == n.CNAME).CNO;
                    string CNO      = cNo.ToString();
                    var    newGrade = gradeDbContext.Grades.Where(u => u.SNO == n.SNO && u.CNO == CNO && u.SEMESTER == "15-16春").FirstOrDefault();
                    if (newGrade == null)
                    {                    //插入
                        grade = new Grade()
                        {
                            SNO = n.SNO, CNO = CNO, GRADE = n.GRADE, SEMESTER = "15-16春"
                        };
                        gradeDbContext.Grades.Add(grade);
                        gradeDbContext.SaveChanges();
                    }
                    else
                    {                    //更新
                        newGrade.GRADE = n.GRADE;
                        gradeDbContext.SaveChanges();
                    }
                }
            }
            else
            {
                result = "返回值为空";
            }

            result = "成功";
            return(result);
        }
コード例 #5
0
        public ActionResult GradesIndex(string sno)
        {
            SelectCourseDBContext dbselectcourse = new SelectCourseDBContext();
            GradeDBContext        dbgrade        = new GradeDBContext();
            SearchResult          searchResult   = null;
            var dbClassNo = dbgrade.Grades.Where(u => u.SNO == sno).ToList();
            List <SearchResult> result = new List <SearchResult>();

            foreach (var u in dbClassNo)
            {
                var classMessage = dbselectcourse.SelectCourses.Where(n => n.CNO == u.CNO).FirstOrDefault();
                if (Convert.ToInt32(u.GRADE) >= 90 && Convert.ToInt32(u.GRADE) <= 100)
                {
                    searchResult = new SearchResult()
                    {
                        CNO = u.CNO, CNAME = classMessage.CNAME, CREDIT = classMessage.CREDIT, GRADE = u.GRADE, GPA = 4.0
                    };
                }
                else if (Convert.ToInt32(u.GRADE) < 60)
                {
                    searchResult = new SearchResult()
                    {
                        CNO = u.CNO, CNAME = classMessage.CNAME, CREDIT = classMessage.CREDIT, GRADE = u.GRADE, GPA = 0.0
                    };
                }
                else if (Convert.ToInt32(u.GRADE) >= 85 && Convert.ToInt32(u.GRADE) <= 89)
                {
                    searchResult = new SearchResult()
                    {
                        CNO = u.CNO, CNAME = classMessage.CNAME, CREDIT = classMessage.CREDIT, GRADE = u.GRADE, GPA = 3.7
                    };
                }
                else if (Convert.ToInt32(u.GRADE) >= 82 && Convert.ToInt32(u.GRADE) <= 84)
                {
                    searchResult = new SearchResult()
                    {
                        CNO = u.CNO, CNAME = classMessage.CNAME, CREDIT = classMessage.CREDIT, GRADE = u.GRADE, GPA = 3.3
                    };
                }
                else if (Convert.ToInt32(u.GRADE) >= 78 && Convert.ToInt32(u.GRADE) <= 81)
                {
                    searchResult = new SearchResult()
                    {
                        CNO = u.CNO, CNAME = classMessage.CNAME, CREDIT = classMessage.CREDIT, GRADE = u.GRADE, GPA = 3.0
                    };
                }
                else if (Convert.ToInt32(u.GRADE) >= 75 && Convert.ToInt32(u.GRADE) <= 77)
                {
                    searchResult = new SearchResult()
                    {
                        CNO = u.CNO, CNAME = classMessage.CNAME, CREDIT = classMessage.CREDIT, GRADE = u.GRADE, GPA = 2.7
                    };
                }
                else if (Convert.ToInt32(u.GRADE) >= 72 && Convert.ToInt32(u.GRADE) <= 74)
                {
                    searchResult = new SearchResult()
                    {
                        CNO = u.CNO, CNAME = classMessage.CNAME, CREDIT = classMessage.CREDIT, GRADE = u.GRADE, GPA = 2.3
                    };
                }
                else if (Convert.ToInt32(u.GRADE) >= 68 && Convert.ToInt32(u.GRADE) <= 71)
                {
                    searchResult = new SearchResult()
                    {
                        CNO = u.CNO, CNAME = classMessage.CNAME, CREDIT = classMessage.CREDIT, GRADE = u.GRADE, GPA = 2.0
                    };
                }
                else if (Convert.ToInt32(u.GRADE) >= 64 && Convert.ToInt32(u.GRADE) <= 67)
                {
                    searchResult = new SearchResult()
                    {
                        CNO = u.CNO, CNAME = classMessage.CNAME, CREDIT = classMessage.CREDIT, GRADE = u.GRADE, GPA = 1.5
                    };
                }
                else if (Convert.ToInt32(u.GRADE) >= 60 && Convert.ToInt32(u.GRADE) <= 63)
                {
                    searchResult = new SearchResult()
                    {
                        CNO = u.CNO, CNAME = classMessage.CNAME, CREDIT = classMessage.CREDIT, GRADE = u.GRADE, GPA = 1.0
                    };
                }
                result.Add(searchResult);
            }
            return(View(result));
        }