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)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (DropDownList1.Text == "职工号")
        {
            string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";
            SqlConnection con = new SqlConnection(ConStr);
            string SqlStr = "select  职工号, max(金额) as 最大金额 , min(金额) as 最小金额 , sum(金额) as 金额总和 ,avg(金额) as 平均金额 , count(*) as 订单次数 from 订购单 group by 职工号";
            SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
            con.Open();
            DataSet ds = new DataSet();
            ada.Fill(ds, "订购单");
            GridView1.DataSource = ds;
            GridView1.DataBind();
            con.Close();
        }
        else
        {
            string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";
            SqlConnection con = new SqlConnection(ConStr);
            string SqlStr = "select  供应商号, max(金额) as 最大金额 , min(金额) as 最小金额 , sum(金额) as 金额总和 ,avg(金额) as 平均金额 , count(*) as 订单次数 from 订购单 group by 供应商号";
            SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
            con.Open();
            DataSet ds = new DataSet();
            ada.Fill(ds, "订购单");
            GridView1.DataSource = ds;
            GridView1.DataBind();
            con.Close();
        }
    }
}
