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 Teacher_Grade : System.Web.UI.Page
{
    SQLHelper sqlhelper = new SQLHelper();
    Common common = new Common();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            common.BindDropDownList(ref ddl_dept, "select id,dept from Major");
            common.BindDropDownList(ref ddl_major, "select id,major from Major");         
            common.BindDropDownList(ref ddl_course, "select courseid,coursename from Course");
            common.BindDropDownList(ref ddl_student, "select sn,sname from Student where dept='" + this.ddl_dept.SelectedItem.ToString() + "' and major='" + this.ddl_major.SelectedItem.ToString() + "'");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlParameter[] prams ={
                sqlhelper.CreateInParam("@courseid",SqlDbType.NVarChar,50,this.ddl_course.SelectedItem.Value),
                sqlhelper.CreateInParam("@grade",SqlDbType.NVarChar,50,this.TextBox1.Text),
                sqlhelper.CreateInParam("@sn",SqlDbType.NVarChar,50,this.ddl_student.SelectedItem.Value),
                sqlhelper.CreateInParam("@sname",SqlDbType.NVarChar,50,this.ddl_student.SelectedItem.Text),
                sqlhelper.CreateInParam("@coursename",SqlDbType.NVarChar,50,this.ddl_course.SelectedItem.Text),
                sqlhelper.CreateInParam("@tname",SqlDbType.NVarChar,50,Session["tname"].ToString()),
         };
        sqlhelper.RunProc("GradeInsert", prams);
        Page.ClientScript.RegisterStartupScript(GetType(), "MyScript", "<script>alert('保存成功');window.close();</script>");
    }
}
