buy.aspx.cs
来自「购物车主要是为广大网上顾客购物的资源平台。购物车主要目标是建设在网上对用户进行信」· CS 代码 · 共 67 行
CS
67 行
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.SqlClient;
public partial class Buy : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Uid"] ==null)
{
Response.Redirect("Default.aspx");
}
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString);
conn.Open();
string sql = "select Gid as '序号',Gpicture as '照片',Gname as '名称', Gprice as '价格',Gdescribe as '描述' from Goods";
SqlCommand cmd = new SqlCommand(sql, conn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataKeyNames = new string[] { "序号" };
GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Next.aspx");
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString);
conn.Open();
string sql = "insert into Temp () values ()";
SqlCommand cmd = new SqlCommand(sql, conn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void LinkButton1_Command(object sender, CommandEventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString);
conn.Open();
int gidID = int.Parse(e.CommandArgument.ToString());
string userID = Session["Uid"].ToString();
string sql = "insert into Temp (Uid,Gid) values('"+userID+"','" + gidID + "')";
SqlCommand cmd = new SqlCommand(sql, conn);
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
Response.Write("<script>alert('添加成功')</script>");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?