【转载】ASP.NET结合前端HTML+javascript+CSS实现高校学生管理系统

程序主要采用ASP.NET框架+html+javascript实现高校学生管理,教师管理,授课管理等功能模块,实现高校老师学生的综合一体化在线治理,方便高校内部维护学生信息,处理班级课程的统计分析等功能。

程序模块实现

程序模块结构

在这里插入图片描述

系统登录界面

在这里插入图片描述

学生管理模块

在这里插入图片描述

用户管理模块

在这里插入图片描述

授课管理模块

在这里插入图片描述

源码地址

需求分析

本系统主要功能:

  1. 学生信息管理:对在校学生信息进行添加、删除、修改、查询等操作。
  2. 学生成绩管理:对已经录入的学生信息进行添加、修改学习成绩,并可以通过关键字进行模糊查询。
  3. 授课信息管理:支持对授课教师、课程编号及授课老师所授课的年级进行添加和修改操作。
  4. 课程管理:可显示每个班级每学期的课程表,并可以对已经开设的课程进行添加、删除和修改。
  5. 用户管理:用于管理系统用户,可进行账号增加、账号删除、权限修改等操作,方便对不同账号进行管理,避免系统权限混乱。

业务流程分析

本系统整体主要围绕学生、教师、课程、管理员用户登实体类展开,实现系统用户的身份权限判断,用户操作授权等等。系统整体用户角色操作流程如下:
在这里插入图片描述

用户登录校验实现

using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using App;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Repository.IRepository;
using Repository.Model;
using StudentManage.Models;

namespace StudentManage.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IAuthRepository _authRepository;
private readonly IRelationRepository _relationRepository;

    <span class="token keyword">public</span> <span class="token class-name">HomeController</span><span class="token punctuation">(</span><span class="token class-name">ILogger</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">HomeController</span><span class="token punctuation">&gt;</span></span> logger<span class="token punctuation">,</span> <span class="token class-name">IAuthRepository</span> authRepository<span class="token punctuation">,</span> <span class="token class-name">IRelationRepository</span> relationRepository<span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        _logger <span class="token operator">=</span> logger<span class="token punctuation">;</span>
        _authRepository <span class="token operator">=</span> authRepository<span class="token punctuation">;</span>
        _relationRepository <span class="token operator">=</span> relationRepository<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">/// &lt;summary&gt;</span>
    <span class="token comment">/// 登录页面</span>
    <span class="token comment">/// &lt;/summary&gt;</span>
    <span class="token comment">/// &lt;returns&gt;显示登陆页面&lt;/returns&gt;</span>
    <span class="token keyword">public</span> <span class="token class-name">IActionResult</span> <span class="token class-name">Login</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token class-name">PartialView</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">/// &lt;summary&gt;</span>
    <span class="token comment">/// 退出页面</span>
    <span class="token comment">/// &lt;/summary&gt;</span>
    <span class="token comment">/// &lt;returns&gt;显示登陆页面&lt;/returns&gt;</span>
    <span class="token keyword">public</span> <span class="token class-name">IActionResult</span> <span class="token class-name">Logout</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        <span class="token class-name">HttpContext<span class="token punctuation">.</span>Session<span class="token punctuation">.</span>Clear</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token class-name">PartialView</span><span class="token punctuation">(</span><span class="token string">"Login"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">/// &lt;summary&gt;</span>
    <span class="token comment">/// 校验登录</span>
    <span class="token comment">/// &lt;/summary&gt;</span>
    <span class="token comment">/// &lt;returns&gt;返回成功失败信息&lt;/returns&gt;</span>
    <span class="token punctuation">[</span><span class="token class-name">HttpPost</span><span class="token punctuation">]</span>
    <span class="token keyword">public</span> async <span class="token class-name">Task</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">IActionResult</span><span class="token punctuation">&gt;</span></span> <span class="token class-name">CheckLogin</span><span class="token punctuation">(</span>string userName<span class="token punctuation">,</span> string password<span class="token punctuation">,</span> <span class="token keyword">int</span> role<span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">var</span> userId <span class="token operator">=</span> await _authRepository<span class="token punctuation">.</span><span class="token function">Login</span><span class="token punctuation">(</span>userName<span class="token punctuation">,</span> password<span class="token punctuation">,</span> role<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>userId <span class="token operator">&gt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
        <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">var</span> token <span class="token operator">=</span> <span class="token class-name">Guid<span class="token punctuation">.</span>NewGuid</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">ToString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">GetHashCode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">ToString</span><span class="token punctuation">(</span><span class="token string">"x"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">var</span> currentUser <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">CurrentUser</span> <span class="token punctuation">{<!-- --></span><span class="token class-name">Role</span> <span class="token operator">=</span> role<span class="token punctuation">,</span> <span class="token class-name">UserId</span> <span class="token operator">=</span> userId<span class="token punctuation">}</span><span class="token punctuation">;</span>
            <span class="token class-name">HttpContext<span class="token punctuation">.</span>Session<span class="token punctuation">.</span>SetString</span><span class="token punctuation">(</span><span class="token string">"UserName"</span><span class="token punctuation">,</span> userName<span class="token punctuation">)</span><span class="token punctuation">;</span>
     
            <span class="token keyword">if</span> <span class="token punctuation">(</span>role <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span>
            <span class="token punctuation">{<!-- --></span> 
                <span class="token keyword">var</span> roles <span class="token operator">=</span> await _relationRepository<span class="token punctuation">.</span><span class="token function">GetRelationsByFirstId</span><span class="token punctuation">(</span><span class="token string">"UserRole"</span><span class="token punctuation">,</span> userId<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token class-name"><span class="token namespace">currentUser<span class="token punctuation">.</span></span>RoleIds</span> <span class="token operator">=</span> <span class="token class-name"><span class="token namespace">roles<span class="token punctuation">.</span></span>Select</span><span class="token punctuation">(</span>n <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token class-name"><span class="token namespace">n<span class="token punctuation">.</span></span>SecondKeyId</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">ToList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>role <span class="token operator">==</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
                <span class="token class-name">HttpContext<span class="token punctuation">.</span>Session<span class="token punctuation">.</span>SetString</span><span class="token punctuation">(</span><span class="token string">"studentName"</span><span class="token punctuation">,</span> userName<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token class-name">HttpContext<span class="token punctuation">.</span>Session<span class="token punctuation">.</span>SetObjectAsJson</span><span class="token punctuation">(</span>token<span class="token punctuation">,</span> currentUser<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">return</span> <span class="token class-name">Json</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token punctuation">{<!-- --></span> status <span class="token operator">=</span> <span class="token string">"success"</span><span class="token punctuation">,</span> msg <span class="token operator">=</span> <span class="token string">"登录成功"</span><span class="token punctuation">,</span> <span class="token class-name">Token</span> <span class="token operator">=</span> token <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token keyword">return</span> <span class="token class-name">Json</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token punctuation">{<!-- --></span> status <span class="token operator">=</span> <span class="token string">"error"</span><span class="token punctuation">,</span> msg <span class="token operator">=</span> <span class="token string">"登录失败"</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">/// &lt;summary&gt;</span>
    <span class="token comment">/// 主页面</span>
    <span class="token comment">/// &lt;/summary&gt;</span>
    <span class="token comment">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span class="token keyword">public</span> <span class="token class-name">IActionResult</span> <span class="token class-name">Index</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        string name <span class="token operator">=</span><span class="token class-name">HttpContext<span class="token punctuation">.</span>Session<span class="token punctuation">.</span>GetString</span><span class="token punctuation">(</span><span class="token string">"UserName"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">ViewBag<span class="token punctuation">.</span>RealName</span> <span class="token operator">=</span> name<span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token class-name">View</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">/// &lt;summary&gt;</span>
    <span class="token comment">/// 错误页</span>
    <span class="token comment">/// &lt;/summary&gt;</span>
    <span class="token punctuation">[</span><span class="token class-name">ResponseCache</span><span class="token punctuation">(</span><span class="token class-name">Duration</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token class-name">Location</span> <span class="token operator">=</span> <span class="token class-name">ResponseCacheLocation<span class="token punctuation">.</span>None</span><span class="token punctuation">,</span> <span class="token class-name">NoStore</span> <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">]</span>
    <span class="token keyword">public</span> <span class="token class-name">IActionResult</span> <span class="token class-name">Error</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token class-name">View</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">ErrorViewModel</span> <span class="token punctuation">{<!-- --></span> <span class="token class-name">RequestId</span> <span class="token operator">=</span> <span class="token class-name">Activity<span class="token punctuation">.</span>Current</span><span class="token operator">?</span><span class="token punctuation">.</span>Id <span class="token operator">?</span><span class="token operator">?</span> <span class="token class-name">HttpContext<span class="token punctuation">.</span>TraceIdentifier</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

}

源码地址

程序主要采用ASP.NET框架+html+javascript实现高校学生管理,教师管理,授课管理等功能模块,实现高校老师学生的综合一体化在线治理,方便高校内部维护学生信息,处理班级课程的统计分析等功能。

程序模块实现

程序模块结构

在这里插入图片描述

系统登录界面

在这里插入图片描述

学生管理模块

在这里插入图片描述

用户管理模块

在这里插入图片描述

授课管理模块

在这里插入图片描述

源码地址

需求分析

本系统主要功能:

  1. 学生信息管理:对在校学生信息进行添加、删除、修改、查询等操作。
  2. 学生成绩管理:对已经录入的学生信息进行添加、修改学习成绩,并可以通过关键字进行模糊查询。
  3. 授课信息管理:支持对授课教师、课程编号及授课老师所授课的年级进行添加和修改操作。
  4. 课程管理:可显示每个班级每学期的课程表,并可以对已经开设的课程进行添加、删除和修改。
  5. 用户管理:用于管理系统用户,可进行账号增加、账号删除、权限修改等操作,方便对不同账号进行管理,避免系统权限混乱。

业务流程分析

本系统整体主要围绕学生、教师、课程、管理员用户登实体类展开,实现系统用户的身份权限判断,用户操作授权等等。系统整体用户角色操作流程如下:
在这里插入图片描述

用户登录校验实现

using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using App;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Repository.IRepository;
using Repository.Model;
using StudentManage.Models;