取 照片
2011-03-04 18:00 沐海 阅读(319) 评论(0) 编辑 收藏 举报public void pictureShow()
{
try
{
int i = 0;
string sql1 = "select UserName,RealName,Photo,Memo from TeacherUser where UserName in (select top 6 UserName from TeacherUser order by NewId()) order by UserName ASC";//头像,用户名查询语句 排序需求 双重嵌套 NEWID 是排序 不能和 ASC 一起
DataTable dt1 = DBUtility.DbHelperSQL.Query(sql1).Tables[0];
string sqlParameter = string.Empty;
for (int r = 0; r < dt1.Rows.Count;r++ ) {
sqlParameter=sqlParameter+"'"+dt1.Rows[r][0]+"'"+",";
}
sqlParameter = sqlParameter.Substring(0, sqlParameter.Length - 1);
string sql2 = "select distinct UserName,SubjectId from R_TeacherSubject where UserName in (" + sqlParameter + ")";//科目信息查询语句
DataTable dt2 = DBUtility.DbHelperSQL.Query(sql2).Tables[0];
string sql3 = "select Id,Caption from D_Subject";
DataTable dt3 = DBUtility.DbHelperSQL.Query(sql3).Tables[0];
picture.InnerHtml = "";
string[] SubCollect = new string[6];
for (i = 0; i < 6; i++)
{
SubCollect[i] = "";
string[] Split = dt2.Rows[i]["SubjectId"].ToString().Split(new char[] { ',' });
for (int k = 0; k < dt3.Rows.Count; k++)
{
for (int j = 0; j <Split.Length; j++)
{
if (j == 2) { break; }
if (dt3.Rows[k]["Id"].ToString().Equals(Split[j]))
{
SubCollect[i] = SubCollect[i] + dt3.Rows[k]["Caption"].ToString() + ",";
}
}
}
Split = null;
SubCollect[i] = SubCollect[i].ToString().Substring(0, SubCollect[i].ToString().Length - 1);
picture.InnerHtml +=
" <li style='margin-left: 10px;'><a href='DefaultTwo.aspx?operationType=6' style='margin-right: 50px;'><img src='" + dt1.Rows[i]["Photo"].ToString() + "' /></a><p><a href='DefaultTwo.aspx?operationType=6'>" + dt1.Rows[i]["RealName"].ToString() + "</a></p><p>主 讲:<span>" + SubCollect[i] + "</span></p></li>";
}
SubCollect = null;
}
catch
{
}