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 System.Data.SqlClient;

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

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string NSconnection = ConfigurationSettings.AppSettings["strconnection"];
        SqlConnection NSconn = new SqlConnection(NSconnection);
        SqlCommand NScmd = new SqlCommand("insert_NSUser_1", NSconn);
        NScmd.CommandType = CommandType.StoredProcedure;
        NScmd.Parameters.Add(new SqlParameter("@NSDepID", SqlDbType.Int, 10));
        NScmd.Parameters.Add(new SqlParameter("@NSNickName", SqlDbType.VarChar, 50));
        NScmd.Parameters.Add(new SqlParameter("@NSUserName", SqlDbType.VarChar, 50));
        NScmd.Parameters.Add(new SqlParameter("@NSUserPwd", SqlDbType.VarChar, 50));
        NScmd.Parameters.Add(new SqlParameter("@NSNoAdmin", SqlDbType.Int, 4));
        NScmd.Parameters["@NSNickName"].Value = this.txtLoginID.Text.Trim();
        NScmd.Parameters["@NSDepID"].Value = 0;
        NScmd.Parameters["@NSUserName"].Value = this.txtRealName.Text.Trim();
        NScmd.Parameters["@NSUserPwd"].Value = this.txtLoginID.Text.Trim();
        NScmd.Parameters["@NSNoAdmin"].Value = 0;
        NScmd.Connection.Open();
        try
        {
            NScmd.ExecuteNonQuery();
            NScmd.Connection.Close();
            Response.Write("<script>alert('注册成功，点击返回登录！');location.href='index.aspx'</script>");
        }
        catch (SqlException ex)
        {
            Response.Write("<script>alert('注册失败！')</script>");
        }
        NScmd.Connection.Close();
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        this.txtRealName.Text = "";
        this.txtLoginID.Text = "";
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect("index.aspx");
    }
}
