




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
电子商务网站建设实验说明根据大纲要求,结合三个实验项目,完成一个综合性的网站实例。项目一:电子商务网站页面规划与设计完成电子商务网站的规划,准备网站建设中需要的各种图片。设计网站的整体风格,考虑颜色的搭配,利用Dreamweaver或者其他工具完成页面的布局。规划各功能模块的内容。完成页头页尾的设计。如下图(可以自己灵活设计,合理布局)(注意:上图首页主要由几个用户控件构成)项目二:电子商务网站基本功能设计需要用到的数据库表结构如下:图书表:book新闻表:存储历史访问人数表:fangwen利用ASP.NET的各种基本控件,以及内建对象。结合数据库,实现电子商务网站的基本功能。1、设计实现统计网站的在线人数和历史访问人数的功能。在Global.asax中加入代码:如下,在Global.asax中加入代码:引如命名空间 void Application_Start(object sender, EventArgs e) / 在应用程序启动时运行的代码 string str = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Server.MapPath(App_Data) + abc.mdb; OleDbConnection con = new OleDbConnection(str); con.Open(); OleDbCommand cmd = new OleDbCommand(select * from fangwen, con); int count = Convert.ToInt32(cmd.ExecuteScalar(); con.Close(); Applicationtotal = count; Applicationonline = 0; void Application_End(object sender, EventArgs e) / 在应用程序关闭时运行的代码 string temp = Applicationtotal.ToString(); string str = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Server.MapPath(App_Data) + abc.mdb; OleDbConnection con = new OleDbConnection(str); con.Open(); OleDbCommand cmd = new OleDbCommand(update student set nl= + temp, con); cmd.ExecuteNonQuery(); con.Close(); void Session_Start(object sender, EventArgs e) / 在新会话启动时运行的代码 Session.Timeout = 1; Application.Lock(); Applicationtotal = (int)Applicationtotal + 1; Applicationonline = (int)Applicationonline + 1; Application.UnLock(); void Session_End(object sender, EventArgs e) / 在会话结束时运行的代码。 Application.Lock(); Applicationonline = (int)Applicationonline - 1; Application.UnLock(); 2实现网站的简单购物车功能。首先做一个图书用户控件,然后在主页中进行动态的添加,用户控件book.ascx如图:代码如下:public partial class book : System.Web.UI.UserControl public string bookidstr; protected void Page_Load(object sender, EventArgs e) string str = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Server.MapPath(App_Data) + abc.mdb; OleDbConnection con = new OleDbConnection(str); con.Open(); OleDbCommand cmd = new OleDbCommand(select * from book where bookid= + bookidstr, con); OleDbDataReader sdr = cmd.ExecuteReader(); sdr.Read(); this.Image1.ImageUrl = images/ + sdr.GetString(4); this.Label1.Text = sdr.GetString(1); this.Label2.Text = sdr.GetString(2); this.Label3.Text = sdr.GetInt32(3).ToString(); this.HyperLink1.NavigateUrl = bookdetail.aspx?id= + bookidstr; protected void LinkButton1_Click(object sender, EventArgs e) string bookid =bookidstr; if (Sessionbus = null) Hashtable ht = new Hashtable(); ht.Add(bookid, 1); Sessionbus = ht; else Hashtable ht = (Hashtable)Sessionbus; if (htbookid = null) ht.Add(bookid, 1); else htbookid = (int)htbookid + 1; Sessionbus = ht; 在主页中动态添加控件代码如下:private int rownum = 2; protected void Page_Load(object sender, EventArgs e) string str = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Server.MapPath(App_Data) + abc.mdb; OleDbConnection con = new OleDbConnection(str); con.Open(); OleDbCommand cmd = new OleDbCommand(select top 7 bookid from book order by price desc, con); int i = 0; OleDbDataReader sdr = cmd.ExecuteReader(); TableRow tr = new TableRow(); while (sdr.Read() i = i + 1; TableCell tc = new TableCell(); book h = (book)this.LoadControl(book.ascx); h.bookidstr = sdr.GetInt32(0).ToString(); tc.Controls.Add(h); tr.Controls.Add(tc); if (i % this.rownum = 0) this.Table2.Rows.Add(tr); tr = new TableRow(); if (i % this.rownum != 0) this.Table2.Rows.Add(tr); sdr.Close(); con.Close(); 3实现新闻公告发布,留言等功能新闻公告控件如图,gridview控件中添加一个模板列和一个超级链接列,进行相关设置后,加入代码: protected void Page_Load(object sender, EventArgs e) string str = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Server.MapPath(App_Data) + abc.mdb; OleDbConnection con = new OleDbConnection(str); con.Open(); OleDbCommand cmd = new OleDbCommand(select top 5 * from news order by newsid desc, con); this.GridView1.DataSource = cmd.ExecuteReader(); GridView1.DataBind(); /查询公告的详细信息页面略4、加入一个广告控件,根据概率显示不同的出版社信息,如图相关的XML文件的代码如下:pic/ad1.jpg清华大学出版社110pic/ad2.jpg北京大学出版社210pic/ad3.jpg电子工业出版社3105、查看购物车功能页面代码如下: protected void Page_Load(object sender, EventArgs e) if (Sessionbus != null) Hashtable ht = (Hashtable)Sessionbus; IDictionaryEnumerator en = ht.GetEnumerator(); while (en.MoveNext() string temp = en.Key.ToString(); string str = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Server.MapPath(App_Data) + abc.mdb; OleDbConnection con = new OleDbConnection(str); con.Open(); OleDbCommand cmd = new OleDbCommand(select bookname from book where bookid=+temp, con); string bname=Convert.ToString(cmd.Execu
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年事业单位工勤技能-湖南-湖南护理员三级(高级工)历年参考题库含答案解析
- 2025年事业单位工勤技能-湖南-湖南家禽饲养员四级(中级工)历年参考题库含答案解析
- 2025年事业单位工勤技能-湖北-湖北房管员一级(高级技师)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-湖北-湖北土建施工人员一级(高级技师)历年参考题库含答案解析
- 2025年事业单位工勤技能-湖北-湖北农机驾驶维修工三级(高级工)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-海南-海南中式面点师二级(技师)历年参考题库含答案解析
- 2025年事业单位工勤技能-浙江-浙江热力运行工四级(中级工)历年参考题库含答案解析(5套)
- 2025年事业单位工勤技能-河南-河南水工监测工四级(中级工)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-江西-江西房管员一级(高级技师)历年参考题库含答案解析(5套)
- 2025年事业单位工勤技能-广西-广西计算机文字录入处理员四级(中级工)历年参考题库含答案解析
- 火灾应急预案组织架构图
- 山东省济宁市第十五中学2023-2024学年(五四学制)六年级上学期第一次月考语文试题
- 北京马拉松赛事运作及战略定位研究
- 高中思想政治-人教版新教材必修1第四课第一框:中国特色社会主义进入新时代教学设计学情分析教材分析课后反思
- DB6105T 180-2022 大豆种子田间检验技术规程
- 惠州卫生职业技术学院辅导员考试题库
- 试用期转正审批表及考核表实用文档
- 2023年爱粮节粮知识竞赛试题
- 印尼劳动法中文版
- 内科大查房课件综合医院抑郁诊疗-包头
- GB/T 9573-2013橡胶和塑料软管及软管组合件软管尺寸和软管组合件长度测量方法
评论
0/150
提交评论