📄 shoppingcar.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 ShoppingCar : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection cnA = new OleDbConnection();
cnA.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=" + Server.MapPath("BDB/BookStore.mdb");
string cmdtext = "SELECT BNum,BPrice1 FROM BookCar ";
cnA.Open();
OleDbCommand cmA = new OleDbCommand(cmdtext, cnA);
OleDbDataReader dr = cmA.ExecuteReader();
Int16 yynum = 0;
Int16 yyprice = 0;
int yyall = 0;
while (dr.Read())
{
yynum = (Int16)dr.GetValue(0);
yyprice = (Int16)dr.GetValue(1);
yyall = yyall + (yynum * yyprice);
}
this.Label2.Text = yyall.ToString();
cnA.Close();
}
protected void Button3_Click1(object sender, EventArgs e)
{
int i = GridView1.Rows.Count;
for (int j = 0; j < i; j++)
{
string nnum = ((TextBox)GridView1.Rows[j].FindControl("TextBox1")).Text;
string iid= GridView1.DataKeys[j].Values[1].ToString();
OleDbConnection cnA = new OleDbConnection();
cnA.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=" + Server.MapPath("BDB/BookStore.mdb");
string cctext = "Update BookCar set BNum='"+nnum+"' WHERE BName='"+iid+"';";
OleDbCommand com = new OleDbCommand(cctext, cnA);
cnA.Open();
com.ExecuteNonQuery();
string cmdtext = "SELECT BNum,BPrice1 FROM BookCar ";
OleDbCommand cmA = new OleDbCommand(cmdtext, cnA);
OleDbDataReader dr = cmA.ExecuteReader();
Int16 yynum=0;
Int16 yyprice=0;
int yyall=0;
while (dr.Read())
{
yynum = (Int16)dr.GetValue(0);
yyprice = (Int16)dr.GetValue(1);
yyall = yyall + (yynum * yyprice);
}
this.Label2 .Text =yyall .ToString ();
cnA.Close();
}
}
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
OleDbConnection cnA = new OleDbConnection();
cnA.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=" + Server.MapPath("BDB/BookStore.mdb");
string cmdtext = "SELECT BNum,BPrice1 FROM BookCar ";
cnA.Open();
OleDbCommand cmA = new OleDbCommand(cmdtext, cnA);
OleDbDataReader dr = cmA.ExecuteReader();
Int16 yynum = 0;
Int16 yyprice = 0;
int yyall = 0;
while (dr.Read())
{
yynum = (Int16)dr.GetValue(0);
yyprice = (Int16)dr.GetValue(1);
yyall = yyall + (yynum * yyprice);
}
this.Label2.Text = yyall.ToString();
cnA.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
if (Session["name"] == null)
{
Response.Write("<script>alert('您还未登陆,请登陆后进行下订单操作')</script>");
}
else
Response.Redirect("newdingdan.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -