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 仓库号, 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();
        }
    }
    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 仓库号, max(工资) as 最大工资, min(工资) as 最小工资, sum(工资) as 工资总和 , avg(工资) as 平均工资,count(*) as 职工人数 from 职工 group by 仓库号 having  min(工资) >= " + Convert.ToInt32 (TextBox1 .Text ) + " and  max(工资) <= " + Convert .ToInt32 (TextBox2 .Text );
        SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
        con.Open();
        DataSet ds = new DataSet();
        ada.Fill(ds, "职工");
        GridView1.DataSource = ds;
        GridView1.DataBind();
        con.Close();
    }
}
