using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;
using xabaraCOM;

public partial class help_show : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        sqlServer sql = new sqlServer();
        classify c = new classify();
        xabara x = new xabara();
        javasrcipt js = new javasrcipt();

        if (!IsPostBack)
        {
            string titleTemp = string.Empty;
            long idTemp = xabara.isNum(Request.QueryString["id"]);
            if (idTemp < 1)
            {
                string urlID = Page.RouteData.Values["sID"].ToString();
                urlID = urlID.Replace(".htm", "");
                idTemp = xabara.isNum(urlID);
            }

            DataTable dt = sql.getDataTable("select treeTid,NewTitle,keyWord,NewsAuthor,linkHttp,NewContent,ReadNums,PostDate from NewsXabara where Nid=" + idTemp.ToString());
            if (dt.Rows.Count > 0)
            {
                string[] strValue = new string[1];      //更新点击数
                strValue[0] = (Convert.ToInt32(dt.Rows[0]["ReadNums"]) + 1).ToString();
                sql.update("NewsXabara", "@ReadNums", strValue, "Nid=" + idTemp.ToString());

                if (!string.IsNullOrEmpty(dt.Rows[0]["linkHttp"].ToString() as string)) //直接指向网址
                {
                    Response.Redirect(dt.Rows[0]["linkHttp"].ToString().Trim(), true);
                }
                else
                {
                    titleTemp = dt.Rows[0]["NewTitle"].ToString().Trim();
                    newsTitle.Text = titleTemp;
                    if (!string.IsNullOrEmpty(dt.Rows[0]["NewsAuthor"].ToString() as string))
                    {
                        newsInfo.Text = "作者：" + dt.Rows[0]["NewsAuthor"].ToString().Trim() + "&nbsp;&nbsp;";
                    }
                    newsInfo.Text += "发布时间：" + Convert.ToDateTime(dt.Rows[0]["PostDate"]).ToString("yyyy-MM-dd HH:mm:ss");
                    newsInfo.Text += "&nbsp;&nbsp;阅览数：" + strValue[0];
                    newsContent.Text = dt.Rows[0]["NewContent"].ToString();

                    string getClassStr = c.readClassName_Link(xabara.isNum(dt.Rows[0]["treeTid"].ToString().Trim()), "/article/*.htm", "link14");
                    navClass.Text = "当前位置：<a href='/' target='_top'>首页</a> - <a href='/help/default.htm' target='_top'>帮助中心</a>";
                    if (!string.IsNullOrEmpty(getClassStr as string))
                    {
                        navClass.Text += " - " + getClassStr;
                    }

                    x.webMeta(this.Page, dt.Rows[0]["keyWord"].ToString().Trim() + titleTemp, xml.read("xabara.config", "KeyWord", 180));
                }
            }
            else
            {
                js.div(false, "", "text", "您的操作有误！", 0, 0, "/", "close");
            }
            dt.Dispose();

            Page.Title = titleTemp + "　" + xml.read("xabara.config", "webName", 180) + xml.read("xabara.config", "titleMeta", 180);
        }
    }
}