📄 searched.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using doughty_BBS.inputcon;
namespace doughty_BBS
{
/// <summary>
/// searched 的摘要说明。
/// </summary>
public class searched : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Lblsearch;
protected System.Web.UI.WebControls.DataList DataList1;
public void BindGrid()
{
SqlConnection sqlConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["DBConnection"]);
string sql1;
if (Request.QueryString["author"]=="")
{
if (Request.QueryString["BID"]==null)
{
sql1="SELECT Q_ID,solved, author, Q_Note, Q_Content, ImageName, HiteCounter, AnsCounter,ReleaseTime, ReferTime, BigClass_ID, SmallClass_ID FROM Questions"+
" WHERE (ReferTime >@ReferTime) AND (Q_Note LIKE @Q_Note)and(Kind >= 0)";
}
else
{
sql1="SELECT Q_ID,solved, author, Q_Note, Q_Content, ImageName, HiteCounter, AnsCounter,ReleaseTime, ReferTime, BigClass_ID, SmallClass_ID FROM Questions"+
" WHERE (BigClass_ID =@BigClassID) AND (SmallClass_ID =@SmallClassID) AND (ReferTime >@ReferTime) AND (Q_Note LIKE @Q_Note)and(Kind >= 0)";
}
}
else
{
if (Request.QueryString["BID"]==null)
{
sql1="SELECT Q_ID,solved,author, Q_Note, Q_Content, ImageName, HiteCounter, AnsCounter,ReleaseTime, ReferTime, BigClass_ID, SmallClass_ID FROM Questions"+
" WHERE (ReferTime > @ReferTime) AND (Q_Note LIKE @Q_Note) AND (author ='"+Request.QueryString["author"]+"')and(Kind >= 0)";
}
else
{
sql1="SELECT Q_ID,solved, author, Q_Note, Q_Content, ImageName, HiteCounter, AnsCounter,ReleaseTime, ReferTime, BigClass_ID, SmallClass_ID FROM Questions"+
" WHERE (BigClass_ID =@BigClassID) AND (SmallClass_ID =@SmallClassID) AND (ReferTime > @ReferTime) AND (Q_Note LIKE @Q_Note) AND (author =@author)and(Kind >= 0)";
}
}
string con;
if (Request.QueryString["Q_Note"]=="%")
con="%";
else
con="%"+Request.QueryString["Q_Note"]+"%";
//con="%"+ConvertString.InputText(Request.QueryString["Q_Note"])+"%";
SqlDataAdapter sqlAdapter1 = new SqlDataAdapter(sql1, sqlConnection);
if (Request.QueryString["BID"]!=null)
{
sqlAdapter1.SelectCommand.Parameters.Add("@BigClassID",SqlDbType.Int,4,"BigClass_ID");
sqlAdapter1.SelectCommand.Parameters.Add("@SmallClassID",SqlDbType.Int,4,"SmallClass_ID");
}
sqlAdapter1.SelectCommand.Parameters.Add("@Q_Note",SqlDbType.VarChar,160,"Q_Note");
sqlAdapter1.SelectCommand.Parameters.Add("@ReferTime",SqlDbType.DateTime,12,"ReferTime");
if (Request.QueryString["BID"]!=null)
{
sqlAdapter1.SelectCommand.Parameters["@BigClassID"].Value=Request.QueryString["BID"];
sqlAdapter1.SelectCommand.Parameters["@SmallClassID"].Value=Request.QueryString["SID"];
}
sqlAdapter1.SelectCommand.Parameters["@Q_Note"].Value=con;
sqlAdapter1.SelectCommand.Parameters["@ReferTime"].Value=Request.QueryString["ReferTime"];
DataSet returns = new DataSet();
sqlAdapter1.Fill(returns);
this.DataList1.DataSource=returns.Tables[0];
this.Page.DataBind();
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (Request.QueryString["Q_Note"]==null)
Lblsearch.Text="没有输入关键字";
else
{
Lblsearch.Text="关键字:"+Request.QueryString["Q_Note"].ToString();
BindGrid();
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
//分页显示
//this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
//this.Page.DataBind();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -