protected void queryAvgBt_Click(object sender, EventArgs e) { foreach (ListItem li in RadioButtonList1.Items) { if (li.Selected) { foreach (EntityCour c in list) { if (c.getCname() == li.Value.ToString()) { string avgSql = "select sid, cno, avg(grade) from sc_v" + c.getCno(); //Response.Write(avgSql); DBconnetor conn = new DBconnetor(avgSql); List <EntityBase> avgList = conn.getList(new EntitySC()); EntitySC sc = (EntitySC)avgList.ElementAt(0); this.AvgLable.Text = sc.getGrade().ToString(); string maxSql = "select sid, cno, max(grade) from sc_v" + c.getCno(); //Response.Write(maxSql); DBconnetor conn1 = new DBconnetor(maxSql); List <EntityBase> maxList = conn1.getList(new EntitySC()); sc = (EntitySC)maxList.ElementAt(0); this.MaxLable.Text = sc.getGrade().ToString(); string minSql = "select sid, cno, min(grade) from sc_v" + c.getCno(); //Response.Write(minSql); DBconnetor conn2 = new DBconnetor(minSql); List <EntityBase> minList = conn2.getList(new EntitySC()); sc = (EntitySC)minList.ElementAt(0); this.MinLable.Text = sc.getGrade().ToString(); } } } } }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); Master.FindControl("NavBar").Visible = true; Master.FindControl("AdminBar").Visible = false; string sql = "select c.* from c,sc where sc.cno = c.cno and sid = \"" + Session["ID"] + "\""; DBconnetor conn = new DBconnetor(sql); CList = conn.getList(new EntityCour()); if (CList.Count() == 0) { Response.Write(sql); Response.Write("<script>alert('选课记录为空!')</script>"); } else { if (!IsPostBack) { foreach (EntityCour c in CList) { string s = "select * from sc where cno = \"" + c.getCno() + "\" and sid = \"" + Session["ID"] + "\""; //Response.Write(s); DBconnetor cc = new DBconnetor(s); SClist = cc.getList(new EntitySC()); if (SClist.Count == 0 || SClist == null) { this.BulletedList1.Items.Add(c.getCname() + "\t\t\t\t成绩:\t\t\t\t" + "N/A"); } else { EntitySC sc = (EntitySC)SClist.ElementAt(0); this.BulletedList1.Items.Add(c.getCname() + "\t\t\t\t成绩:\t\t\t\t" + sc.getGrade().ToString()); } } } } }