资源描述
. . . . A 3.5(C#)实践教程课程设计报告题目:二手交易网 院 系:专 业:班 级:学 号:姓 名:指导老师: 2013年6月28日目录一、系统设计要求3二、设计思路3三、需求分析3四、功能模块3五、用例图4六、系统流程图5七、E-R图5八、数据库和表设计7九、调试程序8十、关键程序代码12十二、参考书目20十一、总结20一 系统设计要求(1)应用Visual Studio 设计、开发和发布; (2)应用HTML相关知识制作页面;(3)应用Table或者CSS对网页进行合理布局;(4)应用ASP.NET置对象完成相关逻辑处理;(5)应用ASP.NET各种控件完成相关模块的重用;(6)应用ADO.NET相关知识完成数据库的连接与处理二、设计思路本为用户提供一个二手商品交易的网络平台,为学生处理个人物品提供一个快捷的途径,操作简单。本组设计具有以下特点:简单性:设计操作简单易懂,用户操作易上手,方便同学处理闲置物品。实用性:系统能完成商品展示管理等功能和管理员对信息的处理,有很好的实用性。三、需求分析非注册用户,浏览商品、注册会员用户注册,商品浏览、添加商品、添加购物车、用户结账、发布留言、修改商品、删除商品等。管理员添加商品、删除商品、修改商品、留言管理、用户管理、网址更新维护等。四、功能模块功能模块主页建立主页面用户注册、登录模块用户注册登录用户注册用户管理模块查看修改用户信息找回密码商品管理模块增加商品修改商品信息商品浏览和购物车模块查看商品信息信息添加物品到购物车清空购物车删除购物车商品搜索和在线帮助模块物品的模糊查找在线服务帮助订单管理模块添加订单处理订单查看订单用户结账留言管理模块留言、查看留言、回复留言、查看回复信息五、用例图六、系统流程图七、E-R图真实XX用户密码性别用户邮箱 号码注册时间用户 登录名用户地址用户编号年龄真实XX管理员密码管理员登录名注册时间邮箱管理员编号管理员商品订单明细订单详细表号商品数量商品代号商品对应订单号备注商品总金额商品商品ID商品种类种类编码名称商品原价销售价格详细描述商品图片用户登录留言留言编号留言内容留言日期用户id八、数据库和表设计管理员表商品表购物车用户表九、调试程序注册登录上传头像修改密码添加商品主页留言后台管理找回密码十、关键程序代码登陆后台代码using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.SqlClient;using System.Data;publicpartialclassAdmin_images_login : System.Web.UI.Pageprotectedvoid Page_Load(object sender, EventArgs e) if (SessionUserLoginName = null) else /string UserLoginName = SessionUserLoginName.ToString(); Response.Redirect(index.aspx?UserLoginName= + SessionUserLoginName.ToString(); protectedvoid Button1_Click(object sender, EventArgs e) if (TextBox1.Text = ) Response.Write(alert(用户名不能为空!);localtion=login.aspx);return; else if (TextBox2.Text = ) Response.Write(alert(密码不能为空!);localtion=login.aspx);return; else string name = TextBox1.Text;string password = TextBox2.Text;string constr = server=.;database=shopdb;trusted_connection=true;SqlConnection conn = newSqlConnection(constr); conn.Open();SqlCommand cmd = newSqlCommand(); cmd mandText = select count(*) from users where UserName= + name + and Password= + TextBox2.Text + ; cmd.Connection = conn;/int count = (int)cmd.ExecuteScalar();if (Convert.ToInt32(cmd.ExecuteScalar() 0) SessionUserLoginName = TextBox1.Text; Response.Write(alert(登录成功); Response.Redirect(usersnews.aspx?UserLoginName= + TextBox1.Text); else Response.Write(alert(用户名或密码错误!);return; conn.Close(); 注册后台代码using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.SqlClient;using System.Data;publicpartialclassAdmin_images_addusers : System.Web.UI.Pageprotectedvoid Page_Load(object sender, EventArgs e) if (SessionUserLoginName = null) else string name = SessionUserLoginName .ToString(); Response.Redirect(index.aspx?sname= + SessionUserLoginName .ToString(); protectedvoid Button1_Click(object sender, EventArgs e) string constr = server=.;database=shopdb;trusted_connection=true;SqlConnection con = newSqlConnection(constr);SqlCommand cmd = newSqlCommand(praddusers, con); cmd.Connection = con; cmd mandText = praddusers; cmd mandType = CommandType.StoredProcedure;SqlParameter sp1 = newSqlParameter(username, SqlDbType.VarChar, 20); sp1.ParameterName = username; sp1.Value = TextBox1.Text; cmd.Parameters.Add(sp1);SqlParameter sp2 = newSqlParameter(password, SqlDbType.VarChar, 20); sp2.ParameterName = password; sp2.Value = TextBox3.Text; cmd.Parameters.Add(sp2);SqlParameter sp3 = newSqlParameter(realname, SqlDbType.VarChar, 20); sp3.ParameterName = realname; sp3.Value = TextBox4.Text; cmd.Parameters.Add(sp3);SqlParameter sp4 = newSqlParameter(sex, SqlDbType.Bit); sp4.ParameterName = sex; sp4.Value =(RadioButtonList1.SelectedItem.ToString()=男?1:0); cmd.Parameters.Add(sp4);SqlParameter sp5 = newSqlParameter(age, SqlDbType.Int); sp5.ParameterName = age; sp5.Value = TextBox5.Text; cmd.Parameters.Add(sp5);SqlParameter sp6 = newSqlParameter(phonecode , SqlDbType.VarChar, 20); sp6.ParameterName = phonecode ; sp6.Value = TextBox6.Text; cmd.Parameters.Add(sp6);SqlParameter sp7 = newSqlParameter(Address, SqlDbType.VarChar, 50); sp7.ParameterName = Address; sp7.Value = TextBox7.Text; cmd.Parameters.Add(sp7);SqlParameter sp8 = newSqlParameter(Postcode, SqlDbType.Char, 20); sp8.ParameterName = Postcode; sp8.Value = TextBox8.Text; cmd.Parameters.Add(sp8);SqlParameter sp9 = newSqlParameter(Email, SqlDbType.Char, 20); sp9.ParameterName = Email; sp9.Value = TextBox9.Text; cmd.Parameters.Add(sp9);SqlParameter sp11 = newSqlParameter(UserQue, SqlDbType.VarChar, 50); sp11.ParameterName = UserQue; sp11.Value = TextBox10.Text; cmd.Parameters.Add(sp11);SqlParameter sp12 = newSqlParameter(UserAns, SqlDbType.VarChar, 50); sp12.ParameterName = UserAns; sp12.Value = TextBox11.Text; cmd.Parameters.Add(sp12);SqlParameter sp10 = newSqlParameter( userid, SqlDbType.Int); sp10.ParameterName = userid; sp10.Direction = ParameterDirection.Output; cmd.Parameters.Add(sp10); con.Open(); cmd.ExecuteNonQuery(); con.Close(); int id = int.Parse(sp10.Value.ToString();if (id 0) Response.Write(alert(注册成功); SessionUserLoginName = TextBox1.Text; Response.Redirect(SuccReg.aspx); else Response.Write(alert(注册失败!); protectedvoid btnTest_Click(object sender, EventArgs e) if (TextBox1.Text = ) Response.Write(alert(会员登录名不能为空!);localtion=addusers.aspx); else string constr = server=.;database=shopdb;trusted_connection=true;SqlConnection sqlconn = newSqlConnection(constr); sqlconn.Open();string sqlstr = select * from Users where UserName= + this.TextBox1.Text + ;SqlCommand sqlcom = newSqlCommand(sqlstr, sqlconn);SqlDataReader read = sqlcom.ExecuteReader(); read.Read();if (read.HasRows) if (this.TextBox1.Text.Trim() = readUserName.ToString().Trim() Response.Write(alert(该会员已经注册过);localtion=adduser.aspx);return; else Response.Write(alert(您可以进行正常注册);localtion=adduser.aspx); read.Close(); sqlconn.Close(); protectedvoid Button2_Click(object sender, EventArgs e) 添加商品后台代码using System;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;using System.IO;publicpartialclassEditGoods : System.Web.UI.PageSqlOperate sqloperate = newSqlOperate();SqlConnection sqlconn = newSqlConnection(ConfigurationManager.AppSettingsConnectionString);protectedvoid Page_Load(object sender, EventArgs e) if (SessionUserLoginName = null) Response.Redirect(login.aspx); else protectedvoid Button1_Click(object sender, EventArgs e) string name = TextBox1.Text;string startprice = TextBox2.Text;string saletprice = TextBox3.Text;string typeid = TextBox4.Text;string wareshow = TextBox5.Text;string pictureName = fupPicturePath.FileName; /获取文件名string lastName = pictureName.Substring(pictureName.LastIndexOf(.) + 1); /获取文件后缀名string constr = server=.;database=shopdb;trusted_connection=true;SqlConnection conn = newSqlConnection(constr); conn.Open();/判断上传文件的格式if (lastName.ToLower() = bmp | lastName.ToLower() = jpg | lastName.ToLower() = gif) int len = fupPicturePath.PostedFile.ContentLength; /获取文件的大小Byte pictureData = newBytelen; PostedFile htp = fupPicturePath.PostedFile;Stream srm = htp.InputStream; srm.Read(pictureData, 0, len); /读取到pictureData中SqlCommand = newSqlCommand(insert into goods (modelname,startprice,saleprice,typeid,wareshow,picture) values( + name + , + startprice + , + saletprice + , + typeid + , + wareshow + ,pictureData), conn); .Parameters.Add(pictureData, SqlDbType.Image); /指定类型 .ParameterspictureData.Value = pictureData; /设置参数值 .ExecuteNonQuery(); conn.Close(); Response.Write(alert(上传成功!);localtion=index.aspx); else /RegisterStartupScript(false, alert(图片格式不正确!); Response.Write(alert(图片格式不正确!); 十一、总结通过这次课程设计的锻炼,本组成员受益很大,我们对有了更深层次的了解,更加熟悉和掌握C#语言,解决问题的能力得到了进一步提升,团队合作意识更加强烈。有了老师和同学的帮助,我们又学到了很多以前未接触到的知识与技巧,总之,此次实训让我们受益匪浅。十二、参考书目ASP.NET开发实战1200例(第卷)清华大学ASP.NET开发实战宝典,跃廷主编,清华大学,2010;ASP.NET 3.5(C#)实践教程,邵良衫主编,清华大学,200921 / 21
展开阅读全文