最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

基于asp .net的购物网站

来源:动视网 责编:小OO 时间:2025-09-30 01:07:44
文档

基于asp .net的购物网站

Asp.net实现的购物车功能包涵商品浏览,新用户注册,购买商品,查看购物车,填写订单,结算等。有问题咨询qq:514997193Madebytruman商品页面usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Data;usingSystem.Data.SqlClie
推荐度:
导读Asp.net实现的购物车功能包涵商品浏览,新用户注册,购买商品,查看购物车,填写订单,结算等。有问题咨询qq:514997193Madebytruman商品页面usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Data;usingSystem.Data.SqlClie
Asp.net实现的购物车

功能包涵商品浏览,新用户注册,购买商品,查看购物车,填写订单,结算等。

有问题咨询qq:514997193  

Made by truman

商品页面

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="goods.aspx.cs" Inherits="shopcar.goods" %>

    

    

    

     

 

    

 

 

    

    

    

    

    

       

                    onselectedindexchanged="GridView1_SelectedIndexChanged" 

            onselectedindexchanging="GridView1_SelectedIndexChanging" 

        DataSourceID="SqlDataSourcegood" Width="468px" 

        Height="153px">

            

                          

                    

                        

                    

                

                                    SortExpression="gname" />

                

                                    SortExpression="publisher" />

                                    SortExpression="author" />

                                    SortExpression="classify" />

            

            

            

        

                ConnectionString="<%$ ConnectionStrings:shopcarConnectionString %>" 

        SelectCommand="SELECT [gname], [price], [publisher], [author], [classify] FROM [good]">

    

        

    

    

    

    

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

using System.Data.Common;

namespace shopcar

{

    public partial class goods : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

        }

        protected void regbtn_Click(object sender, EventArgs e)

        {

            Response.Redirect("register.aspx");

        }

        protected void loginbtn_Click(object sender, EventArgs e)

        {

            string conStr = "server=ZFL-HP;database=shopcar;Integrated Security=true";

            SqlConnection lgCon = new SqlConnection(conStr);

            lgCon.Open();

            SqlCommand lgcod = new SqlCommand();

            lgcod.CommandText = "select id from vip where id='" + idbox.Text + "'and password='" + paswbox.Text + "'";  //vip表括?为a用?户§表括?,?原-来ぁ?叫Duser表括?,?但?是?sql出?现?问ê题琣

            lgcod.Connection = lgCon;

            SqlDataReader lgReader = lgcod.ExecuteReader();

            if (lgReader.Read())

            {

                loginbtn.Visible = false;

                regbtn.Visible = false;

                idbox.Visible = false;

                paswbox.Visible = false;

                Label1.Visible = true;

                Label2.Visible = false;

                Label3.Visible = false;

                Label1.Text = idbox.Text;

            }

            else

            {

                Response.Write("");

            }

            lgReader.Close();

            lgcod.Dispose();

            lgCon.Dispose();

        }

        protected void kobtn_Click(object sender, EventArgs e)

        {

            for (int i = 0; i <= GridView1.Rows.Count - 1; i++)

            {

                CheckBox ck = (CheckBox)GridView1.Rows[i].FindControl("CheckBox2");

                ck.Checked = false;

            }

            Response.Write("");

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

        {

        }

        protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)

        {

        }

        protected void carbtn_Click(object sender, EventArgs e)

        {

            if (Label1.Visible == false)

             {

                Response.Write("");

             }

            else

            {

                for (int i = 0; i <= GridView1.Rows.Count - 1; i++)

                {

                    CheckBox ck = (CheckBox)GridView1.Rows[i].FindControl("CheckBox2");

                    if (ck.Checked == true)

                    {

                        // string stuID = GridView1.Rows[i].Cells[1].Text;

                        string conStr = "server=ZFL-HP;database=shopcar;Integrated Security=true";

                        SqlConnection carCon = new SqlConnection(conStr);

                        carCon.Open();

                        string sqlStr = "insert into scar(userid,gdname,gdprice,count) values('" + Label1.Text + "','" + GridView1.Rows[i].Cells[1].Text + "','" + GridView1.Rows[i].Cells[2].Text + "','" + 1 + "') ;";

                        SqlCommand carComd = new SqlCommand(sqlStr, carCon);

                        carComd.ExecuteNonQuery();

                        carCon.Dispose();

                        carComd.Dispose();

                    }

                }

                Session["uid"] = Label1.Text;

                Response.Redirect("car.aspx");

            }

        }

    }

}

注册页面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="register.aspx.cs" Inherits="shopcar.register" %>

    

    

    

    

    

    

    

            style="height: 21px" />

    

    

        

        

    

    

        

        

    

    

    

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

 using System.Web.Security;

namespace shopcar

{

    public partial class register : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            Label4.Visible = false;

        }

        protected void upbtn_Click(object sender, EventArgs e)

        {

            if (idbox.Text != "" & pasbox.Text == cfmbox.Text&Label4.Text=="可é用?")

            {

                string conStr = "server=ZFL-HP;database=shopcar;Integrated Security=true";

                SqlConnection reCon = new SqlConnection(conStr);

                reCon.Open();

                string sqlStr = "insert into vip(id,password) values('" + idbox.Text + "','" + pasbox.Text + "')";

                SqlCommand reComd = new SqlCommand(sqlStr, reCon);

                reComd.ExecuteNonQuery();

                reCon.Dispose();

                reComd.Dispose();

                

                

                Response.Write("");

            }

        }

        protected void checkbox_Click(object sender, EventArgs e)

        {

            string conStr = "server=ZFL-HP;database=shopcar;Integrated Security=true";

            SqlConnection ckCon = new SqlConnection(conStr);

            ckCon.Open();

            SqlCommand ckcod = new SqlCommand();

            ckcod.CommandText = "select id from vip where id='" + idbox.Text + "'";  //vip表括?为a用?户§表括?,?原-来ぁ?叫Duser表括?,?但?是?sql出?现?问ê题琣

            ckcod.Connection = ckCon;

            SqlDataReader ckReader = ckcod.ExecuteReader();

            if (ckReader.Read())

            {

                

                    Label4.Visible = true;

                    Label4.Text = "此?用?户§名?已?被?注痢?册á";

                  

                }

                else

                {

                    Label4.Visible = true;

                    Label4.Text = "可é用?";

                  

                }

         }

    }

}

购物车页面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="car.aspx.cs" Inherits="shopcar.car" %>

    

    

    

      

    

 

     

    

    

    

            DataKeyNames="userid,gdname" DataSourceID="SqlDataSourcescar" 

        onselectedindexchanged="GridView1_SelectedIndexChanged">

        

            

                            SortExpression="userid" />

                            SortExpression="gdname" ReadOnly="True" />

                            SortExpression="gdprice" ReadOnly="True" />

            

        

    

            ConnectionString="<%$ ConnectionStrings:shopcarConnectionString %>" 

        DeleteCommand="DELETE FROM [scar] WHERE [userid] = @userid AND [gdname] = @gdname" 

        InsertCommand="INSERT INTO [scar] ([userid], [gdname], [gdprice], [count]) VALUES (@userid, @gdname, @gdprice, @count)" 

        SelectCommand="SELECT [userid], [gdname], [gdprice], [count] FROM [scar]" 

        UpdateCommand="UPDATE [scar] SET [count] = @count WHERE [userid] = @userid AND [gdname] = @gdname">

        

            

            

        

        

            

            

            

            

        

        

            

            

            

            

        

    

    

 

        

    

    

    

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

namespace shopcar

{

    public partial class car : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            Label1.Text = (string)Session["uid"];

            SqlDataSourcescar.SelectCommand = "SELECT* FROM scar where userid='" + (string)Session["uid"] + "';";

   

               

            

       

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

        {

        }

        protected void kobtn_Click(object sender, EventArgs e)

        {

            Response.Write("");

        }

        protected void paybtn_Click(object sender, EventArgs e)

        {

            string conStr = "server=ZFL-HP;database=shopcar;Integrated Security=true";

            SqlConnection myCon = new SqlConnection(conStr);

            myCon.Open();

            string sqlStr = "delete from scar where userid='" + (string)Session["uid"] + "'";

            SqlCommand myCom = new SqlCommand(sqlStr, myCon);

            myCom.ExecuteNonQuery();

            myCom.Dispose();

            myCon.Dispose();

            Response.Redirect("sheet.aspx");

        }

        protected void conbtn_Click(object sender, EventArgs e)

        {

            Response.Redirect("goods.aspx");

        }

        protected void Button1_Click(object sender, EventArgs e)

        {

                     float j = 0;

                     for (int i = 0; i <= GridView1.Rows.Count - 1; i++)

                     {

                         string gn = GridView1.Rows[i].Cells[3].Text;

                         string cut = GridView1.Rows[i].Cells[4].Text;

                         float gnn = float.Parse(gn);  //z这a个?屌?

                         float cutn = float.Parse(cut);

                         j = j + gnn * cutn;

                         Label2.Text = "总哩?价?:阰" + j;

                     }

        }

    }

}

结算页面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="sheet.aspx.cs" Inherits="shopcar.sheet" %>

    

    

    

    

    

    

    

    

        

        

    

    

    

    

    

    

    

    

    

    

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace shopcar

{

    public partial class sheet : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

        }

        protected void Button1_Click(object sender, EventArgs e)

        {

            Response.Write("");

        }

    }

}

文档

基于asp .net的购物网站

Asp.net实现的购物车功能包涵商品浏览,新用户注册,购买商品,查看购物车,填写订单,结算等。有问题咨询qq:514997193Madebytruman商品页面usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Data;usingSystem.Data.SqlClie
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top