using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNet.FrameWork.Utils;
using System.Data;

namespace HteamDd.Web.Web
{
    public partial class Dd_text : System.Web.UI.Page
    {
        public string text_ID;
        public string text_title;
        public string text_content;
        public string text_tag;
        public string text;
        public string username;
        public string userid;
        public string user_Mes;
        public string text_originID;
        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("Name");
                        Session["text_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.Contents.Remove("UserID");
                        Session.Remove("Name");
                    }
                    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 Text_Title,Text_Content,Text_Tag,Text_OriginId from Dd_Text where Text_ID=" + ID + "";
            DataSet ds = DotNet.FrameWork.Data.DbHelperSQL.GetDataSet(sql);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                text_title = dr["Text_Title"].ToString();
                text_content = dr["Text_Content"].ToString();
                text_tag = dr["Text_Tag"].ToString();
                text_originID = dr["Text_OriginId"].ToString();
            }
        }
    }
}