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 Student_StudentReg : System.Web.UI.Page
{
    SQLHelper sqlhelper = new SQLHelper();
    Common common = new Common();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["id"] != null)
            {
                DataSet dt = new DataSet();
                sqlhelper.RunSQL("SELECT * from Student where id='" + Request.QueryString["id"].ToString() + "'", ref dt);

                this.tbx_sn.Text = dt.Tables[0].Rows[0]["sn"].ToString();
                this.tbx_name.Text = dt.Tables[0].Rows[0]["sname"].ToString();
                this.tbx_pwd1.Text = dt.Tables[0].Rows[0]["pwd"].ToString();
                this.tbx_pwd2.Text = dt.Tables[0].Rows[0]["pwd"].ToString();
                this.tbx_major.Text = dt.Tables[0].Rows[0]["major"].ToString();
                this.tbx_dept.Text = dt.Tables[0].Rows[0]["dept"].ToString();
            }
            else
            {
            }
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlParameter[] prams ={
                sqlhelper.CreateInParam("@id",SqlDbType.Int,4,Convert.ToInt32(Request.QueryString["id"])),
                sqlhelper.CreateInParam("@sn",SqlDbType.NVarChar,50,this.tbx_sn.Text),
                sqlhelper.CreateInParam("@sname",SqlDbType.NVarChar,50,this.tbx_name.Text),
                sqlhelper.CreateInParam("@pwd",SqlDbType.NVarChar,20,this.tbx_pwd1.Text),
                sqlhelper.CreateInParam("@major",SqlDbType.NVarChar,50,this.tbx_major.Text),
                sqlhelper.CreateInParam("@dept",SqlDbType.NVarChar,50,this.tbx_dept.Text),
         };
        sqlhelper.RunProc("Student_Update", prams);
        Page.ClientScript.RegisterStartupScript(GetType(), "MyScript", "<script>alert('保存成功');window.close();</script>");
    }
}

