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 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";
            SqlConnection con = new SqlConnection(ConStr);
            string SqlStr1 = "select Distinct 城市 from 仓库 ";
            SqlDataAdapter ada1 = new SqlDataAdapter(SqlStr1, con);
            con.Open();
            DataSet ds1 = new DataSet();
            ada1.Fill(ds1, "仓库");
            DropDownList1.DataSource = ds1.Tables["仓库"];
            DropDownList1.DataTextField = "城市";
            DropDownList1.DataBind();
            con.Close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";
        SqlConnection con = new SqlConnection(ConStr);
        string SqlStr1 = "select * from 仓库  where 城市 = '" +  DropDownList1 .Text  + "'";
        SqlDataAdapter ada1 = new SqlDataAdapter(SqlStr1, con);
        con.Open();
        DataSet ds1 = new DataSet();
        ada1.Fill(ds1, "仓库");
        GridView1.DataSource = ds1;
        GridView1.DataBind();
        con.Close();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";
        SqlConnection con = new SqlConnection(ConStr);
        string SqlStr1 = "select * from 职工 where  仓库号  in ( select 仓库号 from 仓库  where 城市 = '" + DropDownList1.Text + "')";
        SqlDataAdapter ada1 = new SqlDataAdapter(SqlStr1, con);
        con.Open();
        DataSet ds1 = new DataSet();
        ada1.Fill(ds1, "职工");
        GridView1.DataSource = ds1;
        GridView1.DataBind();
        con.Close();
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";
        SqlConnection con = new SqlConnection(ConStr);
        string SqlStr1 = "select *  from  订购单  where  职工号  in ( select 职工号 from 职工 where  仓库号  in ( select 仓库号 from 仓库  where 城市 = '" + DropDownList1.Text + "'))";
        SqlDataAdapter ada1 = new SqlDataAdapter(SqlStr1, con);
        con.Open();
        DataSet ds1 = new DataSet();
        ada1.Fill(ds1, "订购单");
        GridView1.DataSource = ds1;
        GridView1.DataBind();
        con.Close();
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";
        SqlConnection con = new SqlConnection(ConStr);
        string SqlStr1 = "select *  from  供应商  where  供应商号  in ( select 供应商号 from 订购单  where  职工号  in  ( select 职工号  from  职工  where  仓库号  in ( select 仓库号 from 仓库  where 城市 = '" + DropDownList1.Text + "')))";
        SqlDataAdapter ada1 = new SqlDataAdapter(SqlStr1, con);
        con.Open();
        DataSet ds1 = new DataSet();
        ada1.Fill(ds1, "供应商");
        GridView1.DataSource = ds1;
        GridView1.DataBind();
        con.Close();
    }
}
