?? yhdacx.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.Data.SqlClient;
using System.Web.UI.HtmlControls;
public partial class main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Session["username"] == null)
Response.Redirect("login.aspx");
else
;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string myConn = System.Configuration.ConfigurationManager.ConnectionStrings["yhdaselect"].ConnectionString;
SqlConnection conn = new SqlConnection(myConn);
try
{
conn.Open();
string x1 = "select * from t_yhda where (0=0)";
string x2 = "select * from t_yhda where (0=0)";
if (CheckBox1.Checked==true)
{
x1 = x1 + "and (F_id='" + TextBox1.Text+"')";
}
if (CheckBox2.Checked == true)
{
x1 = x1 + "and (F_yhxm='" + TextBox2.Text + "')";
}
if (CheckBox3.Checked == true)
{
x1 = x1 + "and (F_glb=" + DropDownList1.SelectedValue + ")";
}
if (CheckBox4.Checked == true)
{
x1 = x1 + "and (F_city=" + DropDownList2.SelectedValue + ")";
}
if (CheckBox5.Checked == true)
{
x1 = x1 + "and (F_wdh='" + TextBox3.Text + "')";
}
if (x1 == x2)
{
Label1.Text = "請選擇查詢條件";
if (conn != null)
conn.Close();
return;
}
SqlDataAdapter sda = new SqlDataAdapter(x1, conn);
DataSet ds = new DataSet();
sda.Fill(ds, "f_yhda");
if(ds.Tables[0].Rows.Count==0)
{
Label1.Text = "無此查詢記錄";
if (conn != null)
conn.Close();
return;
}
Label1.Text = "";
GridView1.DataSourceID = null;
GridView1.DataSource = ds;
GridView1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
if (conn != null)
conn.Close();
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("main.aspx");
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -