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_video : System.Web.UI.Page
    {
        public string video_id;
        public string video_address;
        public string video_descript;
        public string video_tag;
        public string video_img;
        public string video_edit = "1";
        public string text;
        public string username;
        public string text_ID;
        public string user_Mes;
        public string userid;
        public string video_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.Clear();
                        Session["video_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 Video_Address,Video_Radiourl,Video_Imageurl,Video_Description,Video_Tag,Video_OriginId from Dd_Video where Video_ID=" + ID + "";
            DataSet ds = DotNet.FrameWork.Data.DbHelperSQL.GetDataSet(sql);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                video_address = dr["Video_Address"].ToString();
                video_descript = dr["Video_Description"].ToString();
                video_tag = dr["Video_Tag"].ToString();
                video_img = dr["Video_Imageurl"].ToString();
                video_originID = dr["Video_OriginId"].ToString();
            }
        }
    }
}