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

📄 adminhomefloodfind.aspx.cs

📁 一篇vb航空公司管理系统的毕业论文 内容详细
💻 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.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class adminhomefloodfind : System.Web.UI.Page
{
    SqlCommand cmd, cmd1;
    SqlConnection cn;
    SqlDataReader dr;
    SqlDataAdapter da, da1;
    DataSet ds = new DataSet();
    DataSet ds1 = new DataSet();
    string strsql1, strsql2, strsql;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            if (Session["adminname"] == null)
            {
                Response.Redirect("index.aspx");
            }
            else
            {
                cn = sqldata.createcon();
                cn.Open();
                strsql = "select home from homedetail ";
                cmd = new SqlCommand(strsql, cn);
                dr = cmd.ExecuteReader();
                this.DropDownList1.DataSource = dr;
                this.DropDownList1.DataTextField = "home";
                this.DropDownList1.DataBind();
                this.DropDownList1.Items.Add("所有寝室楼");
                this.DropDownList1.SelectedIndex = this.DropDownList1.Items.Count - 1;
                dr.Close();
                cn = sqldata.createcon();
                cn.Open();
                strsql1 = "select * from home";
                da = new SqlDataAdapter(strsql1, cn);
                da.Fill(ds1);
                this.mydatagrid3.DataSource = ds1.Tables[(0)].DefaultView;
                this.mydatagrid3.DataBind();
                cn.Close();
            }
        }
    }
    protected void mydatagrid3_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            e.Item.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#d3d3d3'");
            e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
        }
    }
    protected void mydatagrid3_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
        string flood = this.DropDownList1.SelectedItem.Value.ToString();
        this.mydatagrid3.CurrentPageIndex = e.NewPageIndex;
        cn = sqldata.createcon();
        cn.Open();
        strsql1 = "select * from home ";
        da = new SqlDataAdapter(strsql1, cn);
        da.Fill(ds1);

        if (flood == "所有寝室楼")
        {
            this.mydatagrid3.DataSource = ds1.Tables[(0)].DefaultView;

        }
        else
        {
            DataView ximingds = new DataView(ds1.Tables[0]);
            ximingds.RowFilter = "homeflood='" + flood + "'";
            this.mydatagrid3.DataSource = ximingds;

        }
        this.mydatagrid3.DataBind();
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.mydatagrid3.CurrentPageIndex = 0;
        string flood = this.DropDownList1.SelectedItem.Value.ToString();
      
        cn = sqldata.createcon();
        cn.Open();
        strsql1 = "select * from home ";
        da = new SqlDataAdapter(strsql1, cn);
        da.Fill(ds1);

        if (flood == "所有寝室楼")
        {
            this.mydatagrid3.DataSource = ds1.Tables[(0)].DefaultView;

        }
        else
        {
            DataView ximingds = new DataView(ds1.Tables[0]);
            ximingds.RowFilter = "homeflood='" + flood + "'";
            this.mydatagrid3.DataSource = ximingds;

        }
        this.mydatagrid3.DataBind();
    }
  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -