新 乡 学 院
毕
业
论
文
论 文 题 目
Web 课程网站设计和实现
院(系)名称
专 业 名 称
班 级
学 生 姓 名
学 号
指导教师姓名
20010 年 4 月完成
目录
关键词:精品课程 ASP.NET ACCESS 数据库.................................................................5
KEY WORDS:COURSE RESOURCES WEBSITE ASP.NET DATABASE...............5
1 网站概述.............................................................................................................................6
1.1 引言..................................................................................................................................6
2 相关理论和技术.................................................................................................................6
2.1 开发环境......................................................................................................................6
2.2 ASP.NET 的特点............................................................................................................7
2.3 精品课程网站的其他开发工具..................................................................................8
3.2 课程网站的功能说明...................................................................................................9
4 程序设计...........................................................................................................................11
4.1 用户注册功能的实现.................................................................................................11
当浏览者浏览网站时,若想注册一个账号,方便对网站内容的更高权限的浏览,
则可以点击注册按钮,进入注册页面,主要信息如下所述:用户名,密码,确认
密码等,在输入信息时,要控制格式,所以设置了一下控制信息输入的限制如,
字符、多少等。如果密码与确认密码不同则返回相应的对话框,格式正确点击提
交,则转到相应的页面提示注册成功,部分代码如下:...........................................11
IF (TEXTBOX2.TEXT != TEXTBOX3.TEXT).......................................................................11
{ RESPONSE.REDIRECT("ZHUCEERROR.HTM");................................................................11
}........................................................................................................................................11
ELSE..................................................................................................................................11
{........................................................................................................................................12
1
INT A = 1;.........................................................................................................................12
OLEDBCONNECTION CN = NEW OLEDBCONNECTION();.................................................12
STRING CONSTR = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" +
SERVER.MAPPATH("APP_DATA\\BOOK.MDB");.................................................................12
CN.CONNECTIONSTRING = CONSTR;.................................................................................12
CN.OPEN();.......................................................................................................................12
OLEDBCOMMAND CMD = NEW OLEDBCOMMAND();......................................................12
CMD.CONNECTION = CN;..................................................................................................12
CMD.COMMANDTEXT = "INSERT INTO ADMIN VALUES ('"+TEXTBOX1 .TEXT +"','"+
TEXTBOX2 .TEXT+"','"+ A +"')";.......................................................................................12
OLEDBDATAREADER DR = CMD.EXECUTEREADER();.....................................................12
RESPONSE.REDIRECT("ZHUCESUSSIC.HTM");...................................................................12
DR.CLOSE();......................................................................................................................12
CN.CLOSE();......................................................................................................................12
4.2 用户登陆功能的实现................................................................................................12
当用户访问该网站时要先登录,输入用户名和密码,提交数据库,若在数据库中
存在此用户,则可以进入相应的页面,否则提示用户名或密码错误,并提示从新
输入。部分代码如下所示:..........................................................................................12
OLEDBCONNECTION CN = NEW OLEDBCONNECTION();..................................................12
STRING CONSTR = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="+
SERVER.MAPPATH("APP_DATA\\BOOK.MDB");.................................................................12
CN.CONNECTIONSTRING = CONSTR;.................................................................................12
CN.OPEN();.......................................................................................................................12
OLEDBCOMMAND CMD = NEW OLEDBCOMMAND();......................................................12
CMD.CONNECTION = CN;..................................................................................................12
CMD.COMMANDTEXT = "SELECT * FROM ADMIN";..........................................................12
OLEDBDATAREADER DR=CMD.EXECUTEREADER();.......................................................12
WHILE (DR.READ())..........................................................................................................12
{........................................................................................................................................13
IF (TEXTBOX1.TEXT == DR.GETSTRING(0) && TEXTBOX2.TEXT == DR.GETSTRING(1))
..........................................................................................................................................13
{........................................................................................................................................13
LONG N =LONG.PARSE (DR.GETVALUE(2).TOSTRING ())+1;...........................................13
STRING A = "" + N;...........................................................................................................13
OLEDBCOMMAND CM= NEW OLEDBCOMMAND();.........................................................13
CM.CONNECTION = CN;....................................................................................................13
CM.COMMANDTEXT = "UPDATE ADMIN SET SCORE ='" + A + "'WHERE( GUEST"+"='"
+ TEXTBOX1.TEXT +"')";..................................................................................................13
OLEDBDATAREADER DRD = CM.EXECUTEREADER();.....................................................13
..........................................................................................................................................13
LABEL5.TEXT = "欢迎" + TEXTBOX1.TEXT + "的到来,积分:"+A ;.........................13
SESSION["ZZ"] = TEXTBOX1.TEXT;.................................................................................13
DRD.CLOSE();...................................................................................................................13
2
}........................................................................................................................................13
..........................................................................................................................................13
}........................................................................................................................................13
DR.CLOSE();......................................................................................................................13
CN.CLOSE();......................................................................................................................13
RESPONSE.WRITE(SESSION["ZZ"]);..................................................................................13
4.3 作业提交功能的实现................................................................................................13
作业提交就是把自己的作业以文档的形式保存在本机上,然后通过网站的上传功
能,传到数据库,以保存用户的信息,提交时有浏览器按钮,点击后可选择提交
的内容,选定后点击提交,则传入数据库,由于上传功能是控件构成的,所以在
此不再赘述。..................................................................................................................13
4.4 留言功能的实现........................................................................................................13
留言就是学生对一些问题不明却而要提交一些问题(文本形式),留言主要有学
生名,学号,内容,首先要设置控件格式,即学生名,学号,内容这三个主要控
件内容不能为空,内容不能超过多少字,字体格式等一些信息的设置要符合要求,
如果不符合将会弹出对话框,来提示错误的信息或格式。然后就是提交数据库,
把填写的信息,插入数据库的留言表中,提交成功,则返回相应的页面。部分代
码如下所示:..................................................................................................................13
PROTECTED VOID IMAGEBUTTON1_CLICK(OBJECT SENDER, IMAGECLICKEVENTARGS E)
..........................................................................................................................................14
{........................................................................................................................................14
IF (TEXTBOX6.TEXT == "")..............................................................................................14
{........................................................................................................................................14
RESPONSE.WRITE("<SCRIPT>ALERT('称呼不能为空!')</SCRIPT>");............................14
}........................................................................................................................................14
ELSE IF (TEXTBOX7.TEXT == "").....................................................................................14
{........................................................................................................................................14
RESPONSE.WRITE("<SCRIPT>ALERT('请输入标题!')</SCRIPT>");................................14
}........................................................................................................................................14
ELSE IF (TEXTBOX8.TEXT == "").....................................................................................14
{........................................................................................................................................14
RESPONSE.WRITE("<SCRIPT>ALERT('内容不能为空!')</SCRIPT>");............................14
}........................................................................................................................................14
ELSE..................................................................................................................................14
{........................................................................................................................................14
SESSION["CH"] = TEXTBOX6.TEXT;................................................................................14
SESSION["HEAD"] = TEXTBOX7.TEXT;............................................................................14
CONN.OPEN();...................................................................................................................14
STRING SQL="INSERT INTO
VISITOR_BOOK(NAME,TEL,ADDR,EMAIL,QQ,CH,HEAD,CONTENT) VALUES('" +
TEXTBOX1.TEXT + "','" + TEXTBOX2.TEXT + "','" + TEXTBOX3.TEXT + "','" +
TEXTBOX4.TEXT + "','" + TEXTBOX5.TEXT + "','" + TEXTBOX6.TEXT + "','" +
TEXTBOX7.TEXT + "','" + TEXTBOX8.TEXT + "')";..........................................................14
3
SQLCOMMAND CMD = NEW SQLCOMMAND(SQL, CONN);................................................15
INT N = CMD.EXECUTENONQUERY();...............................................................................15
IF (N == 1)........................................................................................................................15
{........................................................................................................................................15
RESPONSE.WRITE("<SCRIPT>ALERT('感谢您的留言!')</SCRIPT>");............................15
4.5 下载功能的实现........................................................................................................15
下载就是指学生可以在网站上下载信息,此功能的实现使用 ASP.NET 的控件实现
的,现在后可以选择下载工具,或者以网页的形式保存为本地硬盘,功能代码详
见网站。..........................................................................................................................15
4.6 数据库的实现.............................................................................................................15
(1)LOGIN 表:.............................................................................................................15
图 4-1 LOGIN 表.................................................................................................................15
NAME 字段表示学生注册的用户名:............................................................................15
PASSWORD 字段表示学生用户的密码:........................................................................15
ID 字段表示表中的注册顺序,来区分不同的学生:..................................................15
(2)MASSAGE 表:........................................................................................................15
图 4-2 MASSAGE 表...........................................................................................................16
SNAME 字段表示留言人;..............................................................................................16
SNUMBER 字段表示学生的学号;..................................................................................16
TITLE 字段表示学生留言的标题;................................................................................16
ID 字段表示在表中所有学生的留言顺序,方便查询;.............................................16
(3)UP 表:...................................................................................................................16
图 4-3 UP 表......................................................................................................................16
SNAME 字段表示那位学生上传的信息;......................................................................16
SNUMBER 字段表示学生的学号;..................................................................................16
TITLE 字段表示上传内容的标题:................................................................................16
TENT 字段表示上传的信息:.........................................................................................16
ID 字段表示在表中所有学生上传的标识号以便查询。..............................................16
另外说明:ID 是各个表的主键......................................................................................16
4.7 部分的网页截图如下所示:.....................................................................................16
..........................................................................................................................................17
图 4-4 网站首页...............................................................................................................17
..........................................................................................................................................18
图 4-5 布告栏...................................................................................................................18
..........................................................................................................................................18
图 4-6 留言板...................................................................................................................18
..........................................................................................................................................19
图 4-7 下载界面...............................................................................................................19
致谢......................................................................................................................................19
参考文献..............................................................................................................................20
4
- 1
- 2
前往页