﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WorkManagement
{
    public partial class PageRegister : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            PassWord.Attributes.Add("onfocus", "if (this.value=='Password') this.value=''");
            PassWord.Attributes.Add("onblur", "if (this.value=='') this.value='Password'");
            EmailAddress.Attributes.Add("onfocus", "if (this.value=='Email Address') this.value=''");
            EmailAddress.Attributes.Add("onblur", "if (this.value=='') this.value='Email Address'");
            LoginName.Attributes.Add("onfocus", "if (this.value=='Login Name') this.value=''");
            LoginName.Attributes.Add("onblur", "if (this.value=='') this.value='Login Name'");
        }

        protected void Submit_Click(object sender, EventArgs e)
        {
            MODEL.ModelSysUser newUser = new MODEL.ModelSysUser();
            newUser.LoginName = LoginName.Text;
            newUser.Password = PassWord.Text;
            newUser.Email = EmailAddress.Text;
            int state = BLL.BLLSysUser.NewUserRegister(newUser);
            if (state == 0)
            {
                Response.Write("<script languge='javascript'>alert('成功登陆');</script>");
            }
            else if (state == -1)
            {
                Response.Write("<script languge='javascript'>alert('用户名已经存在');</script>");
            }
            else
            {

            }
        }
    }
}