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();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["id"] != null)
            {
                DataSet dt = new DataSet();
                sqlhelper.RunSQL("SELECT * from Grade 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_courseid.Text = dt.Tables[0].Rows[0]["courseid"].ToString();
                this.tbx_coursename.Text = dt.Tables[0].Rows[0]["coursename"].ToString();
                this.tbx_tname.Text = dt.Tables[0].Rows[0]["tname"].ToString();
                this.tbx_score.Text = dt.Tables[0].Rows[0]["grade"].ToString();
            }
            else
            {
            }
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            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("@courseid",SqlDbType.NVarChar,50,this.tbx_courseid.Text),
                sqlhelper.CreateInParam("@coursename",SqlDbType.NVarChar,50,this.tbx_coursename.Text),
                sqlhelper.CreateInParam("@tname",SqlDbType.NVarChar,50,this.tbx_tname.Text),
                sqlhelper.CreateInParam("@grade",SqlDbType.NVarChar,520,this.tbx_score.Text),
         };
            sqlhelper.RunProc("Score_Update", prams);
            Page.ClientScript.RegisterStartupScript(GetType(), "MyScript", "<script>alert('保存成功');window.close();</script>");
        }
        else
        {
        };
    }
}


