Exemplo n.º 1
0
 public List<UserAnswer> selectUserPaperList()
 {
     using (SqlConnection con = DBHelp.GetConnection())
     {
         string sql = @"select
     u.UserName,p.PaperName,ua.ExamTime,ua.UserID,ua.PaperID
     from
     Users as u,Paper as p,UserAnswer as ua
     where
     ua.UserID = u.UserID and ua.PaperID = p.PaperID and ua.ExamTime = ua.ExamTime and ua.UserID= ua.UserID and ua.PaperID=ua.PaperID
     Group by
     u.UserName,p.PaperName,ua.ExamTime,ua.UserID,ua.PaperID";
         SqlCommand cmd = new SqlCommand(sql, con);
         con.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         List<UserAnswer> list = new List<UserAnswer>();
         while (dr.Read())
         {
             UserAnswer user = new UserAnswer();
             user.UserID = dr["UserID"].ToString();
             user.PaperID = Convert.ToInt32(dr["PaperID"]);
             user.ExamTime = Convert.ToDateTime(dr["ExamTime"]);
             user.UserName = dr["UserName"].ToString();
             user.PaperName = dr["PaperName"].ToString();
             list.Add(user);
         }
         return list;
     }
 }
Exemplo n.º 2
0
        //��ѯ�û�������Ϣ
        public List<UserAnswer> selectExamInfo(string name)
        {
            using (SqlConnection con = DBHelp.GetConnection())
            {

                string sql = @"select
            UserName,PaperName,Score,ExamTime,JudgeTime
            from
            Score,Paper,Users
            where
            paper.PaperID = Score.PaperID and Users.UserID = Score.UserID and Score.UserID='" + name + "'";
                SqlCommand cmd = new SqlCommand(sql, con);
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                List<UserAnswer> list = new List<UserAnswer>();
                while (dr.Read())
                {
                    UserAnswer user = new UserAnswer();
                    // user.UserID = dr["UserID"].ToString();
                    user.UserName = dr["UserName"].ToString();
                    user.ExamTime = Convert.ToDateTime(dr["ExamTime"]);
                    // user.UserName = dr["UserName"].ToString();
                    user.PaperName = dr["PaperName"].ToString();
                    user.Score = Convert.ToInt32(dr["Score"]);
                    user.JudgeTime = Convert.ToDateTime(dr["JudgeTime"]);
                    list.Add(user);

                }
                return list;
            }
        }