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;

public partial class Member_Register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AjaxPro.Utility.RegisterTypeForAjax(typeof(AjaxServer.Validate_Name));
        Title = "用户注册";
    }
    /// <summary>
    /// 注册新用户
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void registBt_Click(object sender, EventArgs e)
    {
        string inputname = Request["inputname"].Trim();
        BLL.UserInfo user = new BLL.UserInfo();
        if (user.IsExist(inputname) == false)
        {
            int result = user.createUser(inputname, this.passwordTb.Text.Trim(), 1, this.emailTb.Text.Trim(), this.questionTb.Text.Trim(), this.answerTb.Text.Trim());

            if (result == 1)
            {
                Response.Write("<script>alert('注册成功,请登录');location.href='Default.aspx';</script>");
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('新用户注册失败!请填好资料在尝试!')</script>", false);
            }
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('用户已存在,请换个用户名!')</script>", false);
        }
    }
}
