private void SaveAnswerToDB(string strAnswer) { string strId = Request.QueryString.Get("id"); RandomExamItemBLL randomItemBLL = new RandomExamItemBLL(); RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); RailExam.Model.RandomExamResultCurrent objResultCurrent = objResultCurrentBll.GetNowRandomExamResultInfo(Convert.ToInt32(ViewState["EmployeeID"].ToString()), Convert.ToInt32(strId)); //更新考试成绩表时传入的主键应为站段的成绩表的主键ID objResultCurrent.RandomExamResultId = int.Parse(ViewState["RandomExamResultID"].ToString()); objResultCurrent.RandomExamId = int.Parse(strId); objResultCurrent.AutoScore = 0; objResultCurrent.CurrentDateTime = DateTime.Parse(ViewState["EndTime"].ToString()); objResultCurrent.ExamTime = Convert.ToInt32(ViewState["LastExamTime"].ToString()) + GetSecondBetweenTwoDate(DateTime.Parse(ViewState["EndTime"].ToString()), DateTime.Parse(ViewState["BeginTime"].ToString())); objResultCurrent.EndDateTime = DateTime.Parse(ViewState["EndTime"].ToString()); objResultCurrent.Score = 0; objResultCurrent.OrganizationId = int.Parse(ViewState["OrgID"].ToString()); objResultCurrent.Memo = ""; objResultCurrent.StatusId = 2; objResultCurrent.AutoScore = 0; objResultCurrent.CorrectRate = 0; objResultCurrent.ExamineeId = int.Parse(ViewState["EmployeeID"].ToString()); string[] str1 = strAnswer.Split(new char[] { '$' }); RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL(); //randomExamResultAnswerBLL.DeleteExamResultAnswerCurrent(Convert.ToInt32(ViewState["RandomExamResultID"].ToString())); //IList<RandomExamResultAnswerCurrent> randomExamResultAnswers = new List<RandomExamResultAnswerCurrent>(); int randomExamResultId = int.Parse(ViewState["RandomExamResultID"].ToString()); for (int n = 0; n < str1.Length; n++) { string str2 = str1[n].ToString(); string[] str3 = str2.Split(new char[] { '|' }); string strPaperItemId = str3[0].ToString(); string strTrueAnswer = str2.ToString().Substring(strPaperItemId.Length + 1); RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent(); randomExamResultAnswer.RandomExamResultId = randomExamResultId; randomExamResultAnswer.RandomExamItemId = int.Parse(strPaperItemId); randomExamResultAnswer.JudgeStatusId = 0; randomExamResultAnswer.JudgeRemark = string.Empty; randomExamResultAnswer.ExamTime = 0; randomExamResultAnswer.Answer = strTrueAnswer; //randomExamResultAnswers.Add(randomExamResultAnswer); randomExamResultAnswerBLL.UpdateExamResultAnswerCurrent(randomExamResultAnswer); } try { //将更新答卷信息 //randomExamResultAnswerBLL.AddExamResultAnswerCurrentSave(randomExamResultId, randomExamResultAnswers); //更新实时考试记录 objResultCurrentBll.UpdateRandomExamResultCurrent(objResultCurrent); //获取最后考试成绩 //RandomExamResultCurrent randomExamResultCurrent = objResultCurrentBll.GetRandomExamResult(Convert.ToInt32(ViewState["RandomExamResultID"].ToString())); //decimal nowScore = randomExamResultCurrent.Score; //将实时考试记录(临时表)转存到正式考试成绩表和答卷表 RandomExamResultBLL objResultBll = new RandomExamResultBLL(); //int randomExamResultID = objResultBll.RemoveResultAnswer(Convert.ToInt32(ViewState["RandomExamResultID"].ToString())); //将实时考试记录(临时表)转存到中间考试成绩表和答卷表 int randomExamResultID = objResultBll.RemoveResultAnswerCurrent(Convert.ToInt32(ViewState["RandomExamResultID"].ToString())); //删除登录信息 SystemUserLoginBLL objloginBll = new SystemUserLoginBLL(); objloginBll.DeleteSystemUserLogin(Convert.ToInt32(ViewState["EmployeeID"].ToString())); Response.Write("<script>window.parent.parent.location = '/RailExamBao/Online/Exam/ExamSuccess.aspx?ExamType=1&ExamResultID=" + randomExamResultID + "'</script>"); } catch { SystemUserLoginBLL objloginBll = new SystemUserLoginBLL(); objloginBll.DeleteSystemUserLogin(Convert.ToInt32(ViewState["EmployeeID"].ToString())); string strSql = "update Random_Exam_Result_Current set Exam_Time=Exam_Time-180 where Random_Exam_ID=" + strId + " and Examinee_ID=" + ViewState["EmployeeID"]; OracleAccess db = new OracleAccess(); db.ExecuteNonQuery(strSql); Response.Write("<script>window.parent.parent.location = '/RailExamBao/Common/OtherError.aspx?error=提交试卷失败,请重新进入考试再次进行提交'</script>"); } //如果在站段是随到随考考试,成绩自动上传至路局 //if(ViewState["NowStartMode"].ToString() == PrjPub.START_MODE_NO_CONTROL.ToString() && !PrjPub.IsServerCenter) //{ // objResultBll.RemoveRandomExamResultToServer(Convert.ToInt32(strId), Convert.ToInt32(ConfigurationManager.AppSettings["StationID"])); //} }