?? search.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 Search : System.Web.UI.Page
{
private String strkey;
protected void Page_Load(object sender, EventArgs e)
{
if(Request.QueryString["strkey"]!="")
{
strkey = Request.QueryString["strkey"].ToString();
}
if(!Page.IsPostBack)
{
this.GetProductSearchDataBind();
}
}
private void GetProductSearchDataBind()
{
ProductDB pdb = new ProductDB();
if (pdb.GetSearchProductCountByKey(strkey) > 0)
{
SqlDataReader Sdr = pdb.GetSearchProductDataByKey(strkey);
this.DListSearch.DataSource = Sdr;
this.DListSearch.DataBind();
this.LabelMsg.Visible = false;
Sdr.Close();
}
else
{
this.DListSearch.Visible = false;
this.LabelMsg.Text = "沒有查詢到關鍵字所屬的商品!";
}
}
public String GetProductDescription(String des)
{
if (des.Length > 255)
{
return des.Substring(0, 255) + "...";
}
else
{
return des;
}
}
protected void DListSearch_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 + -