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;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string connectionString = "Data Source=zf;Initial Catalog=SQL_Data;Integrated Security=True";
        DataClassesDataContext db = new DataClassesDataContext(connectionString);
        var result = from r in db.职工
                     select r;
        if (DropDownList1.Text == "仓库号" && RadioButtonList1.SelectedValue == "升序")
        {
            result = from r in db.职工
                     orderby r.仓库号 ascending
                     select r;
        }
        if (DropDownList1.Text == "仓库号" && RadioButtonList1.SelectedValue == "降序")
        {
            result = from r in db.职工
                     orderby r.仓库号 descending 
                     select r;
        }
        if (DropDownList1.Text == "职工号" && RadioButtonList1.SelectedValue == "升序")
        {
            result = from r in db.职工
                     orderby r.职工号 ascending
                     select r;
        }
        if (DropDownList1.Text == "职工号" && RadioButtonList1.SelectedValue == "降序")
        {
            result = from r in db.职工
                     orderby r.职工号  descending
                     select r;
        }
        if (DropDownList1.Text == "姓名" && RadioButtonList1.SelectedValue == "升序")
        {
            result = from r in db.职工
                     orderby r.姓名 ascending
                     select r;
        }
        if (DropDownList1.Text == "姓名" && RadioButtonList1.SelectedValue == "降序")
        {
            result = from r in db.职工
                     orderby r.姓名 descending
                     select r;
        }
        if (DropDownList1.Text == "性别" && RadioButtonList1.SelectedValue == "升序")
        {
            result = from r in db.职工
                     orderby r.性别 ascending
                     select r;
        }
        if (DropDownList1.Text == "性别" && RadioButtonList1.SelectedValue == "降序")
        {
            result = from r in db.职工
                     orderby r.性别  descending
                     select r;
        }
        if (DropDownList1.Text == "工资" && RadioButtonList1.SelectedValue == "升序")
        {
            result = from r in db.职工
                     orderby r.工资 ascending
                     select r;
        }
        if (DropDownList1.Text == "工资" && RadioButtonList1.SelectedValue == "降序")
        {
            result = from r in db.职工
                     orderby r.工资 descending
                     select r;
        }
        GridView1.DataSource = result;
        GridView1.DataBind();
    }
}
