3.2 登录3.2.1 系统总模型 http://www.paper51.com 学生信息管理系统总的模型主要是说明系统注册后才能登录,登录后进么主页面后实现主要有学生资料管理、管理员管理以及更改级别,其中学生资料管理主要实现学生信息的添加、修改、删除和查询功能。管理员管理是只有权限最高的管理员才能进行删除管理员和更改权限的操作。其结构图如下: http://www.paper51.com http://www.paper51.com 3.2.2 登录界面 内容来自论文无忧网 www.paper51.com (1)只有通过index.asp登录界面才能进入主页面进行相应学生信息的操作。 paper51.com
(2)进入登录界面:通过注册页面让用户提交注册并保存在user表里,并通过登录页面读取用户提交的 登录信息与保存在数据库中的数据进行比较以验证是否成功登录。 copyright paper51.com 图1:用户登录界面 http://www.paper51.com
内容来自论文无忧网 www.paper51.com 3.2.3 主页面的实现 http://www.paper51.com
内容来自论文无忧网 www.paper51.com 图2:主页面 copyright paper51.com
学生信息管理系统主要是与数据库的连接,然后数据库的连接必须使用ADO的内置Connection对象,并且调用Recordset对象来进行与数据库的查找、删除、更改等功能,具体脚本如下: paper51.com <% copyright paper51.com dim username,password 内容来自www.paper51.com dim cnn,rst,ssql copyright paper51.com username=trim(request.form("txtusername")) copyright paper51.com
password=trim(request.form("txtpassword")) 内容来自www.paper51.com login=request.form("btnlogin") 内容来自www.paper51.com 'if login="" andsession("username")="" then response.redirect"login.htm" copyright paper51.com
if (username="" orpassword="" ) and login<>"" then response.redirect"login.htm" 内容来自论文无忧网 www.paper51.com %> paper51.com
<% paper51.com 'ifseesion("username")="" or(session("username")<>username andseesion("username")<>"") then paper51.com setcnn=server.createobject("adodb.connection") 内容来自www.paper51.com setrst=server.CreateObject("adodb.recordset") paper51.com
cnn.connectionstring="provider=microsoft.jet.oledb.4.0;datasource="&server.MapPath("Date\date.mdb ") paper51.com cnn.open 内容来自论文无忧网 www.paper51.com ssql="select * from users whereuser_name='"&username&"' and mm='"&password&"' " http://www.paper51.com set rst =cnn.execute(ssql, ,adcmtext) http://www.paper51.com if rst.eof then copyright paper51.com response.Write"<p align=center><b>Username or Passwordis error.sorry!</b></p>" copyright paper51.com response.write"<palign=center><a href=login.asp>重新登录(restart login)</a></p>" paper51.com else copyright paper51.com session("username")=rst("user_name") copyright paper51.com session("level")=rst("purview_level") 内容来自www.paper51.com end if 内容来自论文无忧网 www.paper51.com
%> paper51.com
3.3 后台主要功能的实现3.3.1 添加学生信息资料 copyright paper51.com 在学生信息管理系统首页(index.asp)单击“添加资料”链接,可以进入addinfo.asp页面,在该页面中输入学生资料,并提交给saveinfo.asp页面进行添加,将数据保存到数据库中。界面如下: paper51.com
http://www.paper51.com
图1 添加页面addinfo.asp 内容来自论文无忧网 www.paper51.com 实现功能脚本如下: 内容来自www.paper51.com <!-- #include file="Date\adovbs.inc" --> 内容来自www.paper51.com <% 内容来自www.paper51.com
Dim cnn, rst, sSQL 内容来自www.paper51.com Dim StudentNum,StudentName, StudentSex, BirthDate, Department copyright paper51.com Dim Speciality, Grade,sClass, ParentName, HomeAddr, HomePhone, Remark 内容来自论文无忧网 www.paper51.com StudentNum =Trim(Request.Form("txtStudentNum")) paper51.com
StudentName =Trim(Request.Form("txtStudentName")) copyright paper51.com StudentSex =Request.Form("optStudentSex") 内容来自www.paper51.com BirthDate =Trim(Request.Form("txtBirthDate")) copyright paper51.com Department = Trim(Request.Form("txtDepartment")) paper51.com
Speciality =Trim(Request.Form("txtSpeciality")) 内容来自www.paper51.com Grade =Trim(Request.Form("txtGrade")) copyright paper51.com sClass =Trim(Request.Form("txtClass")) 内容来自论文无忧网 www.paper51.com ParentName =Trim(Request.Form("txtParentName")) http://www.paper51.com HomeAddr =Trim(Request.Form("txtHomeAddr")) 内容来自www.paper51.com HomePhone =Trim(Request.Form("txtHomePhone")) 内容来自www.paper51.com Remark =Trim(Request.Form("txtRemark")) 内容来自论文无忧网 www.paper51.com If StudentNum ="" Or StudentName = "" Then http://www.paper51.com Response.Redirect"addInfo.asp" copyright paper51.com
End If http://www.paper51.com Set cnn =Server.CreateObject("ADODB.Connection") copyright paper51.com Set rst =Server.CreateObject("ADODB.Recordset") 内容来自论文无忧网 www.paper51.com cnn.ConnectionString ="PROVIDER=microsoft.jet.oledb.4.0;DATA SOURCE=" &server.mappath("Date\date.mdb") 内容来自论文无忧网 www.paper51.com cnn.Open paper51.com sSQL = "SELECTstudent_num FROM students WHERE student_num='" & StudentNum &"'" 内容来自www.paper51.com Set rst =cnn.Execute(sSQL, , adCmdText) 内容来自www.paper51.com If Not rst.EOF Then copyright paper51.com Response.Write "<P>学号“" &rst("student_num") & "”已经存在,请重新输入!</P>" 内容来自www.paper51.com Else 内容来自论文无忧网 www.paper51.com
sSQL = "INSERT intostudents(student_num, student_name, " & "student_sex, birthdate,department, speciality," copyright paper51.com
sSQL = sSQL & "grade, class,home_addr, parent_name, " 内容来自论文无忧网 www.paper51.com sSQL = sSQL & "home_phone,remark) VALUES('" 内容来自www.paper51.com sSQL = sSQL & StudentNum &"','" & StudentName & "','" & StudentSex &"','" & BirthDate & "','" copyright paper51.com sSQL = sSQL & Department &"','" & Speciality & "','" & Grade &"','" & sClass & "','" 内容来自论文无忧网 www.paper51.com sSQL = sSQL & HomeAddr &"','" & ParentName & "','" & HomePhone &"','" & Remark & "')" paper51.com cnn.Execute sSQL, , adCmdText paper51.com %> http://www.paper51.com <HR NOSHADE SIZE ="1" COLOR = "red"> 内容来自论文无忧网 www.paper51.com <Pclass="STYLE1">数据保存成功!</P> paper51.com <% End If %> 内容来自论文无忧网 www.paper51.com
3.3.2 修改学生资料 copyright paper51.com 在学生信息管理系统首页(index.asp)单击“修改资料”链接,可以进入editinfo.asp页面,在该页面中输入学生资料,并提交给editinfo2.asp页面进行修改,将数据进行修改操作中。界面如下: 内容来自www.paper51.com
paper51.com 图2 修改页面editinfo.asp 内容来自www.paper51.com 实现功能脚本如下: paper51.com <!-- #include file="Date\adovbs.inc" --> http://www.paper51.com
<% http://www.paper51.com Dim cnn, rst, sSQL, StuNum paper51.com StuNum = Trim(Request.Form("txtStuNum")) 内容来自www.paper51.com Set cnn = Server.CreateObject("ADODB.Connection") copyright paper51.com Set rst = Server.CreateObject("ADODB.Recordset") paper51.com cnn.ConnectionString = "PROVIDER=microsoft.jet.oledb.4.0;DATASOURCE=" & server.mappath("Date\date.mdb") http://www.paper51.com cnn.Open copyright paper51.com If StuNum <> "" Then 内容来自论文无忧网 www.paper51.com sSQL = "SELECT *FROM students WHERE student_num='" & StuNum & "'" 内容来自论文无忧网 www.paper51.com Set rst =cnn.Execute(sSQL, , adCmdText) 内容来自www.paper51.com If rst.EOF Then copyright paper51.com Response.Write "<P><FONT COLOR = red>没有找到符合条件的记录!</FONT></P>" http://www.paper51.com
Else paper51.com %> http://www.paper51.com
<FORM METHOD = "post" ACTION ="editInfo2.asp"> 内容来自论文无忧网 www.paper51.com
<TABLE border="1" align="center"cellpadding="2" cellspacing="1"bordercolor="#0099FF" BGCOLOR = "#B5E6FF"> 内容来自论文无忧网 www.paper51.com <TR ALIGN = "center"> paper51.com <TH COLSPAN = "6" BGCOLOR = "#0034FF"> http://www.paper51.com <FONT COLOR = "#FFFFFF">修改学生资料</FONT></TH> http://www.paper51.com </TR> 内容来自www.paper51.com <TR> 内容来自www.paper51.com <TD ALIGN = "right">学号:</TD> copyright paper51.com <TD><INPUT TYPE = "text" NAME ="txtStudentNum" SIZE = "12" http://www.paper51.com
VALUE = <% = rst("student_num")%>> 内容来自www.paper51.com <INPUT TYPE = "hidden" NAME = "txtOldStuNum"SIZE = "12" 内容来自论文无忧网 www.paper51.com
VALUE = <% = rst("student_num")%>></TD> http://www.paper51.com <TD ALIGN = "right">姓名:</TD> 内容来自论文无忧网 www.paper51.com <TD><INPUT TYPE = "text" NAME ="txtStudentName" SIZE = "12" copyright paper51.com
VALUE = <% = rst("student_name")%>></TD> 内容来自www.paper51.com
<TD ALIGN = "right">性别:</TD> 内容来自www.paper51.com
<TD><INPUT TYPE = "radio" VALUE = "男" http://www.paper51.com NAME="optStudentSex" <% = IIf( rst("student_sex")= "男") %>>男 内容来自论文无忧网 www.paper51.com <INPUT TYPE="radio" VALUE="女" http://www.paper51.com NAME="optStudentSex" <% = IIf(rst("student_sex") = "女")%>>女</TD> paper51.com </TR> 内容来自www.paper51.com <TR> 内容来自论文无忧网 www.paper51.com <TD ALIGN = "right">出生日期:</TD> 内容来自论文无忧网 www.paper51.com <TD><INPUT TYPE = "text" NAME ="txtBirthDate" SIZE = "12" 内容来自www.paper51.com VALUE = <% = rst("birthdate") %>></TD> paper51.com <TD ALIGN = "right">所在院系:</TD> copyright paper51.com <TD><INPUT TYPE = "text" NAME ="txtDepartment" SIZE = "12" 内容来自论文无忧网 www.paper51.com
VALUE = <% = rst("department") %>></TD> copyright paper51.com
<TD ALIGN = "right">所在专业:</TD> 内容来自www.paper51.com <TD><INPUT TYPE = "text" NAME ="txtSpeciality" SIZE = "12" http://www.paper51.com
VALUE = <% = rst("speciality") %>></TD> copyright paper51.com
</TR> http://www.paper51.com <TR> paper51.com <TD ALIGN = "right">年级:</TD> 内容来自www.paper51.com <TD><INPUT TYPE = "text" NAME ="txtGrade" SIZE = "12" 内容来自www.paper51.com VALUE = <% = rst("grade") %>></TD> paper51.com <TD ALIGN = "right">班级:</TD> 内容来自论文无忧网 www.paper51.com
<TD><INPUT TYPE = "text" NAME ="txtClass" SIZE = "12" paper51.com VALUE = <% = rst("class") %>></TD> 内容来自论文无忧网 www.paper51.com <TD ALIGN = "right">家长姓名:</TD> 内容来自www.paper51.com <TD><INPUT TYPE = "text" NAME ="txtParentName" SIZE = "12" paper51.com VALUE = <% = rst("parent_name") %>></TD> 内容来自www.paper51.com </TR> http://www.paper51.com <TR> 内容来自www.paper51.com <TD ALIGN = "right">家庭住址:</TD> 内容来自www.paper51.com
<TD COLSPAN = "3"><INPUT TYPE = "text" 内容来自论文无忧网 www.paper51.com NAME = "txtHomeAddr" SIZE = "33" VALUE = <% =rst("home_addr") %>></TD> paper51.com <TD ALIGN = "right">住宅电话:</TD> 内容来自www.paper51.com <TD><INPUT TYPE = "text" NAME ="txtHomePhone" SIZE = "12" 内容来自论文无忧网 www.paper51.com VALUE = <% = rst("home_phone") %>></TD> 内容来自论文无忧网 www.paper51.com </TR> 内容来自论文无忧网 www.paper51.com <TR> copyright paper51.com <TD ALIGN = "right">备注:</TD> http://www.paper51.com
<TD COLSPAN = "5"><TEXTAREA ROWS = "3"NAME = "txtRemark" paper51.com COLS = "58"><% = rst("remark")%></TEXTAREA></TD> 内容来自论文无忧网 www.paper51.com </TR> 内容来自论文无忧网 www.paper51.com <TR ALIGN = "center"> 内容来自论文无忧网 www.paper51.com <TD COLSPAN = "6"><INPUT TYPE ="submit" VALUE = "保存数据" 内容来自www.paper51.com
NAME = "btnSave"> http://www.paper51.com
<INPUT TYPE="reset" VALUE= "全部重写" paper51.com NAME = "btnReset"></TD> 内容来自论文无忧网 www.paper51.com </TR> http://www.paper51.com
</TABLE> http://www.paper51.com </FORM> copyright paper51.com <% paper51.com End If 内容来自www.paper51.com End If paper51.com
%> copyright paper51.com |