asp二手交易网课程设计报告Word格式.docx
《asp二手交易网课程设计报告Word格式.docx》由会员分享,可在线阅读,更多相关《asp二手交易网课程设计报告Word格式.docx(25页珍藏版)》请在冰点文库上搜索。
(1)应用VisualStudio设计、开发和发布网站;
(2)应用HTML相关知识制作网站页面;
(3)应用Table或者CSS对网页进行合理布局;
(4)应用ASP.NET内置对象完成相关逻辑处理;
(5)应用ASP.NET各种控件完成相关模块地重用;
(6)应用ADO.NET相关知识完成数据库地连接与处理
二、设计思路
本网站为用户提供一个二手商品交易地网络平台,为学生处理个人物品提供一个快捷地途径,操作简单.
本组设计网站具有以下特点:
简单性:
网站设计操作简单易懂,用户操作易上手,方便同学处理闲置物品.
实用性:
系统能完成商品展示管理等功能和管理员对信息地处理,有很好地实用性.
三、需求分析
非注册用户,浏览商品、注册会员
用户注册,商品浏览、添加商品、添加购物车、用户结账、发布留言、修改商品、删除商品等.
管理员添加商品、删除商品、修改商品、留言管理、用户管理、网址更新维护等.
四、功能模块
功能模块
主页
建立主页面
用户注册、登录模块
用户注册登录
用户注册
用户管理模块
查看修改用户信息
找回密码
商品管理模块
增加商品
修改商品信息
商品浏览和购物车模块
查看商品信息信息
添加物品到购物车
清空购物车
删除购物车
商品搜索和在线帮助模块
物品地模糊查找
在线服务帮助
订单管理模块
添加订单
处理订单
查看订单
用户结账
留言管理模块
留言、
查看留言、
回复留言、
查看回复信息
五、用例图
六、系统流程图
七、E-R图
用户登录
留言
留言编号
留言内容
留言日期
用户id
八、数据库和表设计
管理员表
商品表
购物车
用户表
九、调试程序
注册
登录
上传头像
修改密码
添加商品
后台管理
十、关键程序代码
登陆后台代码
usingSystem。
usingSystem.Collections.Generic。
usingSystem.Linq。
usingSystem.Web。
usingSystem.Web.UI。
usingSystem.Web.UI.WebControls。
usingSystem.Data.SqlClient。
usingSystem.Data。
publicpartialclassAdmin_images_login:
System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
if(Session["
UserLoginName"
]==null)
}
else
//stringUserLoginName=Session["
].ToString()。
Response.Redirect("
index.aspx?
UserLoginName="
+Session["
].ToString())。
protectedvoidButton1_Click(objectsender,EventArgse)
if(TextBox1.Text=="
"
)
Response.Write("
<
scriptlanguage='
javascript'
>
alert('
用户名不能为空!
'
)。
localtion='
login.aspx'
/script>
return。
if(TextBox2.Text=="
密码不能为空!
stringname=TextBox1.Text。
stringpassword=TextBox2.Text。
stringconstr="
server=.。
database=shopdb。
trusted_connection=true"
。
SqlConnectionconn=newSqlConnection(constr)。
conn.Open()。
SqlCommandcmd=newSqlCommand()。
cmd.CommandText="
selectcount(*)fromuserswhereUserName='
+name+"
andPassword='
+TextBox2.Text+"
cmd.Connection=conn。
//intcount=(int)cmd.ExecuteScalar()。
if(Convert.ToInt32(cmd.ExecuteScalar())>
0)
Session["
]=TextBox1.Text。
script>
登录成功'
)<
usersnews.aspx?
+TextBox1.Text)。
用户名或密码错误!
conn.Close()。
注册后台代码
publicpartialclassAdmin_images_addusers:
UserLoginName"
{
stringname=Session["
sname="
{
SqlConnectioncon=newSqlConnection(constr)。
SqlCommandcmd=newSqlCommand("
praddusers"
con)。
cmd.Connection=con。
cmd.CommandType=CommandType.StoredProcedure。
SqlParametersp1=newSqlParameter("
@username"
SqlDbType.VarChar,20)。
sp1.ParameterName="
sp1.Value=TextBox1.Text。
cmd.Parameters.Add(sp1)。
SqlParametersp2=newSqlParameter("
@password"
sp2.ParameterName="
sp2.Value=TextBox3.Text。
cmd.Parameters.Add(sp2)。
SqlParametersp3=newSqlParameter("
@realname"
sp3.ParameterName="
sp3.Value=TextBox4.Text。
cmd.Parameters.Add(sp3)。
SqlParametersp4=newSqlParameter("
@sex"
SqlDbType.Bit)。
sp4.ParameterName="
sp4.Value=(RadioButtonList1.SelectedItem.ToString()=="
男"
?
1:
0)。
cmd.Parameters.Add(sp4)。
SqlParametersp5=newSqlParameter("
@age"
SqlDbType.Int)。
sp5.ParameterName="
sp5.Value=TextBox5.Text。
cmd.Parameters.Add(sp5)。
SqlParametersp6=newSqlParameter("
@phonecode"
sp6.ParameterName="
sp6.Value=TextBox6.Text。
cmd.Parameters.Add(sp6)。
SqlParametersp7=newSqlParameter("
@Address"
SqlDbType.VarChar,50)。
sp7.ParameterName="
sp7.Value=TextBox7.Text。
cmd.Parameters.Add(sp7)。
SqlParametersp8=newSqlParameter("
@Postcode"
SqlDbType.Char,20)。
sp8.ParameterName="
sp8.Value=TextBox8.Text。
cmd.Parameters.Add(sp8)。
SqlParametersp9=newSqlParameter("
@Email"
sp9.ParameterName="
sp9.Value=TextBox9.Text。
cmd.Parameters.Add(sp9)。
SqlParametersp11=newSqlParameter("
@UserQue"
sp11.ParameterName="
sp11.Value=TextBox10.Text。
cmd.Parameters.Add(sp11)。
SqlParametersp12=newSqlParameter("
@@UserAns"
sp12.ParameterName="
@UserAns"
sp12.Value=TextBox11.Text。
cmd.Parameters.Add(sp12)。
SqlParametersp10=newSqlParameter("
@userid"
sp10.ParameterName="
@userid"
sp10.Direction=ParameterDirection.Output。
cmd.Parameters.Add(sp10)。
con.Open()。
cmd.ExecuteNonQuery()。
con.Close()。
intid=int.Parse(sp10.Value.ToString())。
if(id>
注册成功'
SuccReg.aspx"
注册失败!
protectedvoidbtnTest_Click(objectsender,EventArgse)
会员登录名不能为空!
addusers.aspx'
SqlConnectionsqlconn=newSqlConnection(constr)。
sqlconn.Open()。
stringsqlstr="
select*fromUserswhereUserName='
+this.TextBox1.Text+"
SqlCommandsqlcom=newSqlCommand(sqlstr,sqlconn)。
SqlDataReaderread=sqlcom.ExecuteReader()。
read.Read()。
if(read.HasRows)
if(this.TextBox1.Text.Trim()==read["
UserName"
].ToString().Trim())
该会员已经注册过'
adduser.aspx'
您可以进行正常注册'
read.Close()。
sqlconn.Close()。
protectedvoidButton2_Click(objectsender,EventArgse)
}
添加商品后台代码
usingSystem.Configuration。
usingSystem.Web.Security。
usingSystem.Web.UI.HtmlControls。
usingSystem.Web.UI.WebControls.WebParts。
usingSystem.Xml.Linq。
usingSystem.IO。
publicpartialclassEditGoods:
SqlOperatesqloperate=newSqlOperate()。
SqlConnectionsqlconn=newSqlConnection(ConfigurationManager.AppSettings["
ConnectionString"
])。
login.aspx"
}
stringstartprice=TextBox2.Text。
stringsaletprice=TextBox3.Text。
stringtypeid=TextBox4.Text。
stringwareshow=TextBox5.Text。
stringpictureName=fupPicturePath.FileName。
//获取文件名
stringlastName=pictureName.Substring(pictureName.LastIndexOf("
."
)+1)。
//获取文件后缀名
//判断上传文件地格式
if(lastName.ToLower()=="
bmp"
||lastName.ToLower()=="
jpg"
gif"
intlen=fupPicturePath.PostedFile.ContentLength。
//获取文件地大小
Byte[]pictureData=newByte[len]。
HttpPostedFilehtp=fupPicturePath.PostedFile。
Streamsrm=htp.InputStream。
srm.Read(pictureData,0,len)。
//读取到pictureData中
SqlCommandcom=newSqlCommand("
insertintogoods(modelname,startprice,saleprice,typeid,wareshow,picture)values('
'
+startprice+"
+saletprice+"
+typeid+"
+wareshow+"
@pictureData)"
conn)。
com.Parameters.Add("
@pictureData"
SqlDbType.Image)。
//指定类型
com.Parameters["
].Value=pictureData。
//设置参数值
com.ExecuteNonQuery()。
上传成功!
index.aspx'
//RegisterStartupScript("
false"
"
图片格式不正确!
!
十一、总结
通过这次课程设计地锻炼,本组成员受益很大,我们对有了更深层次地了解,更加熟悉和掌握C#语言,解决问题地能力得到了进一步提升,团队合作意识更加强烈.有了老师和同学地帮助,我们又学到了很多以前未接触到地知识与技巧,总之,此次实训让我们受益匪浅.
十二、参考书目
《ASP.NET开发实战1200例》(第Ⅱ卷)清华大学出版社
《ASP.NET开发实战宝典》,张跃廷主编,清华大学出版社,2010;
《ASP.NET3.5(C#)实践教程》,邵