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

📄 homebadlist.aspx.cs

📁 学生寝室管理系统
💻 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 homebadlist : System.Web.UI.Page
{
    SqlCommand cmd, cmd1, cmd2;
    SqlConnection cn;
    SqlDataReader dr, dr1;
    SqlDataAdapter da, da1, da2, da3, da4, dr5;
    DataSet ds = new DataSet();
    DataSet ds1 = new DataSet();
    DataSet ds3 = new DataSet();
    DataSet ds4 = new DataSet();
    string strcon, strsql, strsql1, strsql2, strsql3, strsql4, strsql5;
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!this.IsPostBack)
        {
            this.databindlist();
        }
    }
    private void databindlist()
    {

        cn = sqldata.createcon();
        cn.Open();
        strsql = "select * from homebad";
        da = new SqlDataAdapter(strsql, cn);
        da.Fill(ds, "home");
        this.mydatagrid.DataKeyField = "id";
        this.mydatagrid.DataSource = ds.Tables["home"].DefaultView;
        this.mydatagrid.DataBind();
    }
 
    protected void mydatagrid4_SelectedIndexChanged(object sender, EventArgs e)
    {
    
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        
        if (this.IsValid)
        {
            this.Panel2.Visible = false;
            if (this.DropDownList1.Text == "几栋")
            {

                cn = sqldata.createcon();
                cn.Open();
                strsql1 = "select * from homebad where homeflood='" + this.txtcontent.Text.ToString() + "'";
                da1 = new SqlDataAdapter(strsql1, cn);
                da1.Fill(ds1);
                this.mydatagrid4.DataSource = ds1.Tables[(0)].DefaultView;
                this.mydatagrid4.DataBind();
                if (this.mydatagrid4.Items.Count == 0)
                {
                    this.Panel1.Visible = false;
                   
                    this.labmessage.Text = "对不起?要找的" + this.txtcontent.Text.ToString() + "内容还没有找到";
                    this.HyperLink1.Visible = true;
                }
                else
                {
                    this.Panel1.Visible = true;
                    this.HyperLink1.Visible = true;
                    this.labmessage.Text = "恭喜!要找的" + this.txtcontent.Text.ToString() + "内容找到了"; ;
                }
            }
            else if (this.DropDownList1.Text == "几号")
            {

                cn = sqldata.createcon();
                cn.Open();
                strsql = "select *from homebad where homehao='" + this.txtcontent.Text.ToString() + "' ";
                da = new SqlDataAdapter(strsql, cn);
                da.Fill(ds);
                this.mydatagrid4.DataSource = ds.Tables[(0)].DefaultView;
                this.mydatagrid4.DataBind();
                if (this.mydatagrid4.Items.Count == 0)
                {
                    this.Panel1.Visible = false;
                    this.labmessage.Text = "对不起?要找的" + this.txtcontent.Text.ToString() + "内容还没有找到";
                    this.HyperLink1.Visible = true;
                }
                else
                {
                    this.Panel1.Visible = true;
                    this.HyperLink1.Visible = true;
                    this.labmessage.Text = "恭喜!要找的" + this.txtcontent.Text.ToString() + "内容找到了"; ;
                }
            }
            else if (this.DropDownList1.Text == "通过审核")
            {
                string shenhe = "是";
                cn = sqldata.createcon();
                cn.Open();
                strsql3 = "select*from homebad where shenhe='" + this.txtcontent.Text.ToString() + "'";
                da3 = new SqlDataAdapter(strsql3, cn);
                da3.Fill(ds3);
                this.mydatagrid4.DataSource = ds3.Tables[(0)].DefaultView;
                this.mydatagrid4.DataBind();
                if (this.mydatagrid4.Items.Count == 0)
                {
                    this.Panel1.Visible = false;
                    this.labmessage.Text = "对不起?要找的" + this.txtcontent.Text.ToString() + "内容还没有找到";
                    this.HyperLink1.Visible = true;
                }
                else
                {
                    this.Panel1.Visible = true;
                    this.HyperLink1.Visible = true;
                    this.labmessage.Text = "恭喜!要找的" + this.txtcontent.Text.ToString() + "内容找到了"; ;
                }
            }
            else
            {
                string shenhe = " 否";
                cn = sqldata.createcon();
                cn.Open();
                strsql4 = "select*from homebad where shenhe='" + this.txtcontent.Text.ToString() + "'";
                da4 = new SqlDataAdapter(strsql4, cn);
                da4.Fill(ds4);
                this.mydatagrid4.DataSource = ds4.Tables[(0)].DefaultView;
                this.mydatagrid4.DataBind();
                if (this.mydatagrid4.Items.Count == 0)
                {
                    this.Panel1.Visible = false;
                    this.labmessage.Text = "对不起?要找的" + this.txtcontent.Text.ToString() + "内容还没有找到";
                    this.HyperLink1.Visible = true;
                }
                else
                {
                    this.Panel1.Visible = true;
                    this.HyperLink1.Visible = true;
                    this.labmessage.Text = "恭喜!要找的" + this.txtcontent.Text.ToString() + "内容找到了"; ;
                }
            }
        }
    }
    protected void mydatagrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
        this.mydatagrid.CurrentPageIndex = e.NewPageIndex;
        this.databindlist();
    }
    protected void mydatagrid4_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
        this.mydatagrid4.CurrentPageIndex = e.NewPageIndex;
        this.mydatagrid4.DataBind();
    }
}

⌨️ 快捷键说明

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