//protected void ScoreInitData()//初始化成绩 //{ // Scores score = new Scores(); //创建Scores对象 // DataSet ds = score.QueryUserScore(Session["userID"].ToString()); // if (ds.Tables[0].Rows.Count > 0) // { // GridView1.DataSource = ds; //为GridView控件指名数据源 // GridView1.DataBind(); //绑定数据 // } // else // { // lblScore.Text = "没有成绩!"; // } //} //protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) //{ // GridView1.PageIndex = e.NewPageIndex; // ScoreInitData(); //} //protected void imgBtnModifyPwd_Click1(object sender, ImageClickEventArgs e) //{ // Users user = new Users();//创建Users对象user // user.LoadData(Session["userID"].ToString()); // string txtOldPwdMd5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtOldPwd.Text.Trim(), "MD5").ToString(); // if (user.UserPwd == txtOldPwdMd5)//验证用户输入原密码是否正确 // { // string txtNewPwdMD5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPwd.Text.Trim(), "MD5").ToString(); // user.UserPwd = txtNewPwdMD5; // if (user.ModifyPassword(this.Session["userID"].ToString()))//更改用户密码 // { // lblPwd.Text = "成功修改密码!"; // } // else//修改密码失败 // { // lblPwd.Text = "修改密码失败!"; // } // } // else//原密码错误 // { // lblPwd.Text = "输入原密码错误,请重新输入!"; // } //} //protected void imgBtnReset_Click(object sender, ImageClickEventArgs e) //{ // txtOldPwd.Text = txtNewPwd.Text = txtConfirmPwd.Text = ""; //} protected void ImgStartExam_Click(object sender, ImageClickEventArgs e) { Users user = new Users(); //if (user.IsTest(Session["userID"].ToString().Trim(), Convert.ToInt32(ddlPaper.SelectedValue))) //{ // lblExamMessage.Text = "您已经考试过了,不能再考试!"; //} //else //{ Session["PaperID"] = ddlPaper.SelectedValue; Session["PaperName"] = ddlPaper.SelectedItem.Text; TempExam te = new TempExam(); Paper pp = new Paper(); te.PaperID = Convert.ToInt32(Session["PaperID"]); te.UserID = Session["UserID"].ToString(); pp.GetNeedTime(Convert.ToInt32(Session["PaperID"]));//获取数据库内规定的考试时间 if (te.CheckExist(te.UserID, te.PaperID)) { te.GetBeginTime(te.UserID, te.PaperID); long TimeLeft = pp.needtime - Microsoft.VisualBasic.DateAndTime.DateDiff(DateInterval.Second, te.BeginTime, DateTime.Now, Microsoft.VisualBasic.FirstDayOfWeek.Monday, Microsoft.VisualBasic.FirstWeekOfYear.Jan1);//得到曾经考试的记录时间与当前时间的时间差,以“秒”为单位 if (TimeLeft > 0) { Session["time"] = TimeLeft; } else { Page.RegisterStartupScript("", "<script>alert('你规定的考试时间过了,该卷成绩将取消!')</script>"); te.DeleteTempExam(te.UserID, te.PaperID); BindData(); return; } } else { Session["time"] = pp.needtime; te.SetExamBegin(te.UserID, te.PaperID); } Response.Redirect("UserExam.aspx"); //转向考试界面 //} }
public void PageSubmit() { int paperid = Convert.ToInt32(Session["PaperID"].ToString()); DataBase db = new DataBase(); //取出单选题的每题分值 if (GridView11.Rows.Count > 0) { int singlemark = int.Parse(((Label)GridView11.Rows[0].FindControl("Label4")).Text); foreach (GridViewRow dr in GridView11.Rows) { string str = ""; if (((RadioButton)dr.FindControl("RadioButton1")).Checked) { str = "A"; } else if (((RadioButton)dr.FindControl("RadioButton2")).Checked) { str = "B"; } else if (((RadioButton)dr.FindControl("RadioButton3")).Checked) { str = "C"; } else if (((RadioButton)dr.FindControl("RadioButton4")).Checked) { str = "D"; } int titleid = int.Parse(((Label)dr.FindControl("Label40")).Text); string single = "insert into UserAnswertb(UserID,PaperID,Type,TitleID,Mark,UserAnswer,ExamTime) values('" + Session["userID"].ToString() + "','" + paperid + "','单选题','" + titleid + "','" + singlemark + "','" + str + "','" + DateTime.Now.ToString() + "')"; db.Insert(single); } } //取出多选题每题分值 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"; } int titleid = int.Parse(((Label)dr.FindControl("Label41")).Text); string Multi = "insert into UserAnswertb(UserID,PaperID,Type,TitleID,Mark,UserAnswer,ExamTime) values('" + Session["userID"].ToString() + "','" + paperid + "','多选题','" + titleid + "','" + multimark + "','" + str + "','" + DateTime.Now.ToString() + "')"; db.Insert(Multi); } } //取出判断题每题分值 if (GridView3.Rows.Count > 0) { int judgemark = int.Parse(((Label)GridView3.Rows[0].FindControl("Label12")).Text); foreach (GridViewRow dr in GridView3.Rows)//对判断题每题进行判断用户选择答案 { string str = ""; RadioButton rb5 = (RadioButton)dr.FindControl("RadioButton5"); RadioButton rb6 = (RadioButton)dr.FindControl("RadioButton6"); //CheckBox cbox5 = (CheckBox)dr.FindControl("CheckBox5"); //CheckBox cbox6 = (CheckBox)dr.FindControl("CheckBox6"); if (rb5.Checked) { str = Convert.ToString(true); } if (rb6.Checked) { str = Convert.ToString(false); } int titleid = int.Parse(((Label)dr.FindControl("Label42")).Text); string Judge = "insert into UserAnswertb(UserID,PaperID,Type,TitleID,Mark,UserAnswer,ExamTime) values('" + Session["userID"].ToString() + "','" + paperid + "','判断题','" + titleid + "','" + judgemark + "','" + str + "','" + DateTime.Now.ToString() + "')"; db.Insert(Judge); } } //取出填空题每题分值 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(); int titleid = int.Parse(((Label)dr.FindControl("Label43")).Text); string Fill = "insert into UserAnswertb(UserID,PaperID,Type,TitleID,Mark,UserAnswer,ExamTime) values('" + Session["userID"].ToString() + "','" + paperid + "','填空题','" + titleid + "','" + fillmark + "','" + str + "','" + DateTime.Now.ToString() + "')"; db.Insert(Fill); } } //取出问答题每题分值 if (GridView5.Rows.Count > 0) { int quemark = int.Parse(((Label)GridView5.Rows[0].FindControl("Label37")).Text); foreach (GridViewRow dr in GridView5.Rows) { string str = ""; str = ((TextBox)dr.FindControl("TextBox2")).Text.Trim(); int titleid = int.Parse(((Label)dr.FindControl("Label44")).Text); string Que = "insert into UserAnswertb(UserID,PaperID,Type,TitleID,Mark,UserAnswer,ExamTime) values('" + Session["userID"].ToString() + "','" + paperid + "','问答题','" + titleid + "','" + quemark + "','" + str + "','" + DateTime.Now.ToString() + "')"; db.Insert(Que); } } TempExam te = new TempExam(); te.DeleteTempExam(Session["UserID"].ToString(), Convert.ToInt32(Session["PaperID"])); }