コード例 #1
0
    private void showtotal()
    {
        string cidSelect = DDLCid.SelectedValue;

        if (!string.IsNullOrEmpty(cidSelect))
        {
            DateTime dt1               = DateTime.Now;
            int      Sgrade            = Int32.Parse(Request.QueryString["wGrade"].ToString());
            int      Sclass            = Int32.Parse(Request.QueryString["wClass"].ToString());
            int      Cid               = Int32.Parse(cidSelect);
            LearnSite.BLL.Courses cbll = new LearnSite.BLL.Courses();
            string    Ctitle           = cbll.GetTitle(Cid);
            DataTable dt               = cbll.CourseTotals(Cid, Sgrade, Sclass);
            string    clm              = RBsort.SelectedValue;
            if (dt.Columns.Contains("汇总"))
            {
                if (clm == "汇总")
                {
                    dt.DefaultView.Sort = clm + " desc";
                }
                else
                {
                    dt.DefaultView.Sort = clm + " asc";
                }
            }
            else
            {
                dt.DefaultView.Sort = " 学号 asc";
            }
            GridViewclass.DataSource = dt.DefaultView.ToTable();
            GridViewclass.DataBind();

            LearnSite.BLL.Students sbll = new LearnSite.BLL.Students();
            DataTable dtg = sbll.groupscores(Sgrade, Sclass, dt, Cid);
            string    sl  = RBsortGroup.SelectedValue;
            switch (sl)
            {
            case "0":
                break;    //默认排序

            case "1":
                dtg.DefaultView.Sort = "Sgscore desc,Svscore desc";
                break;

            case "2":
                dtg.DefaultView.Sort = "Svscore desc,Sgscore desc";
                break;

            case "3":
                dtg.DefaultView.Sort = "Sgwork desc,Svscore desc,Sgscore desc";
                break;

            case "4":
                dtg.DefaultView.Sort = "Sgattitude desc,Sgwork desc,Svscore desc,Sgscore desc";
                break;    //Sgattitude
            }
            DataList1.DataSource = dtg.DefaultView.ToTable();
            DataList1.DataBind();
            if (DataList1.Items.Count == 0)
            {
                RBsortGroup.Visible = false;
            }
            dtg.Dispose();
            dt.Dispose();//强制释放
            DateTime dt2 = DateTime.Now;
            Labelmsg.Text = "汇总费时:" + LearnSite.Common.Computer.DatagoneMilliseconds(dt1, dt2) + "毫秒";

            this.Page.Title = LabelGradeClass.Text + "《" + DDLCid.SelectedItem.Text + "》学习汇总";
        }
    }