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 SqlStr = "select  * from 订购单";
            SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
            con.Open();
            DataSet ds = new DataSet();
            ada.Fill(ds,"订购单");
            GridView1.DataSource = ds;
            GridView1.DataBind();
            con.Close();
            string SqlStr1 = "select Distinct 职工号 from 订购单 order by 职工号";
            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 SqlStr = "select  * from 订购单 where 职工号 = '" + DropDownList1 .Text + "'";
        SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
        con.Open();
        DataSet ds = new DataSet();
        ada.Fill(ds, "订购单");
        GridView1.DataSource = ds;
        GridView1.DataBind();
        con.Close();
    }
}
