s
..\AddToCart.aspx.resx
..\AssemblyInfo.cs
..\ChangePwd.aspx
..\ChangePwd.aspx.cs
..\中英文摘要51.doc
..\任务书49.doc
..\参考文献38.doc
..\开题报告46.doc
..\电子购物商城系统.ppt
..\盘签48.doc
ASP_net010电子购物商城系统+论文(论文和程序)-论文部分内容 |
附录45-部分内容附录
部分代码如下:
1、首页的实现:
在这一模块中主要包括:页面头部控件、商品分类导航控件、热门商品列表控件以及新到商品控件。其控件的实现代码如下:
页面头部控件的代码实现(UserContro\HeaderMenu.ascx.cs):
privatevoidPage_Load(objectsender,System.EventArgse)
{ showButton();
}
voidshowButton()
{ //是否是匿名用户
if(Request.IsAuthenticated!=true)
{ //登录用户区域不可见
areaLoggedIn.Visible=false;
//匿名用户区域可见
areaLoggedOut.Visible=true;
}
else
{ areaLoggedIn.Visible=true;
areaLoggedOut.Visible=false;
}
}
商品分类导航控件的代码实现(UserControl\CategoryList.ascx.cs):
privatevoidPage_Load(objectsender,System.EventArgse)
{ stringselectionID=Request.Params["selection"];
if(selectionID!=null)
{ MyList.SelectedIndex=Int32.Parse(selectionID);
}
MyList.DataSource=BLL.Product.GetCategoryList();
MyList.DataBind();
}
热门商品列表控件的代码实现(UserControl\PopularProduct.ascx.cs):
privatevoidPage_Load(objectsender,System.EventArgse)
{ PopularList.DataSource=BLL.Product.GetPopularProduct();
PopularList.DataBind(); }
新到商品控件的代码实现(UserControl\NewProducts.ascx.cs):
privatevoidPage_Load(objectsender,System.EventArgse)
{ NewList.DataSource=BLL.Product.GetNewProductsList();
NewList.DataBind();
}
eshop首页控件的实现代码(default.aspx.cs):
publicclass_default:System.Web.UI.Page
{ privatevoidPage_Load(objectsender,System.EventArgse)
{ //在此处放置用户代码以初始化页面
}
}
2、商品信息模块的实现:
商品信息模块共包含如下的页面:分类显示商品、商品详细信息、商品搜索结果,其代码实现如下:
分类显示商品的代码实现:
Product类,方法GetProductsByCategory():
publicstaticSqlDataReaderGetProductsByCategory(intcategoryId,intpageSize,intpageIndex)
{ SqlParameter[]para={ newSqlParameter("@CategoryId",categoryId),
newSqlParameter("@pageSize",pageSize),
newSqlParameter("@pageIndex",pageIndex)
};
returnSQLHelper.ExecuteReader(SQLHelper.CONN_STRING,
CommandType.StoredProcedure,"GetProductByCategory",para);
}
(productlist.aspx.cs)代码如下:
privatestaticintPageSize=5;
privatevoidPage_Load(objectsender,System.EventArgse)
{ if(!Page.IsPostBack)
{ //显示第一页的记录
ShowResult(0,PageSize);
}
}
voidShowResult(intpageIndex,intpageSize)
{ //绑定Repeater控件
products.DataSource=BLL.Product.GetProductsByCategory(int.Parse(Request.QueryString["categoryId"]),pageSize,pageIndex);
products.DataBind();
//调用Product类中的方法获得该类商品的总数
intresultCount=BLL.Product.GetProductCountByCategory(int.Parse(Request.QueryString["categoryId"]));
intcount;
//如果查询结果总数是页大小的整数倍
if(resultCount%PageSize==0)
{ count=resultCount/PageSize;
PageCount.Text=count.ToString();
}
else
{ count=resultCount/PageSize+1;
PageCount.Text=count.ToString();
}
page.Items.Clear();
//绑定页码到DropDownList控件
for(i