using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Maticsoft.DBUtility;

public partial class Registration : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// 会员注册
    /// </summary>
    public void btnRegistration_Click(object sender, EventArgs e)
    {
        try
        {
            EnCode encode = new EnCode();

            JY.BLL.Member bll = new JY.BLL.Member();
            JY.Model.Member model = new JY.Model.Member();          
            
            
            DataTable dt = bll.GetList(" MemberName='" + txtMemberName.Text.Trim() + "' and isdelete=0").Tables[0];

            if (dt.Rows.Count <= 0)               
            {
                model.MemberName = this.txtMemberName.Text.Trim();
                model.Password = encode.md5(this.txtPassword.Text.Trim());
                model.Email = this.txtEmail.Text.Trim();
                model.Phone = this.txtPhone.Text.Trim();
                model.QQ = this.txtQQ.Text.Trim();
                model.Address = this.txtAddress.Text.Trim();
                model.CreateDate = Convert.ToDateTime(DateTime.Now.ToString());
                model.MemberRankId = 4;
                model.IsDelete = false;               

                
                if (bll.Add(model) > 0)
                {
                    publicHandle.ShowMessage(this.Page, "恭喜您，会员注册成功！", "Login.aspx");
                }
                else
                {
                    publicHandle.ShowMessage(this.Page, "对不起，会员注册失败！", "Registration.aspx");
                }
            }           
            else 
            {
                publicHandle.ShowMessage(this.Page, "对不起，该会员名称已存在，请重新输入！");
            }
        }
        catch (Exception er)
        {
            publicHandle.ShowMessage(this, er.Message);
        }
    }
}
