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 UserBasicPrivacy :JuSNS.UI.Page.ManagePage
    {
        protected string sort = "user";
        JuSNS.Home.Space sp = new JuSNS.Home.Space();
        JuSNS.Home.User us = new JuSNS.Home.User();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.txtUserID.Value = Request.QueryString["r"];
                getPrivacyInfo(int.Parse(this.txtUserID.Value));
            }
        }

        #region 读取会员联系信息可见度
        public void getPrivacyInfo(int UserId)
        {
            JuSNS.Model.UserBasicInfo info = us.GetUserBasic(UserId);
            this.selAddress.Value = info.AddrPrivacy.ToString();
            this.selEmail.Value = info.EmailPrivacy.ToString();
            this.selGTalk.Value = info.GTalkPrivacy.ToString();
            this.selHttp.Value = info.WebSitePrivacy.ToString();
            this.selMobile.Value = info.MobilePrivacy.ToString();
            this.selMSN.Value = info.MSNPrivacy.ToString();
            this.selQQ.Value = info.QQPrivacy.ToString();
            this.selSkype.Value = info.GTalkPrivacy.ToString();
            this.selTel.Value = info.TelPrivacy.ToString();
        }
        #endregion

        #region 修改会员联系信息可见度
        protected void Button1_Click(object sender, EventArgs e)
        {
            UserBasicInfo uf = new UserBasicInfo();

            uf.UserID = int.Parse(this.txtUserID.Value);
            uf.AddrPrivacy = int.Parse(this.selAddress.Value);
            uf.EmailPrivacy = int.Parse(this.selEmail.Value);
            uf.GTalkPrivacy = int.Parse(this.selGTalk.Value);
            uf.WebSitePrivacy = int.Parse(this.selHttp.Value);
            uf.MobilePrivacy = int.Parse(this.selMobile.Value);
            uf.MSNPrivacy = int.Parse(this.selMSN.Value);
            uf.QQPrivacy = int.Parse(this.selQQ.Value);
            uf.GTalkPrivacy = int.Parse(this.selSkype.Value);
            uf.TelPrivacy = int.Parse(this.selTel.Value);
            if (us.UpdateUserPrivacy(uf) == 1)
            {
                Response.Redirect("userbasicPrivacy.aspx?r=" + this.txtUserID.Value + "");
            }
            else
            {
                PageError("修改会员联系信息可见度失败!", "userbasicPrivacy.aspx");
            }
        }
        #endregion
    }
}
