예제 #1
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        string h_password = Password1.Text.ToString();
        String h_UserID = Request.Cookies["UserID"].Value;
        SqlConnection objconn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
        objconn.Open();

        SqlCommand objcmd = new SqlCommand(" select UsrPassword from UserInfo where UsrID='" + h_UserID + "'", objconn);
        String m = objcmd.ExecuteScalar().ToString();
        m = m.Trim();
        SqlDataReader dr = objcmd.ExecuteReader(CommandBehavior.CloseConnection);
        if (m.Equals(h_password))
        {
            if ((Password2.Text.ToString() != null) && (Password2.Text.ToString().Equals(Password3.Text.ToString())))
            {
                StuExam.StudentExam studentExam = new StuExam.StudentExam();
                string strError = studentExam.EditPassword(h_UserID, Password2.Text.ToString());
                if (strError == "1")
                {
                    Response.Write("<script>alert('修改密码成功,请重新登录!');location='Default.aspx'</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('两次密码不匹配!')</script>");
                return;
            }

        }
        else {
            Response.Write("<script>alert('原密码错误!')</script>");
            return;
        }
    }
예제 #2
0
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     SqlConnection objconn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
     DataSet ds = new DataSet();
     objconn.Open();
     string strTemp = TextBox1.Text;  //需要查寻的数据,从TextBox中读取
     string cmdtext = "select *  from UserInfo WHERE UsrID='" + strTemp + "'";
     SqlCommand sqlcmd = new SqlCommand(cmdtext, objconn);
     int count = Convert.ToInt32(sqlcmd.ExecuteScalar());
     if (count!=0)
     {
         panelAdd.Visible = true;
         Label1.Text = "查看/修改学生信息";
         PanelView.Visible = false;
         TextUsrID.Enabled = false;
         StuExam.StudentExam studentExam = new StuExam.StudentExam();
         StudentDetail myStudent = studentExam.GetStudent(Convert.ToString(TextBox1.Text));
         TextUsrID.Text = TextBox1.Text;
         txtPrivilege.Text = (myStudent.UsrPrivilege).ToString();
         txtName.Text = myStudent.UsrName;
         txtPassword.Text = myStudent.UsrPassword;
         txtClass.Text = myStudent.UsrClass;
         TextDept.Text = myStudent.UsrDept;
     }
     else {
         Response.Write("<script>alert('学号不存在')</script> ");
         return;//当无文件时,返回
     }
 }
예제 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     stuexam = new StudentExam();
 }
예제 #4
0
 //提交试卷,生成成绩
 protected void imgBtnSubmit_Click(object sender, ImageClickEventArgs e)
 {
     int score = 0;
     if (GridView1.Rows.Count > 0)
     {
         int singlemark = int.Parse(((Label)GridView1.Rows[0].FindControl("Label4")).Text);//取出单选题的每题分值
         foreach (GridViewRow dr in GridView1.Rows)//对单选题每题进行判断用户选择答案
         {
             string str = "";
             if (((RadioButton)dr.FindControl("RadioButton1")).Checked == true)
             {
                 str = "A";
             }
             else if (((RadioButton)dr.FindControl("RadioButton2")).Checked == true)
             {
                 str = "B";
             }
             else if (((RadioButton)dr.FindControl("RadioButton3")).Checked == true)
             {
                 str = "C";
             }
             else if (((RadioButton)dr.FindControl("RadioButton4")).Checked == true)
             {
                 str = "D";
             }
             if (((Label)dr.FindControl("Label3")).Text.Trim() == str)//将用户选择结果和答案进行比较
             {
                 score = score + singlemark;
             }
         }
     }
     if (GridView2.Rows.Count > 0)
     {
         int multimark = int.Parse(((Label)GridView2.Rows[0].FindControl("Label8")).Text);//取出多选题每题分值
         foreach (GridViewRow dr in GridView2.Rows)//对多选题每题进行判断用户选择答案
         {
             string str = "";
             if (((CheckBox)dr.FindControl("CheckBox1")).Checked)
             {
                 str += "A";
             }
             if (((CheckBox)dr.FindControl("CheckBox2")).Checked)
             {
                 str += "B";
             }
             if (((CheckBox)dr.FindControl("CheckBox3")).Checked)
             {
                 str += "C";
             }
             if (((CheckBox)dr.FindControl("CheckBox4")).Checked)
             {
                 str += "D";
             }
             if (((Label)dr.FindControl("Label7")).Text.Trim() == str)//将用户选择结果和答案进行比较
             {
                 score = score + multimark;
             }
         }
     }
     if (GridView3.Rows.Count > 0)
     {
         int judgemark = int.Parse(((Label)GridView3.Rows[0].FindControl("Label12")).Text);//取出判断题每题分值
         foreach (GridViewRow dr in GridView3.Rows)//对判断题每题进行判断用户选择答案
         {
             bool j = false;
             if (((CheckBox)dr.FindControl("CheckBox5")).Checked == true)
             {
                 j = true;
             }
             if (j == bool.Parse(((Label)dr.FindControl("Label11")).Text.Trim()))
             {
                 score = score + judgemark;
             }
         }
     }
     if (GridView4.Rows.Count > 0)
     {
         int fillmark = int.Parse(((Label)GridView4.Rows[0].FindControl("Label17")).Text);//取出填空题每题分值
         foreach (GridViewRow dr in GridView4.Rows)
         {
             string str = "";
             str = ((TextBox)dr.FindControl("TextBox1")).Text.Trim();
             if (str == ((Label)dr.FindControl("Label16")).Text.Trim())
             {
                 score = score + fillmark;
             }
         }
     }
     String h_UserID = Request.Cookies["UserID"].Value;
     StudentExam myStudentExam = new StudentExam();
     InitData1();
     string strError = myStudentExam.setSingleScore(h_UserID, score);
     if (strError == "1")
     {
         string userSequence = GetUserSequence();
         stuInfo.alertData(userSequence, Request.Cookies["UserID"].Value);
         stuInfo.finshed(Request.Cookies["UserID"].Value);
         ScriptManager.RegisterStartupScript(this, this.GetType(), "updateScript", "var flag= window.confirm('确认交卷?点击确认后就不能继续答题,请慎重选择!');if(flag||!flag)location.href = 'sendBlank.aspx';", true);
     }
     else Response.Write("<script language=javascript>alert('自动评分失败,请等待老师公布成绩!')</script>");
 }
예제 #5
0
    protected void btn_Submit_Click(object sender, EventArgs e)
    {
        StuExam.StudentExam studentExam = new StuExam.StudentExam();
        if (Label1.Text == "添加学生信息")
        {
            string UserID = TextUsrID.Text.ToString();
            SqlConnection objconn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
            objconn.Open();
            SqlCommand objcmd = new SqlCommand(" select * from UserInfo where UsrID='" + UserID + "'", objconn);
            SqlDataReader dr = objcmd.ExecuteReader(CommandBehavior.CloseConnection);
            if (dr.Read())
            {
                Response.Write("<script>alert('存在学号!')</script>");
            }
            else
            {
                string strError = studentExam.AddStudent(TextUsrID.Text.ToString(), Convert.ToInt32(txtPrivilege.Text.ToString()), txtName.Text.ToString(), txtPassword.Text.ToString(), txtClass.Text.ToString(), TextDept.Text.ToString());

                if (strError == "1")
                {
                    Response.Write("<script>alert('添加学生信息成功!');location='StuInfo.aspx'</script>");
                    GridView1.DataBind();
                }
            }

        }
        else if (Label1.Text == "修改学生信息" || Label1.Text == "查看/修改学生信息")
        {
            string strError = studentExam.EditStudent(GridView1.SelectedDataKey.Value.ToString(), Convert.ToInt32(txtPrivilege.Text.ToString()), txtName.Text.ToString(),txtPassword.Text.ToString(), txtClass.Text.ToString(), TextDept.Text.ToString());
            if (strError == "1")
            {
                Response.Write("<script>alert('修改信息成功!');location='StuInfo.aspx'</script>");
                GridView1.DataBind();

            }
        }
    }
예제 #6
0
 protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
 {
     panelAdd.Visible = true;
     Label1.Text = "修改学生信息";
     PanelView.Visible = false;
     TextUsrID.Enabled = false;
     StuExam.StudentExam studentExam = new StuExam.StudentExam();
     StudentDetail myStudent = studentExam.GetStudent(Convert.ToString(GridView1.SelectedDataKey.Value));
     TextUsrID.Text = GridView1.SelectedDataKey.Value.ToString();
     txtPrivilege.Text = (myStudent.UsrPrivilege).ToString();
     txtName.Text = myStudent.UsrName;
     txtPassword.Text = myStudent.UsrPassword;
     txtClass.Text = myStudent.UsrClass;
     TextDept.Text = myStudent.UsrDept;
 }
예제 #7
0
 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     StudentExam myStudentExam = new StudentExam();
     myStudentExam.getScore(Convert.ToInt32(GridView1.SelectedDataKey.Value));
     GridView2.DataBind();
 }