using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using EnterpriseNET.BusinessLogicLayer;

public partial class news_detail : System.Web.UI.Page
{
    public string NewsTitle, SeoTitle, SeoKeywords, SeoDesc, NewsContent, AddTime;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                int newsID = -1;
                string strSql = "";
                if (Request.QueryString["NewsID"] != "")
                    newsID = Convert.ToInt32(Request.QueryString["NewsID"]);

                News news = new News();
                news.LoadData(newsID);

                if (news.exist)
                {
                    //显示新闻信息详细内容
                    NewsTitle = news.newsTitle;
                    SeoTitle = news.seoTitle;
                    SeoKeywords = news.seoKeywords;
                    SeoDesc = news.seoDesc;
                    NewsContent = news.newsContent;
                    AddTime = news.addTime.ToString();

                    //上一条
                    strSql = "select top 1 NewsID,ClassID,NewsTitle from cai_News where NewsID<" + newsID + " order by NewsID desc";
                    DataView dvlist_N = News.QueryNews(strSql);
                    if (dvlist_N.Count > 0)
                    {
                        this.pre_p.Text = "<a href=news_detail-" + dvlist_N.Table.Rows[0][0].ToString() + ".html>" + dvlist_N.Table.Rows[0][2].ToString() + "</a>";
                    }
                    else
                    {
                        this.pre_p.Text = "<a href=news__1.html>[" + "资讯中心" + "]</a>";
                    }

                    //下一条
                    strSql = "select top 1 NewsID,ClassID,NewsTitle from cai_News where NewsID>" + newsID + " order by NewsID";
                    DataView dvlist_N2 = Product2.QueryProducts(strSql);
                    if (dvlist_N2.Count > 0)
                    {
                        this.next_p.Text = "<a href=news_detail-" + dvlist_N2.Table.Rows[0][0].ToString() + ".html>" + dvlist_N2.Table.Rows[0][2].ToString() + "</a>";
                    }
                    else
                    {
                        this.next_p.Text = "<a href=news__1.html>[" + "资讯中心" + "]</a>";
                    }

                    Page.DataBind();
                }
                else
                {
                    Response.Write("数据不存在.");
                    Response.End();
                }
            }
            catch
            {
                Response.Write("发生错误.");
                Response.End();
            }
        }
    }
}
