留言板设计项目报告4.docx

上传人:b****8 文档编号:9551671 上传时间:2023-02-05 格式:DOCX 页数:14 大小:75.17KB
下载 相关 举报
留言板设计项目报告4.docx_第1页
第1页 / 共14页
留言板设计项目报告4.docx_第2页
第2页 / 共14页
留言板设计项目报告4.docx_第3页
第3页 / 共14页
留言板设计项目报告4.docx_第4页
第4页 / 共14页
留言板设计项目报告4.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

留言板设计项目报告4.docx

《留言板设计项目报告4.docx》由会员分享,可在线阅读,更多相关《留言板设计项目报告4.docx(14页珍藏版)》请在冰豆网上搜索。

留言板设计项目报告4.docx

留言板设计项目报告4

分 类 号:

密  级:

   学  号:

33

留言板设计

 

摘要

本项目将介绍怎样才能轻松的制作网络留言板的方法,步骤,及其代码,为想要建立有续的投票模块的朋友提供参考借鉴,这里就将详细的介绍网络留言板的创建,通过系统的操作,可以提高我们对程序编码的了解,同时还可以对代码编程的原理、结构、运用方法的详细知识更进一步了解……

目录

摘要1

目录3

一设计分析4

1、环境简介4

2、需求分析4

3、功能分析4

二数据结构设计5

三程序及界面设计5

1、公共文件header和footer5

2、发表留言界面设计5

3、显示留言界面设计7

4、管理员登录页面设计10

5、回复留言页面设计11

总结12

谢辞14

参考文献14

一设计分析

1、环境简介

随着网络的逐步普及,以及网络技术的不断发展,人们通过网络进行交流的方式变得多样化。

网络留言板便是其中之一。

现在很多人都在开博客,这里面也有留言板,现在网络上很流行网上留言。

网络留言板为用户提供发表留言、发表评论的便捷功能,,已成为普通企业网站、新闻网站等类型网站的重要组成部分。

网络留言板的主要功能包括:

普通用户发表留言功能、普通(管理员)用户浏览留言功能(分页显示)、管理员登录后台功能、管理员删除留言功能。

+

2、需求分析

1)系统运行环境

硬件环境:

处理器:

Inter系列

内存:

512M

硬盘空间:

1GB

软件环境:

操作系统:

WindoinsXP

开发软件:

VisualStudio2008,SQLServer2005

2)功能需求

需要实现以下一些基本功能:

1.留言:

要实现用户登录后,可以添加留言。

2.查看:

要实现用户登录后,可以查看所有留言。

3.删除:

要实现用户登录后,可以删除自己的留言。

3、功能分析

1)通过系统各个方面的研究,系统功能如图分析:

二数据结构设计

1)admin表

列名

数据类型

长度

允许空

ID

int

4

adminName

varchar

20

adminPwd

varchar

20

2)留言数据表liuyan

列名

数据类型

长度

允许空

ID

Int

4

userName

varchar

20

sex

varchar

10

content

varchar

3000

reply

varchar

3000

postTime

datetime

8

imageUrl

varchar

20

faceUrl

varchar

20

三程序及界面设计

1、公共文件header和footer

在解决方案中右击,添加一个名为Control的文件夹。

右击建一个header.ascx的用户自定义控件。

并在该文件中插入一个图片,作为所有网页的头部信息。

同样在Control中添加一个footer.ascx用户自定义控件。

并在该文件中输入“您现在的身份是”,以及“你的IP是:

”,然后在拖入两个Label控件,用于显示用户的身份信息及用户的IP地址。

如图:

 

Web.config

2、发表留言界面设计

发表留言功能是留言板中重要的功能模块之一,发表留言的功能是将用户提交的“用户名”,“性别”,“头像”,“留言内容”等信息写入到数据库中。

在解决方案中右击选择“添加新项”输入“add.aspx”的文件,做好表个布局输入“发表新留言”,“用户名”,“性别”,“头像”,“留言内容”,然后在拖入一个文本框TextBox控件,最后拖入两个按钮(提交、清空),设计如图所示:

 

控件属性如表所示:

控件

属性

属性值

说明

TextBox

Name

txtUserName

用户名

RadioButton

Name

rbtnNan

性别男

RadioButton

Name

rbtnNv

性别女

DropDownList

Name

ddlPic

头像下拉菜单

AutoPostBack

True

自动回滚

TextBox

Name

txtContent

内容文本框

发表留言界面“提交”按钮的单击事件

stringimageUrl;

protectedvoidPage_Load(objectsender,EventArgse)

{if(!

IsPostBack)

{for(inti=1;i<=10;i++)

{this.ddlPic.Items.Add("pic"+i.ToString()+".gif");}

this.Image1.ImageUrl="images/face/"+ddlPic.SelectedValue;}}

protectedvoidButton1_Click(objectsender,EventArgse)

{stringsex;

//stringpostTime;//时间为数据库更新时自动根据系统时间设置

//stringimageUrl;

stringuserName=this.txtUserName.Text;

stringcontent=this.txtContent.Text;

stringimageUrl=ddlPic.SelectedValue;

if(this.rbtnNv.Checked==true)

{sex="女";}

else

{sex="男";}

SqlConnectionconn=DB.createCon();

SqlCommandcmd=newSqlCommand();

cmd.Connection=conn;

cmd.CommandText="insertintoguest(userName,sex,content,imageUrl,faceUrl)values('"+userName+"','"+sex+"','"+content+"','"+imageUrl+"','"+imageUrl+"')";

if(cmd.ExecuteNonQuery()>0)

{Response.Write("");}

else

{Response.Write("");

}}

“清空”按钮的单击事件

protectedvoidButton2_Click(objectsender,EventArgse)

{

this.txtUserName.Text="";

this.txtContent.Text="";

}}

下拉菜单ddlPic_SelectedIndexChanged事件

protectedvoidddlPic_SelectedIndexChanged(objectsender,EventArgse)

{

this.Image1.ImageUrl="images/face/"+ddlPic.SelectedValue;

}

3、显示留言界面设计

显示留言页面是将用户的留言信息显示出来,并做分页显示。

显示的信息包括:

用户名、用户头像、留言发表时间、留言内容以及有没有管理员回复。

显示留言界面使用Default.aspx页面。

首先设置合理的表格布局,在拖入header.aspx作为该页面头部。

接下来拖入一个DataList控件,用于分页显示留言信息并编辑该控件的ItemTemplate模板,以及再改模板中添加表格布局显示留言信息的各个字段。

显示留言界面代码:

stringcurPage;

protectedvoidPage_Load(objectsender,EventArgse)

{if(!

IsPostBack)

{this.lblPageCur.Text="1";//不能放到dataGridBind()后面,不然lblPageCur.Text没有被初始化,出错

dataGridBind();

}}

dataGridBind方法

publicvoiddataGridBind()

{curPage=this.lblPageCur.Text;

SqlConnectionconn=DB.createCon();

SqlCommandcmd=newSqlCommand();

cmd.CommandText="select*fromguestorderbypostTimedesc";

cmd.Connection=conn;

SqlDataAdaptersda=newSqlDataAdapter();

sda.SelectCommand=cmd;

DataSetds=newDataSet();

sda.Fill(ds,"guest");

PagedDataSourcepds=newPagedDataSource();

pds.AllowPaging=true;

pds.PageSize=3;

pds.DataSource=ds.Tables["guest"].DefaultView;

pds.CurrentPageIndex=Convert.ToInt32(curPage)-1;

this.lblPageTotal.Text=pds.PageCount.ToString();

this.Button1.Enabled=true;

this.Button2.Enabled=true;

if(curPage=="1")

{this.Button1.Enabled=false;}

if(curPage==pds.PageCount.ToString())

{this.Button2.Enabled=false;}

this.DataList1.DataSource=pds;

this.DataList1.DataBind();

cmd.CommandText="selectcount(*)fromguest";

this.lblMesTotal.Text=Convert.ToString(cmd.ExecuteScalar());

inta=pds.PageCount;

for(inti=1;i<=a;i++)

{this.DropDownList1.Items.Add(i.ToString());}

}

DataList_ItemDataBound事件

protectedvoidDataList1_ItemDataBound(objectsender,DataListItemEventArgse)

{LinkButtondele=(LinkButton)(e.Item.FindControl("lbtnDelete"));

if(dele!

=null)

{dele.Attributes.Add("onclick","returnconfirm('确定删除吗?

')");}

}

“删除”功能

protectedvoidlbtnDelete_Command(objectsender,CommandEventArgse)

{if(Session["admin"]!

=null)

{//stringuserID=Request.QueryString["userID"];//不好传送,试了N遍

stringuserID=e.CommandArgument.ToString();

SqlCommandcmd=newSqlCommand();

cmd.Connection=DB.createCon();

cmd.CommandText="deletefromguestwhereID='"+userID+"'";

if(cmd.ExecuteNonQuery()>0)

{Response.Write("");}

else

{Response.Write("");}

}

else

{Response.Write("");}}

“回复”功能

protectedvoidlbtnReply_Command(objectsender,CommandEventArgse)

{if(Session["admin"]!

=null)

{//stringuserID=Request.QueryString["userID"];

stringuserID=e.CommandArgument.ToString();

Response.Redirect("reply.aspx?

userID="+userID+"");

}

else

{Response.Write("");}

}

protectedvoidButton1_Click(objectsender,EventArgse)

{this.lblPageCur.Text=Convert.ToString(Convert.ToInt32(this.lblPageCur.Text)-1);

dataGridBind();

}

protectedvoidButton2_Click(objectsender,EventArgse)

{this.lblPageCur.Text=Convert.ToString(Convert.ToInt32(this.lblPageCur.Text)+1);

dataGridBind();

}

protectedvoidButton3_Click(objectsender,EventArgse)

{this.lblPageCur.Text="1";

dataGridBind();

}

protectedvoidButton4_Click(objectsender,EventArgse)

{this.lblPageCur.Text=this.lblPageTotal.Text;

dataGridBind();

}

protectedvoidButton5_Click(objectsender,EventArgse)

{if(!

IsPostBack)

{this.lblPageCur.Text=this.DropDownList1.SelectedValue;

dataGridBind();

}}}

4、管理员登录页面设计

当用户单击“回复”按钮或者删除文件时,会有提示登录的界面,系统限制只有管理员才能回复和删除留言。

当点击“确定”按钮之后,会进入管理员登录界面。

在解决方案中右击选择“添加新项”输入“Login.aspx”的文件,做好表个布局拖入用户自定义控件header.ascx作为该页面的头部信息,并拖入用户自定义控件footer.ascx作为该页面的尾部。

在中间拖入两个文本框作为用户名与密码的输入框,在放两个按钮作为“登录”和“重置”按钮。

如图所示:

 

“登录”按钮的单击事件

protectedvoidButton1_Click(objectsender,EventArgse)

{SqlConnectionconn=DB.createCon();

SqlCommandcmd=newSqlCommand();

cmd.CommandText="selectcount(*)fromadminwhereadminName='"+this.txtUserName.Text+"'andadminPwd='"+this.txtPwd.Text+"'";

cmd.Connection=conn;

if(Convert.ToInt32(cmd.ExecuteScalar())>0)

{Session["admin"]="admin";

Response.Write("");

}

else

{Response.Write("");

}}}

5、回复留言页面设计

在管理员登录之后,重新回到留言显示页面Default.aspx,此时单击“删除”按钮可以对留言内容进行删除。

单击“回复”按钮可以回复对应的留言。

在解决方案中右击选择“添加新项”输入“Replay.aspx”的文件,做好表个布局拖入用户自定义控件header.ascx作为该页面的头部信息,并拖入用户自定义控件footer.ascx作为该页面的尾部。

在中间拖入一个TextBox多行文本控件,作为输入回复用。

最后拖入两个按钮,作为“提交”和“清空”按钮。

效果如图:

 

“提交”按钮事件

protectedvoidButton1_Click(objectsender,EventArgse)

{stringreply=this.txtReply.Text;

stringuserID=Request.QueryString["userID"].ToString();

SqlCommandcmd=newSqlCommand();

cmd.Connection=DB.createCon();

cmd.CommandText="updateguestsetreply='"+reply+"'whereID='"+userID+"'";

if(Convert.ToInt32(cmd.ExecuteNonQuery())>0)

{Response.Write("");}

else

{Response.Write("");}}

“重置”按钮的事件

protectedvoidButton2_Click(objectsender,EventArgse)

{

this.txtReply.Text="";

}

 

总结

网站设计充满无穷魅力,网站设计会运用到计算机领域的各种技术,学习做网站,也是一种乐趣,网站不可能一次就能做的非常完美,需要不停的去修改,调试。

网站在将来的计算机领域中的作用依然非常重要。

同时,只有不停的去学习最新的网络技术,才能作出更好的网站。

由于本人学识有限,论文还有许多纰漏之处,望大家多提宝贵意见,同时也感谢学校及老师对我们的正确教导。

使我们毕业后都能找到理想的工作。

 

 

参考文献

  1.《asp、net》清华大学出版社2004年第1版作者:

郑伟

 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1