protected void btnOK_Click(object sender, EventArgs e)
        {
            string        strId  = Request.QueryString.Get("RandomExamID");
            RandomExamBLL objBll = new RandomExamBLL();

            RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId));

            #region 验证试卷完整性

            /*OracleAccess db = new OracleAccess();
             *
             * //查询本场考试现有生成试卷的总题数(完型填空子题除外)
             *      int beginYear = obj.BeginTime.Year;
             * string strSql =
             * @"select * from Random_Exam_Result_Answer_Cur a
             *          inner join Random_Exam_Item_"+beginYear+@" b on a.Random_Exam_Item_ID=b.Random_Exam_Item_ID
             *          where b.Type_ID<>5 and Random_Exam_Result_ID in (
             *          select Random_Exam_Result_ID from Random_Exam_Result_Current
             *          where Random_Exam_ID=" + strId + ")";
             * DataSet dsAnswer = db.RunSqlDataSet(strSql);
             *
             * //查询本场考试题目个数
             *      strSql = "select Sum(Item_Count) from Random_Exam_Subject where Random_Exam_ID=" + strId;
             * DataSet dsSubject = db.RunSqlDataSet(strSql);
             *      int itemCount = Convert.ToInt32(dsSubject.Tables[0].Rows[0][0]);
             *
             * //查询本服务器所有考生信息
             * strSql = "select a.* from Random_Exam_Arrange_Detail a "
             + " inner join Computer_Room b on a.Computer_Room_ID=b.Computer_Room_ID"
             + " inner join Computer_Server c on c.Computer_server_ID=b.Computer_Server_ID"
             + " where c.Computer_Server_No='" + PrjPub.ServerNo + "' "
             + " and Random_Exam_ID=" + strId;
             + DataSet ds = db.RunSqlDataSet(strSql);
             +      string strChooseID = string.Empty;
             + foreach (DataRow dr in ds.Tables[0].Rows)
             + {
             +  if (string.IsNullOrEmpty(strChooseID))
             +  {
             +      strChooseID += dr["User_Ids"].ToString();
             +  }
             +  else
             +  {
             +      strChooseID += "," + dr["User_Ids"];
             +  }
             + }
             +      int employeeCount = strChooseID.Split(',').Length;
             +
             + if (dsAnswer.Tables[0].Rows.Count != itemCount*employeeCount)
             + {
             +  Response.Write("<script>alert('本场考试试卷生成有误,请联系监考老师删除考试试卷后重新下载后生成!'); top.close();</script>");
             +  return;
             + }*/
            #endregion

            objBll.UpdateStartCode(Convert.ToInt32(strId), PrjPub.ServerNo, txtCode.Text);
            objBll.UpdateIsStart(Convert.ToInt32(strId), PrjPub.ServerNo, 1);

            SystemLogBLL objLogBll = new SystemLogBLL();
            objLogBll.WriteLog("“" + obj.ExamName + "”开始考试");
            Response.Write("<script>top.returnValue='true';top.close();</script>");
        }
Beispiel #2
0
        protected void btnDelPaper_Click(object sender, EventArgs e)
        {
            string strId = Request.QueryString.Get("RandomExamID");

            if (string.IsNullOrEmpty(strId))
            {
                SessionSet.PageMessage = "缺少参数!";
                return;
            }

            //获取当前考试的生成试卷的状态和次数
            RandomExamBLL objBll = new RandomExamBLL();

            RailExam.Model.RandomExam objExam = objBll.GetExam(Convert.ToInt32(strId));

            RandomExamResultCurrentBLL      objResultCurrentBll = new RandomExamResultCurrentBLL();
            IList <RandomExamResultCurrent> objList             = objResultCurrentBll.GetRandomExamResultInfo(Convert.ToInt32(strId));
            int n = 0;

            foreach (RandomExamResultCurrent current in objList)
            {
                if (current.StatusId > 0)
                {
                    n = 1;
                    break;
                }
            }
            if (n > 0)
            {
                SessionSet.PageMessage = "当前考试有考生参加考试,不能再删除试卷!";
                return;
            }

            RandomExamComputerServerBLL serverBll = new RandomExamComputerServerBLL();
            RandomExamComputerServer    server    = serverBll.GetRandomExamComputerServer(objExam.RandomExamId,
                                                                                          PrjPub.ServerNo);

            //if (!server.HasPaper)
            //{
            //    SessionSet.PageMessage = "当前考试还未生成试卷,不能删除试卷!";
            //    return;
            //}

            if (server.IsStart == 2)
            {
                SessionSet.PageMessage = "当前考试已经结束,不能再删除试卷!";
                return;
            }

            try
            {
                objResultCurrentBll.DelRandomExamResultCurrent(Convert.ToInt32(strId));
                objBll.UpdateHasPaper(Convert.ToInt32(strId), PrjPub.ServerNo, false);
                objBll.UpdateIsStart(Convert.ToInt32(strId), PrjPub.ServerNo, 0);
                if (objExam.StartMode == 2)
                {
                    objBll.UpdateStartCode(Convert.ToInt32(strId), PrjPub.ServerNo, string.Empty);
                    lblTitle.Visible = false;
                    lblCode.Visible  = false;
                    btnApply.Visible = false;
                }
                SystemLogBLL objLogBll = new SystemLogBLL();
                objLogBll.WriteLog("“" + objExam.ExamName + "”删除所有考试试卷");
                SessionSet.PageMessage = "删除试卷成功!";

                ClientScript.RegisterStartupScript(GetType(),
                                                   "jsSelectFirstNode",
                                                   @"refreshGrid();",
                                                   true);
            }
            catch (Exception ex)
            {
                SessionSet.PageMessage = "删除试卷失败!";
                Pub.ShowErrorPage(ex.Message);
            }
        }