功能包涵商品浏览,新用户注册,购买商品,查看购物车,填写订单,结算等。
有问题咨询qq:514997193
Made by truman
商品页面
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="goods.aspx.cs" Inherits="shopcar.goods" %>
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" %>
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" %>
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("");
}
}
}