Ejemplo n.º 1
0
        public ActionResult StudentList2(string tname)
        {
            int i = 0;
            SelectedCourseDBContext selectSno      = new SelectedCourseDBContext();
            SelectCourseDBContext   selectCname    = new SelectCourseDBContext();
            BasicInfoDBContext      studentMessage = new BasicInfoDBContext();
            List <SelectedCourse>   studentSno     = selectSno.SelectedCourses.Where(u => u.TNAME == tname).ToList();
            List <SelectCourse>     cname          = selectCname.SelectCourses.Where(u => u.TNAME == tname).ToList();

            string[]         className = new string[cname.Count];
            List <BasicInfo> result    = new List <BasicInfo>();

            foreach (var n in cname)
            {
                className[i] = n.CNAME;
                i++;
            }
            foreach (var u in studentSno)
            {
                string name = className[1];
                if (name == u.CNAME)
                {
                    List <BasicInfo> message = studentMessage.Basics.Where(m => m.ID == u.SNO && u.CNAME == name && u.SEMESTER == "15-16春").ToList();
                    result.AddRange(message);
                }
            }
            return(View(result));
        }
Ejemplo n.º 2
0
        public ActionResult TableIndex(FormCollection fc)
        {
            string cno  = fc["cno"].Replace(" ", "");
            string name = fc["cname"].Replace(" ", "");
            SelectCourseDBContext selectCourse = new SelectCourseDBContext();

            if (!string.IsNullOrEmpty(cno) && !string.IsNullOrEmpty(name))
            {
                result = selectCourse.SelectCourses.Where(u => u.CNO == cno && u.CNAME == name).ToList();
            }
            return(View(result));
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
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());
        }
Ejemplo n.º 6
0
        public string DropCourse(string sno, string cno)
        {
            string result = null;
            SelectCourseDBContext   selectDbCourse   = new SelectCourseDBContext();
            SelectedCourse          selectedCourse   = new SelectedCourse();
            SelectedCourseDBContext selectedDbCourse = new SelectedCourseDBContext();
            var selectedResult = selectedDbCourse.SelectedCourses.Where(u => u.SNO == sno && u.CNO == cno).FirstOrDefault();
            int id             = selectedResult.ID;
            var deleteResult   = selectedDbCourse.SelectedCourses.First(u => u.ID == id);

            selectedDbCourse.SelectedCourses.Remove(deleteResult);
            var selectResult = selectDbCourse.SelectCourses.Where(u => u.CNO == cno).FirstOrDefault();

            selectedDbCourse.SaveChanges();
            selectResult.SELECTEDNUM--;
            selectDbCourse.SaveChanges();
            result = "退课成功!";
            return(result);
        }
Ejemplo n.º 7
0
        public string StudentSelectCourse(string sno, string cno, string cname, string tname, string cdept, string credit, string time)
        {
            string result = null;
            SelectCourseDBContext selectDbContext = new SelectCourseDBContext();
            var message = selectDbContext.SelectCourses.Where(u => u.CNO == cno && u.CNAME == cname).FirstOrDefault();
            SelectedCourseDBContext selectedDbContext = new SelectedCourseDBContext();
            var isSelected = selectedDbContext.SelectedCourses.Where(u => u.CNO == cno && u.SNO == sno).FirstOrDefault();
            var classTime  = selectedDbContext.SelectedCourses.Where(u => u.SNO == sno).ToList();

            if (message == null)
            {
                result = "该课程不存在,请核实该课程信息!";
            }
            else if (message.SELECTEDNUM == message.CAPACITY)
            {
                result = "该课程所选人数已达人数上限!";
            }
            else if (isSelected != null)
            {
                result = "您已经选过该课程!";
            }
            else if (classTime != null)
            {
                if (IsConflict(classTime, time))
                {
                    result = "课时冲突";
                }
                else
                {
                    SelectedCourse selectedCourse = new SelectedCourse()
                    {
                        SNO = sno, CNO = cno, CNAME = cname, CREDIT = Convert.ToInt32(credit), CDEPT = cdept, TNAME = tname, TIME = time, SEMESTER = "15-16春"
                    };
                    selectedDbContext.SelectedCourses.Add(selectedCourse);
                    selectedDbContext.SaveChanges();
                    message.SELECTEDNUM++;
                    selectDbContext.SaveChanges();
                    result = "选课成功!";
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
        public string Dilatation(string classNumber, string className, string classCapacity)
        {
            string message = null;
            SelectCourseDBContext selectDbCourse = new SelectCourseDBContext();
            var result = selectDbCourse.SelectCourses.Where(u => u.CNO == classNumber && u.CNAME == className).FirstOrDefault();

            if (result == null)
            {
                message = "没有查到该课程!";
            }
            else
            {
                int number = result.CAPACITY;
                result.CAPACITY = number + Convert.ToInt32(classCapacity);
                selectDbCourse.SaveChanges();
                message = "扩容成功";
            }

            return(message);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public string AddCourse(string tno, string tname, string cno, string cname, string credit, string cdept, string time, string selectednum, string capacity)
        {
            string                lastResult  = null;
            BasicInfoDBContext    basicDbInfo = new BasicInfoDBContext();
            SelectCourse          selectcourse;
            SelectCourseDBContext selectDbContext = new SelectCourseDBContext();
            var result = basicDbInfo.Basics.Where(u => u.ID == tno && u.NAME == tname).FirstOrDefault();            //判断教师是否存在

            //教师是否存在
            if (result == null)
            {
                lastResult = "该教师不存在,请核实!";
            }
            //教师存在
            else
            {
                var teacherTeachCourse = selectDbContext.SelectCourses.Where(u => u.TNAME == tname).ToList();
                //该教师自己课程间是否冲突
                foreach (var t in teacherTeachCourse)
                {
                    if (t.TIME.ToString().Trim() == time || t.CNO.ToString().Trim() == cno)
                    {
                        lastResult = "该教师课时或课号冲突,请重新确认!";
                        break;
                    }
                }
                if (lastResult == null)
                {
                    selectcourse = new SelectCourse()
                    {
                        CNO = cno, TNO = tno, CNAME = cname, CREDIT = Convert.ToInt32(credit), CDEPT = cdept, TNAME = tname, TIME = time, SELECTEDNUM = Convert.ToInt32(selectednum), CAPACITY = Convert.ToInt32(capacity)
                    };
                    selectDbContext.SelectCourses.Add(selectcourse);
                    selectDbContext.SaveChanges();
                    lastResult = "添加成功!";
                }
            }
            return(lastResult);
        }
Ejemplo n.º 11
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));
        }
Ejemplo n.º 12
0
        public ActionResult QueryTable(string tname)
        {
            string number = null;

            string[,] timeTable = new string[13, 5];
            for (int i = 0; i < 13; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    timeTable[i, j] = "0";
                }
            }
            SelectCourseDBContext selectCourse = new SelectCourseDBContext();
            List <SelectCourse>   result       = selectCourse.SelectCourses.Where(u => u.TNAME == tname).ToList();
            Regex regexCharacter = new Regex("[\u4E00-\u9FA5]");
            Regex regexDigit     = new Regex(@"(\d{1,2})-(\d{1,2})");

            foreach (var u in result)
            {
                int             n = 0;
                MatchCollection characterRegex = regexCharacter.Matches(u.TIME);
                MatchCollection digitRegex     = regexDigit.Matches(u.TIME);
                foreach (Match week in characterRegex)
                {
                    int m = 0;
                    switch (week.Value.ToString())
                    {
                    case "一":
                        number = "0";
                        break;

                    case "二":
                        number = "1";
                        break;

                    case "三":
                        number = "2";
                        break;

                    case "四":
                        number = "3";
                        break;

                    case "五":
                        number = "4";
                        break;
                    }
                    foreach (Match classTime in digitRegex)
                    {
                        if (m == n)
                        {
                            string[] firstTime = classTime.Value.ToString().Split('-');
                            for (int i = Convert.ToInt32(firstTime[0]) - 1; i <= Convert.ToInt32(firstTime[1]) - 1; i++)
                            {
                                timeTable[i, Convert.ToInt32(number)] = u.CNAME;
                            }
                        }
                        m++;
                    }
                    n++;
                }
            }
            RowColKey        rowColKey     = null;
            List <RowColKey> listRowColKey = new List <RowColKey>();

            for (int i = 0; i < 13; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    if (timeTable[i, j] != "0")
                    {
                        rowColKey = new RowColKey()
                        {
                            Row = i, Col = j, Key = timeTable[i, j]
                        };
                        listRowColKey.Add(rowColKey);
                    }
                }
            }
            return(View(listRowColKey));
        }