protected void loginBtn_Click(object sender, EventArgs e)
    {
        int    studentID       = Convert.ToInt32(idTxt.Text);
        string studentPsw      = pswTxt.Text;
        studentTableAdapter ta = new studentTableAdapter();

        if (ta.GetDataBy学生登陆(studentID, studentPsw).Rows.Count == 1)
        {
            Session["StudentID"] = studentID.ToString();
            Response.Redirect("学生主页.aspx");
        }
        else
        {
            Response.Write("<script>alert('用户名或密码错误')</script>");
            //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Startup", "alert('用户名或密码错误!');", true);
        }
    }
Пример #2
0
    protected void btnSlt_Click(object sender, EventArgs e)
    {
        ASPxButton                 btnSlt = (sender as ASPxButton);
        studentTableAdapter        ta     = new studentTableAdapter();
        course_studentTableAdapter tb     = new course_studentTableAdapter();
        int    index   = Convert.ToInt32(btnSlt.CommandArgument);
        int    crsID   = Convert.ToInt32(courseSlt.GetRowValues(index, "课程编号"));
        string crsDate = Convert.ToString(courseSlt.GetRowValues(index, "开课时间"));
        string crsName = Convert.ToString(courseSlt.GetRowValues(index, "课程名"));
        int    stuID   = Convert.ToInt32(Session["StudentID"]);
        string stuName = ta.GetDataBy学生姓名(stuID).Rows[0][2].ToString();

        if (tb.GetDataBy判断(stuID, crsID).Rows.Count != 1)
        {
            tb.InsertQuery选课表(stuID, crsID, stuName, crsName);
            Response.Write("<script>alert('选课成功!')</script>");
        }
        else
        {
            Response.Write("<script>alert('请勿重复选课!')</script>");
        }
        courseSlt.DataBind();
    }