using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Drawing;
using DotNet.FrameWork.Common.Web;

namespace HteamDd.Web.Web
{
    public partial class Dd_picture : System.Web.UI.Page
    {
        public string pic_ID;
        public string pic_addres;
        public string pic_discript;
        public string pic_tag;
        public string pic_edit;
        public string user_name;
        public string userid;
        public string user_Mes;
        public string pic_OriginId;
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["user_Message"] != null)
            {
                user_Mes = Session["user_Message"].ToString();
                if (Request["state"] == "edit")
                {
                    Session["pic_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["pic_ID"] != null)
                {
                    pic_ID = Session["pic_ID"].ToString();
                    Get_privateDatas(pic_ID);
                    user_name = Session["Name"].ToString();
                    pic_edit = "编辑图片";
                    Session.Remove("update");
                    Session.Remove("pic_ID");
                    Session["update"] = pic_addres;
                    Session["image_ID"] = pic_ID;//用来区分是否是编辑
                }
                else if (Session["reship_ID"] != null)
                {
                    pic_ID = Session["reship_ID"].ToString();
                    Get_privateDatas(pic_ID);
                    user_name = Session["Name"].ToString();
                    userid = Session["UserID"].ToString();
                    pic_edit = "转载图片";
                    Session.Remove("update");
                    Session.Remove("pic_ID");
                    Session["update"] = pic_addres;
                    Session["image_ID"] = pic_ID;//用来区分是否是编辑
                }
                else
                {
                    pic_edit = "上传图片";
                }
            }
            else
            {
                Response.Redirect("/Dd_login.aspx");
            }

        }

        /// <summary>
        /// 根据传值过来的ID查询信息
        /// </summary>
        /// <param name="ID">编辑传值过来的图片ID</param>
        private void Get_privateDatas(string ID)
        {
            string sql = " select Picture_Address,Picture_Discription,Picture_Tag,Picture_OriginId from Dd_Picture where Picture_ID=" + ID + "";
            DataSet ds = DotNet.FrameWork.Data.DbHelperSQL.GetDataSet(sql);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                pic_discript = dr["Picture_Discription"].ToString();
                pic_tag = dr["Picture_Tag"].ToString();
                pic_OriginId = dr["Picture_OriginId"].ToString();

                string pic_url = string.Empty;
                string[] Pic_iamges =dr["Picture_Address"].ToString().Split('|');
                for (int i = 0; i < Pic_iamges.Length-2; i++)
                {
                    pic_url += Pic_iamges[i + 1]+"|";
                }
                pic_addres =Pic_iamges[0]+"$"+ pic_url;
            }
        }       
    }
}