using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    SqlConnection sqlcon;
    string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)    //首次执行页面时执行如下代码
        {
            sqlcon = new SqlConnection(ConStr);
            string SqlStr = "select * from 员工信息";
            SqlDataAdapter ada = new SqlDataAdapter(SqlStr, sqlcon);
            sqlcon.Open();
            DataSet ds = new DataSet();
            ada.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            sqlcon.Close();
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (DropDownList1.Text == "仓库号")
        {
            sqlcon = new SqlConnection(ConStr);
            sqlcon.Open();
            SqlCommand com = new SqlCommand("delete from 员工信息 where 仓库号='" + TextBox1.Text + "'", sqlcon);
            com.ExecuteNonQuery();
            string SqlStr = "select * from 员工信息";
            SqlDataAdapter ada = new SqlDataAdapter(SqlStr, sqlcon);
            DataSet ds = new DataSet();
            ada.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            sqlcon.Close();
        }
        if (DropDownList1.Text == "性别")
        {
            sqlcon = new SqlConnection(ConStr);
            sqlcon.Open();
            SqlCommand com = new SqlCommand("delete from 员工信息 where 性别='" + TextBox1.Text + "'", sqlcon);
            com.ExecuteNonQuery();
            string SqlStr = "select * from 员工信息";
            SqlDataAdapter ada = new SqlDataAdapter(SqlStr, sqlcon);
            DataSet ds = new DataSet();
            ada.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            sqlcon.Close();
        }
        if (DropDownList1.Text == "工资")
        {
            sqlcon = new SqlConnection(ConStr);
            sqlcon.Open();
            SqlCommand com = new SqlCommand("delete from 员工信息 where 工资 < " + Convert .ToInt32 (TextBox1.Text) , sqlcon);
            com.ExecuteNonQuery();
            string SqlStr = "select * from 员工信息";
            SqlDataAdapter ada = new SqlDataAdapter(SqlStr, sqlcon);
            DataSet ds = new DataSet();
            ada.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            sqlcon.Close();
        }
    }
}
