📄 displayproductcategory.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.SqlClient;
public partial class DisplayProductcategory : System.Web.UI.Page
{ private static int categoryid;
protected void Page_Load(object sender, EventArgs e)
{
if(Request.QueryString["CID"]!="")
{
categoryid=Int32.Parse(Request.QueryString["CID"].ToString());
}
if(!Page.IsPostBack)
{
this.GetProductDataByCIDBind();
}
}
private void GetProductDataByCIDBind()
{
ProductDB pdb=new ProductDB();
SqlDataReader Sdr=pdb.GetProductDataByCategoryId(categoryid);
this.DListProductByCategory.DataSource=Sdr;
this.DListProductByCategory.DataBind();
Sdr.Close();
}
public String GetProductDescription(String des)
{
if(des.Length>255)
{
return des.Substring(0,255)+"...";
}
else
{
return des;
}
}
protected void DListProductByCategory_ItemCommand(object source, DataListCommandEventArgs e)
{
if (!User.Identity.IsAuthenticated)
{
Response.Redirect("~/login_Register.aspx");
}
else
{
Shopcart shopcart = new Shopcart();
shopcart.CustomerID = User.Identity.Name;
shopcart.Quantity = 1;
shopcart.ProductID = Int32.Parse(e.CommandArgument.ToString());
ShopcarDB Sdb = new ShopcarDB();
if (Sdb.GetShopcartItem(shopcart) > 0)
{
Sdb.UpdateShopCartFirst(shopcart, true);
}
else
{
Sdb.AddShopCart(shopcart);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -