using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using JuSNS.Home;
using JuSNS.Model;
using JuSNS.Common;


namespace JuSNS.Web.home.space
{
    public partial class edit_like : JuSNS.UI.Page.UserPage
    {
        Space sp = new Space();
        public static string GetTiShiDivStr = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["f"] != string.Empty && Request.QueryString["f"] != null)
            {
                GetTiShiDivStr = "<div class=\"tishicss\">您是第一次登陆本系统，请您完善基本资料。以方便未来的朋友认识您！特别是您的头像！</div>";
            }
            else
            {
                GetTiShiDivStr = string.Empty;
            }
            getLXInfo(this.UserID);
            try
            {
                string type = Request.QueryString["Type"];
                if (type == "Edit")
                {
                    Submit();
                }
            }
            catch { }

        }

        #region 读取会员爱好
        public void getLXInfo(int UserId)
        {
            DataTable dtt = sp.getUserInfo(UserId, 11);
            if (dtt != null && dtt.Rows.Count > 0)
            {
                this.Favourite.Value = dtt.Rows[0]["Favourite"].ToString();
                this.FavMusics.Value = dtt.Rows[0]["FavMusics"].ToString();
                this.FavMovies.Value = dtt.Rows[0]["FavMovies"].ToString();
                this.FavCartoons.Value = dtt.Rows[0]["FavCartoons"].ToString();
                this.FavGames.Value = dtt.Rows[0]["FavGames"].ToString();
                this.FavSports.Value = dtt.Rows[0]["FavSports"].ToString();
                this.FavBooks.Value = dtt.Rows[0]["FavBooks"].ToString();
                this.FavAdages.Value = dtt.Rows[0]["FavAdages"].ToString();
                this.AppreciateMen.Value = dtt.Rows[0]["AppreciateMen"].ToString();
                this.Presetation.Value = dtt.Rows[0]["Presentation"].ToString();
            }
            dtt.Clear(); dtt.Dispose();
        }
        #endregion

        //更新会员信息
        public void Submit()
        {
            UserBasicInfo uf = new UserBasicInfo();
            uf.UserID = this.UserID;
            uf.Favourite = Request.QueryString["Favourite"];
            uf.FavMovies = Request.QueryString["FavMovies"];
            uf.FavMusics = Request.QueryString["FavMusics"];
            uf.FavCartoons = Request.QueryString["FavCartoons"];
            uf.FavGames = Request.QueryString["FavGames"];
            uf.FavSports = Request.QueryString["FavSports"];
            uf.FavBooks = Request.QueryString["FavBooks"];
            uf.FavAdages = Request.QueryString["FavAdages"];
            uf.AppreciateMen = Request.QueryString["AppreciateMen"];
            uf.Presetation = Request.QueryString["Presetation"];

            if (sp.UpdateUserInfo(uf, this.UserID, 3) >0)
            {
                Response.Write("修改成功!");
                Response.End();
            }
        }
    }
}
