while (reader.Read())
{
Label2.Text += reader.GetString(0)+"<br>";
}
reader.Close();
conn.Close();
}
protected void BindData()
{
conn = new SqlConnection(sets.ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select * from Products", conn);
DataSet ds = new DataSet();
da.Fill(ds);
productList.DataSource = ds;
productList.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
BindData2();
}
protected void BindData2()
{
string spmc = prodtdesn.Text;
conn = new SqlConnection(sets.ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select * from Products where Description='" + spmc + "'", conn);
DataSet ds = new DataSet();
da.Fill(ds);
productList.DataSource = ds;
productList.DataBind();
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
Response.Redirect("userupdate.aspx");
}
protected void productList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
productList.PageIndex = e.NewPageIndex;
productList.DataBind();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
}
}
收银台功能实现代码(CheckShopCart2.aspx.cs):
public partial class CheckShopCart2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Userorders dingdan = (Userorders)Session["userorder"];
Label1.Text = dingdan.UserName;
Label2.Text = dingdan.UserAddress;
Label3.Text = dingdan.UserCity;
Label4.Text = dingdan.UserPhone;
ShoppingCarts cart;
cart = (ShoppingCarts)Session["shoppingcart"];
GridView1.DataSource = cart.Product;
GridView1.DataBind();
Label5.Text += cart.TotalPrice;
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("shopping.aspx");
}
protected void Button1_Click(object sender, EventArgs e)
{
ConnectionStringSettings sets = ConfigurationManager.ConnectionStrings["DBConnection"];
SqlConnection conn = new SqlConnection(sets.ConnectionString);
string username = Session["username"].ToString();
int n = GridView1.Rows.Count;
for (int i = 0; i < n; i++)
{
int id =Convert.ToInt32( GridView1.Rows[i].Cells[0].Text);
int num = Convert.ToInt32(GridView1.Rows[i].Cells[4].Text);
SqlCommand cmd = new SqlCommand("insert into ShopCarts(username,ProductID,ProductNum) values ('" + username+ "'," + id + "," + num+ ")", conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
SqlCommand cmd1 = new SqlCommand("insert into SHInformation(username,SHName,SHAddress,SHCity,SHPhone) values ('" + username + "','" + Label1.Text + "','" + Label2.Text + "','" + Label3.Text + "','" + Label4.Text + "')", conn);
conn.Open();
cmd1.ExecuteNonQuery();
conn.Close();
Response.Write("<script>if(window.confirm('谢谢您的购买!')) location.replace('zxhIndex.aspx');else location.replace('zxhIndex.aspx');</script>");
}
}
冻结/解冻用户实现代码(fre-unfre-user.aspx.cs):
public partial class fre_unfre_user : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
BindData();
}
ConnectionStringSettings sets = ConfigurationManager.ConnectionStrings["DBConnection"];
SqlConnection conn;
protected void BindData()
{
conn = new SqlConnection(sets.ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select * from Users", conn);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int id = Convert.ToInt32(GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text);
if (e.CommandName == "djyh")
{
conn = new SqlConnection(sets.ConnectionString);
SqlCommand cmd = new SqlCommand("update Users set freeze='1' where userID=" + id,conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
else if (e.CommandName == "jdyh")
{
conn = new SqlConnection(sets.ConnectionString);
SqlCommand cmd = new SqlCommand("update Users set freeze='0' where userID=" + id,conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
else
{ }
}
protected void Button1_Click(object sender, EventArgs e)
{
BindData2();
}
protected void BindData2()
{
string gkxm1 = gkxm.Text;
conn = new SqlConnection(sets.ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select * from Users where username='" + gkxm1 + "'", conn);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>