




已阅读5页,还剩17页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
经济管理学院管科系 课程设计报告课程设计名称 : web技术课程设计 课程设计时间: 第19周上午4节和晚上4节 专 业 班 级 学生姓名 学 号 指导老师 课程设计报告格式1.课程设计目的 Web技术课程设计是信息管理与信息系统专业的一个重要的实践性环节,是Web开发技术课的理论实践,课程设计涉及到网页设计基础、数据库应用有关知识与技能,通过本课程设计目的是让学生掌握B/S体系结构开发的基本开发思想与开发步骤及方法,掌握设计、开发、调试Web应用系统,理解HTTP协议,掌握.NET环境下有关理论与特性,学会使用C#进行系统业务逻辑的编写,掌握使用 ADO.NET进行数据库开发,掌握ASP.NET 控件和创建自定义 ASP.NET 控件,了解分层架构的基本思想。2.课程设计题目描述和要求 使用.NET技术实现类似Microsoft Petshop 4.0 的宠物店网站。 要求:使用主题、母版、Web用户控件、自定义控件等特性,使用标准、数据、验证、登录等控件,实现宠物浏览,购物车,用户注册登录等功能,独立完成,正常运行,鼓励创新。3.课程设计报告内容3.1 实现的主要功能和使用的关键技术3.2 主要文件及有关功能说明3.3 核心代码及有关逻辑说明3.4 遇到的主要问题及解决思路3.5 系统特色4.课程设计总结附页参考书目:1 (美)Stephen Walther主编,ASP.NET 3.5揭秘(卷1),人民邮电出版社,北京,2009年2 (美)Stephen Walther主编,ASP.NET 3.5揭秘(卷2),人民邮电出版社,北京,2009年课程设计报告(附页)PetShop 是一个范例,微软用它来展示.Net企业系统开发的能力。然而PetShop随着版本的不断更新,至现在基 于.Net 2.0的PetShop4.0为止,整个设计逐渐变得成熟而优雅,却又很多可以借鉴之处。PetShop是一个小型的项目,系统架构与代码都比较简单,却也凸现了许多颇有价值的设计与开发理念。经过一个学期的课程设计,下面根据我自己做的petshop,对里面的内容进行分析。一、 实现的主要功能和使用的关键技术1) 数据库链接:两种方法:datasource手动连接。 Web.config 中链接,利用connectionstring连接到对应的数据库中。 2)注册页面:通过使用TextBox、DropDownList、Button等控件实现页面的布置,并提供注册信息的输入功能。MySqlConnection实现对数据库的链接,运用sql语句判断用户名注册与否。非已注册用户完成注册功能。3)登录,首先判断用户是否存在和密码是否正确,若存在,则更新数据库中用户最后登录时间、建立SessionUsername、跳转页面至首页;若不存在,则弹窗警告。4)菜单展示,使用DataList实现。首先通过SessionUsername判断用户是否登录。默认首次登录后菜单页显示第一页。在cs文件中初始化DataList1的各项属性,DataSource属性实现与数据库的product_info表的链接。在前台页运用DataBind绑定数据 至所需位置。最终实现菜单页面的显示。另外还可进行菜单类别的选择。 5) 购物车功能,DataList实现订单的显示,所使用技术类似菜单显示,最终按钮为确认按钮,确认菜谱确认。另外还可实现对订单的增删改操作。二、 主要文件及有关功能说明Default.aspx: 主页:利用repeatercontrol控件,控制宠物分类,是的每个宠物链接均能与product页面中的分类相链接。建立登录按钮,可以登录到数据库中,并且利用session 记住登录状态。Product.aspx页面:Datalist中绑定数据,分页处理,包括:上一页 下一页 首页 末页 跳转页。 Placeholder中将每个弹出页面反映到导航上;建立一个MasterPage.master:Product的页面、Item页面均利用此页面来构建。Newuser.aspx页面注册新用户。Newusersuccess页面注册新用户成功提示。SignIn页面:登陆页面,购物车页面运行之前必须登录。ShoppingCart页面购物车页面,用户将购物存进临时表。包括单价汇总。Checkout页面支付页面,从购物车跳入此页面,支付成功。三、 核心代码及有关逻辑说明Default.aspx页面中:Default.aspx.cs中: protected void LinkButton1_Click(object sender, EventArgs e) Response.Redirect(SignIn.aspx);表示点击登录按钮进入到登录页面。Product.aspx: asp:Image ID=Image1 runat=server ImageUrl= / a href=Items.aspx?productId= > > 上一页 下一页 首 页 末页 Product.aspx.cs中:int CurrentPage, Pagesize, RecordCount, PageCount; protected void Page_Load(object sender, EventArgs e) Pagesize = 4; Page.Title = Request.QueryStringCategoryId.ToLower(); if (!Page.IsPostBack) ListBind(); CurrentPage = 0; ViewStatecurrentPage = CurrentPage; RecordCount = newRecordCount(); PageCount = RecordCount / Pagesize; if (RecordCount % Pagesize 0) PageCount = PageCount + 1; ViewStatepageCount = PageCount; lbRecorderCount.Text = 总记录 + RecordCount.ToString(); lbpageandTotal.Text = (CurrentPage + 1) + / + PageCount.ToString(); lbTotalpage.Text = 共 + PageCount.ToString()+页; protected void ListBind() SqlConnection myconn = new SqlConnection(DB.CreateConnStr(); SqlDataAdapter myda = new SqlDataAdapter(select * from product where Categoryid= + Request.QueryStringCategoryId.ToString() + , myconn); DataSet myds = new DataSet(); int StartIndex = CurrentPage * Pagesize; myda.Fill(myds, StartIndex,Pagesize,product); DataList1.DataSource = myds.Tables0.DefaultView; DataList1.DataBind(); myconn.Close(); lbdown.Enabled = true; lbup.Enabled = true; if (CurrentPage = 0) lbup.Enabled = false; if (CurrentPage = PageCount - 1) lbdown.Enabled = false; private int newRecordCount() SqlConnection myconn = new SqlConnection(DB.CreateConnStr(); myconn.Open(); SqlCommand myCommand = new SqlCommand(select count(*) from product where Categoryid= + Request.QueryStringCategoryId.ToString() + ,myconn); return Int32.Parse(myCommand.ExecuteScalar().ToString(); myconn.Close() protected void Page_Click(object sender, CommandEventArgs e) CurrentPage = (int)ViewStatecurrentPage; PageCount = (int)ViewStatepageCount; string lbname = e.CommandName; switch (lbname) case up: if (CurrentPage 0) CurrentPage-; break; case down: if (CurrentPage PageCount - 1) CurrentPage+; break; case first: CurrentPage = 0; break; caselast: CurrentPage = PageCount - 1; break ViewStatecurrentPage = CurrentPage; ListBind(); lbpageandTotal.Text = (CurrentPage + 1) + / + PageCount.ToString(); protected void btgo_Click(object sender, EventArgs e) CurrentPage =Int32.Parse(TextBox2.Text.ToString()-1; PageCount = (int)ViewStatepageCount; if (CurrentPage PageCount - 1) CurrentPage = PageCount - 1; /ViewStatecurrentPage = CurrentPage; ListBind(); lbpageandTotal.Text = (CurrentPage + 1) + / + PageCount.ToString(); MasterPage.master中:源代码:protected void Page_Load(object sender, EventArgs e) HtmlAnchor lnkhome = new HtmlAnchor(); lnkhome.InnerText = 主页; lnkhome.HRef = default.aspx; PlaceHolder1.Controls.Add(lnkhome); Literal myLt = new Literal(); myLt.Text = ; PlaceHolder1.Controls.Add(myLt); if (Request.QueryStringCategoryId != null) HtmlAnchor lnkProsuct = new HtmlAnchor(); lnkProsuct.InnerText = Request.QueryStringCategoryId.ToString(); lnkProsuct.HRef = Products.aspx?page=0&CategoryId= + Request.QueryStringCategoryId.ToString(); PlaceHolder1.Controls.Add(lnkProsuct); Label1.Text = Page.Title.ToString(); Page.Title = string.Format(.net pet shop: 0,Page.Title.ToString();if (Request.QueryStringProductId != null) SqlConnection myconn = new SqlConnection(DB.CreateConnStr(); SqlCommand myCommand = new SqlCommand(select CategoryId from product where ProductId= + Request.QueryStringProductId.ToString() + , myconn);myconn.Open(); string CategoryId = myCommand.ExecuteScalar().ToString(); myconn.Close();HtmlAnchor lnkProsuct1 = new HtmlAnchor(); lnkProsuct1.InnerText = CategoryId; lnkProsuct1.HRef = Products.aspx?page=0&CategoryId= + CategoryId+; PlaceHolder1.Controls.Add(lnkProsuct1);Literal myll = new Literal(); myll.Text = ; PlaceHolder1.Controls.Add(myll);HtmlAnchor lnkItem = new HtmlAnchor(); SqlConnection myconn1 = new SqlConnection(DB.CreateConnStr(); SqlCommand myCommand1 = new SqlCommand(select name from product where ProductId= + Request.QueryStringProductId.ToString() + , myconn);myconn.Open(); string name = myCommand1.ExecuteScalar().ToString(); myconn.Close(); lnkItem.InnerText = name; lnkItem.HRef = Items.aspx?productId=&categoryId= + name+; PlaceHolder1.Controls.Add(lnkItem); protected void LinkButton1_Click(object sender, EventArgs e) Response.Redirect(SignIn.aspx); protected void LinkButton2_Click(object sender, EventArgs e)Response.Redirect(ShoppingCart.aspx);Items页面中:Item.aspx.cs中代码: private string ItemId; private string CategoryId; private string productName; string _ItemId, _ItemName, pId,Qty; int m; float Unitprice; int CurrentPage, Pagesize, RecordCount, PageCount; protected void Page_Load(object sender, EventArgs e) SqlConnection myconn = new SqlConnection(DB.CreateConnStr(); SqlCommand myCommand = new SqlCommand(select name from product where ProductId= + Request.QueryStringProductId.ToString() + , myconn);myconn.Open(); string name = myCommand.ExecuteScalar().ToString(); myconn.Close(); Page.Title = name; Pagesize = 4; /Page.Title = Request.QueryStringItemId.ToLower(); if (!Page.IsPostBack) ListBind(); CurrentPage = 0; ViewStatecurrentPage = CurrentPage; PageCount = RecordCount / Pagesize; if (RecordCount % Pagesize 0) PageCount = PageCount + 1; ViewStatepageCount = PageCount; protected void ListBind() SqlConnection myconn = new SqlConnection(DB.CreateConnStr(); SqlDataAdapter myda = new SqlDataAdapter(select b.* ,c.* from Product a join Item b on a.ProductId =b.ProductId join Inventory c on b.ItemId =c.ItemId where a.ProductId= + Request.QueryStringProductId.ToString() + , myconn); DataSet myds = new DataSet(); int StartIndex = CurrentPage * Pagesize; myda.Fill(myds, StartIndex, Pagesize, select b.* ,c.* from Product a join Item b on a.ProductId =b.ProductId join Inventory c on b.ItemId =c.ItemId ); DataList1.DataSource = myds.Tables0.DefaultView; DataList1.DataBind(); myconn.Close(); private int newRecordCount() SqlConnection myconn = new SqlConnection(DB.CreateConnStr(); myconn.Open(); SqlCommand myCommand = new SqlCommand(select count(*) from Item where ProductId= + Request.QueryStringProductId.ToString() + , myconn); return Int32.Parse(myCommand.ExecuteScalar().ToString(); myconn.Close(); protected void Page_Click(object sender, CommandEventArgs e) string lbname = e.CommandName; switch (lbname) case back: SqlConnection myconn = new SqlConnection(DB.CreateConnStr(); SqlCommand myCommand = new SqlCommand(select Categoryid from product where ProductId= + Request.QueryStringProductId.ToString() + , myconn); myconn.Open(); string Categoryid= myCommand.ExecuteScalar().ToString(); myconn.Close(); Response.Redirect(Products.aspx?page=0&CategoryId= + Categoryid + ); break; ListBind();protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) if (Sessionusername != null) if (e.CommandName.ToString() != addCart) string ConnSql = System.Configuration.ConfigurationManager.ConnectionStringsmyConn.ConnectionString; SqlConnection myConn = new SqlConnection(ConnSql); string SelectSql = select * from Item where itemid= + e.CommandName.ToString() + ; SqlDataAdapter da = new SqlDataAdapter(SelectSql, myConn); DataSet ds = new DataSet(); da.Fill(ds, Item); DataTable mydt = new DataTable(); if (SessionCart = null) mydt.Columns.Add(Qty, typeof(Int32); mydt.Columns.Add(ItemPrice, typeof(float); mydt.Columns.Add(pId, typeof(string); mydt.Columns.Add(ItemId, typeof(string); mydt.Columns.Add(ItemName, typeof(string); SessionCart = mydt; /DataList1.DataSource = ds.Tables0.DefaultView; /DataList1.DataBind(); /Response.Write(ds.Tables0.Rows.Count); _ItemName = ds.Tables0.Rows0Name.ToString(); Unitprice = float.Parse(ds.Tables0.Rows0ListPrice.ToString(); pId = ds.Tables0.Rows0ProductId.ToString(); myConn.Close();DataTable dt = (DataTable)SessionCart; for (int i = 0; i dt.Rows.Count; i+) if (_ItemId = dt.RowsiItemId.ToString() m = 1; dt.RowsiQty = int.Parse(dt.RowsiQty.ToString() + 1; break; if (m = 1) SessionCart = dt; Response.Redirect(ShoppingCart.aspx); if (m != 1) mydt = (DataTable)SessionCart; DataRow mydr = mydt.NewRow(); mydrItemId = _ItemId; mydrItemName = _ItemName; mydrQty = 1; mydrItemPrice = Unitprice; mydrpId = pId; mydt.Rows.Add(mydr); SessionCart = mydt; Response.Redirect(ShoppingCart.aspx); SessionItemId = _ItemId; Response.Redirect(ShoppingCart.aspx); /Response.Write(e.CommandArgument.ToString(); else Response.Redirect(SignIn.aspx); Newuser.aspx:注册新用户:Newuser.aspx.cs:代码:protected void Page_Load(object sender, EventArgs e) Page.Title = 注册; protected void Button1_Click(object sender, EventArgs e) string username = TextBox2.Text; string pwd = TextBox3.Text; string pwdconfirm = TextBox4.Text; string telephone = TextBox5.Text;SqlDataSource1.InsertParametersusername.DefaultValue = username; SqlDataSource1.InsertParameterspwd.DefaultValue = pwd; SqlDataSource1.InsertParameterspwdconfirm.DefaultValue = pwdconfirm;SqlDataSource1.InsertParameterstelephone.DefaultValue = telephone;SqlDataSource1.Insert();Response.Redirect(newusersuccess.aspx);注册成功后:跳转到newusersuccess.aspx页面恭喜您,注册成功,请继续购买吧首页 请登录.登陆页面:SignIn.aspx页面:Sign.aspx.cs页面中: protected void Page_Load(object sender, EventArgs e) Page.Title = 登录; protected
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 党校试讲题库及答案
- 期末冲刺考试题(押题卷)
- 2025年新能源汽车自动驾驶技术发展与车险产品市场潜力研究报告
- 2025年新能源汽车电池供应链绿色化发展报告
- 2025年智能电网行业市场前瞻:智能电网在电力系统安全防护中的应用报告
- 2025年泰州音乐美术试卷及答案
- 宠物食品OEM市场细分需求与OEM产品创新研究报告
- 2025年新能源企业危机公关处理策略与案例解析报告
- 潞河招生考试题目及答案
- 贵州公共基础试题及答案
- 2025年《3~6岁儿童学习与发展指南》试题(+答案)
- 2025年秋招:中国银行笔试题库及答案
- 2025大连国际机场招聘25人笔试历年参考题库附带答案详解
- 微生物-昆虫互作机制-洞察及研究
- 2025年浙江铁塔招聘笔试备考题库(带答案详解)
- 苯二氮卓药讲课件
- 班主任班级卫生管理培训
- 施工班组驻地管理制度
- 城投公司成本控制管理制度
- 万亨工业科技(台州)股份有限公司年产500万套逆变器及配件、800万套新能源汽车控制器配件技改项目环评报告
- 防止触电事故的安全技术措施
评论
0/150
提交评论