代码拉取完成,页面将自动刷新
using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using cn.edu.jnmc.pb;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
public int userCounter;
private ArrayList articleList;
private const int ARTICLE_NUM = 6;
private string[] articleTitles;
private OleDbConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
conn = DatabaseService.DBopen();
initList();
bindResultData();
}
}
private void bindResultData()
{
articleList = new ArrayList();
string resultSql = "select article_id, avg(student_score) as s_score, avg(teacher_score) as t_score from article_score group by article_id";
OleDbDataReader reader = DatabaseService.excuteQuerySQLOnline(resultSql, conn);
if (reader.HasRows)
{
int i = 0;
while (reader.Read())
{
Article article = new Article();
article.Name = articleTitles[i];
article.Id = int.Parse(reader["article_id"].ToString());
article.TeacherScore = double.Parse(reader["t_score"].ToString());
article.StudentScore = double.Parse(reader["s_score"].ToString());
i++;
articleList.Add(article);
}
}
else
{
for (int i = 0; i < ARTICLE_NUM; i++)
{
Article article = new Article();
article.Name = articleTitles[i];
article.Id = i+1;
article.TeacherScore =0;
article.StudentScore = 0;
articleList.Add(article);
}
}
reader.Close();
ResultRepeater.DataSource = articleList;
ResultRepeater.DataBind();
}
private void initList()
{
string countSql = "select count(*) as count_num from article_score where article_id=1";
articleTitles = new string[ARTICLE_NUM]
{
"GSZ 英语翻译竞赛参评译文",
"GZG 英语翻译竞赛参评译文",
"LLM 英语翻译竞赛参评译文",
"LXM 英语翻译竞赛参评译文",
"LYF 英语翻译竞赛参评译文",
"XS 英语翻译竞赛参评译文"
};
OleDbDataReader reader = DatabaseService.excuteQuerySQLOnline(countSql, conn);
if (reader.HasRows)
{
while (reader.Read())
{
userCounter = int.Parse(reader["count_num"].ToString());
}
}
reader.Close();
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。