网上购物系统的设计与实现源代码.doc
精品文档,仅供学习与交流,如有侵权请联系网站删除cm.aspx(页面)<% Page Language="C#" MasterPageFile="/MasterPage.master" AutoEventWireup="true" CodeFile="cm1.aspx.cs" Inherits="cm1" Title="无标题页" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> 地址<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br />邮编<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br />电话<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <br />真实姓名<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="下一步" style="height: 26px" /> <br /> <br /> <br /> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <br /></asp:Content>cm.aspx.csusing System;using System.Collections;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;public partial class cm1 : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) class insert protected void Button1_Click(object sender, EventArgs e) DataTable dtable; string sql = ConfigurationManager.ConnectionStrings"Con".ConnectionString.ToString(); SqlConnection sqlb = new SqlConnection(sql); sqlb.Open(); string strt = "select * from gouwuche where username='" + Session"name".ToString() + "'" SqlDataAdapter sqlt = new SqlDataAdapter(strt, sqlb); DataSet ds = new DataSet(); DataRowCollection drow; sqlt.Fill(ds,"tab"); dtable = ds.Tables"tab" drow = dtable.Rows; Random rnd = new Random(); long n = rnd.Next(10000, 99999); long m = rnd.Next(10000, 99999); long x = rnd.Next(10000, 99999); for (int i = 0; i < drow.Count; i+) SqlCommand com = new SqlCommand(); com.Connection = sqlb; com.CommandText = "insert into dingdan(id,sum,sprice,youbian,name,address,username,pho,sname,time,photo,sno)values(id,sum,sprice,youbian,name,address,username,pho,sname,time,photo,sno)" com.Parameters.AddWithValue("id", n.ToString()+m.ToString()+x.ToString(); com.Parameters.AddWithValue("sum", drowi4.ToString(); com.Parameters.AddWithValue("sprice", drowi3.ToString(); com.Parameters.AddWithValue("youbian", TextBox2.Text.ToString(); com.Parameters.AddWithValue("name", TextBox4.Text.ToString(); com.Parameters.AddWithValue("address", TextBox1.Text.ToString(); com.Parameters.AddWithValue("username", Session"name".ToString(); com.Parameters.AddWithValue("pho", TextBox3.Text.ToString(); com.Parameters.AddWithValue("sname", drowi2.ToString(); com.Parameters.AddWithValue("time", System.DateTime.Now.ToString(); com.Parameters.AddWithValue("photo", drowi5.ToString(); com.Parameters.AddWithValue("sno", drowi0.ToString(); com.ExecuteNonQuery(); DataTable dtable2; string strt2 = "select kucun from shangping where name='" + drowi2.ToString() + "'" SqlDataAdapter sqlf = new SqlDataAdapter(strt2, sqlb); DataSet ds2 = new DataSet(); DataRowCollection drow2; sqlf.Fill(ds, "tab2"); dtable2 = ds.Tables"tab2" drow2 = dtable2.Rows; int a=Int32.Parse(drow200.ToString() - Int32.Parse(drowi4.ToString(); string strt3 = "update shangping set kucun='" + a.ToString() + "' where name='" + drowi2.ToString() + "'" SqlCommand upkc = new SqlCommand(strt3,sqlb); upkc.ExecuteNonQuery(); SqlCommand coms = new SqlCommand(); coms.Connection = sqlb; coms.CommandText = "delete from gouwuche where username=name" coms.Parameters.AddWithValue("name", Session"name".ToString(); coms.ExecuteNonQuery(); sqlb.Close(); Response.Write("<script>alert('恭喜你,订单已生成');</script>"); FenLeishop.aspx<% Page Language="C#" MasterPageFile="/MasterPage.master" AutoEventWireup="true" CodeFile="FenLeishop.aspx.cs" Inherits="FenLeishop" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><link href="StyleSheet.css" rel="stylesheet" type="text/css" /><div id="main"><br/><div id="fenleitop"><div id="fenleileft"><div id="fenleiBT">数码精品</div><br/><div id="fenleishop"> <asp:DataList ID="DataList1" runat="server" Height="259px" Width="485px" RepeatDirection="Horizontal" RepeatColumns="3" HorizontalAlign="Justify" > <ItemTemplate> <table class="style3"> <tr> <td class="style5" style="width: 151px" align="left"> <a href='ShopMessage.aspx?no=<%#DataBinder.Eval(Container.DataItem,"no")%>'target="blank" ><img style="border:none;" alt="商品" src='./image/Products/<%#Eval("photo") %>'/></a></td> </tr> <tr> <td style="width: 151px" align="left"> <span style="color: #ff0033"> 商品名:<%#Eval("name") %></span></td> </tr> <tr> <td style="width: 151px; height: 25px" align="left"> <span style="color: #ff0000"> 价格:<%#Eval("price") %></span></td> </tr> </table> </ItemTemplate> </asp:DataList> </div></div> <div id="fenleiright"> <div id="fenleiBT">服饰精品</div><br/> <div id="fenleishop"> <asp:DataList ID="DataList2" runat="server" Height="259px" Width="485px" RepeatDirection="Horizontal" RepeatColumns="3" HorizontalAlign="Justify" > <ItemTemplate> <table class="style3"> <tr> <td class="style5" style="width: 151px" align="left"> <a href='ShopMessage.aspx?no=<%#DataBinder.Eval(Container.DataItem,"no")%>'target="blank" ><img style="border:none;" alt="商品" src='./image/Products/<%#Eval("photo") %>'/></a></td> </tr> <tr> <td style="width: 151px" align="left"> <span style="color: #ff0033"> 商品名:<%#Eval("name") %></span></td> </tr> <tr> <td style="width: 151px; height: 25px" align="left"> <span style="color: #ff0000"> 价格:<%#Eval("price") %></span></td> </tr> </table> </ItemTemplate> </asp:DataList></div> </div> </div><br/> <div id="fenleitop"> <div id="fenleileft"><div id="fenleiBT">玩具精品</div><br/><div id="fenleishop"> <asp:DataList ID="DataList3" runat="server" Height="259px" Width="485px" RepeatDirection="Horizontal" RepeatColumns="3" HorizontalAlign="Justify" > <ItemTemplate> <table class="style3"> <tr> <td class="style5" style="width: 151px" align="left"> <a href='ShopMessage.aspx?no=<%#DataBinder.Eval(Container.DataItem,"no")%>'target="blank" ><img style="border:none;" alt="商品" src='./image/Products/<%#Eval("photo") %>'/></a></td> </tr> <tr> <td style="width: 151px" align="left"> <span style="color: #ff0033"> 商品名:<%#Eval("name") %></span></td> </tr> <tr> <td style="width: 151px; height: 25px" align="left"> <span style="color: #ff0000"> 价格:<%#Eval("price") %></span></td> </tr> </table> </ItemTemplate> </asp:DataList></div></div> <div id="fenleiright"> <div id="fenleiBT">家居精品</div><br/> <div id="fenleishop"> <asp:DataList ID="DataList4" runat="server" Height="259px" Width="485px" RepeatDirection="Horizontal" RepeatColumns="3" HorizontalAlign="Justify" > <ItemTemplate> <table class="style3"> <tr> <td class="style5" style="width: 151px" align="left"> <a href='ShopMessage.aspx?no=<%#DataBinder.Eval(Container.DataItem,"no")%>'target="blank" ><img style="border:none;" alt="商品" src='./image/Products/<%#Eval("photo") %>'/></a></td> </tr> <tr> <td style="width: 151px" align="left"> <span style="color: #ff0033"> 商品名:<%#Eval("name") %></span></td> </tr> <tr> <td style="width: 151px; height: 25px" align="left"> <span style="color: #ff0000"> 价格:<%#Eval("price") %></span></td> </tr> </table> </ItemTemplate> </asp:DataList></div> </div> </div> </div> </asp:Content>FenLeishop.aspx.csusing System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class FenLeishop : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) listbind(); void listbind() string sql = ConfigurationManager.ConnectionStrings"con".ConnectionString; DataSet ds = new DataSet(); using (SqlConnection sqlc = new SqlConnection(sql) SqlDataAdapter sqld = new SqlDataAdapter("select * from shangping where style='数码精品' ", sqlc); SqlDataAdapter sqle = new SqlDataAdapter("select * from shangping where style='服饰精品' ", sqlc); SqlDataAdapter sqlf = new SqlDataAdapter("select * from shangping where style='玩具精品' ", sqlc); SqlDataAdapter sqla = new SqlDataAdapter("select * from shangping where style='家居精品' ", sqlc); sqld.Fill(ds, "tbsp"); sqle.Fill(ds, "tbsp1"); sqlf.Fill(ds, "tbsp2"); sqla.Fill(ds, "tbsp3"); DataList1.DataSource = ds.Tables"tbsp".DefaultView; DataList1.DataBind(); DataList2.DataSource = ds.Tables"tbsp1".DefaultView; DataList2.DataBind(); DataList3.DataSource = ds.Tables"tbsp2".DefaultView; DataList3.DataBind(); DataList4.DataSource = ds.Tables"tbsp3".DefaultView; DataList4.DataBind();Hotshop.aspx<% Page Language="C#" MasterPageFile="/MasterPage.master" AutoEventWireup="true" CodeFile="Hotshop.aspx.cs" Inherits="Hotshop" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><div id="main12313"> <br/><br/> <asp:DataList ID="DataList1" runat="server" Height="259px" Width="485px" RepeatDirection="Horizontal" RepeatColumns="4" HorizontalAlign="Justify" > <ItemTemplate> <table class="style3"> <tr> <td class="style5" style="width: 151px" align="left"> <a href='ShopMessage.aspx?no=<%#DataBinder.Eval(Container.DataItem,"no")%>'target="blank" ><img style="border:none;" alt="商品" src='./image/Products/<%#Eval("photo") %>'/></a></td> </tr> <tr> <td style="width: 151px" align="left"> <span style="color: #ff0033"> 商品名:<%#Eval("name") %></span></td> </tr> <tr> <td style="width: 151px; height: 25px" align="left"> <span style="color: #ff0000"> 价格:<%#Eval("price") %></span></td> </tr> </table> </ItemTemplate> </asp:DataList> </div></asp:Content>Hotshop.aspx.csusing System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class Hotshop : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) listbind(); void listbind() string sql = ConfigurationManager.ConnectionStrings"con".ConnectionString; DataSet ds = new DataSet(); using (SqlConnection sqlc = new SqlConnection(sql) SqlDataAdapter sqld = new SqlDataAdapter("select top 20* from shangping ", sqlc); sqld.Fill(ds, "tbsp"); DataList1.DataSource = ds.Tables"tbsp".DefaultView; DataList1.DataBind();index.aspx<% Page Language="C#" MasterPageFile="/MasterPage.master" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" Title="耀思娜,欢迎您" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <div id="main" style="text-align:center; height: 1029px;" align="center" > <div id="niu" style="height: 426px; width: 1060px;" align="center"><div id="jin" style="height: 422px; width: 527px; float:left; margin-left: 8px;"><div id="jin1"style="height: 39px; width: 520px; margin-left: 0px;" align="left"><img src="image/123.jpg" /><div> </div> </div><div id="jin2" style="height: 365px; width: 507px; border: 2px dashed #FF6666; margin-left: 0px; margin-right: 7px; margin-top: 8px;"><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "http:/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http:/www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title></title><meta http-equiv="imagetoolbar" content="no"><style type="text/css">body #screen span position:absolute;overflow:hidden;border:#FFF solid 1px;background:#FFF;#screen imgposition:absolute;left:-32px;top:-32px;cursor: pointer;#caption, #titlecolor: #FFF;font-family: georgia, 'times new roman', times, veronica, serif;font-size: 1em;text-align: center;#caption b