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.Model;
using TopWinCMS.BLL;
using TopWinCMS.Common;


namespace TopWinCMS.WebUI
{
    public partial class Member_Reg : TopWinCMS.BLL.PageFactory.Pages.ClientPublicPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //TB_Name.Attributes.Add("onblur", "CheckUserName();");
                if (Request["Action"] == null)
                {
                    ZhuCe.Visible = true;
                    CG.Visible = false;
                }
                else
                {
                    ZhuCe.Visible = false;
                    CG.Visible = true;
                }
                if (MemberConfig.IsReg == false)
                {

                    MsgBox.Alert("对不起。管理员已经关闭了会员注册！", "/");
                    BT_Reg.Enabled = false;
                }
            }
        }
        protected void BT_Reg_Click(object sender, EventArgs e)
        {
            if (PostData.PostFormRight() == false)
            {
                Response.Write("来源错误。");

                return;
            }
            MemberInfo model = new MemberInfo();
            model.ID = 0;
            model.Name = TB_Name.Text.Trim();
            model.PSW = TB_PSW1.Text.Trim();
            model.PetName = TB_PetName.Text.Trim();
            model.Question = TB_Question.Text;
            model.Answer = TB_Answer.Text.Trim();
            model.eMail = TB_email.Text.Trim();
            model.Sex =int.Parse( RBL_Sex.SelectedValue);
            model.HomePage = TB_HomePage.Text.Trim();
            model.QQ = TB_QQ.Text.Trim();
            model.Introduce = TB_Introduce.Text.Trim();
            model.PassCode = TB_PassCode.Text.Trim();  
            model.Location = "";
            


            model.TrueName = TB_TrueName.Text.Trim();
            model.MSN = TB_MSN.Text.Trim();
            model.Birthday = TB_Birthday.Text.Trim();
            model.ICQ = TB_ICQ.Text.Trim();
            model.Yahoo = TB_Yahoo.Text.Trim();
            model.Skype = TB_Skype.Text.Trim();
            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 strErr = null;
            new Public_Member(false).RegMember(model, ref strErr);

            if (string.IsNullOrEmpty(strErr) == false)
            {
                MsgBox.Alert(strErr, this);
            }
            else
            {
                HttpContext.Current.Response.Redirect("Reg.aspx?Action=Done");
            }
        }
    }
}