using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TopWinCMS.Model;
using TopWinCMS.BLL;
using TopWinCMS.Common;
namespace TopWinCMS.WebUI.Member
{
    public partial class Information : TopWinCMS.BLL.PageFactory.Pages.ClientPublicPage
    {
        Public_Member MyClassBLL = new Public_Member(false);
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "资料修改";
            if (!IsPostBack)
            {
                string Err = null;
                MemberInfo model = new MemberManage().GetInfo(MemberLoginInfo.UserName, ref Err);

                if (model != null)
                {
                    TB_HomePage.Text = model.HomePage;
                    TB_QQ.Text = model.QQ;
                    TB_PetName.Text = model.PetName;
                    TB_Introduce.Text = model.Introduce;
                    TB_email.Text = model.eMail;

                    TB_Question.Text = model.Question;
                    TB_Answer.Text = model.Answer;
                    RBL_Sex.SelectedValue = model.Sex.ToString();
                    TB_TrueName.Text = model.TrueName;
                    TB_MSN.Text = model.MSN;
                    TB_Birthday.Text = model.Birthday;
                    //TB_Province.Text = model.Province;
                    //TB_City.Text = model.City;
                    TB_ICQ.Text = model.ICQ;
                    TB_Yahoo.Text = model.Yahoo;
                    TB_Skype.Text = model.Skype;
                    //TB_Location.Text = model.Location;
                    TB_IdCard.Text = model.IdCard;
                    TB_Mobile.Text = model.Mobile;
                    TB_Phone.Text = model.Phone;
                    TB_Address.Text = model.Address;
                }
            }
        }


        protected void BT_Edit_Click(object sender, EventArgs e)
        {
            if (MemberRightsCheck.IsLogined == false)
            {
                MsgBox.Alert("登录超时，请重新登录。", "Login.aspx");
            }
            MemberInfo model = new MemberInfo();

            model.Name = MemberLoginInfo.UserName;

            model.HomePage = TB_HomePage.Text.Trim();
            model.QQ = TB_QQ.Text.Trim();
            model.PetName = TB_PetName.Text.Trim();
            model.Introduce = TB_Introduce.Text.Trim();
            model.eMail = TB_email.Text.Trim();

            model.Question = TB_Question.Text.Trim();
            model.Answer = TB_Answer.Text.Trim();
            model.Sex = int.Parse(RBL_Sex.SelectedValue);
            model.TrueName = TB_TrueName.Text.Trim();
            model.MSN = TB_MSN.Text.Trim();

            model.Birthday = TB_Birthday.Text.Trim();
            model.Province = string.Empty;
            model.City = string.Empty;
            model.ICQ = TB_ICQ.Text.Trim();
            model.Yahoo = TB_Yahoo.Text.Trim();

            model.Skype = TB_Skype.Text.Trim();
            model.Location = string.Empty;
            model.IdCard = TB_IdCard.Text.Trim();
            model.Mobile = TB_Mobile.Text.Trim();
            model.Phone = TB_Phone.Text.Trim();
            model.Address = TB_Address.Text.Trim();

          

            string Err = null;


            MyClassBLL.EditByMemberSelf(model, ref Err);

            if (string.IsNullOrEmpty(Err) == false)
            {
                MsgBox.Alert(Err, UpdatePanel1);
            }
            else
            {
                MsgBox.Alert("修改成功!", UpdatePanel1);
            }
        }
    }
}