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 TopWinCMS.BLL;
using TopWinCMS.Model;
using TopWinCMS.Common;
public partial class Admin_Member_Member_Edit : System.Web.UI.Page
{
    MemberManage MyClassBLL = new MemberManage();
    MemberInfo model = new MemberInfo();
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            RightsCheck.CheckWorkPower("MM_4");
            Edit_Load();
        }

    }
    private void Edit_Load()
    {
        new MemberRoleManage().BindDropDownList(DDL_MemberRoleID);

        model = MyClassBLL.EditLoad(Request["ID"]);
        path.InnerHtml = Config.SiteName + " → <a href=\"Member.aspx\">会员中心</a> → " + model.Name + " → 修改信息";
       
        LB_Name.Text = model.Name;
        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;

        NTB_Coin.Text = model.Coin.ToString();
        NTB_Point.Text = model.Point.ToString();
        DDL_ActiveType.SelectedValue = model.ActiveType.ToString();
        CD_Mature.Value = model.Mature.ToString();
        NTB_Experience.Text = model.Experience.ToString();
        DDL_MemberRoleID.SelectedValue = model.MemberRoleID.ToString();
 
        RBL_IsLocked.SelectedValue = model.IsLocked.ToString();
    }
    protected void BT_OK_Click(object sender, EventArgs e)
    {
        model.ID = int.Parse(Request["ID"]);
        model.Name = LB_Name.Text;

        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 = TB_Province.Text.Trim();
        //model.City = TB_City.Text.Trim();
        model.ICQ = TB_ICQ.Text.Trim();
        model.Yahoo = TB_Yahoo.Text.Trim();
        model.Skype = TB_Skype.Text.Trim();
        model.Location = "";
        model.IdCard = TB_IdCard.Text.Trim();
        model.Mobile = TB_Mobile.Text.Trim();
        model.Phone = TB_Phone.Text.Trim();
        model.Address = TB_Address.Text.Trim();

        model.Coin = int.Parse(NTB_Coin.Text);
        model.Point = int.Parse(NTB_Point.Text);
        model.Mature = DateTime.Parse(CD_Mature.Value);
        model.Experience = int.Parse(NTB_Experience.Text);
        model.MemberRoleID = int.Parse(DDL_MemberRoleID.SelectedValue);
        model.ActiveType = int.Parse(DDL_ActiveType.SelectedValue);
        model.ActiveBBS = true;
        model.ActiveBlog = true;
        model.IsLocked = Convert.ToInt16(RBL_IsLocked.SelectedValue);
        string strErr = null;

        new Public_Member(false).Add(model, ref  strErr);

        if (string.IsNullOrEmpty(strErr) == false)
        {
            MsgBox.Alert(strErr, this);
        }
    }
}