⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searched.aspx.cs

📁 勇敢者论坛全部源代码。 支持SQL2000/Access数据库
💻 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_cn.inputcon;
using System.Data.OleDb;
using System.Configuration;

namespace doughty_cn
{
	/// <summary>
	/// searched 的摘要说明。
	/// </summary>
	public partial class searched : System.Web.UI.Page
	{
	
		public void BindGrid() 
		{
			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 (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 (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 (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  (Q_Note LIKE @Q_Note) AND (author =@author)and(Kind >= 0)";
				}
			}
			string con,tpf;
            string DBtype = ConfigurationManager.AppSettings["DBtype"];
            tpf = "%";
			if (Request.QueryString["Q_Note"]=="%")
				con=tpf;
			else
				con=tpf+Request.QueryString["Q_Note"]+tpf;

            if (DBtype == "Accsee")
            {
                DBsql exsql = new DBsql();
                exsql.Open();
                OleDbDataAdapter da = new OleDbDataAdapter(sql1, exsql.con);

                if (Request.QueryString["BID"] != null)
                {
                    da.SelectCommand.Parameters.Add("@BigClassID", OleDbType.Integer, 4, "BigClass_ID");
                    da.SelectCommand.Parameters.Add("@SmallClassID", OleDbType.Integer, 4, "SmallClass_ID");
                }
                da.SelectCommand.Parameters.Add("@Q_Note", OleDbType.VarChar).Value = con;

                DataSet ds = new DataSet();
                da.Fill(ds);
                exsql.Close();
                this.DataList1.DataSource = ds.Tables[0];
            }
            else
            {
                //con="%"+ConvertString.InputText(Request.QueryString["Q_Note"])+"%";
                SqlConnection sqlConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["DBConnection"]);
                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").Value = con;

                DataSet returns = new DataSet();
                sqlAdapter1.Fill(returns);
                this.DataList1.DataSource = returns.Tables[0];
                sqlConnection.Close();
            }
			this.Page.DataBind();		
		}

		protected 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()
		{    

		}
		#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 + -