コード例 #1
0
        public IActionResult Showscores()
        {
            this.Request.Cookies.TryGetValue("Sno", out string value);
            ScoreMethod   method  = new ScoreMethod();
            List <Score>  scores  = method.GettureScores(value);
            List <Course> courses = new List <Course>();
            decimal?      credit  = 0;

            using (var dbcontext = new srContext())
            {
                for (int i = 0; i < scores.Count; i++)
                {
                    courses.Add(dbcontext.Course.FirstOrDefault(u => u.Cno == scores[i].Cno));
                    if (scores[i].Grade >= 60 && scores[i].Grade != null)
                    {
                        credit += courses[i].Credit;
                    }
                }
            }
            var Crd = credit.ToString();

            ViewBag.courses = courses;
            ViewBag.scores  = scores;
            ViewBag.credit  = Crd;
            return(View());
        }
コード例 #2
0
 /// <summary>
 /// 退课
 /// </summary>
 /// <param name="stu_id"></param>
 /// <param name="cou_id"></param>
 /// <returns></returns>
 public void Delscore(string stu_id, string cou_id)
 {
     using (var dbcontext = new srContext())
     {
         var infor = dbcontext.Score.FirstOrDefault(u => u.Sno == stu_id && u.Cno == cou_id);
         dbcontext.Score.Remove(infor);
         dbcontext.SaveChanges();
     }
 }
コード例 #3
0
 public IActionResult ChangeInfor(Teacher teacher)
 {
     using (var dbcontext = new srContext())
     {
         var temp = dbcontext.Teacher.FirstOrDefault(s => s.Tno == teacher.Tno);
         temp.Tphone = teacher.Tphone;
         dbcontext.SaveChanges();
     }
     return(RedirectToAction("Detail", "Teacher"));
 }
コード例 #4
0
ファイル: TCmethod.cs プロジェクト: BiLanGang/C-Prime-Program
        /// <summary>
        /// 删除一条老师授课信息
        /// </summary>
        /// <param name="Tid"></param>
        /// <param name="Cid"></param>
        /// <returns></returns>
        public void DelTC(string Tid, string Cid)
        {
            using (var db = new srContext())
            {
                var value = db.Teachercourse.FirstOrDefault(t => t.Cno == Cid && t.Tno == Tid);

                db.Teachercourse.Remove(value);
                db.SaveChanges();
            }
        }
コード例 #5
0
        /// <summary>
        /// 按课程编号查找一门课程
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public Course FindCourse(string value)
        {
            var course = new Course();

            using (var dbcontext = new srContext())
            {
                course = dbcontext.Course.FirstOrDefault(c => c.Cno == value);
            }
            return(course);
        }
コード例 #6
0
        /// <summary>
        /// 获取一个老师信息
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public Teacher GetTeacher(string value)
        {
            var teacher = new Teacher();

            using (var dbcontext = new srContext())
            {
                var infor = dbcontext.Teacher.FirstOrDefault(u => u.Tno == value);
                teacher = infor;
            }
            return(teacher);
        }
コード例 #7
0
 public IActionResult ChangeInfor(Student student)
 {
     using (var dbcontext = new srContext())
     {
         var temp = dbcontext.Student.FirstOrDefault(s => s.Sno == student.Sno);
         temp.Sphone   = student.Sphone;
         temp.Saddress = student.Saddress;
         dbcontext.SaveChanges();
     }
     return(RedirectToAction("Detail", "Student"));
 }
コード例 #8
0
        /// <summary>
        /// 获取教务人员信息
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public Administrator GetAdmin(string value)
        {
            var admin = new Administrator();

            using (var dbcontext = new srContext())
            {
                var infor = dbcontext.Administrator.FirstOrDefault(u => u.Ano == value);
                admin = infor;
            }
            return(admin);
        }
コード例 #9
0
        /// <summary>
        /// 获取所有教师信息
        /// </summary>
        /// <returns></returns>
        public List <Teacher> ReadDB()
        {
            List <Teacher> teachers = new List <Teacher>();

            using (var dbcontext = new srContext())
            {
                foreach (var infor in dbcontext.Teacher)
                {
                    teachers.Add(infor);
                }
            }
            return(teachers);
        }
コード例 #10
0
        /// <summary>
        /// 获取所有课程信息
        /// </summary>
        /// <returns></returns>
        public List <Course> GetAllCourses()
        {
            List <Course> courses = new List <Course>();

            using (var dbcontext = new srContext())
            {
                foreach (var infor in dbcontext.Course)
                {
                    courses.Add(infor);
                }
            }
            return(courses);
        }
コード例 #11
0
 /// <summary>
 /// 判断证书信息是否存在
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public bool Check(string value)
 {
     using (var dbcontext = new srContext())
     {
         if (dbcontext.Certificate.FirstOrDefault(c => c.Cerno == value) != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
コード例 #12
0
        /// <summary>
        /// 获取一个学生所有有成绩的课程
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public List <Score> GettureScores(string value)
        {
            List <Score> scores = new List <Score>();

            using (var dbcontext = new srContext())
            {
                foreach (var infor in dbcontext.Score)
                {
                    if (infor.Sno == value && infor.Grade != null)
                    {
                        scores.Add(infor);
                    }
                }
            }
            return(scores);
        }
コード例 #13
0
        /// <summary>
        /// 获取一个学生的所有证书信息
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public List <Certificate> GetCertificates(string value)
        {
            List <Certificate> certificates = new List <Certificate>();

            using (var dbcontext = new srContext())
            {
                foreach (var infor in dbcontext.Certificate)
                {
                    if (infor.Sno == value)
                    {
                        certificates.Add(infor);
                    }
                }
            }
            return(certificates);
        }
コード例 #14
0
ファイル: TCmethod.cs プロジェクト: BiLanGang/C-Prime-Program
        /// <summary>
        /// 按教师ID获取他所教授的所有课程
        /// </summary>
        /// <param name="Tea_id"></param>
        /// <returns></returns>
        public List <Course> GetCourseByTno(string Tea_id)
        {
            var List = new List <Course>();

            using (var db = new srContext())
            {
                foreach (var infor in db.Teachercourse)
                {
                    if (infor.Tno == Tea_id)
                    {
                        List.Add(db.Course.FirstOrDefault(c => c.Cno == infor.Cno));
                    }
                }
            }
            return(List);
        }
コード例 #15
0
        /// <summary>
        /// 获取一个学生的四六级信息
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public List <Cet> GetCets(string value)
        {
            List <Cet> cets = new List <Cet>();

            using (var dbcontext = new srContext())
            {
                foreach (var infor in dbcontext.Cet)
                {
                    if (infor.Sno == value)
                    {
                        cets.Add(infor);
                    }
                }
            }
            return(cets);
        }
コード例 #16
0
        /// <summary>
        /// 按类别获取课程列表
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public List <Course> GetCourses(string type)
        {
            List <Course> courses = new List <Course>();

            using (var dbcontext = new srContext())
            {
                foreach (var infor in dbcontext.Course)
                {
                    if (infor.Ctype == type)
                    {
                        courses.Add(infor);
                    }
                }
            }
            return(courses);
        }
コード例 #17
0
 /// <summary>
 /// 删除一个教师
 /// </summary>
 /// <param name="teacher_id"></param>
 /// <returns></returns>
 public IActionResult Delteamethod(string teacher_id)
 {
     using (var dbcontext = new srContext())
     {
         var infor = dbcontext.Teacher.FirstOrDefault(u => u.Tno == teacher_id);
         if (infor != null)
         {
             TeacherMethod method = new TeacherMethod();
             method.Delete(teacher_id);
             return(Content("<script>alert('删除成功');window.location.href='../Administrator/Delteacher';</script>", "text/html;charset=UTF-8"));
         }
         else
         {
             return(Content("<script>alert('该教师不存在');history.go(-1);</script>", "text/html;charset=UTF-8"));
         }
     }
 }
コード例 #18
0
 /// <summary>
 /// 删除一门课程
 /// </summary>
 /// <param name="course"></param>
 /// <returns></returns>
 public IActionResult Delcou(Course course)
 {
     using (var dbcontext = new srContext())
     {
         var infor = dbcontext.Course.FirstOrDefault(u => u.Cno == course.Cno);
         if (infor != null)
         {
             CourseMethod method = new CourseMethod();
             method.Delete(course.Cno);
             return(Content("<script>alert('删除成功');window.location.href='../Administrator/Delcourse';</script>", "text/html;charset=UTF-8"));
         }
         else
         {
             return(Content("<script>alert('删除失败,该课程不存在');history.go(-1);</script>", "text/html;charset=UTF-8"));
         }
     }
 }
コード例 #19
0
 /// <summary>
 /// 删除一个学生
 /// </summary>
 /// <param name="student_id"></param>
 /// <returns></returns>
 public IActionResult Delstudent(string student_id)
 {
     using (var dbcontext = new srContext())
     {
         var infor = dbcontext.Student.FirstOrDefault(u => u.Sno == student_id);
         if (infor != null)
         {
             StudentMethod student = new StudentMethod();
             student.Delete(student_id);
             return(Content("<script>alert('删除成功');history.go(-1);</script>", "text/html;charset=UTF-8"));
         }
         else
         {
             return(Content("<script>alert('该学生不存在');history.go(-1);</script>", "text/html;charset=UTF-8"));
         }
     }
 }
コード例 #20
0
        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"));
                }
            }
        }
コード例 #21
0
        public IActionResult Showcourses()
        {
            this.Request.Cookies.TryGetValue("Sno", out string value);
            ScoreMethod   method  = new ScoreMethod();
            List <Score>  scores  = method.GetScores(value);
            List <Course> courses = new List <Course>();

            using (var dbcontext = new srContext())
            {
                for (int i = 0; i < scores.Count; i++)
                {
                    courses.Add(dbcontext.Course.FirstOrDefault(u => u.Cno == scores[i].Cno));
                }
            }
            ViewBag.scores  = scores;
            ViewBag.courses = courses;
            return(View());
        }
コード例 #22
0
 public IActionResult Showstu(Student student)
 {
     using (var dbcontext = new srContext())
     {
         var infor = dbcontext.Student.FirstOrDefault(u => u.Sno == student.Sno);
         if (infor != null)
         {
             StudentMethod method = new StudentMethod();
             var           stu    = method.FindStudent(student.Sno);
             ViewBag.student = stu;
             return(View());
         }
         else
         {
             return(Content("<script>alert('该学生不存在');history.go(-1);</script>", "text/html;charset=UTF-8"));
         }
     }
 }
コード例 #23
0
        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"));
                }
            }
        }
コード例 #24
0
        public IActionResult Mycer(Student student)
        {
            var infor = new Student();

            using (var dbcontext = new srContext())
            {
                infor = dbcontext.Student.FirstOrDefault(u => u.Sno == student.Sno);
            }
            CerMethod method = new CerMethod();

            if (infor == null)
            {
                return(Content("<script>alert('该学生不存在');history.go(-1);</script>", "text/html;charset=UTF-8"));
            }
            else
            {
                var cers = method.GetCertificates(student.Sno);
                ViewBag.cers = cers;
                return(View());
            }
        }
コード例 #25
0
ファイル: TCmethod.cs プロジェクト: BiLanGang/C-Prime-Program
        /// <summary>
        /// 增加一条老师授课信息
        /// </summary>
        /// <param name="Tid"></param>
        /// <param name="Cid"></param>
        /// <returns></returns>
        public bool AddTC(string Tid, string Cid)
        {
            using (var db = new srContext())
            {
                var value = db.Teachercourse.FirstOrDefault(t => t.Cno == Cid && t.Tno == Tid);
                if (value != null)
                {
                    return(false);
                }
                else

                {
                    var TC = new Teachercourse {
                        Tno = Tid, Cno = Cid
                    };
                    db.Teachercourse.Add(TC);
                    db.SaveChanges();
                    return(true);
                }
            }
        }
コード例 #26
0
 /// <summary>
 /// 增加一门课程
 /// </summary>
 /// <param name="course"></param>
 /// <returns></returns>
 public bool Addcourse(Course course)
 {
     if (Check(course) == null)
     {
         using (var dbcontext = new srContext())
         {
             var infor = FindCourse(course.Cno);
             if (infor == null)
             {
                 dbcontext.Course.Add(course);
                 dbcontext.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     else
     {
         return(false);
     }
 }
コード例 #27
0
 public IActionResult ChangePasw(Administrator admin, string newpwd, string rcnewpwd)
 {
     using (var dbcontext = new srContext())
     {
         var temp = dbcontext.Administrator.FirstOrDefault(s => s.Ano == admin.Ano);
         if (temp.Apassword == admin.Apassword)
         {
             if (newpwd == rcnewpwd)
             {
                 temp.Apassword = newpwd;
                 dbcontext.SaveChanges();
                 return(RedirectToAction("Index", "Home"));
             }
             else
             {
                 return(RedirectToAction("ChangePassword", "Administrator"));
             }
         }
         else
         {
             return(RedirectToAction("ChangePassword", "Administrator"));
         }
     }
 }
コード例 #28
0
 /// <summary>
 /// 按职工号删除教师
 /// </summary>
 /// <param name="value"></param>
 public void Delete(string value)
 {
     using (var dbcontext = new srContext())
     {
         var teacher = dbcontext.Teacher.FirstOrDefault(u => u.Tno == value);
         var TCs     = new List <Teachercourse>();
         foreach (var infor in dbcontext.Teachercourse)
         {
             if (infor.Tno == value)
             {
                 TCs.Add(infor);
             }
         }
         if (TCs != null)
         {
             foreach (var infro in TCs)
             {
                 dbcontext.Teachercourse.Remove(infro);
             }
         }
         dbcontext.Remove(teacher);
         dbcontext.SaveChanges();
     }
 }
コード例 #29
0
 public IActionResult  Insertcet(Cet cet)
 {
     if (cet.Sno == null || cet.Etype == null || cet.Egade == null)
     {
         return(Content("<script>alert('录入失败');history.go(-1);</script>", "text/html;charset=UTF-8"));
     }
     else
     {
         using (var dbcontext = new srContext())
         {
             var infor = dbcontext.Student.FirstOrDefault(u => u.Sno == cet.Sno);
             if (infor == null)
             {
                 return(Content("<script>alert('录入失败,该学生不存在');history.go(-1);</script>", "text/html;charset=UTF-8"));
             }
             else
             {
                 infor.Cet.Add(cet);
                 dbcontext.SaveChanges();
                 return(Content("<script>alert('录入成功');window.location.href='../Teacher/Pirntcet';</script>", "text/html;charset=UTF-8"));
             }
         }
     }
 }
コード例 #30
0
 public IActionResult ChangePasw(Teacher teacher, string newpwd, string rcnewpwd)
 {
     using (var dbcontext = new srContext())
     {
         var temp = dbcontext.Teacher.FirstOrDefault(u => u.Tno == teacher.Tno);
         if (temp.Tpassword == teacher.Tpassword)
         {
             if (newpwd == rcnewpwd)
             {
                 temp.Tpassword = newpwd;
                 dbcontext.SaveChanges();
                 return(RedirectToAction("Index", "Home"));
             }
             else
             {
                 return(Content("<script>alert('修改失败');history.go(-1);</script>", "text/html;charset=UTF-8"));
             }
         }
         else
         {
             return(Content("<script>alert('原密码错误,修改失败');history.go(-1);</script>", "text/html;charset=UTF-8"));
         }
     }
 }