📄 default.aspx.cs
字号:
using 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.OleDb;
public partial class Default4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
Label BName = (Label)e.Item.FindControl("Label1");
string BBName = BName.Text.ToString();
Label BKind=(Label )e.Item .FindControl ("Label2");
string BBKind = BKind.Text.ToString();
Label BAuthor= (Label)e.Item.FindControl("Label4");
string BBAuthor = BAuthor.Text.ToString();
Label BChuban = (Label)e.Item.FindControl("Label3");
string BBChuban = BChuban.Text.ToString();
Label BPrice = (Label)e.Item.FindControl("Label5");
string BBPrice = BPrice.Text.ToString();
//Response.Write(BBPrice );
string StrCoon = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Server.MapPath("BDB/BookStore.mdb");
OleDbConnection cnA = new OleDbConnection();
cnA.ConnectionString = StrCoon;
cnA.Open();
string sqlinsert = " INSERT INTO [BookCar] ([BName], [BKind],[BAuthor],[BChuban],[BPrice1],[BPrice2]) VALUES ('" + BBName + "','" + BBKind + "','" + BBAuthor + "','" + BBChuban + "','" + BBPrice + "','" + BBPrice + "')";
OleDbCommand ccma = new OleDbCommand(sqlinsert, cnA);
ccma.ExecuteNonQuery();
cnA.Close();
Response.Write("<script>alert('已加入到购物车!')</script>");
}
protected void DataList2_ItemCommand(object source, DataListCommandEventArgs e)
{
Label BName = (Label)e.Item.FindControl("Label1");
string BBName = BName.Text.ToString();
Label BKind = (Label)e.Item.FindControl("Label2");
string BBKind = BKind.Text.ToString();
Label BAuthor = (Label)e.Item.FindControl("Label4");
string BBAuthor = BAuthor.Text.ToString();
Label BChuban = (Label)e.Item.FindControl("Label3");
string BBChuban = BChuban.Text.ToString();
Label BPrice = (Label)e.Item.FindControl("Label5");
string BBPrice = BPrice.Text.ToString();
//Response.Write(BBPrice );
string StrCoon = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Server.MapPath("BDB/BookStore.mdb");
OleDbConnection cnA = new OleDbConnection();
cnA.ConnectionString = StrCoon;
cnA.Open();
string sqlinsert = " INSERT INTO [BookCar] ([BName], [BKind],[BAuthor],[BChuban],[BPrice1],[BPrice2]) VALUES ('" + BBName + "','" + BBKind + "','" + BBAuthor + "','" + BBChuban + "','" + BBPrice + "','" + BBPrice + "')";
OleDbCommand ccma = new OleDbCommand(sqlinsert, cnA);
ccma.ExecuteNonQuery();
cnA.Close();
Response.Write("<script>alert('已加入到购物车!')</script>");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -