小项目之学生报到管理系统

学生报到管理系统:

假定学生报到的流程如下:

  系统报到(分班)->财务交费(交学费)->宿舍分配(分宿舍)

系统功能需求:

  1.基础数据管理模块:

    <1.专业设置

    <2.学生名册

    <3.宿舍情况

    <4.班级设置

    <5.报到状况查询

    <6.用户管理

  2.报到分班管理:

    <1.报到分班

    <2.分班情况查询

  3.报到收费管理:

    <1.收费情况登记

    <2.收费情况查询

  4.学生宿舍管理:

    <1.宿舍分配

    <2.宿舍情况查询

除了以上模块以外,还有一个用户登录功能。不同用户具有不同身份,不同身份的管理员可以使用不同的功能。

本项目的所有数据处理逻辑,业务逻辑,数据表现逻辑都在JSP页面中完成,系统是最简单的二层结构:JSP<---->数据库。数据库采用mysql。

1.数据库系统的实现:

create database StudentManageSystem;

use StudentManageSystem;

create table Student(
StudentId int not null primary key,
StudentName
varchar(40),
SpecialityId int, //专业
ClassId int,
BedchamberId
int, //宿舍
PayAmount int,
PayOk char(1),
RegistDate date,

MatriNo varchar(20); //录取通知书号
);

create table Adminuser(
Adminusername varchar(40) not null primary
key,
Adminuserpassword varchar(40),
Adminuserrole int
);

create table Classtt(
ClassId int not null primary key,
ClassName
varchar(40)
);

create table Speciality(
SpecialityId int not null primary
key,
SpecialityName varchar(40)
);

create table Bedchamber(
BedchamberId int not null primary
key,
BedchamberName varchar(40)
);

alter table Student add constraint FK_Student_Bedchamber foreign
key(
BedchamberId
)references Bedchamber(
BedchamberId
);

alter table Student add constraint FK_Student_Classtt foreign
key(
ClassId
)references Classtt(
ClassId
);

alter table Student add constraint FK_Student_Speciality foreign
key(
SpecialityId
)references Spciality(
SpecialityId

);

2.插入数据:

INSERT INTO Speciality VALUES(11,‘微电子‘);
INSERT INTO Speciality
VALUES(12,‘自动化‘);
INSERT INTO Speciality VALUES(13,‘计算机‘);
INSERT INTO
Speciality VALUES(14,‘软件‘);
INSERT INTO Speciality VALUES(15,‘会计‘);
INSERT
INTO Speciality VALUES(16,‘英语‘);
INSERT INTO Speciality VALUES(17,‘财经‘);

INSERT INTO Adminuser VALUES(‘admin‘,‘admin‘,1);
INSERT INTO Adminuser
VALUES(‘wuenqiang‘,‘wuenqiang‘,2);
INSERT INTO Adminuser
VALUES(‘mosquito‘,‘mosquito‘,3);
INSERT INTO Adminuser
VALUES(‘punkhippie‘,‘punkhippie‘,4);

INSERT INTO Classtt VALUES(1,‘one‘);
INSERT INTO Classtt
VALUES(2,‘two‘);
INSERT INTO Classtt VALUES(3,‘three‘);
INSERT INTO
Classtt VALUES(4,‘four‘);
INSERT INTO Classtt VALUES(5,‘five‘);
INSERT
INTO Classtt VALUES(6,‘six‘);
INSERT INTO Classtt
VALUES(7,‘seven‘);
INSERT INTO Classtt VALUES(8,‘eight‘);
INSERT INTO
Classtt VALUES(9,‘nine‘);

INSERT INTO Bedchamber VALUES(1,‘one‘);
INSERT INTO Bedchamber
VALUES(2,‘two‘);
INSERT INTO Bedchamber VALUES(3,‘three‘);
INSERT INTO
Bedchamber VALUES(4,‘four‘);
INSERT INTO Bedchamber
VALUES(5,‘five‘);
INSERT INTO Bedchamber VALUES(6,‘six‘);
INSERT INTO
Bedchamber VALUES(7,‘seven‘);
INSERT INTO Bedchamber
VALUES(8,‘eight‘);
INSERT INTO Bedchamber VALUES(9,‘nine‘);

INSERT INTO Student
VALUES(01,‘吴恩强‘,11,1,1,6000,‘y‘,‘2014-05-01‘,3111001);
INSERT INTO Student
VALUES(02,‘吴晓强‘,12,1,1,6000,‘y‘,‘2014-05-02‘,3111001);
INSERT INTO Student
VALUES(03,‘吴小强‘,13,1,1,6000,‘y‘,‘2014-05-03‘,3111001);
INSERT INTO Student
VALUES(04,‘吴强强‘,14,1,1,6000,‘y‘,‘2014-05-02‘,3111001);
INSERT INTO Student
VALUES(05,‘吴恩恩‘,15,1,1,6000,‘y‘,‘2014-05-01‘,3111001);
INSERT INTO Student
VALUES(06,‘吴强恩‘,16,1,1,6000,‘y‘,‘2014-05-03‘,3111001);

3.设计总体页面效果:

讲一个页面拆分为三个部分,每部分各是一个网页,如图。

-----index.jsp-----

?





1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<%@ page contentType="text/html;charset=GBK"
%>

<%if(session.getAttribute("adminusername")==null||session.getAttribute("adminusername").toString().length()==0)

    response.sendRedirect("login.jsp");

%>

<html>

    <head>

        <title>报道管理系统</title>

    </head>

    <frameset framespacing="0"
border="0"
frameborder="0"
rows="64,*"
marginwidth="0"
marginheight="0">

            <frame name="banner"
scrolling="no"
noresize target="contents"
src="banner.html">

        <frameset cols="160,*">

            <frame name="left"
target="main"
scrolling="auto"
src="left.jsp"
marginwidth="10"
marginheight="0">

            <frame name="main"
scrolling="auto"
marginwidth="0"
marginheight="0"
src="regstatus.jsp">

        </frameset>

            <noframes>

                <body>

                </body>

            </noframes>

    </frameset>

</html>

  首先检查adminusername的内容是否为空,如果是则用户没有登陆,页面重定向到login.jsp页面要求用户重新登陆。

-----left.jsp-----

?





1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

<%@ page contentType="text/html;charset=GBK"
%>

<html>

    <head><title>登陆系统</title></head>

    <body>

        <div align="center">

        <table border="1"
cellpadding="0"
cellspacing="0"
style="border-collapse:collapse"
bordercolor="#c0c0c0"
width="140">

        <%String adminuserrole=session.getAttribute("adminuserrole")+"";

        int
adminuserroleint=0;

        if(adminuserrole!=null&&adminuserrole.length()!=0)

            adminuserroleint=Integer.parseInt(adminuserrole);

        %>

        <%if(adminuserroleint==1||adminuserroleint==2){ %>

        <tr>

            <td width="100%"
bgcolor="#c0c0c0"
align="center">

            <font color="#0000ff">报到分班管理</font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="classadmin.jsp"
target="main">报到分班</a></font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="classview.jsp"
target="main">分班情况查询</a></font>

            </td>

        </tr>

        <%} %>

        <%if(adminuserroleint==1||adminuserroleint==3){ %>

        <tr>

            <td width="100%"
bgcolor="#c0c0c0"
align="center">

            <font color="#0000ff">报到收费管理</font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="acceptmoney.jsp"
target="main">收费情况登记</a></font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="classview.jsp"
target="main">收费情况查询</a></font>

            </td>

        </tr>

        <%} %>

        <%if(adminuserroleint==1||adminuserroleint==4){ %>

        <tr>

            <td width="100%"
bgcolor="#c0c0c0"
align="center">

            <font color="#0000ff">学生宿舍管理</font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="bedchamber.jsp"
target="main">宿舍分配</a></font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="classview.jsp"
target="main">宿舍情况查询</a></font>

            </td>

        </tr>

        <%} %>

        <%if(adminuserroleint==1){ %>

        <tr>

            <td width="100%"
bgcolor="#c0c0c0"
align="center">

            <font color="#0000ff">基础数据管理</font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="specialityadmin.jsp"
target="main">录入专业</a></font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="matri.jsp"
target="main">录入录取学生名册</a></font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="bedchamber.jsp"
target="main">录入宿舍</a></font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="class.jsp"
target="main">录入班级</a></font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="regstatus.jsp"
target="main">学生报道状况查询</a></font>

            </td>

        </tr>

        <tr>

            <td width="100%"
align="center">

            <font><a href="adminuser.jsp"
target="main">用户管理</a></font>

            </td>

        </tr>

        <%} %>

        </table>

        </div>

    </body>

</html>

通过session变量daminuserrole的值来获取用户角色,根据用户角色来相应的显示可操作的功能菜单。

4.系统功能的实现:

用户登陆功能的实现:

-----login.jsp-----


<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="com.bjsxt.DB.*,java.sql.*" %>
<%Connection conn=DBConn.createDBConn(); %>
<%
String adminusername=request.getParameter("adminusername");
String adminuserpassword=request.getParameter("adminuserpassword");
String action=request.getParameter("action");
String errormsg=request.getParameter("errormsg");
if(action != null && action.trim().equals("login")){
String sql="select * from Adminuser where Adminusername=? and Adminuserpassword=?";
PreparedStatement state=conn.prepareStatement(sql);
state.setString(1,adminusername);
state.setString(2,adminuserpassword);
ResultSet rs=state.executeQuery();
if(rs.next()) {
session.setAttribute("adminusername",adminusername);
session.setAttribute("adminuserrole",rs.getString("Adminuserrole"));
response.sendRedirect("index.jsp");
}
}
%>

<html>
<body>
<br><br><br><br>
<div align="center">
<form method="post" action="login.jsp">
<table table border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse" bordercolor="#c0c0c0" width="300">
<tr>
<td width="100%" bgcolor="#c0c0c0" align="center">
<font color="#0000ff">用户登录</font>
</td>
</tr>
<%
if(errormsg!=null&&errormsg.length()!=0){
%>
<tr>
<td align="center">
<%=errormsg %>
</td>
</tr>
<%
}
%>
<tr>
<td>
请输入用户名:<input type="text" name="adminusername"><br>
请输入密&nbsp;&nbsp;码:<input type="password" name="adminuserpassword"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="提 交">
<input type="hidden" name="action" value="login">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<%DBConn.closeConn(conn); %>

为防止SQL注入攻击,使用了PreparedStatement对象来执行带参数的SQL语句。如果校验没有通过,则将错误的提示文件放入字符串errormsg中,在后续的代码显示表格时,

如果errormsg的值不为空,说明有错误信息,则显示出来。

-----DBConn.java-----


<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="com.bjsxt.DB.*,java.sql.*" %>
<%Connection conn=DBConn.createDBConn(); %>
<%
String adminusername=request.getParameter("adminusername");
String adminuserpassword=request.getParameter("adminuserpassword");
String action=request.getParameter("action");
String errormsg=request.getParameter("errormsg");
if(action != null && action.trim().equals("login")){
String sql="select * from Adminuser where Adminusername=? and Adminuserpassword=?";
PreparedStatement state=conn.prepareStatement(sql);
state.setString(1,adminusername);
state.setString(2,adminuserpassword);
ResultSet rs=state.executeQuery();
if(rs.next()) {
session.setAttribute("adminusername",adminusername);
session.setAttribute("adminuserrole",rs.getString("Adminuserrole"));
response.sendRedirect("index.jsp");
}
}
%>

<html>
<body>
<br><br><br><br>
<div align="center">
<form method="post" action="login.jsp">
<table table border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse" bordercolor="#c0c0c0" width="300">
<tr>
<td width="100%" bgcolor="#c0c0c0" align="center">
<font color="#0000ff">用户登录</font>
</td>
</tr>
<%
if(errormsg!=null&&errormsg.length()!=0){
%>
<tr>
<td align="center">
<%=errormsg %>
</td>
</tr>
<%
}
%>
<tr>
<td>
请输入用户名:<input type="text" name="adminusername"><br>
请输入密&nbsp;&nbsp;码:<input type="password" name="adminuserpassword"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="提 交">
<input type="hidden" name="action" value="login">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<%DBConn.closeConn(conn); %>

这个类中有两个静态的方法,一个用于生成一个数据库连接对象,一个用于关闭数据库连接。

-----specialityadmin.jsp-----

?





1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

<%@page
contentType="text/html;charset=GBK"
%>

<%@page
import="com.bjsxt.DB.*,java.sql.*"
%>

<%Connection conn=DBConn.createDBConn(); %>

<html>

<body>

<%

    //----获取请求参数值

    String action=request.getParameter("action");

    if(action!=null&&action.length()!=0)

        action=new
String(action.getBytes("ISO-8859-1"));

    String specialityname=request.getParameter("specialityname");

    if(specialityname!=null&&specialityname.length()!=0)

        specialityname=new
String(specialityname.getBytes("ISO-8859-1"));

    String specialityid=request.getParameter("specialityid");

    if(specialityid!=null&&specialityid.length()!=0)

        specialityid=new
String(specialityid.getBytes("ISO-8859-1"));

    //----如果想增加一个专业

    if("add".equals(action)){

        String sql="selet * from Spciality where SpecialityName=?";

        PreparedStatement preSQLSelect=conn.prepareStatement(sql);

        preSQLSelect.setString(1,specialityname);

        ResultSet rs=preSQLSelect.executeQuery();

        if(!rs.next()){

            sql="insert into Speciality(SpecialityName) values(?)";

            PreparedStatement preSQLInsert=conn.prepareStatement(sql);

            preSQLInsert.setString(1,specialityname);

            preSQLInsert.executeUpdate();

        }

    }

    //----如果是删除一个专业----

    if("del".equals(action)){

        String sql="delete from Speciality where SpecialityId=?";

        PreparedStatement preSQLDel=conn.prepareStatement(sql);

        int
specialityidInt=0;

        if(specialityid!=null&&specialityid.length()>0){

            specialityidInt=Integer.parseInt(specialityid);

            preSQLDel.setInt(1,specialityidInt);

            preSQLDel.executeUpdate();

        }

    }

%>

<form method="post"
action="specialityadmin.jsp">

<table border="1"
cellpadding="0"
cellspacing="0"
style="border-collapse:collapse"
bordercolor="#c0c0c0"
width="600">

    <tr>

        <td width="100%"
bgcolor="#c0c0c0">

        <font color="#0000ff">录入专业数据</font></td>

    </tr>

    <tr>

        <td width="100%">

        请输入专业名称:

        <input type="text"
name="specialityname">

        <input type="hidden"
name="action"
value="add">

        <imput type="submit"
value="提交">

        </td>

    </tr>

</table>

</form>

<table border="1"
cellpadding="0"
cellspacing="0"
style="border-collapse:collapse"
bordercolor="#c0c0c0"
width="600">

    <tr>

        <td width="100%"
bgcolor="#c0c0c0"
align="center"
colspan="3">

        <font color="#0000ff">已有专业数据</font></td>

    </tr>

    <tr>

        <td width="20%"
align="center">

        序号

        </td>

        <td width="60%"
align="center">

        专业名称

        </td>

        <td width="20%"
align="center">

        删除?

        </td>

    </tr>

    <%

    //----查询出已有的专业名称

    String sql="select * from Speciality";

    Statement state=conn.createStatement();

    ResultSet rs=state.executeQuery(sql);

    int
i=0;

    while(rs.next()){

        i++;

    %>

    <tr>

        <td width="20%"
align="center">

        <%=i%>

        </td>

        <td width="60%"
align="center">

        <%=rs.getString("SpecialityName")%>

        </td>

        <td width="20%"
align="center">

            <a href="specialityadmin.jsp?action=del&specialityid=<%=rs.getInt("SpecialityId") %>">删除</a>

        </td>

    </tr>

<% } %>

</table>

</body>

</html>

<%DBConn.closeConn(conn);%>

在表单中使用了一个名为action的隐藏域,值为add,表明是要增加一个专业;在删除的超链接中也带了action参数,值为del,表示要删除一个专业。再页面的第一个JSP程序块中首先接收传来的参数。为了解决中文乱码问题,对提交的数据做了编码转换。根据action的值的判断,作出不同的处理。

-----classadmin.jsp-----

?





1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

<%@page
contentType="text/html;charset=GBK"
%>

<%@page
import="com.bjsxt.DB.*,java.sql.*"
%>

<%Connection conn=DBConn.createDBConn(); %>

<%

    //----获取请求参数值----

    String studentname=request.getParameter("studentname")+"";

    if(studentname!=null&&studentname.length()!=0)

        studentname=new
String(studentname.getBytes("ISO-8859-1"));

    String action=request.getParameter("action")+"";

    String matrino=request.getParameter("matrino")+"";

    //----构造查询的SQL语句----

    String sqlwhere=new
String("");

    String sql=new
String("");

    if("select".equals(action)){

        if(studentname!=null&&studentname.trim().length()!=0)

            sqlwhere="where studentname like ‘%"+studentname.trim()+"%‘ ";

        if(sqlwhere!=null&&sqlwhere.length()!=0){

            if(matrino!=null&&matrino.trim().length()!=0)

                sqlwhere+=" and matrino like ‘%"+matrino.trim()+"%‘";

        }else{

            if(matrino!=null&&matrino.trim().length()!=0)

                sqlwhere=" where matrino like ‘%"+matrino.trim()+"%‘";

        }

        sql="select * from student "+sqlwhere;

    }

    //----设置分班情况----

    if("update".equals(action)){    //如果设置分班情况

        String studentcount=request.getParameter("studentcount");

        for(int
i=1;i<=Integer.parseInt(studentcount);i++){

            String studentid=request.getParameter("studentid"+i);

            String classid=request.getParameter("classid"+i);

            if(classid!=null&&classid.length()!=0&&studentid!=null&&studentid.length()!=0){

                String sqlstr="update student set classid="+classid+" where studentid="+studentid+studentid;

                Statement state=conn.createStatement();

                state.executeQuery(sqlstr);

            }

        }

        out.print("设置分班操作成功!");

    }

%>

<html>

<body>

<form method="post"
action="calssadmin.jsp">

<table border="1"
cellpadding="0"
cellspacing="0"
style="border-collapse:collapse"
bordercolor="#c0c0c0"
width="700">

    <tr>

        <td width="100%"
bgcolor="#c0c0c0">

        <font color="#0000ff">要查询的条件</font></td>

    </tr>

    <tr>

        <td width="100%"
>

        请输入姓名:

        <input type="text"
name="studentname">

        请输入录取通知书号:

        <input type="text"
name="matrino">

        <input type="hidden"
name="action"
value="select">

        <input type="submit"
name="提交">

        </td>

    </tr>

</table>

</form>

<form action="calssadmin.jsp"
method="post">

<table border="1"
cellpadding="0"
cellspacing="0"
style="border-collapse:collapse"
bordercolor="#c0c0c0"
width="700">

    <tr>

        <td width="100%"
bgcolor="#c0c0c0"
align="center"
colspan="8">

        <font color="#0000ff">查询到的学生数据</font></td>

    </tr>

    <tr>

        <td width="5%"
align="center">序号</td>

        <td width="12%"
align="center">姓名</td>

        <td width="16%"
align="center">录取通知书号</td>

        <td width="12%"
align="center">录取班级</td>

        <td width="15%"
align="center">所在班级</td>

    </tr>

        <%if("select".equals(action)){ %>

        <%Statement state=conn.createStatement();

          ResultSet rs=state.executeQuery(sql);

          int
i=0;

          while(rs.next()){

            i++;

        %>

        <tr>

            <td width="5%"
align="center"><%=i%></td>

            <td width="12%"
align="center"><%=rs.getString("studentname")%></td>

            <td width="16%"
align="center"><%=rs.getString("matrino")%></td>

            <td width="12%"
align="center">

            <%int
specialityid=rs.getInt("specialityid");

                if(specialityid==0)

                    out.print("尚无专业");

                else{

                    sql="select * from speciality where specialityid="+specialityid;

                    Statement statetemp=conn.createStatement();

                    ResultSet rstemp=statetemp.executeQuery(sql);

                    if(rstemp.next())

                        out.print(rstemp.getString("specialityname"));

                    else

                        out.print("尚无专业");

                }

                %>

            </td>

            <td width="15%"
align="center">

            <input type="hidden"
name="<%="studentid"+i%>"
value="<%=rs.getString("studentid")%>">

            <select name="<%="classid"+i%>"
>

            <option value="">==尚未分班==</option>

            <%int
classid=rs.getInt("classid");

              sql="select * from classtt";

              Statement statetemp=conn.createStatement();

              ResultSet rstemp=statetemp.executeQuery(sql);

              while(rstemp.next()){

                int
rstempclassid=rstemp.getInt("classid");%>

            <option value="<%=rstempclassid%>"

            <%if(rstempclassid==classid){%>selected<%} %>>

            <%=rstemp.getString("classname") %>

            </option>

            <%} %>

            </select>

            </td>

        </tr>

        <%} %>

        <tr>

            <td width="100%"
bgcolor="#c0c0c0"
align="center"
colspan="8">

            <font color="#0000ff">

            <input type="submit"
value="确  定">

            </font></td>

        </tr>

        <input type="hidden"
name="studentcount"
value="<%=i%>">

        <input type="hidden"
name="cation"
value="update">

        <%} %>

</table>

</form>

</body>

</html>

<%DBConn.closeConn(conn);%>

  -----acceptmoney-----

?





1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

<%@ page contentType="text/html;charset=GBK"
%>

<%@ page import="com.bjsxt.DB.*,java.sql.*"
%>

<%Connection conn=DBConn.createDBConn(); %>

<%

    //----获取请求参数值----

    String studentname=request.getParameter("studentname")+"";

    if(studentname!=null&&studentname.length()!=0)

        studentname=new
String(studentname.getBytes("ISO-8859-1"));

    String action=request.getParameter("action")+"";

    String matrino=request.getParameter("matrino")+"";

    //----构造查询的SQL语句----

    String sqlwhere=new
String("");

    String sql=new
String("");

    if("select".equals(action)){    //如果是查询操作

        if(studentname!=null&&studentname.trim().length()!=0)

            sqlwhere="where studentname like ‘%"+studentname.trim()+"%‘ ";

        if(sqlwhere!=null&&sqlwhere.length()!=0){

            if(matrino!=null&&matrino.trim().length()!=0)

                sqlwhere+=" and matrino like ‘%"+matrino.trim()+"%‘";

        }else{

            if(matrino!=null&&matrino.trim().length()!=0)

                sqlwhere=" where matrino like ‘%"+matrino.trim()+"%‘";

        }

        sql="select * from student "+sqlwhere;

    }

    //----交费操作----

    if("update".equals(action)){    //如果是交费操作  

        String studentcount=request.getParameter("studentcount");

        for(int
i=1;i<=Integer.parseInt(studentcount);i++){

            String studentid=request.getParameter("studentid"+i);

            String payamount=request.getParameter("payamount"+i)+"";

            String payok=request.getParameter("payok"+i)+"";

            if(studentid!=null&&studentid.length()!=0&&payamount!=null&&payamount.length()!=0){

                String sqlstr="update student set payamount="+payamount+","+"payok="+payok+" where studentid="+studentid;

                Statement state=conn.createStatement();

                state.executeQuery(sqlstr);

            }

        }

        out.print("收费情况登记成功!");

    }

%>

<html>

<body>

<form method="post"
action="acceptmoney.jsp">

<table border="1"
cellpadding="0"
cellspacing="0"
style="border-collapse:collapse"
bordercolor="#c0c0c0"
width="700">

    <tr>

        <td width="100%"
bgcolor="#c0c0c0">

        <font color="#0000ff">要查询的条件</font></td>

    </tr>

    <tr>

        <td width="100%"
>

        请输入姓名:

        <input type="text"
name="studentname">

        请输入录取通知书号:

        <input type="text"
name="matrino">

        <input type="hidden"
name="action"
value="select">

        <input type="submit"
name="提交">

        </td>

    </tr>

</table>

</form>

<form action="acceptmoney.jsp"
method="post">

<table border="1"
cellpadding="0"
cellspacing="0"
style="border-collapse:collapse"
bordercolor="#c0c0c0"
width="700">

    <tr>

        <td width="100%"
bgcolor="#c0c0c0"
align="center"
colspan="7">

        <font color="#0000ff">查询到的学生数据</font></td>

    </tr>

    <tr>

        <td width="5%"
align="center">序号</td>

        <td width="12%"
align="center">姓名</td>

        <td width="16%"
align="center">录取通知书号</td>

        <td width="12%"
align="center">录取专业</td>

        <td width="15%"
align="center">所在班级</td>

        <td width="15%"
align="center">交费金额</td>

        <td width="15%"
align="center">是否交清</td>

    </tr>

        <%if("select".equals(action)){ %>

        <%Statement state=conn.createStatement();

          ResultSet rs=state.executeQuery(sql);

          int
i=0;

          while(rs.next()){

            i++;

        %>

        <tr>

            <td width="5%"
align="center"><%=i%></td>

            <td width="12%"
align="center"><%=rs.getString("studentname")%></td>

            <td width="16%"
align="center"><%=rs.getString("matrino")%></td>

            <td width="12%"
align="center">

            <%int
specialityid=rs.getInt("specialityid");

                if(specialityid==0)

                    out.print("尚无专业");

                else{

                    sql="select * from speciality where specialityid="+specialityid;

                    Statement statetemp=conn.createStatement();

                    ResultSet rstemp=statetemp.executeQuery(sql);

                    if(rstemp.next())

                        out.print(rstemp.getString("specialityname"));

                    else

                        out.print("尚无专业");

                }

                %>

            </td>

            <td width="15%"
align="center">

            <input type="hidden"
name="<%="studentid"+i%>"
value="<%=rs.getString("studentid")%>">

            <%int
classid=rs.getInt("classid");

              boolean
isclass=false;

              sql="select * from classtt where classid="+classid;

              Statement statetemp=conn.createStatement();

              ResultSet rstemp=statetemp.executeQuery(sql);

              if(rstemp.next()){

                out.print(rstemp.getString("classname"));

                isclass=true;

              }else{

                  out.print("尚未分班");

              }

            %>

            </td>

            <td width="15%"
align="center">

            <%if(isclass){ %>

            <inptu type="text"
name="<%="payamount"+i%>"
value="<%=rs.getFloat("payamount")%> size="12">

            <%} %>

            </td>

            <td width="15%"
align="center">

            <%if(isclass){ %>

            <inptu type="radio"
name="<%="payok"+i%>"
value="1"
size="12"
<%if(rs.getInt("payok")==1) out.print("checked=true"); %>>是

            <inptu type="radio"
name="<%="payok"+i%>"
value="0"
size="12"
<%if(rs.getInt("payok")==0) out.print("checked=true"); %>>否

            <%} %>

            </td>

        </tr>

    <%} %>

    <tr>

        <td width="100%"
bgcolor="#c0c0c0"
align="center"
colspan="8">

        <font color="#0000ff">

        <input type="submit"
value="确 定">

        </font></td>

    </tr>

        <input type="hidden"
name="studentcount"
value="<%=i%>">

        <input type="hidden"
name="cation"
value="update">

    <%} %>

</table>

</form>

</body>

</html>

<%DBConn.closeConn(conn);%>

如果已经分班且付清学费,则会显示一个宿舍下拉框,供操作人员选择宿舍。下拉框的option标签根据宿舍表中的记录条数来定,如果正要增加的option中,宿舍的ID号正好等于当前记录的宿舍ID号,则将此option标签设为selected,表示被选中。

难点:录取学生名册基础数据管理功能的实现-----matri.jsp-----

总结:

通过完成系统开发手动操作后,对软件工程的思想会有深一步的认识,对MyEclipse开发Web应用的方法也能熟练操作,对JSP只是的综合运用也更加灵活了。

时间: 2024-08-08 18:37:22

小项目之学生报到管理系统的相关文章

web实践小项目&lt;一&gt;:简单日程管理系统(涉及html/css,javascript,python,sql,日期处理)

暑假自学了些html/css,javascript和python,苦于学完无处练手几乎过目即忘...最后在同学的建议下做了个简单日程管理系统.借第一版完成之际,希望能将实践期间犯过的错误和获得的新知进行整理,希望能给其他初学者提供参考,也希望有大神在浏览我粗糙的开发过程中能指出一些意见或建议. (阅读以下内容需要有一定的html/css,javascript,python和sql基础,and谢谢阅读!) 注:实践中的环境为ubuntu 14.04操作系统,python3.4(2.7实测也可行),

Java小项目之:图书馆管理系统!有借有还再借不难!

Java小项目之:图书馆管理系统!今天给大家分享的java小项目是图书馆管理系统.这个图书馆管理系统是很完善的,包括书籍信息录入.借阅者信息.书籍类别添加.新书订购等等功能.和现实生活中的图书馆管理系统没什么两样,毫不夸张的说,你只要学会了今天我分享的这个小项目,以后自己创建一个图书馆管理系统是没一点问题的.按照惯例先上图: 部分代码展示:public class BookLoginIFrame extends JFrame { private class BookResetAction imp

3.python小项目:学生选课系统

学生选课系统 编程核心:在对象中封装对象 目录结构: 1.administrator.py import random import os import sys sys.path.append(os.path.dirname(os.path.dirname(__file__))) import time import pickle from lib import models from config import settings from lib.models import * # 全部导入

小学期,学生信息管理系统

#include <stdio.h> #define M 10 void modify(struct student *stu, int st);//修改函数 void input(struct student *stu, int st);//输入函数 void (display(struct student *stu, int N));//显示函数 struct student{     int number;     //学号     char name[M];  //姓名     cha

javaEE项目实践——学生信息管理系统

一.项目运行环境及工具 myeclipse2014 + tomcat 7.x/tomcat 8.x + jdk 1.8 二.项目开发周期 10天(前端界面直接拿来使用的还有系统很多功能未能去实现,仅供开发学习): 三.开发期间实现的功能 时间紧.任务重.基础差  -->  导致 10天内(其实满算只有7天左右)仅完成了登录.查询.全选.全否.反选.添加.分页.删除.退出等功能 四.效果展示 1)登录 2)查询 3)全选 4)反选 5)全否 6)添加 7)分页 8)修改(自学) 9)退出 五.业务

【软件工程】02组软件工程组队项目计划安排及选题介绍——学生课程管理系统

一.项目概述 我们选择的项目是学生课程管理系统,是基于上一届学长的项目进行改进和实现. 学生课程管理系统是一个集成了课程信息查询,课程信息管理,成绩管理等面向老师与学生群体的系统. 定位:我们小组明确了这个系统的定位是辅助教务处的系统,适用范围是在一个比较小范围的人群内,而不是面向有数万人的学校.我们对教务处系统中一些比较繁琐或者需要复杂的权限才能使用的功能进行简化,使系统可以在一个小范围中比较简单地进行上手使用(例如一个老师要在院系中开一个培训班,那么教务处系统就不太方便,就可以用我们的系统)

【PHP小项目使用MVC架构】

小项目名称是雇员管理系统. mvc是一种项目的开发模式,中文名称为模式视图控制器,是强制程序员将数据的输入.处理.输出分开的一种开发模式. 在这个小项目中,控制器使用service作为后缀名. 项目uml图解概述: 在此之前,需要先创建数据库empmanage,同时创建两张表,一张表为admin,令一张表为emp,创建admin表的sql语句: create table admin ( id int primary key, name varchar(32) not null, password

[项目记录] 用c语言完成的一个学生成绩管理系统

一.要求: 学生成绩管理系统 某班有最多不超过30人(具体人数由键盘输入)参加期末考试,最多不超过6门(具体门数由键盘输入).使用链表编程实现如下菜单驱动的学生成绩管理系统. 从文件读入每个学生个人信息和成绩信息,可以由键盘输入文件名.读入成功提示读入学生记录的个数,不成功提示相应出错信息. 增量式手动录入每个学生的学号.姓名和各科考试成绩.不考虑中文姓名,但需要考虑重名情况下的处理,学生的学号是唯一的. 计算每门课程的总分和平均分: 计算每个学生的总分和平均分: 按每个学生的总分由高到低排出名

python3开发进阶-Django框架学习前的小项目(一个简单的学员管理系统)

''' 自己独立写一个学员管理系统 表结构: 班级表: -id -grade_name 学生表: -id -student_name -grade 关联外键班级表 老师表: -id -teacher_name -grades (多对多 关联班级表) ''' 在写小项目之前我们先复习一下小知识: 1. form表单提交数据的注意事项: 是form不是from,必须要有method和action 所有获取用户输入的表单标签要放在form表单里面,表单标签必须要有name属性 form表单必须要有su