using System; using System.Data; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using PlugNT.Common; using PlugNT.Cms.Custom; using PlugNT.Cms.Model; using PlugNT.Cms.BLL; using PlugNT.Cms.Page; using PlugNT.Cms.Utility; public partial class _Newsinfo : SitePager { protected int artId = 0; protected string prevlink = ""; protected string nextlink = ""; //资讯模型数据 protected DataRow drInfo = null; protected void Page_Load(object sender, EventArgs e) { //id为1的资讯模型 int sysModelId = 1; //或者根据栏目id调用模型 //int sysModelId = Channel.GetSysModelId(1); int.TryParse(Request["id"] as string, out artId); if (artId==0) { PageHelper.ShowError(this.Context, "参数错误!"); return; } Article bllArticle = new Article(); drInfo = bllArticle.GetDataRow(sysModelId, artId); if (drInfo == null) { PageHelper.ShowError(this.Context, "查看的内容不存在!"); return; } //点击数加1 ArticleInfo info = new ArticleInfo(); info.id = artId; info.SetExtField("hits", Type_Field.integerType, "hits+1"); bllArticle.UpdateData(sysModelId, info); //上一页 string[] arrPrevLink = Article.GetArray(sysModelId, "id,title", " and id<" + artId + " and [channel_id]=" + drInfo["channel_id"].ToString() + " order by id desc"); if (arrPrevLink == null) { prevlink = "没有了"; } else { //获取真实字符数 int lenLink=Utils.GetStringLength(arrPrevLink[1]); string strLink=lenLink>30?Utils.CutLenString(arrPrevLink[1],28)+"...":arrPrevLink[1]; prevlink = string.Format("<a href='/newsinfo.aspx?id={0}' title='{1}'>{2}</a>", arrPrevLink[0], arrPrevLink[1], strLink); } //下一页 string[] arrNextLink = Article.GetArray(sysModelId, "id,title", " and id>" + artId + " and [channel_id]=" + drInfo["channel_id"].ToString() + " order by id asc"); if (arrNextLink == null) { nextlink = "没有了"; } else { //获取真实字符数 int lenLink = Utils.GetStringLength(arrNextLink[1]); string strLink = lenLink > 30 ? Utils.CutLenString(arrNextLink[1], 28) + "..." : arrNextLink[1]; nextlink = string.Format("<a href='/newsinfo.aspx?id={0}' title='{1}'>{2}</a>", arrNextLink[0], arrNextLink[1], strLink); } } }