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

namespace HteamDd.Web.Web
{
    public partial class Dd_link : System.Web.UI.Page
    {
        public string link_id;
        public string link_title;
        public string link_address;
        public string link_discript;
        public string link_tag;
        public string text_ID;
        public string username;
        public string text;
        public string user_Mes;
        public string link_originID;
        public string userid;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["user_Message"] != null)
                {
                    user_Mes = Session["user_Message"].ToString();
                    if (Request["state"] == "edit")
                    {
                        Session["text_ID"] = Request["ID"].ToString();
                        Session["Name"] = Request["userName"].ToString();
                    }
                    else if (Request["state"] == "reship")
                    {
                        Session["reship_ID"] = Request["ID"].ToString();
                        Session["Name"] = Request["userName"].ToString();
                        Session["UserID"] = Request["UserID"].ToString();
                    }
                    else if (Session["text_ID"] != null)
                    {
                        text_ID = Session["text_ID"].ToString();
                        Get_privateDatas(text_ID);
                        username = Session["Name"].ToString();
                        text = "编辑链接";
                        Session.Remove("text_ID");
                        Session.Remove("Name");
                        Session["link_mark_ID"] = text_ID;
                    }
                    else if (Session["reship_ID"] != null)
                    {
                        text_ID = Session["reship_ID"].ToString();
                        Get_privateDatas(text_ID);
                        username = Session["Name"].ToString();
                        userid = Session["UserID"].ToString();
                        text = "转载链接";
                        Session.Remove("reship_ID");
                        Session.Remove("Name");
                        Session.Remove("UserID");
                    }
                    else
                    {
                        text = "分享链接";
                    }
                }
                else
                {
                    Response.Redirect("/Dd_login.aspx");
                }
            }
        }

        /// <summary>
        /// 根据传值过来的ID查询信息
        /// </summary>
        /// <param name="ID">编辑传值过来的文章ID</param>
        private void Get_privateDatas(string ID)
        {
            string sql = "select Link_Title,Link_Address,Link_Description,Link_Tag,Link_OriginId from Dd_Link where Link_ID=" + ID + "";
            DataSet ds = DotNet.FrameWork.Data.DbHelperSQL.GetDataSet(sql);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                link_title = dr["Link_Title"].ToString();
                link_address = dr["Link_Address"].ToString();
                link_discript = dr["Link_Description"].ToString();
                link_tag = dr["Link_Tag"].ToString();
                link_originID = dr["Link_OriginId"].ToString();
            }
        }
    }
}