using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using web; public partial class control_shop2 : System.Web.UI.UserControl { protected string sqlwhere=""; public string YUANBAOSHOPURLS { get { if (base.Request.QueryString["ybshop"] != null && base.Request.QueryString["ybshop"].ToString() == "1") { return "1"; } return "0"; } } public bool YUANBAOSHOP { get { if (YUANBAOSHOPURLS == "1") { return true; } return false; } } public string SHOWYUANBAOSHOP { get { if (YUANBAOSHOP) { return "none"; } return "inline"; } } private void btnsearch_Click(object sender, EventArgs e) { string str = new system().ChkSql(this.tbitemname.Text.ToString()); base.Response.Redirect("shop.aspx?word=" + str + "&ybshop=" + base.Request.QueryString["ybshop"].ToString()); } public void DataGrid1_PageIndexChanged(object sender, DataGridPageChangedEventArgs e) { this.DataGrid1.CurrentPageIndex = e.NewPageIndex; this.DataGrid1.DataSource = new DataProviders().ExecuteSqlDs("select a.id as id ,a.itemid,a.name,pic,case isbb when 0 then '百寶物品' when 1 then '普通物品' end as isbb, b.name as type,price,gold,yuanbao,comment from web_item a,web_itemtype b where b.used=1 and a.type=b.id" + this.sqlwhere + " order by id desc", "DataGrid1"); this.DataGrid1.DataBind(); } private void InitializeComponent() { this.btnsearch.Click += new EventHandler(this.btnsearch_Click); this.DataGrid1.PageIndexChanged += new DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged); base.Load += new EventHandler(this.Page_Load); } protected override void OnInit(EventArgs e) { this.InitializeComponent(); base.OnInit(e); } protected void Page_Load(object sender, EventArgs e) { if (base.Request.QueryString["type"] != null) { int num = int.Parse(base.Request.QueryString["type"].ToString()); this.sqlwhere = " and a.type=" + num; } if (base.Request.QueryString["word"] != null) { string str = new system().ChkSql(base.Request.QueryString["word"].ToString().Trim()); this.sqlwhere += " and a.name like '%" + str + "%'"; } if (YUANBAOSHOP) { this.sqlwhere += " and a.yuanbao>0 and a.gold=0 "; } else { this.sqlwhere += " and ((a.yuanbao=0 and a.gold=0) or (a.gold>0)) "; } if (!this.Page.IsPostBack) { this.DataGrid1.DataSource = new DataProviders().ExecuteSqlDs("select a.id as id ,a.itemid,a.name,pic,case isbb when 0 then '百寶物品' when 1 then '普通物品' end as isbb, b.name as type,price,gold,yuanbao,comment from web_item a,web_itemtype b where b.used=1 and a.type=b.id" + this.sqlwhere + " order by id desc", "DataGrid1"); this.DataGrid1.CurrentPageIndex = 0; this.DataGrid1.DataBind(); if (YUANBAOSHOP) { this.DataList1.DataSource = new DataProviders().ExecuteSqlDs("select * from web_itemtype a where a.used=1 and exists(select 1 from web_item b where a.id=b.type and b.yuanbao>0 and b.gold=0 )", "DataGrid1"); } else { this.DataList1.DataSource = new DataProviders().ExecuteSqlDs("select * from web_itemtype where used=1", "DataGrid1"); } this.DataList1.DataBind(); } } }