学生信息管理系统 订阅
学生信息管理系统是针对学校人事处的大量业务处理工作而开发的管理软件,主要用于学校学生信息管理,总体任务是实现学生信息关系的系统化、科学化、规范化和自动化,其主要任务是用计算机对学生各种信息进行日常管理,如查询、修改、增加、删除,另外还考虑到学生选课,针对这些要求设计了学生信息管理系统。 展开全文
学生信息管理系统是针对学校人事处的大量业务处理工作而开发的管理软件,主要用于学校学生信息管理,总体任务是实现学生信息关系的系统化、科学化、规范化和自动化,其主要任务是用计算机对学生各种信息进行日常管理,如查询、修改、增加、删除,另外还考虑到学生选课,针对这些要求设计了学生信息管理系统。
信息
外文名
Standard Student Information System
类    型
管理软件
主要用于
学校学生信息管理
中文名
学生信息管理系统(SIS)
目    的
科学化、规范化和自动化
学生信息管理系统定义
推行学校信息管理系统的应用是进一步推进学生学籍管理规范化、电子化、控制辍学和提高义务教育水平的重要举措
收起全文
精华内容
下载资源
问答
  • java学生信息管理系统(附源码)

    万次阅读 多人点赞 2016-07-14 16:36:30
     学生管理系统就完成了  其中的登陆界面是 我借鉴别人的  文中难免有不足之处,恳请批评指正  2016-7-14 再此上传不了附件 所以我给链接去在云盘下载  首次上传 (2017_6_12更新)链接: ...

    一:   介绍

          

      1:实现登录界面

        2:实现主界面

               有两种操作 一种是按钮操作  另外一种是SQL语句。

        3:连接SQL server 2008 数据库,后续我更新了,加了一个MySql 版本。在我的下载链接里面都有,里面也有使用说明。另外*myeclipse和eclipse,            jcreator什么的都是IDE,使用都一样,基本没什么区别,只不过myeclipse更商业化不开源,也就意味着收费,里面集成的插件比较多而已。

               *****************************************************************************************************

               用到的软件及环境SQLserver2008,eclipse,sqljdbc4.jar(数据库驱动包)

               *****************************************************************************************************

               另外一个Mysql 5.7.15.  Myeclipse2015,mysql-connector-java-5.1.34.jar

                 **********************************************************************************************************************

     

               java的JDK环境 (自行安装配置)

                切记:

                另外要新建数据库wtf 和新建学生表student(也可以用你自己创建的数据库及表,不过你得在源代码中进行修改):

                还要导入sqljdbc4.jar

            

        4:实现增删改查  (另有退出和刷新)

    二:    使用

      1:首先导入rjgc包

     

    然后点开browse  找到rjgc  

    最后点击finish

    得到    下图

    加载出来以后可能有的java文件前面有错,因为还没有导入sqljdbc4.jar

    (*******************************************************************************************************************************                    注意,方式一导入jdbc的图是之前我做的时候比较麻烦的一种方式,但是也能达到效果,在后期的我更新的链接资源中,如果导入任意版本源码包的话,都会自动加载lib包以及下面不同版本对应的jdbc连接驱动。这时候你只需要在那个lib文件夹下的.jar 文件上右键点击-->build path--->add to build path,导入jdbc结束。

    方式二导入:贴一张图

    上面这张图是方式二导入的,

    **************************************************************************************************************************)

     

    接下来继续,方式一导入  看下图:

     

     

     

    这时候应该就差不多可以运行了,不过还得把SQLserver2008的(MSSQLSERVER)服务开启了。

    上图

    再回到eclipse界面 打开rjgc

    最后双击LoginIn.java打开代码文本

    运行  就可以出现登录界面  

    在LoginIn.java代码文本里面找到登录用户 和密码后就可以登录了 

    比如admin 123  和wangtangfu 123456      (注意不要多加空格)

    其实用户权限都一样  如果你想加用户权限  可以写两个不同的Qframe.java。要做到主窗口里面的功能不同   ,可以屏蔽一些按钮

    比如修改  增加  等功能。然后在不同用户登陆的时候调用不同的Qframe.java,这样应该可以实现权限问题。。。

     

    2:

    还有程序里面应运了一些图片,它们的位置路径位置可能不一样 ,自行参照代码理解修改(很容易的哟);

     

    三:程序运行截图

       登陆窗口

     主窗口

    SQL语句执行  比如select * from student  

    刷新按钮:

    增加按钮:

                                                                                                                                                         添加成功之后刷新即可:

    删除按钮:

    修改按钮:

    查询按钮

     

     

    至此  

          学生管理系统就完成了   

               其中的登陆界面是 我借鉴别人的  

                   文中难免有不足之处,恳请批评指正

                                                                                                                                       2016-7-14

    再此上传不了附件 所以我给链接去在云盘下载 


    首次上传

    (2017_6_12更新)链接: https://pan.baidu.com/s/1aSeKJ8gXxWSElHaTU6_PdA 密码: yqpv

     


    添加myeclipse+mysql 版本:

    (2017_12_17更新)链接: https://pan.baidu.com/s/1dFAlILj 密码: 9z7k

    (2017_12_17更新)链接: https://pan.baidu.com/s/1dFAlILj 密码: 9z7k

    (2017_12_17更新)链接: https://pan.baidu.com/s/1dFAlILj 密码: 9z7k


     


    修改student.sql执行报错 (执行时可以打开偷偷看一眼)

    (2019_04_13更新)链接: https://pan.baidu.com/s/121sRLAerxEa3UmTD50Uu6g 密码: xjge

    (2019_04_13更新)链接: https://pan.baidu.com/s/121sRLAerxEa3UmTD50Uu6g 密码: xjge

    (2019_04_13更新)链接:https://pan.baidu.com/s/121sRLAerxEa3UmTD50Uu6g 密码: xjge

     

    展开全文
  • 学生信息管理系统

    千次阅读 2019-03-08 09:58:47
    学生信息管理系统

    学生信息管理系统

    #include<iostream>
    #include<algorithm>
    #include<windows.h>
    #include<fstream>
    #include<string>
    using namespace std;
    
    class student
    {
    private:
        string stu_ID;
        string stu_Name;
        float stu_Score;
    public:
        void Set_ID(string ID);
        void Set_Name(string Name);
        void Set_Score(float Score);
        string Show_ID();
        string Show_Name();
        float Show_Score();
    };
    
    void student::Set_ID(string ID)
    {
        stu_ID = ID;
    }
    void student::Set_Name(string Name)
    {
        stu_Name = Name;
    }
    void student::Set_Score(float Score)
    {
        stu_Score = Score;
    }
    string student::Show_ID()
    {
        return stu_ID;
    }
    string student::Show_Name()
    {
        return stu_Name;
    }
    float student::Show_Score()
    {
        return stu_Score;
    }
    
    
    int Init(student info[],int n)
    {
        string ID;
        string Name;
        float Score;
        
        ifstream in("C:\\Users\\Lenovo\\Desktop\\student.txt");
        while (! in.eof())
        {
           in >> ID >> Name >> Score;
           info[n].Set_ID(ID);
           info[n].Set_Name(Name);
           info[n].Set_Score(Score);
           n++;
        }
        
        in.close();
        return n;
    }
    
    
    int Insert_Student(student info[],int n)
    {
        string ID;
        string Name;
        float Score;
        
        cout << "请输入要添加学生的ID,Name,Score:" << endl;
        
        loop:
        cin >> ID >> Name >> Score ;
        for (int i=0;i<n;i++)
        {
            if (info[i].Show_ID() == ID)
            {
                cout << "改学号已被注册,请你重新出入:" << endl;
                goto loop;
            }
        }
    
        info[n].Set_ID(ID);
        info[n].Set_Name(Name);
        info[n].Set_Score(Score);
        
        cout << "添加成功!" << endl;
        n++;
        return n;
    }
    
    
    void Show_info(student info[],int n)
    {
        string ID;
        cout << "请输入你要查询的学号:" << endl;
        
        loop:
        cin >> ID;
        for (int i=0;i<n;i++)
        {
            if (ID == info[i].Show_ID())
            {
                cout << info[i].Show_ID() << "\t" ;
                cout << info[i].Show_Name() << "\t" ;
                cout << info[i].Show_Score() << endl;
                return ;
            }
        }
        
        cout << "对不起,你输入的学号并不存在。请你重新输入学号:" << endl;
        goto loop;
    }
    
    
    int  Delet_Student(student info[],int n)
    {
        cout << "下面是去全部学生的信息情况:" << endl;
        for (int i=0;i<n;i++)
        {
            cout << info[i].Show_ID() << "\t" ;
            cout << info[i].Show_Name() << "\t" ;
            cout << info[i].Show_Score() << endl;
        }
        
        cout << "请输入你要删除的学号:" << endl;
        string delID;
        loop:
        cin >> delID ;
        for (int i=0;i<n;i++)
        {
            if (delID == info[i].Show_ID())
            {
                cout << "删除成功!" << endl;
                for (int j=i;j<n-1;j++)
                    info[j] = info[j+1];
                n--;
                return n;
            }
        }
    
        cout << "对不起,你要删除的学号并不存在。请你重新输入要删除的学号:" << endl;
        goto loop;
    }
    
    
    void Save_info(student info[],int n)
    {
        ofstream out ("C:\\Users\\Lenovo\\Desktop\\student.txt");
        
        for (int i=0;i<n;i++)
        {
            out << info[i].Show_ID() << '\t';
            out << info[i].Show_Name() << '\t';
            out << info[i].Show_Score() << endl;
        }
        
        cout << "保存成功!" << endl;
        out.close();
    }
    
    
    void Main_Menu()
    {
        system("cls");
        cout << endl;
        cout << "1.添加学生信息:" << endl << endl;
        cout << "2.查询学生信息:" << endl << endl;
        cout << "3.删除学生信息:" << endl << endl;
        cout << "4.保存修改:" << endl << endl;
        cout << "5.操作结束,退出系统" << endl << endl;
        cout << endl;
        cout << "请输入指令:";
    }
    
    
    int main()
    {
        int n = 0;
        student info[100];
        n = Init(info,n);
        int order;
        while (true)
        {
            Main_Menu();
            
            cin >> order;
            
            if ( order == 1)
                n = Insert_Student(info,n);
                
            if ( order == 2)
                Show_info(info,n);
                
            if ( order == 3)
                n = Delet_Student(info,n);
                
            if ( order == 4)
                Save_info(info,n);
                
            if ( order == 5)
                break;
                
            system("pause");
        }
        return 0;
    }
    
    展开全文
  • JavaWeb-简单学生信息管理系统的实现-Jsp+Servlet+MySql

    万次阅读 多人点赞 2019-04-05 14:58:42
    关注公众号:吾爱代码,回复Java学生管理系统,获取下载链接~ 关注公众号:吾爱代码,回复Java学生管理系统,获取下载链接~ 关注公众号:吾爱代码,回复Java学生管理系统,获取下载链接~

    关注公众号:吾爱代码,回复Java学生管理系统,获取下载链接~

    关注公众号:吾爱代码,回复Java学生管理系统,获取下载链接~

    运行截图:

     

    项目文件结构:

    获取 数据库连接类:

    package db;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    
    /**
     * @ClassName: DbConnect
     * @Author: Leo
     * @Description:
     * @Date: 2019/3/27 21:36
     */
    public class DbConnect {
        public static Connection connection;
        public static String url = "jdbc:mysql://localhost/stumanage?user=root&password=root"
                + "&useUnicode=true&characterEncoding=utf-8&useSSL=true";
    
        public static Connection getConnection() {
            try {
                Class.forName("com.mysql.cj.jdbc.Driver");
                connection = DriverManager.getConnection(url);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return connection;
        }
    }
    

    对应学生的实体类:

    package entity;
    
    
    public class Student {
    
        private long id;
        private String name;
        private String sex;
        private String specialty;
        private String grade;
    
        public Student() {
        }
    
        public Student(long id, String name, String sex, String specialty, String grade) {
            this.id = id;
            this.name = name;
            this.sex = sex;
            this.specialty = specialty;
            this.grade = grade;
        }
    
        public Student(String name, String sex, String specialty, String grade) {
            this.name = name;
            this.sex = sex;
            this.specialty = specialty;
            this.grade = grade;
        }
    
        public long getId() {
            return id;
        }
    
        public void setId(long id) {
            this.id = id;
        }
    
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
    
        public String getSex() {
            return sex;
        }
    
        public void setSex(String sex) {
            this.sex = sex;
        }
    
    
        public String getSpecialty() {
            return specialty;
        }
    
        public void setSpecialty(String specialty) {
            this.specialty = specialty;
        }
    
    
        public String getGrade() {
            return grade;
        }
    
        public void setGrade(String grade) {
            this.grade = grade;
        }
    
    }
    

    登录界面jsp:

    <%--
      Created by IntelliJ IDEA.
      User: 24234
      Date: 2019/3/27
      Time: 19:26
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
    <html>
    <head>
        <title>学生管理系统</title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
    </head>
    <body>
    <center>
        <form action="/loginServer" method="post">
            <table>
                <tr>
                    <td>
                        用户名
                    </td>
                    <td>
                        <input type="text" name="admin">
                    </td>
                </tr>
                <tr>
                    <td>
                        密&nbsp&nbsp码
                    </td>
                    <td>
                        <input type="password" name="pwd">
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="submit" value="登录">
                    </td>
                </tr>
    
            </table>
        </form>
    </center>
    </body>
    </html>
    

    登录servlet:(查询所有学生信息显示到主页面jsp)

    package servlet;
    
    import db.DbConnect;
    
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    /**
     * @ClassName: ${NAME}
     * @Author: Leo
     * @Description:
     * @Date: 2019/3/28 20:29
     */
    @WebServlet(name = "loginServer")
    public class loginServer extends HttpServlet {
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            resp.setContentType("text/html");
            req.setCharacterEncoding("utf-8");
            resp.setCharacterEncoding("utf-8");
            String admin = req.getParameter("admin");
            String pwd = req.getParameter("pwd");
            if (admin.equals("admin") && pwd.equals("123")) {
                Connection connection = DbConnect.getConnection();
                String sql = "SELECT * FROM STUDENT";
                PreparedStatement preparedStatement = null;
                ResultSet resultSet = null;
                try {
                    preparedStatement = connection.prepareStatement(sql);
                    resultSet = preparedStatement.executeQuery();
                    HttpSession httpSession = req.getSession();
    //                设置session有效时间为两小时
                    httpSession.setMaxInactiveInterval(7200);
                    httpSession.setAttribute("resultSet", resultSet);
                    resp.sendRedirect("loginAction.jsp");
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            } else {
                resp.sendRedirect("index.jsp");
            }
    
        }
    
        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            doGet(req, resp);
        }
    }
    

    主页面jsp:

    <%@ page import="java.sql.ResultSet" %><%--
      Created by IntelliJ IDEA.
      User: Administrator
      Date: 2019/3/28
      Time: 14:31
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
    <% ResultSet resultSet = (ResultSet) session.getAttribute("resultSet");%>
    <html>
    <head>
        <title>学生管理系统</title>
        <link rel="stylesheet" type="text/css" href="css/table.css">
    </head>
    <body>
    <center>
        <table class="gridtable">
            <tr>
                <td align="center" colspan="6">学生信息</td>
            </tr>
            <tr>
                <td>姓名</td>
                <td>性别</td>
                <td>专业</td>
                <td>年级</td>
                <td align="center" colspan="2">操作</td>
            </tr>
            <%
                while (resultSet.next()) {
            %>
    
            <tr>
                <td><%=resultSet.getString("name")%>
                </td>
                <td><%=resultSet.getString("sex")%>
                </td>
                <td><%=resultSet.getString("specialty")%>
                </td>
                <td><%=resultSet.getString("grade")%>
                </td>
                <td><a href="selectServlet?id=<%=resultSet.getInt("id")%>">修改</a></td>
                <td><a href="deleteServlet?id=<%=resultSet.getInt("id")%>" onclick="return confirm('确定删除?')">删除</a></td>
            </tr>
            <%}%>
            <tr>
                <td align="center" colspan="6">
                    <a href="stuAdd.jsp">添加</a>
                </td>
            </tr>
        </table>
    </center>
    </body>
    </html>
    

    根据id查询数据库记录:

    package servlet;
    
    import db.DbConnect;
    import entity.Student;
    
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    /**
     * @ClassName: ${NAME}
     * @Author: Leo
     * @Description:
     * @Date: 2019/3/29 15:20
     */
    @WebServlet(name = "selectServlet")
    public class selectServlet extends HttpServlet {
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }
    
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.setContentType("text/html");
            response.setCharacterEncoding("utf-8");
            request.setCharacterEncoding("utf-8");
            String id = request.getParameter("id");
            String sql = "SELECT * FROM STUDENT WHERE ID=?";
            Connection connection = DbConnect.getConnection();
            PreparedStatement preparedStatement = null;
            ResultSet resultset = null;
            Student student = null;
            try {
                preparedStatement = connection.prepareStatement(sql);
                preparedStatement.setInt(1, Integer.parseInt(id));
                resultset = preparedStatement.executeQuery();
                while (resultset.next()) {
                    String name = resultset.getString("name");
                    String sex = resultset.getString("sex");
                    String specialty = resultset.getString("specialty");
                    String grade = resultset.getString("grade");
                    student = new Student(Integer.parseInt(id), name, sex, specialty, grade);
                }
                HttpSession httpSession = request.getSession();
                httpSession.setAttribute("student", student);
                response.sendRedirect("stuEdit.jsp");
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    

     修改学生信息jsp:

    <%@ page import="entity.Student" %><%--
      Created by IntelliJ IDEA.
      User: 24234
      Date: 2019/3/29
      Time: 14:59
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
    <html>
    <head>
        <title>修改学生信息</title>
        <link rel="stylesheet" type="text/css" href="css/table.css">
    </head>
    <body>
    <%Student student = (Student) session.getAttribute("student");%>
    <form action="/updateServlet" method="post">
        <center>
            <table class="gridtable">
                <tr>
                    <td align="center" colspan="2">
                        修改学生信息
                        <input type="hidden" name="id" value="<%=student.getId()%>">
                    </td>
                </tr>
                <tr>
                    <td>姓名</td>
                    <td><input type="text" name="name" value="<%=student.getName()%>"></td>
                </tr>
                <tr>
                    <td>性别</td>
                    <td><%if (student.getSex().equals("男")) {%>
                        <input type="radio" name="sex" value="男" checked="checked">男
                        <input type="radio" name="sex" value="女">女
                    </td>
                    <%
                    } else {
                    %>
                    <td>
                        <input type="radio" name="sex" value="男">男
                        <input type="radio" name="sex" value="女" checked="checked">女
                    </td>
                    <%}%>
                </tr>
                <tr>
                    <td>专业</td>
                    <td><input type="text" name="specialty" value="<%=student.getSpecialty()%>"></td>
                </tr>
                <tr>
                    <td>年级</td>
                    <td>
                        <%
                            if (student.getGrade().equals("大一")) {
                        %>
                        <select name="grade">
                            <option value="大一" selected="selected">大一</option>
                            <option value="大二">大二</option>
                            <option value="大三">大三</option>
                            <option value="大四">大四</option>
                        </select>
                        <%} else if (student.getGrade().equals("大二")) {%>
                        <select name="grade">
                            <option value="大一">大一</option>
                            <option value="大二" selected="selected">大二</option>
                            <option value="大三">大三</option>
                            <option value="大四">大四</option>
                        </select>
                        <%} else if (student.getGrade().equals("大三")) {%>
                        <select name="grade">
                            <option value="大一">大一</option>
                            <option value="大二">大二</option>
                            <option value="大三" selected="selected">大三</option>
                            <option value="大四">大四</option>
                        </select>
                        <%} else if (student.getGrade().equals("大四")) {%>
                        <select name="grade">
                            <option value="大一">大一</option>
                            <option value="大二">大二</option>
                            <option value="大三">大三</option>
                            <option value="大四" selected="selected">大四</option>
                        </select>
                        <%}%>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <input type="submit" value="修改">
                    </td>
                </tr>
            </table>
        </center>
    </form>
    </body>
    </html>
    

    修改学生信息servlet:

    package servlet;
    
    import db.DbConnect;
    
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    /**
     * @ClassName: ${NAME}
     * @Author: Leo
     * @Description:
     * @Date: 2019/3/29 15:44
     */
    @WebServlet(name = "updateServlet")
    public class updateServlet extends HttpServlet {
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }
    
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.setContentType("text/html");
            response.setCharacterEncoding("utf-8");
            request.setCharacterEncoding("utf-8");
            String id = request.getParameter("id");
            String name = request.getParameter("name");
            String sex = request.getParameter("sex");
            String specialty = request.getParameter("specialty");
            String grade = request.getParameter("grade");
            Connection connection = DbConnect.getConnection();
            String sql = "UPDATE STUDENT SET name=? , sex=? , specialty=? , grade=? where id=?";
            PreparedStatement preparedStatement = null;
            ResultSet resultSet = null;
            try {
                preparedStatement = connection.prepareStatement(sql);
                preparedStatement.setInt(5, Integer.parseInt(id));
                preparedStatement.setString(1, name);
                preparedStatement.setString(2, sex);
                preparedStatement.setString(3, specialty);
                preparedStatement.setString(4, grade);
                int i = preparedStatement.executeUpdate();
                HttpSession httpSession = request.getSession();
                if (i == 1) {
                    String selectAll = "SELECT * FROM STUDENT";
                    preparedStatement = connection.prepareStatement(selectAll);
                    resultSet = preparedStatement.executeQuery();
                    httpSession.setMaxInactiveInterval(7200);
                    httpSession.setAttribute("resultSet", resultSet);
                    response.sendRedirect("loginAction.jsp");
                } else {
                    httpSession.setAttribute("message", "修改失败!");
                    response.sendRedirect("error.jsp");
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
    
        }
    }
    

    添加学生信息jsp:

    <%--
      Created by IntelliJ IDEA.
      User: Administrator
      Date: 2019/3/28
      Time: 14:50
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
    <html>
    <head>
        <title>添加学生信息</title>
        <link rel="stylesheet" type="text/css" href="css/table.css">
    </head>
    <body>
    <form action="/addServlet" method="post">
        <center>
            <table class="gridtable">
                <tr>
                    <td align="center" colspan="2">添加学生信息</td>
                </tr>
                <tr>
                    <td>姓名</td>
                    <td><input type="text" name="name"></td>
                </tr>
                <tr>
                    <td>性别</td>
                    <td>
                        <input type="radio" name="sex" value="男" checked="checked">男
                        <input type="radio" name="sex" value="女">女
                    </td>
                </tr>
                <tr>
                    <td>专业</td>
                    <td><input type="text" name="specialty"></td>
                </tr>
                <tr>
                    <td>年级</td>
                    <td><select name="grade">
                        <option value="大一">大一</option>
                        <option value="大二">大二</option>
                        <option value="大三">大三</option>
                        <option value="大四">大四</option>
                    </select></td>
                </tr>
                <tr>
                    <td align="center" colspan="2"><input type="submit" value="添加"></td>
                </tr>
            </table>
        </center>
    </form>
    </body>
    </html>
    

    添加学生信息servlet:

    package servlet;
    
    import db.DbConnect;
    import entity.Student;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    /**
     * @ClassName: ${NAME}
     * @Author: Leo
     * @Description:
     * @Date: 2019/3/28 20:24
     */
    public class addServlet extends javax.servlet.http.HttpServlet {
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }
    
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.setContentType("text/html");
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            String name = request.getParameter("name");
            String sex = request.getParameter("sex");
            String specialty = request.getParameter("specialty");
            String grade = request.getParameter("grade");
            Student student = new Student(name, sex, specialty, grade);
            Connection connection = DbConnect.getConnection();
            String sql = "INSERT INTO student(name,sex,specialty,grade) values(?,?,?,?)";
            PreparedStatement preparedStatement = null;
            ResultSet resultSet = null;
            try {
                preparedStatement = connection.prepareStatement(sql);
                preparedStatement.setString(1, student.getName());
                preparedStatement.setString(2, student.getSex());
                preparedStatement.setString(3, student.getSpecialty());
                preparedStatement.setString(4, student.getGrade());
                int i = preparedStatement.executeUpdate();
                HttpSession httpSession = request.getSession();
                if (i == 1) {
                    String selectSql = "SELECT * FROM STUDENT";
                    preparedStatement = connection.prepareStatement(selectSql);
                    resultSet = preparedStatement.executeQuery();
                    httpSession.setMaxInactiveInterval(7200);
                    httpSession.setAttribute("resultSet", resultSet);
                    response.sendRedirect("loginAction.jsp");
                } else {
                    httpSession.setAttribute("message", "添加失败!");
                    response.sendRedirect("error.jsp");
                }
    
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    

    删除学生信息servlet:

    package servlet;
    
    import db.DbConnect;
    
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    /**
     * @ClassName: ${NAME}
     * @Author: Leo
     * @Description:
     * @Date: 2019/3/29 16:05
     */
    @WebServlet(name = "deleteServlet")
    public class deleteServlet extends HttpServlet {
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }
    
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.setContentType("text/html");
            response.setCharacterEncoding("utf-8");
            request.setCharacterEncoding("utf-8");
            String id = request.getParameter("id");
            String sql = "DELETE FROM STUDENT WHERE ID=?";
            Connection connection = DbConnect.getConnection();
            PreparedStatement preparedStatement = null;
            ResultSet resultSet = null;
            HttpSession httpSession = request.getSession();
            try {
                preparedStatement = connection.prepareStatement(sql);
                preparedStatement.setInt(1, Integer.parseInt(id));
                int i = preparedStatement.executeUpdate();
                if (i == 1) {
                    String select = "SELECT * FROM STUDENT";
                    preparedStatement = connection.prepareStatement(select);
                    resultSet = preparedStatement.executeQuery();
                    httpSession.setMaxInactiveInterval(7200);
                    httpSession.setAttribute("resultSet", resultSet);
                    response.sendRedirect("loginAction.jsp");
                } else {
                    httpSession.setAttribute("message", "删除失败!");
                    response.sendRedirect("error.jsp");
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    

    错误页面:

    <%--
      Created by IntelliJ IDEA.
      User: Administrator
      Date: 2019/3/28
      Time: 15:18
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
    <html>
    <head>
        <title>Error</title>
    </head>
    <body>
    <%
        String message = (String) session.getAttribute("message");
        out.print(message);
    %>
    </body>
    </html>
    

    web.xml

    <!DOCTYPE web-app PUBLIC
            "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
            "http://java.sun.com/dtd/web-app_2_3.dtd" >
    
    <web-app>
        <display-name>Archetype Created Web Application</display-name>
        <servlet>
            <servlet-name>addServlet</servlet-name>
            <servlet-class>servlet.addServlet</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>loginServer</servlet-name>
            <servlet-class>servlet.loginServer</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>selectServlet</servlet-name>
            <servlet-class>servlet.selectServlet</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>updateServlet</servlet-name>
            <servlet-class>servlet.updateServlet</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>deleteServlet</servlet-name>
            <servlet-class>servlet.deleteServlet</servlet-class>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>addServlet</servlet-name>
            <url-pattern>/addServlet</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>loginServer</servlet-name>
            <url-pattern>/loginServer</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>selectServlet</servlet-name>
            <url-pattern>/selectServlet</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>updateServlet</servlet-name>
            <url-pattern>/updateServlet</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>deleteServlet</servlet-name>
            <url-pattern>/deleteServlet</url-pattern>
        </servlet-mapping>
    
    </web-app>
    

     

    展开全文
  • 学生信息管理系统c++

    万次阅读 2017-07-01 19:28:02
    一个简单的c语言学生信息管理系统,是控制台程序。 运行界面如下,功能已经全部实现 本资料绝对原创,请认准发表时间,如有相同,请私信我。

    一个简单的c语言学生信息管理系统,是控制台程序。

    运行界面如下,功能已经全部实现

    void function();//所有操作在该函数下进行
    void init();//欢迎界面
    void menu();//主菜单
    void input();//录入学生数据
    void print();// 学生信息浏览-输出
    void find();//查找功能
    void Sort();//按学号进行排序
    void add_stu();//添加学生信息
    void detele();//删除学生信息
    void modify();//修改学生信息
    void save();//保存学生信息到文件
    void read();//从文件中读取学生信息
    void detele_file();//删除文件中学生信息

    点击获取代码

    本资料绝对原创。

    展开全文

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 18,241
精华内容 7,296
关键字:

学生信息管理系统