J I A N G S U U N I V E R S I T
购物网站设计报告
班 级:
学生姓名:
学 号:
完成时间:20141118
购物网站设计报告
一:设计要求
1.购物车包含注册页面、登录页面、购物页面、购物车四个页 面。
2.在购物页面中,将页面信息与数据库绑定,直接将数据库中 的内容显示到网页上。另外,对“名称”设计超链接,点击进入 商品的详细信息介绍页面。
3.网站美观大方
2.实现效果
1•登录页面
用户名,    zhangxinji
額玉    TFT
登录 注册
2.注册页面
用户名 密码 电话 邮箱
submit
返回登录页面
3.购物页面
CartLD
yuuiber
5ame
| Price |
um]
编辑删
ihangxtnjt
2
Apple XID 711CH-
B
5650
]
编辑删
zhangxnyi
3
戴尔 Ins5CR-
|    152SB
3(599
1
编辑刪
zhangxtiij'i
4
Lenovo Y4l Op
4999
1
维续购物    结算商品
4.购物车
   
CartlD
Number|
Price
Num
编辑删
ziiangxiriji
2
Apple MD711CH- B
个人网站的制作实验报告
5650
1
请删
zhatizxtnj'i
3
輸尔 InsSCR-
(    152EB
3699
]
编辑刪
zhansjcinji
4
Lenovo- Y410p
4999
1
3.主要代码
1•登录页面与数据库连接
protected void Butt on 2_Click(    object sen der.    Eve ntArgs e)
{
stri ng connstr = @"Data Source=XIAOZHENZHEN-PC;l nitial Catalog=logi n;ln tegrated Security=True";
StringBuilder sb = new StringBuilder ();
sb.Appe nd(    "select cou nt (”    );
sb.Append(    "'");
sb.Appe nd( TextBox1.Text);
sb.Appe nd( "') from useri nfo where password="    );
sb.Appe nd( TextBox2.Text);
using ( SqlConnection conn = new SqlConnection (connstr))
{
SqlComma notmd = conn .CreateComma nd();
cmd.Comma ndText = sb.ToStri ng();
conn. Ope n();
int num = ( int )cmd.ExecuteScalar();
if    (n um > 0)
{
Response.Redirect(    "shop.aspx");
}
else
{
Response.Write(    "账号密码错误“);
}
}
}
2.注册页面与数据库连接
protected void Butt on 1_Click(    object sen der, Eve ntArgs e)
{
stri ng conn str =    @"Data Source=XIAOZHENZHEN-PC;l nitial Catalog=logi n;ln tegrated
Security=True";
StringBuilder sb = new StringBuilder    ();
sb.Appe nd(    "in sert into
useri nfo(user name,password,she nfen,n ame,sex,birthday,telepho ne)values(”    );
sb.Append(    "'" );sb.Append(TextBox1.Text);sb.Append(    "'" ); sb.Append(",");
sb.Append(    "'" );sb.Append(TextBox2.Text);sb.Append(    "'" );sb.Append(",");
Respo nse.Write(sb.ToStr in g());
using ( SqlConnection conn = new SqlConnection (connstr))
{
conn. Ope n();
SqlComma nobmd = conn .CreateComma nd(); cmd.Comma ndText = sb.ToStri ng();
int num =( int ) cmd.ExecuteNonQuery(); int count =( int )cmd.ExecuteNonQuery(); if (count > 0)
{ Respo nse.Redirect(    "Default.aspx" ); }
else
{Resp on se.Redirect(    "fault.aspx" );}
conn. Close();}}
3.购物车页面
<asp: GridView ID="GridView1" run at ="server" AutoGe nerateColum ns ="False"
DataSourceID ="SqlDataSource1" Height ="162px"
Width ="644px" BackColor ="LightGoldenrodYellow"    BorderColor ="Tan"
BorderWidth ="1px" CellPadding ="2" ForeColor ="Black" GridLines ="None" style ="text-alig n    : cen ter"
on selected in dexcha nged ="GridView1_SelectedI ndexCha nged">
<Alternati ngRowStyle    BackColor ="PaleGolde nrod" />
<Colu mns>
<asp: BoundField DataField ="序列"HeaderText="序列"SortExpression ="序列"/>
<asp: HyperLinkField DataNavigateUrlFields    ="序列"
DataNavigateUrlFormatStri ng ="detail.aspx?id={0}" DataTextField ="名称"    HeaderText="
“ />
<asp: BoundField DataField ="介绍 HeaderText="介绍 SortExpression ="介绍” />
<asp: ImageField DataAlternateTextField    ="图片"DataImageUrlField ="图片"
HeaderText ="图片">
</asp: ImageField >
<asp: BoundField DataField ="价格"HeaderText ="价格"SortExpression ="价格"/>
<asp: CommandField ShowDeleteButton ="True" />
<asp: TemplateField    HeaderText ="o 6" ShowHeade="False">
vltemTemplate >
<asp: LinkButton    ID="LinkButton1" runat ="server" CausesValidation ="false"
CommandNam’e’ Text ="加入购物车"    CommandArgume=t <%#
Eval("序列 ")%>' On Click ="Li nkButto n1_Click"
></asp: LinkButton >
</ ItemTemplate ></asp: TemplateField ></Columns>
</ asp: GridView >
<asp: SqlDataSource ID="SqlDataSource1"    run at ="server"
Conn ecti on Stri ng ="<%$ Conn ecti on Stri ngs:logi nConn ecti on Str ing %>    "
SelectCommand="SELECT * FROM [shopping]"></ asp: SqlDataSource >
4.详细信息
<asp: FormView ID="FormView1"
vEditItemTemplate >
runat ="server"
DataSourceID ="SqlDataSource1">
序列
<asp: TextBox ID="序列 TextBox"
<br />
名称
runat ="server"
Text='<%# Bind("序列"%>'
/>
<asp: TextBox
ID="名称 TextBox"
<br />
介绍
runat ="server"
Text='<%# Bind("名称")%>'
/>
<asp: TextBox
ID="介绍 TextBox"
<br />
价格:
runat ="server"
Text='<%# Bind("介绍” )%>'
/>
<asp: TextBox
ID="价格 TextBox"
<br />
runat ="server"
Text='<%# Bind(“ 价格")%>'
/>
<asp: LinkButton ID="UpdateButton" runat ="server" CausesValidation ="True"
CommandNameJpdate" Text="更新"/>
&n bsp;<asp: L in kButt on ID="UpdateCa ncelButt on"    run at ="server"
CausesValidation ="False" CommandNameCancel" Text ="取消"/>
</ EditItemTemplate >

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。