62,267
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if (Session["_AdminUser"] == null || Session["_Pm"].ToString().Trim() != "Manager")
{
Response.Write("<script>alert('Sorry,You are not Persissions!');top.window.location.href='Login.aspx';</script>");
}
if (Request["shopid"] != null)
{
try
{
SqlConnection conn0 = new SqlConnection("Data Source=plesksql1.ehosting.com;Database=ukmobi;Uid=ukmobi;Pwd=123456");
conn0.Open();
string sql;
if (Request.QueryString["import"] == "False")
{
sql = "update shop_snsn set Stock_import=1 where shopid=" + Request.QueryString["shopid"];
}
else
{
sql = "update shop_snsn set Stock_import=0 where shopid=" + Request.QueryString["shopid"];
}
SqlCommand sc0 = new SqlCommand(sql, conn0);
sc0.ExecuteNonQuery();
conn0.Close();
this.bind();
}
catch
{
Response.Write("<script>alert('shopid is error!');history.back(-1);</script>");
}
}
}
public void bind()
{
System.Collections.ArrayList a = new System.Collections.ArrayList();
string s = SearchText.Text.Trim();
string[] ss = s.Split(' ');
foreach (string si in ss)
{
a.Add(si);
}
//for (int i = 0; i < ss.Length; i++)
//{
// Response.Write(ss[i] + "<br>");
//}
string sql = "select top 100 * from shop_snsn ";
for (int i = 0; i < ss.Length; i++)
{
if (i == 0)
{
sql = sql + "where shopname like '%" + ss[i] + "%' ";
}
else
{
sql = sql + "and shopname like '%" + ss[i] + "%' ";
}
}
//Response.Write(sql);
SqlConnection conn = new SqlConnection("Data Source=plesksql1.ehosting.com;Database=ukmobi;Uid=ukmobi;Pwd=123456");
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
sda.Fill(ds, "shop_snsn");
GridView1.DataSource = ds.Tables["shop_snsn"];
GridView1.DataKeyNames = new string[] { "shopid" };
GridView1.DataBind();
conn.Close();
}
protected void Search_Click(object sender, EventArgs e)
{
this.bind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.bind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
try
{
switch (e.Row.Cells[4].Text)
{
case "True":
e.Row.Cells[4].Text = "<font color=green>Show</font>";
break;
case "False":
e.Row.Cells[4].Text = "<font color=gray>Hide</font>";
break;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
}
嗯,没错。。有什么好的办法解决!!??