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 JuSNS.Model;
using JuSNS.UI.Control;

namespace JuSNS.Web.system.user
{
    public partial class UserFav : JuSNS.UI.Page.ManagePage
    {
        JuSNS.Home.Space sp = new JuSNS.Home.Space();
        JuSNS.Home.User us = new JuSNS.Home.User();
        protected string sort = "user";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.txtUserID.Value = Request.QueryString["r"];
                getFavInfo(int.Parse(this.txtUserID.Value));
            }
        }

        #region 读取会员爱好信息
        public void getFavInfo(int UserId)
        {
            JuSNS.Model.UserBasicInfo info = us.GetUserBasic(UserId);
            this.Favourite.Value = info.Favourite;
            this.FavMusics.Value = info.FavMusics;
            this.FavSports.Value = info.FavSports;
            this.FavMovies.Value = info.FavMovies;
            this.FavGames.Value = info.FavGames;
            this.FavCartoons.Value = info.FavCartoons;
            this.FavBooks.Value = info.FavBooks;
            this.FavAdages.Value = info.FavAdages;
            this.AppreciateMen.Value = info.AppreciateMen;
            this.Presetation.Value = info.Presetation;
        }
        #endregion

        #region 修改会员爱好信息
        protected void Button1_Click(object sender, EventArgs e)
        {
            UserBasicInfo uf = new UserBasicInfo();

            uf.UserID = int.Parse(this.txtUserID.Value);
            uf.Favourite = this.Favourite.Value;
            uf.FavMusics = this.FavMusics.Value;
            uf.FavSports = this.FavSports.Value;
            uf.FavMovies = this.FavMovies.Value;
            uf.FavGames = this.FavGames.Value;
            uf.FavCartoons = this.FavCartoons.Value;
            uf.FavBooks = this.FavBooks.Value;
            uf.FavAdages = this.FavAdages.Value;
            uf.AppreciateMen = this.AppreciateMen.Value;
            uf.Presetation = this.Presetation.Value;

            if (sp.UpdateUserInfo(uf, int.Parse(this.txtUserID.Value), 3) == 1)
            {
                Response.Redirect("userFav.aspx?r=" + this.txtUserID.Value + "");
            }
            else
            {
                PageError("修改会员爱好信息失败!", "userFav.aspx");
            }
        }
        #endregion
    }
}
