protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string strExamId = Request.QueryString.Get("id"); ViewState["StudentID"] = Request.QueryString.Get("employeeID"); ViewState["ExamID"] = strExamId; if (strExamId != null && strExamId != "") { RandomExamBLL randomExamBLL = new RandomExamBLL(); RailExam.Model.RandomExam randomExam = randomExamBLL.GetExam(int.Parse(strExamId)); OracleAccess db = new OracleAccess(); string strSql = @"select * from Random_Exam_Result_Answer_Cur where Random_Exam_Result_ID in ( select Random_Exam_Result_ID from Random_Exam_Result_Current where Examinee_ID=" + ViewState["StudentID"] + " and Random_Exam_ID=" + strExamId + ")"; DataSet dsAnswer = db.RunSqlDataSet(strSql); strSql = "select * from Random_Exam_Result_Current where Examinee_ID=" + ViewState["StudentID"] + " and Random_Exam_ID=" + strExamId; DataSet dsCurrent = db.RunSqlDataSet(strSql); if (dsAnswer.Tables[0].Rows.Count == 0 && dsCurrent.Tables[0].Rows.Count > 0) { Response.Write("<script>alert('您的考试试卷生成有误,请联系监考老师删除您的考试试卷后重新生成!'); top.close();</script>"); return; } strSql = "select * from Random_Exam_Computer_Server where Random_Exam_ID=" + ViewState["ExamID"].ToString() + " and Computer_Server_No=" + PrjPub.ServerNo; DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0]; //如果当前考试为手动控制,则需判断考试是否开始 if (randomExam.StartMode == 2 && dr["Is_Start"].ToString() == "0") { Response.Write("<script>alert('该考试还没有开始,请耐心等待!'); top.close();</script>"); return; } if (randomExam.StartMode == 2 && dr["Is_Start"].ToString() == "2") { Response.Write("<script>alert('该考试已经结束!'); top.close();</script>"); return; } RandomExamResultBLL RandomExamResultBLL = new RandomExamResultBLL(); int nowCount; IList <RandomExamResult> RandomExamResults = RandomExamResultBLL.GetRandomExamResultByExamineeID( Convert.ToInt32(Request.QueryString.Get("employeeID")), int.Parse(strExamId)); nowCount = RandomExamResults.Count; if (nowCount > (randomExam.MaxExamTimes - 1)) { Response.Write("<script>alert('您参加考试的次数已经达到考试设定的最大次数!'); top.close();</script>"); return; } RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); RailExam.Model.RandomExamResultCurrent randomExamResult = objResultCurrentBll.GetNowRandomExamResultInfo( Convert.ToInt32(Request.QueryString.Get("employeeID")), Convert.ToInt32(strExamId)); if (randomExamResult.RandomExamResultId == 0) { Response.Write("<script>alert('该考试已经结束!'); top.close();</script>"); return; } } FillPage(); } }
private void BindGrid() { RandomExamResultBLL objResultBll = new RandomExamResultBLL(); IList <RandomExamResult> objResultList = objResultBll.GetRandomExamResultByExamID(Convert.ToInt32(ViewState["ExamID"])); Hashtable htResult = new Hashtable(); foreach (RandomExamResult result in objResultList) { htResult.Add(result.ExamineeId, result.ExamineeName); } DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("RandomExamResultID", typeof(int))); dt.Columns.Add(new DataColumn("ExamineeID", typeof(int))); dt.Columns.Add(new DataColumn("ExamineeName", typeof(string))); dt.Columns.Add(new DataColumn("WorkNo", typeof(string))); dt.Columns.Add(new DataColumn("PostName", typeof(string))); dt.Columns.Add(new DataColumn("OrganizationName", typeof(string))); dt.Columns.Add(new DataColumn("ExamOrgName", typeof(string))); dt.Columns.Add(new DataColumn("Score", typeof(string))); RandomExamArrangeBLL objArrangeBll = new RandomExamArrangeBLL(); IList <RandomExamArrange> objArrangeList = objArrangeBll.GetRandomExamArranges(Convert.ToInt32(ViewState["ExamID"])); if (objArrangeList.Count == 0) { Grid1.DataSource = dt; Grid1.DataBind(); return; } RandomExamArrange objArrange = objArrangeList[0]; string[] str = objArrange.UserIds.Split(','); EmployeeBLL objEmployeeBll = new EmployeeBLL(); for (int i = 0; i < str.Length; i++) { Employee objEmployee = objEmployeeBll.GetEmployee(Convert.ToInt32(str[i])); if (!htResult.ContainsKey(Convert.ToInt32(str[i]))) { DataRow dr = dt.NewRow(); dr["RandomExamResultID"] = 0; dr["ExamineeID"] = Convert.ToInt32(str[i]); dr["ExamineeName"] = objEmployee.EmployeeName; dr["WorkNo"] = objEmployee.WorkNo; dr["PostName"] = objEmployee.PostName; dr["OrganizationName"] = objEmployee.OrgName; dr["ExamOrgName"] = ViewState["ExamOrgName"].ToString(); dr["Score"] = ""; dt.Rows.Add(dr); } else { RandomExamResult objResult = objResultBll.GetRandomExamResultByExamineeID(Convert.ToInt32(str[i]), Convert.ToInt32(ViewState["ExamID"]))[0]; DataRow dr = dt.NewRow(); dr["RandomExamResultID"] = objResult.RandomExamResultId; dr["ExamineeID"] = Convert.ToInt32(str[i]); dr["ExamineeName"] = objResult.ExamineeName; dr["WorkNo"] = objResult.WorkNo; dr["PostName"] = objEmployee.PostName; dr["OrganizationName"] = objEmployee.OrgName; dr["ExamOrgName"] = ViewState["ExamOrgName"].ToString(); dr["Score"] = objResult.Score; dt.Rows.Add(dr); } } Grid1.DataSource = dt; Grid1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack && !Callback1.IsCallback && !ItemAnswerChangeCallBack.IsCallback) { string strExamId = Request.QueryString.Get("id"); ViewState["ExamID"] = strExamId; ViewState["BeginTime"] = DateTime.Now.ToString(); //记录当前考试所在地的OrgID ViewState["OrgID"] = ConfigurationManager.AppSettings["StationID"]; ViewState["EmployeeID"] = Request.QueryString.Get("employeeID"); if (strExamId != null && strExamId != "") { RandomExamBLL randomExamBLL = new RandomExamBLL(); RailExam.Model.RandomExam randomExam = randomExamBLL.GetExam(int.Parse(strExamId)); ViewState["Year"] = randomExam.BeginTime.Year.ToString(); HiddenFieldExamTime.Value = DateTime.Now.AddMinutes(randomExam.ExamTime).ToString(); HfExamTime.Value = (randomExam.ExamTime * 60).ToString(); //获取当前考生最新需要做的考试试卷主表记录 RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); RailExam.Model.RandomExamResultCurrent objResultCurrent = objResultCurrentBll.GetNowRandomExamResultInfo(Convert.ToInt32(ViewState["EmployeeID"].ToString()), Convert.ToInt32(strExamId)); ViewState["LastExamTime"] = objResultCurrent.ExamTime.ToString(); HfExamTime.Value = ((randomExam.ExamTime * 60) - objResultCurrent.ExamTime).ToString(); if (objResultCurrent.ExamTime < 600 && randomExam.ExamTime * 60 > 600) { hfNeed.Value = (600 - objResultCurrent.ExamTime).ToString(); } else { hfNeed.Value = ""; } //获取该考生当前考试次数 RandomExamResultBLL RandomExamResultBLL = new RandomExamResultBLL(); int nowCount; //如果在站段考试为随到随考,需要检测路局异地考试的情况 //if (randomExam.StartMode == PrjPub.START_MODE_NO_CONTROL && !PrjPub.IsServerCenter) //{ // IList<RandomExamResult> RandomExamResultsServer = // RandomExamResultBLL.GetRandomExamResultByExamineeIDFromServer(PrjPub.CurrentStudent.EmployeeID, // int.Parse(strExamId)); // nowCount = RandomExamResultsServer.Count; //} //else //{ // IList<RandomExamResult> RandomExamResults = RandomExamResultBLL.GetRandomExamResultByExamineeID(PrjPub.CurrentStudent.EmployeeID, int.Parse(strExamId)); // nowCount = RandomExamResults.Count; //} //如果是随到随考,需要往回复请求表加入一条记录 //if (randomExam.StartMode == PrjPub.START_MODE_NO_CONTROL) //{ RandomExamApplyBLL objApplyBll = new RandomExamApplyBLL(); RandomExamApply objNowApply = objApplyBll.GetRandomExamApplyByExamResultCurID(objResultCurrent.RandomExamResultId); if (objNowApply.RandomExamApplyID == 0) { RandomExamApply objApply = new RandomExamApply(); objApply.RandomExamID = Convert.ToInt32(strExamId); objApply.RandomExamResultCurID = objResultCurrent.RandomExamResultId; objApply.ApplyStatus = 1; objApply.CodeFlag = true; objApply.IPAddress = Pub.GetRealIP(); objApplyBll.AddRandomExamApply(objApply); } else { objNowApply.IPAddress = Pub.GetRealIP(); objApplyBll.UpdateRandomExamApply(objNowApply); } //} IList <RandomExamResult> RandomExamResults = RandomExamResultBLL.GetRandomExamResultByExamineeID(Convert.ToInt32(ViewState["EmployeeID"].ToString()), int.Parse(strExamId)); nowCount = RandomExamResults.Count; ViewState["NowStartMode"] = randomExam.StartMode.ToString(); HiddenFieldMaxCount.Value = (randomExam.MaxExamTimes - nowCount - 1).ToString(); //更新考试状态 UpdateResultToDB(strExamId); FillPage(strExamId); } } string strAnswer = Request.Form.Get("strreturnAnswer"); if (strAnswer != null && strAnswer != "") { ViewState["EndTime"] = DateTime.Now.ToString(); SaveAnswerToDB(strAnswer); //int examTime = Convert.ToInt32(ViewState["LastExamTime"].ToString()) + //GetSecondBetweenTwoDate(DateTime.Parse(ViewState["EndTime"].ToString()), // DateTime.Parse(ViewState["BeginTime"].ToString())); //ClientScript.RegisterStartupScript(GetType(), "jsHide", "<script>showProgressbar(" + // Request.QueryString.Get("id") + "," + // ViewState["RandomExamResultID"] + "," + // ViewState["EmployeeID"]+ "," + ViewState["OrgID"]+ // ",'" + // ViewState["EndTime"] + "'," + // examTime + ")</script>"); } }