public DataTable ITbSeeArti(string id)
{
string idstr = "";
EBM.DBUtility.DbHelperSQL.ExecuteSql("update tbArticle set arVisitCounts=arVisitCounts+1 where arid=" + id);
string sql = "select arid,artitle,arTitleEn,arUpdatetime,arColumn,arPdfDownCounts,arVisitCounts,arNumber,arPageCount,arPdfUrl,arKeywords,arKeywordsEn,arClassificationNum,arDol,arDocumentMark,arAbstract,arAbstractEn,arMemo,arReferences from tbarticle where arid=" + id;
DataSet ds = EBM.DBUtility.DbHelperSQL.Query(sql);
if (ds.Tables[0].Rows.Count > 0)
{
ds.Tables[0].Columns.Add("author");
ds.Tables[0].Columns.Add("LikeAr");
ds.Tables[0].Columns.Add("work");
foreach (DataRow dr in ds.Tables[0].Rows)
{
//添加作者姓名
DataSet auth = EBM.DBUtility.DbHelperSQL.Query(string.Format("select auid,auname,ausubtitle,auworkunit from tbauthor where auarticleid={0}", dr["arid"]));
if (auth.Tables[0].Rows.Count > 0)
{
int i = 0;
foreach (DataRow _dr in auth.Tables[0].Rows)
{
if (i > 0)
{
dr["author"] += "|";
idstr += ",";
//
}
//dr["work"]+=string.Format("{0}",_dr["auworkunit"]) ;
dr["author"] += string.Format("{0},{1},{2}", _dr["auid"], _dr["auName"], _dr["ausubtitle"]);
idstr += _dr["auid"];
i++;
}
}
else
{
dr["author"]="";
idstr = "0";
//dr["work"] = "";
}
//添加作者工作地点
DataSet dswork = EBM.DBUtility.DbHelperSQL.Query("select distinct auworkunit from tbauthor where auid in(" + idstr + ")");
if (dswork.Tables[0].Rows.Count > 0)
{
int i = 0;
foreach (DataRow drw in dswork.Tables[0].Rows)
{
if (i > 0)
{
dr["work"] += " ";
}
//判断是否为空
dr["work"] +=string.Format("{0}",drw["auworkunit"]) ;
i++;
}
}
else
{
dr["work"] ="";
}
//添加相似文章
DataSet likeAr = EBM.DBUtility.DbHelperSQL.Query(string.Format("select arid,artitle from tbarticle where (arkeywords like '%{0}%' or arkeywordsen like '%{1}%') and arid!={2}", dr["arKeywords"], dr["arkeywordsen"],dr["arid"]));
if (likeAr.Tables[0].Rows.Count > 0)
{
int j = 0;
foreach (DataRow dr_ in likeAr.Tables[0].Rows)
{
if (j > 0)
dr["LikeAr"] += "|";
dr["LikeAr"] += string.Format("{0},{1}", dr_["arid"], dr_["artitle"]);
j++;
}
}
else
{
dr["LikeAr"] ="";
}
}
}
return ds.Tables[0];
}
转载于:https://www.cnblogs.com/sunnysmile/archive/2009/06/10/1500409.html