protected void callback_callback(object sender, CallBackEventArgs e)
        {
            string strID = e.Parameters[0];
            RandomExamSubjectBLL      objSubjectBll  = new RandomExamSubjectBLL();
            IList <RandomExamSubject> objSubjectList = objSubjectBll.GetRandomExamSubjectByRandomExamId(Convert.ToInt32(strID));

            lblSubjectNow.Text = "";
            RandomExamStrategyBLL objBll = new RandomExamStrategyBLL();

            foreach (RandomExamSubject subject in objSubjectList)
            {
                IList <RandomExamStrategy> objList = objBll.GetRandomExamStrategys(subject.RandomExamSubjectId);
                int nowCount = 0;
                foreach (RandomExamStrategy strategy in objList)
                {
                    nowCount += strategy.ItemCount;
                }

                if (lblSubjectNow.Text == "")
                {
                    lblSubjectNow.Text = subject.TypeName + ":" + nowCount + "题";
                }
                else
                {
                    lblSubjectNow.Text = lblSubjectNow.Text + "    " + subject.TypeName + ":" + nowCount + "题";
                }
            }

            lblSubjectNow.RenderControl(e.Output);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (PrjPub.CurrentLoginUser == null)
            {
                Response.Redirect("/RailExamBao/Common/Error.aspx?error=Session过期请重新登录本系统!");
                return;
            }
            if (!IsPostBack && !subjectCallback.IsCallback)
            {
                ViewState["mode"]      = Request.QueryString.Get("mode");
                ViewState["startmode"] = Request.QueryString.Get("startmode");
                if (ViewState["mode"].ToString() == "ReadOnly")
                {
                    // btnSave.Visible = false;
                    btnCancel.Visible = true;
                }

                string strId = Request.QueryString.Get("id");
                RandomExamSubjectBLL      paperStrategySubjectBLL = new RandomExamSubjectBLL();
                IList <RandomExamSubject> paperStrategySubjects   = paperStrategySubjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));

                if (paperStrategySubjects != null)
                {
                    RandomExamStrategyBLL objBll = new RandomExamStrategyBLL();
                    for (int i = 0; i < paperStrategySubjects.Count; i++)
                    {
                        if (i == 0)
                        {
                            lblSubject.Text = paperStrategySubjects[i].SubjectName + ":" + paperStrategySubjects[i].ItemCount + "题";
                        }
                        else
                        {
                            lblSubject.Text = lblSubject.Text + "    " + paperStrategySubjects[i].SubjectName + ":" + paperStrategySubjects[i].ItemCount + "题";
                        }

                        IList <RandomExamStrategy> objList = objBll.GetRandomExamStrategys(paperStrategySubjects[i].RandomExamSubjectId);
                        int nowCount = 0;
                        foreach (RandomExamStrategy strategy in objList)
                        {
                            nowCount += strategy.ItemCount;
                        }

                        if (lblSubjectNow.Text == "")
                        {
                            lblSubjectNow.Text = paperStrategySubjects[i].TypeName + ":" + nowCount + "题";
                        }
                        else
                        {
                            lblSubjectNow.Text = lblSubjectNow.Text + "    " + paperStrategySubjects[i].TypeName + ":" + nowCount + "题";
                        }
                    }
                }

                BindBookTree();
            }
        }
        protected void FillPaper()
        {
            string strId = Request.QueryString.Get("id");

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

                return;
            }

            RandomExamItemBLL     randomItemBLL = new RandomExamItemBLL();
            RandomExamSubjectBLL  subjectBLL    = new RandomExamSubjectBLL();
            RandomExamStrategyBLL strategyBLL   = new RandomExamStrategyBLL();

            IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));

            if (randomExamSubjects != null)
            {
                Hashtable hashTableItemIds = new Hashtable();
                for (int i = 0; i < randomExamSubjects.Count; i++)
                {
                    RandomExamSubject paperSubject = randomExamSubjects[i];
                    int nSubjectId = paperSubject.RandomExamSubjectId;
                    //  int nItemCount = paperSubject.ItemCount;

                    Hashtable htSubjectItemIds           = new Hashtable();
                    IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                    for (int j = 0; j < strategys.Count; j++)
                    {
                        int nStrategyId = strategys[j].RandomExamStrategyId;
                        int nItemCount  = strategys[j].ItemCount;
                        IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, Convert.ToInt32(ViewState["Year"].ToString()));

                        // IList<RandomExamItem> itemList = randomItemBLL.GetItemsBySubjectId(nSubjectId);

                        Random    ObjRandom      = new Random();
                        Hashtable hashTable      = new Hashtable();
                        Hashtable hashTableCount = new Hashtable();
                        while (hashTable.Count < nItemCount)
                        {
                            int k = ObjRandom.Next(itemList.Count);
                            hashTableCount[k] = k;
                            int itemID     = itemList[k].ItemId;
                            int examItemID = itemList[k].RandomExamItemId;
                            if (!hashTableItemIds.ContainsKey(itemID))
                            {
                                hashTable[examItemID]        = examItemID;
                                hashTableItemIds[itemID]     = itemID;
                                htSubjectItemIds[examItemID] = examItemID;
                            }
                            if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount)
                            {
                                SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!";
                                return;
                            }
                        }
                    }

                    IList <RandomExamItem> paperItems = new List <RandomExamItem>();

                    foreach (int key in htSubjectItemIds.Keys)
                    {
                        string         strItemId = htSubjectItemIds[key].ToString();
                        RandomExamItem item      = randomItemBLL.GetRandomExamItem(int.Parse(strItemId), Convert.ToInt32(ViewState["Year"].ToString()));
                        paperItems.Add(item);
                    }


                    Response.Write("<table width='95%' class='ExamContent'>");
                    Response.Write(" <tr> <td class='ExamBigTitle' >");
                    Response.Write(" " + GetNo(i) + "");
                    Response.Write("、" + paperSubject.SubjectName + "");
                    Response.Write("  (共" + paperItems.Count + "题,共" + paperItems.Count * paperSubject.UnitScore + "分)</td></tr >");

                    if (paperItems != null)
                    {
                        int y = 1;
                        for (int j = 0; j < paperItems.Count; j++)
                        {
                            RandomExamItem paperItem = paperItems[j];
                            int            k         = j + 1;

                            if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                k = y;
                                y++;
                            }
                            else if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANKDETAIL)
                            {
                                continue;
                            }

                            Response.Write("<tr><td class='ExamItem'>&nbsp;&nbsp;&nbsp;" + k + ".&nbsp; " + paperItem.Content +
                                           "&nbsp;&nbsp; (" + paperSubject.UnitScore + "分)</td></tr >");

                            if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_MULTICHOOSE)   //多选
                            {
                                string[] strAnswer = paperItem.SelectAnswer.Split(new char[] { '|' });
                                for (int n = 0; n < strAnswer.Length; n++)
                                {
                                    string strN  = intToString(n + 1);
                                    string strij = "-" + paperItem.RandomExamItemId + "-" + i.ToString() + "-" + j.ToString() +
                                                   "-" + n.ToString();
                                    string strName = i.ToString() + j.ToString();

                                    Response.Write(
                                        "<tr><td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type='checkbox' id='Answer" +
                                        strij + "' name='Answer" + strName + "'> " + strN + "." + strAnswer[n] +
                                        "</td></tr>");
                                }
                            }
                            else if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_SINGLECHOOSE || paperSubject.ItemTypeId == PrjPub.ITEMTYPE_JUDGE)    //单选
                            {
                                string[] strAnswer = paperItem.SelectAnswer.Split(new char[] { '|' });
                                for (int n = 0; n < strAnswer.Length; n++)
                                {
                                    string strN  = intToString(n + 1);
                                    string strij = "-" + paperItem.RandomExamItemId + "-" + i.ToString() + "-" + j.ToString() +
                                                   "-" + n.ToString();
                                    string strName = i.ToString() + j.ToString();
                                    Response.Write(
                                        "<tr><td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type='Radio' id='RAnswer" +
                                        strij + "' name='RAnswer" + strName + "'> " + strN + "." + strAnswer[n] +
                                        "</td></tr>");
                                }
                            }
                            else if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                IList <RandomExamItem> randomExamItems =
                                    randomItemBLL.GetItemsByParentItemID(paperItem.ItemId, Convert.ToInt32(strId),
                                                                         Convert.ToInt32(ViewState["Year"].ToString()));

                                int z = 1;
                                foreach (RandomExamItem randomExamItem in randomExamItems)
                                {
                                    Response.Write("<tr><td class='ExamItem'>&nbsp;&nbsp;&nbsp;(" + z + ").&nbsp; " + randomExamItem.Content +
                                                   "&nbsp;&nbsp; (" + System.String.Format("{0:0.##}", (decimal)paperSubject.UnitScore / (decimal)randomExamItems.Count) + "分)</td></tr >");

                                    string[] strAnswer = randomExamItem.SelectAnswer.Split(new char[] { '|' });
                                    for (int n = 0; n < strAnswer.Length; n++)
                                    {
                                        string strN  = intToString(n + 1);
                                        string strij = "-" + randomExamItem.RandomExamItemId + "-" + i.ToString() + "-" + j.ToString() +
                                                       "-" + n.ToString() + "-" + z.ToString();
                                        string strName = i.ToString() + j.ToString() + z.ToString();

                                        Response.Write(
                                            "<tr><td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type='Radio' id='RAnswer" +
                                            strij + "' name='RAnswer" + strName + "'> " + strN + "." + strAnswer[n] +
                                            "</td></tr>");
                                    }
                                    z++;
                                }
                            }
                            else
                            {
                                Response.Write(
                                    "<tr><td class='ExamItemAnswer'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <textarea id='" + paperItem.RandomExamItemId + "' rows='5' cols='120' ></textarea></td></tr>");
                            }
                        }
                    }
                    Response.Write("</table>");
                }

                Response.Write(" <div class='ExamButton'><input id='btnClose' class='button' name='btnClose' type='button' value='关闭' onclick='Save()' /></div>");
            }
            else
            {
                SessionSet.PageMessage = "未找到记录!";
            }
        }
        private void GetPaper()
        {
            // 根据 ProgressBar.htm 显示进度条界面
            string       templateFileName = Path.Combine(Server.MapPath("."), "ProgressBar.htm");
            StreamReader reader           = new StreamReader(@templateFileName, System.Text.Encoding.GetEncoding("gb2312"));
            string       html             = reader.ReadToEnd();

            reader.Close();
            Response.Write(html);
            Response.Flush();
            System.Threading.Thread.Sleep(200);

            string jsBlock;

            ViewState["BeginTime"] = DateTime.Now.ToString();
            string strId = Request.QueryString.Get("RandomExamID");

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

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

            int year      = obj.BeginTime.Year;
            int ExamCount = obj.MaxExamTimes;

            RandomExamArrangeBLL eaBll = new RandomExamArrangeBLL();
            IList <RailExam.Model.RandomExamArrange> ExamArranges = eaBll.GetRandomExamArranges(int.Parse(strId));
            string       strChooseID = "";
            OracleAccess db          = new OracleAccess();
            OracleAccess dbCenter    = new OracleAccess(System.Configuration.ConfigurationManager.ConnectionStrings["OracleCenter"].ConnectionString);

            string strSql;

            if (ExamArranges.Count > 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);

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (string.IsNullOrEmpty(strChooseID))
                    {
                        strChooseID += dr["User_Ids"].ToString();
                    }
                    else
                    {
                        strChooseID += "," + dr["User_Ids"];
                    }
                }
            }
            else
            {
                strChooseID = "";
            }

            if (strChooseID == "")
            {
                Response.Write("<script>top.returnValue='本场考试未在本单位安排考生!';window.close();</script>");
                return;
            }

            if (db.GetCount("RANDOM_EXAM_ITEM_TEMP_" + year, "TABLE") == 0)
            {
                strSql = "create table RANDOM_EXAM_ITEM_TEMP_" + year + "  as select * from RANDOM_EXAM_ITEM_" + year + " where 1=2 ";
                db.ExecuteNonQuery(strSql);
            }
            strSql = "insert into RANDOM_EXAM_ITEM_TEMP_" + year + " select * from RANDOM_EXAM_ITEM_" + year + " where Random_Exam_ID=" + strId;
            db.ExecuteNonQuery(strSql);

            if (!PrjPub.IsServerCenter)
            {
                if (dbCenter.GetCount("RANDOM_EXAM_ITEM_TEMP_" + year, "TABLE") == 0)
                {
                    strSql = "create table RANDOM_EXAM_ITEM_TEMP_" + year + "  as select * from RANDOM_EXAM_ITEM_" + year + " where 1=2 ";
                    dbCenter.ExecuteNonQuery(strSql);
                }
                strSql = "insert into RANDOM_EXAM_ITEM_TEMP_" + year + " select * from RANDOM_EXAM_ITEM_" + year + " where Random_Exam_ID=" + strId;
                dbCenter.ExecuteNonQuery(strSql);
            }

            System.Threading.Thread.Sleep(10);
            jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((1 * 100) / ((double)2) + "'); </script>");
            Response.Write(jsBlock);
            Response.Flush();


            //每次生成试卷之前删除已生成的考试试卷
            RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL();

            randomExamResultBLL.DelRandomExamResultCurrent(Convert.ToInt32(strId));
            System.Threading.Thread.Sleep(10);
            jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((2 * 100) / ((double)2) + "'); </script>");
            Response.Write(jsBlock);
            Response.Flush();

            System.Threading.Thread.Sleep(200);
            jsBlock = string.Empty;

            string[] str = strChooseID.Split(',');

            RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            //定义全局答卷对象List
            IList <RandomExamResultAnswerCurrent> randomExamResultAnswersCurrentAll = new List <RandomExamResultAnswerCurrent>();
            //定义一个考生一次答卷对象List
            IList <RandomExamResultAnswerCurrent> randomExamResultAnswers = null;

            int progressNum = 1;

            for (int n = 1; n <= ExamCount; n++)
            {
                for (int m = 0; m < str.Length; m++)
                {
                    RandomExamResultCurrent randomExamResult = new RandomExamResultCurrent();

                    randomExamResult.RandomExamId    = int.Parse(strId);
                    randomExamResult.AutoScore       = 0;
                    randomExamResult.BeginDateTime   = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.CurrentDateTime = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.ExamTime        = 0;
                    randomExamResult.EndDateTime     = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.Score           = 0;
                    randomExamResult.OrganizationId  = int.Parse(ConfigurationManager.AppSettings["StationID"]);
                    randomExamResult.Memo            = "";
                    randomExamResult.StatusId        = 0;
                    randomExamResult.AutoScore       = 0;
                    randomExamResult.CorrectRate     = 0;
                    randomExamResult.ExamineeId      = int.Parse(str[m]);
                    randomExamResult.ExamSeqNo       = n;

                    int nRandomExamResultPK = randomExamResultBLL.AddRandomExamResultCurrent(randomExamResult);
                    ViewState["RandomExamResultPK"] = nRandomExamResultPK;

                    strSql = "select a.* from Random_Exam_Arrange_Detail a "
                             + " where ','||User_Ids||',' like '%," + str[m] + ",%' "
                             + " and Random_Exam_ID=" + strId;
                    DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0];

                    //strSql = "insert into Random_Exam_Result_Detail(Random_Exam_Result_Detail_ID,"
                    //         + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID) "
                    //         + "values(Random_Exam_Result_Detail_SEQ.NextVal,"
                    //         + nRandomExamResultPK + ","
                    //         + randomExamResult.RandomExamId + ","
                    //         + randomExamResult.ExamineeId + ","
                    //         + "0," + dr["Computer_Room_ID"] + ") ";
                    //db.ExecuteNonQuery(strSql);

                    strSql = "insert into Random_Exam_Result_Detail_Temp(Random_Exam_Result_Detail_ID,"
                             + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID,Is_Remove) "
                             + "values(Random_Exam_Result_Detail_SEQ.NextVal,"
                             + nRandomExamResultPK + ","
                             + randomExamResult.RandomExamId + ","
                             + randomExamResult.ExamineeId + ","
                             + "0," + dr["Computer_Room_ID"] + ",0) ";
                    db.ExecuteNonQuery(strSql);

                    RandomExamItemBLL     randomItemBLL = new RandomExamItemBLL();
                    RandomExamSubjectBLL  subjectBLL    = new RandomExamSubjectBLL();
                    RandomExamStrategyBLL strategyBLL   = new RandomExamStrategyBLL();

                    IList <RandomExamSubject> randomExamSubjects =
                        subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));

                    if (randomExamSubjects != null)
                    {
                        Hashtable hashTableItemIds = new Hashtable();
                        Hashtable htSubjectItemIds = new Hashtable();
                        for (int i = 0; i < randomExamSubjects.Count; i++)
                        {
                            RandomExamSubject paperSubject = randomExamSubjects[i];
                            int nSubjectId = paperSubject.RandomExamSubjectId;
                            //  int nItemCount = paperSubject.ItemCount;

                            IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                            for (int j = 0; j < strategys.Count; j++)
                            {
                                int nStrategyId = strategys[j].RandomExamStrategyId;
                                int nItemCount  = strategys[j].ItemCount;
                                IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, year);

                                // IList<RandomExamItem> itemList = randomItemBLL.GetItemsBySubjectId(nSubjectId);

                                Random    ObjRandom      = new Random();
                                Hashtable hashTable      = new Hashtable();
                                Hashtable hashTableCount = new Hashtable();
                                int       index          = 0;
                                while (hashTable.Count < nItemCount)
                                {
                                    int k = ObjRandom.Next(itemList.Count);
                                    hashTableCount[index] = k;
                                    index = index + 1;
                                    int itemID     = itemList[k].ItemId;
                                    int examItemID = itemList[k].RandomExamItemId;
                                    if (!hashTableItemIds.ContainsKey(itemID))
                                    {
                                        hashTable[examItemID]        = examItemID;
                                        hashTableItemIds[itemID]     = itemID;
                                        htSubjectItemIds[examItemID] = examItemID;
                                    }
                                    //if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount)
                                    //{
                                    //    SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!";
                                    //    return;
                                    //}
                                }
                            }
                        }


                        foreach (int key in htSubjectItemIds.Keys)
                        {
                            string         strItemId = htSubjectItemIds[key].ToString();
                            RandomExamItem item      = randomItemBLL.GetRandomExamItem(Convert.ToInt32(strItemId), year);

                            string nowSelectAnswer   = string.Empty;
                            string nowStandardAnswer = string.Empty;
                            if (item.TypeId != PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                Pub.GetNowAnswer(item, out nowSelectAnswer, out nowStandardAnswer);
                            }

                            RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent();
                            randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK;
                            randomExamResultAnswer.RandomExamItemId   = int.Parse(strItemId);
                            randomExamResultAnswer.JudgeStatusId      = 0;
                            randomExamResultAnswer.JudgeRemark        = string.Empty;
                            randomExamResultAnswer.ExamTime           = 0;
                            randomExamResultAnswer.Answer             = string.Empty;
                            randomExamResultAnswer.SelectAnswer       = nowSelectAnswer;
                            randomExamResultAnswer.StandardAnswer     = nowStandardAnswer;
                            randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer);

                            //完型填空子题
                            IList <RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(item.ItemId, obj.RandomExamId, year);
                            foreach (RandomExamItem randomExamItem in randomExamItems)
                            {
                                Pub.GetNowAnswer(randomExamItem, out nowSelectAnswer, out nowStandardAnswer);

                                randomExamResultAnswer = new RandomExamResultAnswerCurrent();
                                randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK;
                                randomExamResultAnswer.RandomExamItemId   = randomExamItem.RandomExamItemId;
                                randomExamResultAnswer.JudgeStatusId      = 0;
                                randomExamResultAnswer.JudgeRemark        = string.Empty;
                                randomExamResultAnswer.ExamTime           = 0;
                                randomExamResultAnswer.Answer             = string.Empty;
                                randomExamResultAnswer.SelectAnswer       = nowSelectAnswer;
                                randomExamResultAnswer.StandardAnswer     = nowStandardAnswer;
                                randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer);
                            }

                            System.Threading.Thread.Sleep(10);
                            jsBlock = "<script>SetPorgressBar('正在生成试卷,请等待......','" + ((progressNum * 100) / ((double)ExamCount * str.Length * htSubjectItemIds.Count)).ToString("0.00") + "'); </script>";
                            Response.Write(jsBlock);
                            Response.Flush();

                            progressNum++;
                        }
                    }
                    else
                    {
                        SessionSet.PageMessage = "未找到记录!";
                    }
                }
            }

            bool isRefresh = true;

            try
            {
                objBll.UpdateHasPaper(Convert.ToInt32(strId), PrjPub.ServerNo, true);
            }
            catch
            {
                strSql =
                    @"  update Random_Exam_Computer_Server set  has_paper=1
                      where random_exam_id=" + strId + @" and Computer_server_no='" + PrjPub.ServerNo + @"'";
                dbCenter.ExecuteNonQuery(strSql);
                strSql = @"select count(*)  from Random_Exam_Computer_Server where has_paper=1 and  random_exam_id=" + strId;
                int count = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]);
                if (count > 0)
                {
                    strSql = @"update Random_Exam set has_paper=1 where random_exam_id=" + strId;
                    dbCenter.ExecuteNonQuery(strSql);
                }
                else
                {
                    strSql = @"update Random_Exam set has_paper=0 where random_exam_id=" + strId;
                    dbCenter.ExecuteNonQuery(strSql);
                }
            }


            //如果考试是随到随考,考试状态自动变为正在进行
            if (obj.StartMode == 1)
            {
                try
                {
                    objBll.UpdateIsStart(Convert.ToInt32(strId), PrjPub.ServerNo, 1);
                    isRefresh = false;
                }
                catch
                {
                    strSql =
                        @"  update Random_Exam_Computer_Server set  Is_Start=1
                      where random_exam_id=" + strId + @" and Computer_server_no='" + PrjPub.ServerNo + @"'";
                    dbCenter.ExecuteNonQuery(strSql);
                    strSql = @"select count(*)  from Random_Exam_Computer_Server where random_exam_id=" + strId;
                    int totalcount = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]);
                    strSql = @"select count(*)  from Random_Exam_Computer_Server where Is_Start=0 and  random_exam_id=" + strId;
                    int count = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]);
                    if (totalcount == count)
                    {
                        strSql = @"update Random_Exam set Is_Start=0 where random_exam_id=" + strId;
                        dbCenter.ExecuteNonQuery(strSql);
                    }
                    else
                    {
                        strSql = @"select count(*)  from Random_Exam_Computer_Server where Is_Start=1 and  random_exam_id=" + strId;
                        count  = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]);
                        if (count > 0)
                        {
                            strSql = @"update Random_Exam set Is_Start=1 where random_exam_id=" + strId;
                            dbCenter.ExecuteNonQuery(strSql);
                        }
                        else
                        {
                            strSql = @"select count(*)  from Random_Exam_Computer_Server where Is_Start=2 and  random_exam_id=" + strId;
                            count  = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]);
                            if (count == totalcount)
                            {
                                strSql = @"update Random_Exam set Is_Start=2 where random_exam_id=" + strId;
                                dbCenter.ExecuteNonQuery(strSql);
                            }
                        }
                    }
                }
            }
            else
            {
                isRefresh = false;
            }

            if (isRefresh)
            {
                objBll.RandomExamRefresh();
            }

            SystemLogBLL objLogBll = new SystemLogBLL();

            objLogBll.WriteLog("“" + obj.ExamName + "”生成所有考试试卷");

            Response.Write("<script>top.returnValue='true';top.close();</script>");
        }
        private void GetPaperAfter()
        {
            // 根据 ProgressBar.htm 显示进度条界面
            string       templateFileName = Path.Combine(Server.MapPath("."), "ProgressBar.htm");
            StreamReader reader           = new StreamReader(@templateFileName, System.Text.Encoding.GetEncoding("gb2312"));
            string       html             = reader.ReadToEnd();

            reader.Close();
            Response.Write(html);
            Response.Flush();
            System.Threading.Thread.Sleep(200);

            ViewState["BeginTime"] = DateTime.Now.ToString();
            string strId = Request.QueryString.Get("RandomExamID");

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

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

            int year      = obj.BeginTime.Year;
            int ExamCount = obj.MaxExamTimes;

            System.Threading.Thread.Sleep(10);
            string jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((1 * 100) / ((double)1) + "'); </script>");

            Response.Write(jsBlock);
            Response.Flush();

            if (!PrjPub.IsServerCenter)
            {
                RandomExamArrangeBLL objArrangeBll = new RandomExamArrangeBLL();
                objArrangeBll.RefreshRandomExamArrange();
            }

            //RandomExamArrangeBLL eaBll = new RandomExamArrangeBLL();
            //IList<RailExam.Model.RandomExamArrange> ExamArranges = eaBll.GetRandomExamArranges(int.Parse(strId));
            //string strChooseID = "";
            //if (ExamArranges.Count > 0)
            //{
            //    strChooseID = ExamArranges[0].UserIds;
            //}
            //else
            //{
            //    strChooseID = "";
            //}

            //RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL();
            //IList<RandomExamResultCurrent> examResults = objResultCurrentBll.GetRandomExamResultInfo(Convert.ToInt32(strId));
            //for (int i = 0; i < examResults.Count; i++)
            //{
            //    strChooseID = ("," + strChooseID + ",").Replace("," + examResults[i].ExamineeId + ",", ",");
            //}

            //strChooseID = strChooseID.TrimStart(',').TrimEnd(',');

            string strChooseID = Request.QueryString.Get("addIds");

            if (strChooseID == string.Empty)
            {
                return;
            }

            string[] str = strChooseID.Split('|');

            System.Threading.Thread.Sleep(10);
            jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((2 * 100) / ((double)2) + "'); </script>");
            Response.Write(jsBlock);
            Response.Flush();

            OracleAccess db = new OracleAccess();
            string       strSql;

            RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            //定义全局答卷对象List
            IList <RandomExamResultAnswerCurrent> randomExamResultAnswersCurrentAll = new List <RandomExamResultAnswerCurrent>();
            //定义一个考生一次答卷对象List
            IList <RandomExamResultAnswerCurrent> randomExamResultAnswers = null;

            System.Threading.Thread.Sleep(200);
            jsBlock = string.Empty;
            int progressNum = 1;

            for (int n = 1; n <= ExamCount; n++)
            {
                for (int m = 0; m < str.Length; m++)
                {
                    RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL();
                    RandomExamResultCurrent    randomExamResult    = new RandomExamResultCurrent();

                    randomExamResult.RandomExamId    = int.Parse(strId);
                    randomExamResult.AutoScore       = 0;
                    randomExamResult.BeginDateTime   = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.CurrentDateTime = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.ExamTime        = 0;
                    randomExamResult.EndDateTime     = DateTime.Parse(ViewState["BeginTime"].ToString());
                    randomExamResult.Score           = 0;
                    randomExamResult.OrganizationId  = int.Parse(ConfigurationManager.AppSettings["StationID"]);
                    randomExamResult.Memo            = "";
                    randomExamResult.StatusId        = 0;
                    randomExamResult.AutoScore       = 0;
                    randomExamResult.CorrectRate     = 0;
                    randomExamResult.ExamineeId      = int.Parse(str[m]);
                    randomExamResult.ExamSeqNo       = n;

                    int nRandomExamResultPK = randomExamResultBLL.AddRandomExamResultCurrent(randomExamResult);
                    ViewState["RandomExamResultPK"] = nRandomExamResultPK;

                    strSql = "select a.* from Random_Exam_Arrange_Detail a "
                             + " where ','||User_Ids||',' like '%," + str[m] + ",%' "
                             + " and Random_Exam_ID=" + strId;
                    DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0];


                    //strSql = "insert into Random_Exam_Result_Detail(Random_Exam_Result_Detail_ID,"
                    //         + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID) "
                    //         + "values(Random_Exam_Result_Detail_SEQ.NextVal,"
                    //         + nRandomExamResultPK + ","
                    //         + randomExamResult.RandomExamId + ","
                    //         + randomExamResult.ExamineeId + ","
                    //         + "0," + dr["Computer_Room_ID"] + ") ";
                    //db.ExecuteNonQuery(strSql);


                    strSql = "insert into Random_Exam_Result_Detail_Temp(Random_Exam_Result_Detail_ID,"
                             + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID,Is_Remove) "
                             + "values(Random_Exam_Result_Detail_SEQ.NextVal,"
                             + nRandomExamResultPK + ","
                             + randomExamResult.RandomExamId + ","
                             + randomExamResult.ExamineeId + ","
                             + "0," + dr["Computer_Room_ID"] + ",0) ";
                    db.ExecuteNonQuery(strSql);

                    RandomExamItemBLL     randomItemBLL = new RandomExamItemBLL();
                    RandomExamSubjectBLL  subjectBLL    = new RandomExamSubjectBLL();
                    RandomExamStrategyBLL strategyBLL   = new RandomExamStrategyBLL();

                    IList <RandomExamSubject> randomExamSubjects =
                        subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));

                    if (randomExamSubjects != null)
                    {
                        Hashtable hashTableItemIds = new Hashtable();
                        Hashtable htSubjectItemIds = new Hashtable();
                        for (int i = 0; i < randomExamSubjects.Count; i++)
                        {
                            RandomExamSubject paperSubject = randomExamSubjects[i];
                            int nSubjectId = paperSubject.RandomExamSubjectId;
                            //  int nItemCount = paperSubject.ItemCount;

                            IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                            for (int j = 0; j < strategys.Count; j++)
                            {
                                int nStrategyId = strategys[j].RandomExamStrategyId;
                                int nItemCount  = strategys[j].ItemCount;
                                IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, year);

                                // IList<RandomExamItem> itemList = randomItemBLL.GetItemsBySubjectId(nSubjectId);

                                Random    ObjRandom      = new Random();
                                Hashtable hashTable      = new Hashtable();
                                Hashtable hashTableCount = new Hashtable();
                                int       index          = 0;
                                while (hashTable.Count < nItemCount)
                                {
                                    int k = ObjRandom.Next(itemList.Count);
                                    hashTableCount[index] = k;
                                    index = index + 1;
                                    int itemID     = itemList[k].ItemId;
                                    int examItemID = itemList[k].RandomExamItemId;
                                    if (!hashTableItemIds.ContainsKey(itemID))
                                    {
                                        hashTable[examItemID]        = examItemID;
                                        hashTableItemIds[itemID]     = itemID;
                                        htSubjectItemIds[examItemID] = examItemID;
                                    }
                                    //if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount)
                                    //{
                                    //    SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!";
                                    //    return;
                                    //}
                                }
                            }
                        }
                        randomExamResultAnswers = new List <RandomExamResultAnswerCurrent>();
                        foreach (int key in htSubjectItemIds.Keys)
                        {
                            string strItemId = htSubjectItemIds[key].ToString();

                            RandomExamItem item = randomItemBLL.GetRandomExamItem(Convert.ToInt32(strItemId), year);

                            string nowSelectAnswer   = string.Empty;
                            string nowStandardAnswer = string.Empty;
                            if (item.TypeId != PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                Pub.GetNowAnswer(item, out nowSelectAnswer, out nowStandardAnswer);
                            }

                            RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent();
                            randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK;
                            randomExamResultAnswer.RandomExamItemId   = int.Parse(strItemId);
                            randomExamResultAnswer.JudgeStatusId      = 0;
                            randomExamResultAnswer.JudgeRemark        = string.Empty;
                            randomExamResultAnswer.ExamTime           = 0;
                            randomExamResultAnswer.Answer             = string.Empty;
                            randomExamResultAnswer.SelectAnswer       = nowSelectAnswer;
                            randomExamResultAnswer.StandardAnswer     = nowStandardAnswer;
                            randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer);

                            //完型填空子题
                            IList <RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(item.ItemId, obj.RandomExamId, year);
                            foreach (RandomExamItem randomExamItem in randomExamItems)
                            {
                                Pub.GetNowAnswer(randomExamItem, out nowSelectAnswer, out nowStandardAnswer);

                                randomExamResultAnswer = new RandomExamResultAnswerCurrent();
                                randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK;
                                randomExamResultAnswer.RandomExamItemId   = randomExamItem.RandomExamItemId;
                                randomExamResultAnswer.JudgeStatusId      = 0;
                                randomExamResultAnswer.JudgeRemark        = string.Empty;
                                randomExamResultAnswer.ExamTime           = 0;
                                randomExamResultAnswer.Answer             = string.Empty;
                                randomExamResultAnswer.SelectAnswer       = nowSelectAnswer;
                                randomExamResultAnswer.StandardAnswer     = nowStandardAnswer;
                                randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer);
                            }

                            System.Threading.Thread.Sleep(10);
                            jsBlock = "<script>SetPorgressBar('正在生成试卷,请等待......','" + ((progressNum * 100) / ((double)ExamCount * str.Length * htSubjectItemIds.Count)).ToString("0.00") + "'); </script>";
                            Response.Write(jsBlock);
                            Response.Flush();

                            progressNum++;
                        }
                    }
                    else
                    {
                        SessionSet.PageMessage = "未找到记录!";
                    }
                }
            }

            //临时添加考生无需更改考试状态,因为考试状态肯定是正在进行和生成试卷
            //objBll.UpdateHasPaper(Convert.ToInt32(strId), PrjPub.ServerNo, true);
            ////如果考试是随到随考,考试状态自动变为正在进行
            //if (obj.StartMode == 1)
            //{
            //    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>");
        }
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            string strId        = Request.QueryString.Get("id");
            string strMode      = ViewState["mode"].ToString();
            string strStartMode = ViewState["startmode"].ToString();

            if (ViewState["mode"].ToString() == "ReadOnly")
            {
                if (strStartMode == "Edit")
                {
                    //Response.Redirect("/RailExamBao/RandomExamOther/RandomExamStudent.aspx?startmode=Edit&mode=Edit&id=" + strId);
                    Response.Redirect("/RailExamBao/RandomExam/SelectEmployeeDetailNew.aspx?startmode=Edit&mode=Edit&id=" + strId);
                    return;
                }
                else
                {
                    Response.Redirect("/RailExamBao/RandomExam/SelectEmployeeDetailNew.aspx?startmode=" + strStartMode + "&mode=" + strMode + "&id=" + strId);
                    return;
                }
            }

            RandomExamStrategyBLL psbcBll = new RandomExamStrategyBLL();

            int Ncount = psbcBll.GetRandomExamStrategysByExamID(int.Parse(strId)).Count;

            if (Ncount == 0)
            {
                SessionSet.PageMessage = "请添加策略!";
                return;
            }

            RandomExamSubjectBLL  subjectBLL  = new RandomExamSubjectBLL();
            RandomExamStrategyBLL strategyBLL = new RandomExamStrategyBLL();
            ItemBLL           itemBLL         = new ItemBLL();
            RandomExamItemBLL randomItemBLL   = new RandomExamItemBLL();

            IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));
            int ExamItemCounts = 0;

            for (int i = 0; i < randomExamSubjects.Count; i++)
            {
                int     nSubjectId      = randomExamSubjects[i].RandomExamSubjectId;
                decimal nTotalItemCount = randomExamSubjects[i].ItemCount;

                IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                int nItemCount = 0;
                for (int j = 0; j < strategys.Count; j++)
                {
                    nItemCount += strategys[j].ItemCount;
                }

                ExamItemCounts += nItemCount;
                if (nItemCount != nTotalItemCount)
                {
                    SessionSet.PageMessage = "大题设定的试题数和取题范围设定的总题数不相等,请重新设置!";
                    return;
                }
            }

            if (ExamItemCounts == 0)
            {
                SessionSet.PageMessage = "考试的总题数不能为0,请重新设置!";
                return;
            }

            //获取考试信息
            RandomExamBLL objBll = new RandomExamBLL();

            RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId));
            int year = obj.BeginTime.Year;

            //删除可能的取题范围
            randomItemBLL.DeleteItems(int.Parse(strId), year);

            Hashtable htItemID  = new Hashtable();
            Hashtable htChapter = new Hashtable();

            for (int i = 0; i < randomExamSubjects.Count; i++)
            {
                IList <RailExam.Model.Item> itemList = new List <RailExam.Model.Item>();
                int     nSubjectId = randomExamSubjects[i].RandomExamSubjectId;
                decimal nUnitScore = randomExamSubjects[i].UnitScore;

                IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                for (int k = 0; k < strategys.Count; k++)
                {
                    //策略
                    int    nChapterId        = strategys[k].RangeId;
                    int    nRangeType        = strategys[k].RangeType;
                    int    typeId            = strategys[k].ItemTypeId;
                    int    StrategyId        = strategys[k].RandomExamStrategyId;
                    int    strDiffId         = strategys[k].ItemDifficultyID;
                    int    strMaxDiffId      = strategys[k].MaxItemDifficultyID;
                    string excludesChapterID = strategys[k].ExcludeChapterId;

                    IList <RailExam.Model.Item> itemListTemp = new List <RailExam.Model.Item>();
                    itemListTemp = itemBLL.GetItemsByStrategyNew(nRangeType, strDiffId, strMaxDiffId, nChapterId, typeId, excludesChapterID);

                    if (itemListTemp.Count < strategys[k].ItemCount)
                    {
                        SessionSet.PageMessage = "大题" + (i + 1).ToString() + "在设定的取题范围内的试题量不够,请重新设置取题范围!";
                        return;
                    }

                    for (int m = 0; m < itemListTemp.Count; m++)
                    {
                        itemListTemp[m].StrategyId = StrategyId;
                        if (itemListTemp[m].StatusId == 1)
                        {
                            if (htChapter.ContainsKey(itemListTemp[m].ChapterId))
                            {
                                ArrayList objList = (ArrayList)htChapter[itemListTemp[m].ChapterId];

                                if (objList.IndexOf(itemListTemp[m].KeyWord) < 0)
                                {
                                    itemList.Add(itemListTemp[m]);
                                    if (itemListTemp[m].KeyWord != "" && itemListTemp[m].KeyWord != null)
                                    {
                                        objList.Add(itemListTemp[m].KeyWord);
                                    }
                                }
                            }
                            else
                            {
                                ArrayList objList = new ArrayList();
                                if (itemListTemp[m].KeyWord != "" && itemListTemp[m].KeyWord != null)
                                {
                                    objList.Add(itemListTemp[m].KeyWord);
                                }

                                itemList.Add(itemListTemp[m]);

                                htChapter.Add(itemListTemp[m].ChapterId, objList);
                            }
                        }
                    }
                }

                if (itemList.Count < randomExamSubjects[i].ItemCount)
                {
                    SessionSet.PageMessage = "大题" + (i + 1).ToString() + "在设定的取题范围内符合要求的试题量不够,请重新设置取题范围!";
                    return;
                }

                IList <RandomExamItem> randomExamItems = new List <RandomExamItem>();

                int n = 0;
                foreach (RailExam.Model.Item item in itemList)
                {
                    if (string.IsNullOrEmpty(item.StandardAnswer) && (item.TypeId == PrjPub.ITEMTYPE_SINGLECHOOSE || item.TypeId == PrjPub.ITEMTYPE_MULTICHOOSE || item.TypeId == PrjPub.ITEMTYPE_JUDGE))
                    {
                        n = n + 1;
                        break;
                    }
                    if (!htItemID.ContainsKey(item.ItemId))
                    {
                        htItemID.Add(item.ItemId, item.ItemId);
                    }
                    else
                    {
                        continue;
                    }
                    RandomExamItem paperItem = new RandomExamItem();
                    paperItem.SubjectId      = nSubjectId;
                    paperItem.StrategyId     = item.StrategyId;
                    paperItem.RandomExamId   = int.Parse(strId);
                    paperItem.AnswerCount    = item.AnswerCount;
                    paperItem.BookId         = item.BookId;
                    paperItem.CategoryId     = item.CategoryId;
                    paperItem.ChapterId      = item.ChapterId;
                    paperItem.CompleteTime   = item.CompleteTime;
                    paperItem.Content        = item.Content;
                    paperItem.CreatePerson   = item.CreatePerson;
                    paperItem.CreateTime     = item.CreateTime;
                    paperItem.Description    = item.Description;
                    paperItem.DifficultyId   = item.DifficultyId;
                    paperItem.ItemId         = item.ItemId;
                    paperItem.Memo           = item.Memo;
                    paperItem.OrganizationId = item.OrganizationId;
                    paperItem.OutDateDate    = item.OutDateDate;
                    paperItem.Score          = nUnitScore;
                    paperItem.SelectAnswer   = item.SelectAnswer;
                    paperItem.Source         = item.Source;
                    paperItem.StandardAnswer = item.StandardAnswer;
                    paperItem.StatusId       = item.StatusId;
                    paperItem.TypeId         = item.TypeId;
                    paperItem.UsedCount      = item.UsedCount;
                    paperItem.Version        = item.Version;
                    randomExamItems.Add(paperItem);
                }

                if (n == 1)
                {
                    SessionSet.PageMessage = "大题" + (i + 1).ToString() + "有无标准答案的试题,请重新设置取题范围!";
                    return;
                }

                if (randomExamItems.Count > 0)
                {
                    randomItemBLL.AddItem(randomExamItems, year);
                }
            }

            /*
             * Hashtable hashTableItemIds = new Hashtable();
             * for (int i = 0; i < randomExamSubjects.Count; i++)
             * {
             *      int nSubjectId = randomExamSubjects[i].RandomExamSubjectId;
             *      //int nItemCount = randomExamSubjects[i].ItemCount;
             *
             *      IList<RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
             *      for (int j = 0; j < strategys.Count; j++)
             *      {
             *              int nStrategyId = strategys[j].RandomExamStrategyId;
             *              int nItemCount = strategys[j].ItemCount;
             *
             *              IList<RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, year);
             *              Random ObjRandom = new Random();
             *              Hashtable hashTable = new Hashtable();
             *              Hashtable hashTableCount = new Hashtable();
             *              while (hashTable.Count < nItemCount)
             *              {
             *                      int k = ObjRandom.Next(itemList.Count);
             *                      hashTableCount[k] = k;
             *                      int itemID = itemList[k].ItemId;
             *                      if (!hashTableItemIds.ContainsKey(itemID))
             *                      {
             *                              hashTable[itemID] = itemID;
             *                              hashTableItemIds[itemID] = itemID;
             *                      }
             *
             *                      if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount)
             *                      {
             *                              SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!";
             *                              return;
             *                      }
             *              }
             *      }
             * }*/
            Response.Redirect("/RailExamBao/RandomExam/SelectEmployeeDetailNew.aspx?startmode=" + strStartMode + "&mode=" + strMode + "&id=" + strId);
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strID = Request.QueryString.Get("id");
                ViewState["mode"]     = Request.QueryString.Get("mode");
                hfItemType.Value      = Request.QueryString.Get("itemTypeID");
                ddlType.SelectedValue = hfItemType.Value;
                if (ViewState["mode"].ToString() == "Insert")
                {
                    string subjectId = Request.QueryString.Get("subjectid");
                    hfSubjectId.Value = subjectId;
                    if (!string.IsNullOrEmpty(subjectId))
                    {
                        RandomExamSubjectBLL paperStrategySubjectBLL = new RandomExamSubjectBLL();
                        RandomExamSubject    paperStrategySubject    = paperStrategySubjectBLL.GetRandomExamSubject(int.Parse(subjectId));

                        if (paperStrategySubject != null)
                        {
                            hfExamID.Value        = paperStrategySubject.RandomExamId.ToString();
                            txtSubjectName.Text   = paperStrategySubject.SubjectName;
                            ddlType.SelectedValue = paperStrategySubject.ItemTypeId.ToString();
                            labelTotalCount.Text  = paperStrategySubject.ItemCount.ToString();

                            RandomExamStrategyBLL randomExamStrategyBLL = new RandomExamStrategyBLL();
                            IList <RailExam.Model.RandomExamStrategy> RandomExamStrategys = randomExamStrategyBLL.GetRandomExamStrategys(paperStrategySubject.RandomExamSubjectId);

                            int hasCount = 0;
                            foreach (RailExam.Model.RandomExamStrategy randomExamStrategy in RandomExamStrategys)
                            {
                                hasCount += randomExamStrategy.ItemCount;
                            }

                            labelLeaveCount.Text = (paperStrategySubject.ItemCount - hasCount).ToString();

                            txtNDR.Text = labelLeaveCount.Text;

                            RandomExamResultBLL reBll = new RandomExamResultBLL();
                            IList <RailExam.Model.RandomExamResult> examResults = reBll.GetRandomExamResultByExamID(paperStrategySubject.RandomExamId);

                            if (examResults.Count > 0)
                            {
                                SaveButton.Visible = false;
                            }
                        }

                        hfSubjectId.Value = subjectId;

                        mother1.Visible = false;
                        mother2.Visible = false;
                    }

                    OracleAccess db     = new OracleAccess();
                    string       strSql = "select RANDOM_EXAM_STRATEGY_SEQ.nextval from dual";
                    DataRow      dr     = db.RunSqlDataSet(strSql).Tables[0].Rows[0];
                    hfKeyID.Value = dr[0].ToString();
                }
                else
                {
                    hfKeyID.Value = strID;
                    FillPage(int.Parse(strID));
                }
            }

            if (!string.IsNullOrEmpty(HfChapterId.Value))
            {
                if (HfRangeType.Value == "4")
                {
                    BookChapterBLL chapterBll = new BookChapterBLL();
                    BookChapter    chapter    = chapterBll.GetBookChapter(Convert.ToInt32(HfChapterId.Value));

                    txtChapterName.Text = chapter.ChapterName;
                }
                else
                {
                    BookBLL             bookBll = new BookBLL();
                    RailExam.Model.Book book    = bookBll.GetBook(Convert.ToInt32(HfChapterId.Value));

                    txtChapterName.Text = book.bookName;
                }
            }

            if (!string.IsNullOrEmpty(HfExCludeChaptersId.Value))
            {
                string strSql = "select * from Book_Chapter where Chapter_ID in (" + HfExCludeChaptersId.Value + ")";

                OracleAccess db = new OracleAccess();
                DataSet      ds = db.RunSqlDataSet(strSql);

                string strName = string.Empty;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (strName == string.Empty)
                    {
                        strName += dr["Chapter_Name"].ToString();
                    }
                    else
                    {
                        strName += "," + dr["Chapter_Name"].ToString();
                    }
                }

                txtExCludeChapters.Text = strName;
            }
        }
Esempio n. 8
0
        private void FillPage(int nID)
        {
            RandomExamStrategyBLL paperStrategyBookChapterBLL = new RandomExamStrategyBLL();

            RandomExamStrategy paperStrategyBookChapter = paperStrategyBookChapterBLL.GetRandomExamStrategy(nID);

            if (paperStrategyBookChapter != null)
            {
                txtMemo.Text        = paperStrategyBookChapter.Memo;
                txtChapterName.Text = paperStrategyBookChapter.RangeName;
                HfRangeName.Value   = paperStrategyBookChapter.RangeName;

                hfSubjectId.Value     = paperStrategyBookChapter.SubjectId.ToString();
                HfRangeType.Value     = paperStrategyBookChapter.RangeType.ToString();
                HfChapterId.Value     = paperStrategyBookChapter.RangeId.ToString();
                ddlType.SelectedValue = paperStrategyBookChapter.ItemTypeId.ToString();
                txtNDR.Text           = paperStrategyBookChapter.ItemCount.ToString();



                RandomExamSubjectBLL paperStrategySubjectBLL = new RandomExamSubjectBLL();
                RandomExamSubject    paperStrategySubject    = paperStrategySubjectBLL.GetRandomExamSubject(int.Parse(hfSubjectId.Value));

                if (paperStrategySubject != null)
                {
                    hfExamID.Value       = paperStrategySubject.RandomExamId.ToString();
                    txtSubjectName.Text  = paperStrategySubject.SubjectName;
                    labelTotalCount.Text = paperStrategySubject.ItemCount.ToString();

                    IList <RailExam.Model.RandomExamStrategy> RandomExamStrategys = paperStrategyBookChapterBLL.GetRandomExamStrategys(paperStrategySubject.RandomExamSubjectId);

                    int hasCount = 0;
                    foreach (RailExam.Model.RandomExamStrategy randomExamStrategy in RandomExamStrategys)
                    {
                        if (randomExamStrategy.RandomExamStrategyId != nID)
                        {
                            hasCount += randomExamStrategy.ItemCount;
                        }
                    }

                    labelLeaveCount.Text = (paperStrategySubject.ItemCount - hasCount).ToString();

                    RandomExamResultBLL reBll = new RandomExamResultBLL();
                    IList <RailExam.Model.RandomExamResult> examResults = reBll.GetRandomExamResultByExamID(paperStrategySubject.RandomExamId);

                    if (examResults.Count > 0)
                    {
                        ViewState["mode"] = "ReadOnly";
                    }
                }

                string strSql = "select a.random_exam_strategy_id as RandomExamStrategyId,a.Item_Count as ItemCount,"
                                + "GetBookChapterName(b.Chapter_ID) ChapterName, b.Chapter_ID as ChapterId,b.ID_Path as IDPath "
                                + "from random_exam_strategy a"
                                + " inner join Book_Chapter b on a.Range_ID=b.Chapter_ID "
                                + " where a.Is_Mother_Item=1 and a.Mother_ID=" + nID;

                OracleAccess db = new OracleAccess();

                DataSet ds = db.RunSqlDataSet(strSql);


                if (paperStrategyBookChapter.RangeType == 3 && ds.Tables[0].Rows.Count == 0)
                {
                    txtExCludeChapters.Text = paperStrategyBookChapter.ExcludeChapterId;

                    if (string.IsNullOrEmpty(paperStrategyBookChapter.ExcludeChapterId) == false)
                    {
                        FillExcludeCategorysID(paperStrategyBookChapter.ExcludeChapterId);
                    }
                }

                int     sumTotalCount = 0;
                ItemBLL itembll       = new ItemBLL();
                if (HfRangeType.Value == "3")
                {
                    sumTotalCount = itembll.GetItemsByBookID(Convert.ToInt32(HfChapterId.Value),
                                                             Convert.ToInt32(hfItemType.Value));
                }
                else
                {
                    BookChapterBLL bookChapterBll = new BookChapterBLL();
                    BookChapter    bookChapter    = bookChapterBll.GetBookChapter(Convert.ToInt32(HfChapterId.Value));
                    sumTotalCount = itembll.GetItemsByBookChapterIdPath(bookChapter.IdPath,
                                                                        Convert.ToInt32(hfItemType.Value));
                }

                if (ds.Tables[0].Rows.Count == 0)
                {
                    mother1.Visible = false;
                    mother2.Visible = false;
                }
                else
                {
                    mother1.Visible = true;
                    mother2.Visible = true;

                    DataColumn dc1 = ds.Tables[0].Columns.Add("MaxItemCount");

                    ItemBLL item        = new ItemBLL();
                    int     sumCount    = 0;
                    int     sumMaxCount = 0;
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        dr["MaxItemCount"] = item.GetItemsByBookChapterIdPath(dr["IDPath"].ToString(),
                                                                              Convert.ToInt32(hfItemType.Value));

                        sumCount    += Convert.ToInt32(dr["ItemCount"].ToString());
                        sumMaxCount += Convert.ToInt32(dr["MaxItemCount"].ToString());
                    }

                    txtNDR.Text = (paperStrategyBookChapter.ItemCount + sumCount).ToString();

                    Grid1.DataSource = ds;
                    Grid1.DataBind();

                    lblMotherInfo.Text = "其中子题最大题数:" + (sumTotalCount - sumMaxCount) + ";母题最大题数:" + sumMaxCount;
                }
                strSql              = "select * from Item a inner join Book_Chapter b on a.Chapter_ID=b.Chapter_ID " + GetSelectSql();
                lblTotalCount.Text  = db.RunSqlDataSet(strSql).Tables[0].Rows.Count.ToString();
                strSql              = " select * from  Random_Exam_Item_Select where RANDOM_EXAM_STRATEGY_ID=" + nID;
                lblSelectCount.Text = db.RunSqlDataSet(strSql).Tables[0].Rows.Count.ToString();
            }

            if (ViewState["mode"].ToString() == "ReadOnly")
            {
                SaveButton.Visible   = false;
                CancelButton.Visible = true;
                ddlType.Enabled      = false;
                txtMemo.Enabled      = false;
            }
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["mode"]      = Request.QueryString.Get("mode");
                ViewState["startmode"] = Request.QueryString.Get("startmode");
                if (ViewState["mode"].ToString() == "ReadOnly")
                {
                    // btnSave.Visible = false;
                    btnCancel.Visible = true;
                }

                string strId = Request.QueryString.Get("id");
                ViewState["ExamId"] = strId;
                RandomExamSubjectBLL      paperStrategySubjectBLL = new RandomExamSubjectBLL();
                IList <RandomExamSubject> paperStrategySubjects   = paperStrategySubjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));

                if (paperStrategySubjects != null)
                {
                    RandomExamStrategyBLL objBll = new RandomExamStrategyBLL();
                    int     sumItem  = 0;
                    decimal sumScore = 0;
                    for (int i = 0; i < paperStrategySubjects.Count; i++)
                    {
                        int      j  = i + 1;
                        ListItem Li = new ListItem();
                        Li.Value = paperStrategySubjects[i].ItemTypeId + "|" + paperStrategySubjects[i].RandomExamSubjectId.ToString();
                        Li.Text  = "第" + j + "题:  " + paperStrategySubjects[i].SubjectName;
                        lbType.Items.Add(Li);

                        if (i == 0)
                        {
                            lblSubject.Text = paperStrategySubjects[i].SubjectName + ":" + paperStrategySubjects[i].ItemCount + "题";
                        }
                        else
                        {
                            lblSubject.Text = lblSubject.Text + "    " + paperStrategySubjects[i].SubjectName + ":" + paperStrategySubjects[i].ItemCount + "题";
                        }

                        sumItem  += paperStrategySubjects[i].ItemCount;
                        sumScore += paperStrategySubjects[i].ItemCount * paperStrategySubjects[i].UnitScore;

                        IList <RandomExamStrategy> objList = objBll.GetRandomExamStrategys(paperStrategySubjects[i].RandomExamSubjectId);
                        int nowCount = 0;
                        foreach (RandomExamStrategy strategy in objList)
                        {
                            nowCount += strategy.ItemCount;
                        }

                        if (lblSubjectNow.Text == "")
                        {
                            lblSubjectNow.Text = paperStrategySubjects[i].TypeName + ":" + nowCount + "题";
                        }
                        else
                        {
                            lblSubjectNow.Text = lblSubjectNow.Text + "    " + paperStrategySubjects[i].TypeName + ":" + nowCount + "题";
                        }
                    }
                    lblSubject.Text = lblSubject.Text + "    " + "共" + sumItem + "题,共" + System.String.Format("{0:0.##}", sumScore) + "分";


                    lbType.SelectedIndex = 0;
                    ViewState["value"]   = lbType.SelectedValue;
                }
            }

            string strRefresh = Request.Form.Get("Refresh");

            if (!string.IsNullOrEmpty(strRefresh))
            {
                OracleAccess db     = new OracleAccess();
                string       strSql = "delete from Random_Exam_Item_Select where RANDOM_EXAM_STRATEGY_ID=" + strRefresh;
                db.ExecuteNonQuery(strSql);
            }
        }
Esempio n. 10
0
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            string strId        = Request.QueryString.Get("id");
            string strMode      = ViewState["mode"].ToString();
            string strStartMode = ViewState["startmode"].ToString();

            if (ViewState["mode"].ToString() == "ReadOnly")
            {
                //if (strStartMode == "Edit")
                //{
                //    Response.Redirect("SelectEmployeeDetailNew.aspx?startmode=Edit&mode=Edit&id=" + strId);
                //    return;
                //}
                //else
                //{
                //    Response.Redirect("SelectEmployeeDetailNew.aspx?startmode=" + strStartMode + "&mode=" + strMode + "&id=" + strId);
                //    return;
                //}

                Response.Redirect("SelectEmployeeDetailNew.aspx?startmode=" + strStartMode + "&mode=" + strMode + "&id=" + strId);
                return;
            }

            if (Pub.HasPaper(Convert.ToInt32(strId)))
            {
                Response.Write("<script>alert('该考试已生成试卷,不能被编辑!');window.close();</script>");
                return;
            }

            RandomExamStrategyBLL psbcBll = new RandomExamStrategyBLL();

            int Ncount = psbcBll.GetRandomExamStrategysByExamID(int.Parse(strId)).Count;

            if (Ncount == 0)
            {
                SessionSet.PageMessage = "请添加策略!";
                return;
            }

            RandomExamSubjectBLL  subjectBLL  = new RandomExamSubjectBLL();
            RandomExamStrategyBLL strategyBLL = new RandomExamStrategyBLL();
            ItemBLL           itemBLL         = new ItemBLL();
            RandomExamItemBLL randomItemBLL   = new RandomExamItemBLL();


            IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));
            int ExamItemCounts = 0;

            for (int i = 0; i < randomExamSubjects.Count; i++)
            {
                int     nSubjectId      = randomExamSubjects[i].RandomExamSubjectId;
                decimal nTotalItemCount = randomExamSubjects[i].ItemCount;

                IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                int nItemCount = 0;
                for (int j = 0; j < strategys.Count; j++)
                {
                    nItemCount += strategys[j].ItemCount;  //改动2011-10-17
                }

                ExamItemCounts += nItemCount;
                if (nItemCount != nTotalItemCount)
                {
                    SessionSet.PageMessage = "大题设定的试题数和取题范围设定的总题数不相等,请重新设置!";
                    return;
                }
            }

            if (ExamItemCounts == 0)
            {
                SessionSet.PageMessage = "考试的总题数不能为0,请重新设置!";
                return;
            }

            RandomExamBLL objBll = new RandomExamBLL();

            RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId));
            int year = obj.BeginTime.Year;

            randomItemBLL.DeleteItems(int.Parse(strId), year);

            Hashtable htItemID = new Hashtable();
            int       count    = 0;

            for (int i = 0; i < randomExamSubjects.Count; i++)
            {
                IList <RailExam.Model.Item> itemList = new List <RailExam.Model.Item>();
                int     nSubjectId = randomExamSubjects[i].RandomExamSubjectId;
                decimal nUnitScore = randomExamSubjects[i].UnitScore;

                IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                for (int k = 0; k < strategys.Count; k++)
                {
                    //策略
                    int    nChapterId    = strategys[k].RangeId;
                    int    nRangeType    = strategys[k].RangeType;
                    int    typeId        = strategys[k].ItemTypeId;
                    int    StrategyId    = strategys[k].RandomExamStrategyId;
                    string strExcludeIDs = strategys[k].ExcludeChapterId;
                    int    ndr           = 0;
                    IList <RailExam.Model.Item> itemListTemp = new List <RailExam.Model.Item>();
                    itemListTemp = itemBLL.GetItemsByStrategy(nRangeType, ndr, nChapterId, typeId, strExcludeIDs, StrategyId);

                    if (itemListTemp.Count < strategys[k].ItemCount)
                    {
                        SessionSet.PageMessage = "大题" + (i + 1).ToString() + "在设定的取题范围内的试题量不够,请重新设置取题范围!";
                        return;
                    }

                    Hashtable htChapter = new Hashtable();
                    for (int m = 0; m < itemListTemp.Count; m++)
                    {
                        itemListTemp[m].StrategyId = StrategyId;
                        if (itemListTemp[m].StatusId == 1)
                        {
                            if (htChapter.ContainsKey(itemListTemp[m].ChapterId))
                            {
                                ArrayList objList = (ArrayList)htChapter[itemListTemp[m].ChapterId];

                                if (objList.IndexOf(itemListTemp[m].MotherCode) < 0)
                                {
                                    itemList.Add(itemListTemp[m]);
                                    if (itemListTemp[m].MotherCode != "" && itemListTemp[m].MotherCode != null)
                                    {
                                        objList.Add(itemListTemp[m].MotherCode);
                                    }
                                }
                            }
                            else
                            {
                                ArrayList objList = new ArrayList();
                                if (itemListTemp[m].MotherCode != "" && itemListTemp[m].MotherCode != null)
                                {
                                    objList.Add(itemListTemp[m].MotherCode);
                                }

                                itemList.Add(itemListTemp[m]);

                                htChapter.Add(itemListTemp[m].ChapterId, objList);
                            }
                        }
                    }
                }

                if (itemList.Count < randomExamSubjects[i].ItemCount)
                {
                    SessionSet.PageMessage = "大题" + (i + 1).ToString() + "在设定的取题范围内的试题量不够,请重新设置取题范围!";
                    return;
                }

                IList <RandomExamItem> randomExamItems = new List <RandomExamItem>();

                int n = 0;
                foreach (RailExam.Model.Item item in itemList)
                {
                    if (string.IsNullOrEmpty(item.StandardAnswer) && (item.TypeId == PrjPub.ITEMTYPE_SINGLECHOOSE || item.TypeId == PrjPub.ITEMTYPE_MULTICHOOSE || item.TypeId == PrjPub.ITEMTYPE_JUDGE))
                    {
                        n = n + 1;
                        break;
                    }
                    if (!htItemID.ContainsKey(item.ItemId))
                    {
                        htItemID.Add(item.ItemId, item.ItemId);
                    }
                    else
                    {
                        count = count + 1;
                        break;
                    }

                    RandomExamItem paperItem = new RandomExamItem();
                    paperItem.SubjectId      = nSubjectId;
                    paperItem.StrategyId     = item.StrategyId;
                    paperItem.RandomExamId   = int.Parse(strId);
                    paperItem.AnswerCount    = item.AnswerCount;
                    paperItem.BookId         = item.BookId;
                    paperItem.CategoryId     = item.CategoryId;
                    paperItem.ChapterId      = item.ChapterId;
                    paperItem.CompleteTime   = item.CompleteTime;
                    paperItem.Content        = item.Content;
                    paperItem.CreatePerson   = item.CreatePerson;
                    paperItem.CreateTime     = item.CreateTime;
                    paperItem.Description    = item.Description;
                    paperItem.DifficultyId   = item.DifficultyId;
                    paperItem.ItemId         = item.ItemId;
                    paperItem.Memo           = item.Memo;
                    paperItem.OrganizationId = item.OrganizationId;
                    paperItem.OutDateDate    = item.OutDateDate;
                    paperItem.Score          = nUnitScore;
                    paperItem.SelectAnswer   = item.SelectAnswer;
                    paperItem.Source         = item.Source;
                    paperItem.StandardAnswer = item.StandardAnswer;
                    paperItem.StatusId       = item.StatusId;
                    paperItem.TypeId         = item.TypeId;
                    paperItem.UsedCount      = item.UsedCount;
                    paperItem.Version        = item.Version;
                    paperItem.ParentItemID   = 0;
                    paperItem.MotherCode     = item.MotherCode;
                    paperItem.ItemIndex      = item.ItemIndex;
                    randomExamItems.Add(paperItem);

                    //完型填空
                    if (item.TypeId == PrjPub.ITEMTYPE_FILLBLANK)
                    {
                        IList <RailExam.Model.Item> itemDetails = itemBLL.GetItemsByParentItemID(item.ItemId);

                        foreach (RailExam.Model.Item itemDetail in itemDetails)
                        {
                            paperItem                = new RandomExamItem();
                            paperItem.SubjectId      = nSubjectId;
                            paperItem.StrategyId     = itemDetail.StrategyId;
                            paperItem.RandomExamId   = int.Parse(strId);
                            paperItem.AnswerCount    = itemDetail.AnswerCount;
                            paperItem.BookId         = itemDetail.BookId;
                            paperItem.CategoryId     = itemDetail.CategoryId;
                            paperItem.ChapterId      = itemDetail.ChapterId;
                            paperItem.CompleteTime   = itemDetail.CompleteTime;
                            paperItem.Content        = itemDetail.Content;
                            paperItem.CreatePerson   = itemDetail.CreatePerson;
                            paperItem.CreateTime     = itemDetail.CreateTime;
                            paperItem.Description    = itemDetail.Description;
                            paperItem.DifficultyId   = itemDetail.DifficultyId;
                            paperItem.ItemId         = itemDetail.ItemId;
                            paperItem.Memo           = itemDetail.Memo;
                            paperItem.OrganizationId = itemDetail.OrganizationId;
                            paperItem.OutDateDate    = itemDetail.OutDateDate;
                            paperItem.Score          = Math.Round(nUnitScore / itemDetails.Count, 2);
                            paperItem.SelectAnswer   = itemDetail.SelectAnswer;
                            paperItem.Source         = itemDetail.Source;
                            paperItem.StandardAnswer = itemDetail.StandardAnswer;
                            paperItem.StatusId       = itemDetail.StatusId;
                            paperItem.TypeId         = itemDetail.TypeId;
                            paperItem.UsedCount      = itemDetail.UsedCount;
                            paperItem.Version        = itemDetail.Version;
                            paperItem.ParentItemID   = item.ItemId;
                            paperItem.MotherCode     = itemDetail.MotherCode;
                            paperItem.ItemIndex      = itemDetail.ItemIndex;
                            randomExamItems.Add(paperItem);
                        }
                    }
                }

                if (count == 1)
                {
                    SessionSet.PageMessage = "组卷策略不能重复,请重新设置取题范围!";
                    return;
                }

                if (n == 1)
                {
                    SessionSet.PageMessage = "大题" + (i + 1).ToString() + "有无标准答案的试题,请重新设置取题范围!";
                    return;
                }

                if (randomExamItems.Count > 0)
                {
                    randomItemBLL.AddItem(randomExamItems, year);
                }
            }

            Hashtable hashTableItemIds = new Hashtable();

            for (int i = 0; i < randomExamSubjects.Count; i++)
            {
                int nSubjectId = randomExamSubjects[i].RandomExamSubjectId;
                //int nItemCount = randomExamSubjects[i].ItemCount;

                IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                for (int j = 0; j < strategys.Count; j++)
                {
                    int nStrategyId = strategys[j].RandomExamStrategyId;
                    int nItemCount  = strategys[j].ItemCount;

                    IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, year);
                    Random    ObjRandom             = new Random();
                    Hashtable hashTable             = new Hashtable();
                    Hashtable hashTableCount        = new Hashtable();
                    while (hashTable.Count < nItemCount)
                    {
                        int k = ObjRandom.Next(itemList.Count);
                        hashTableCount[k] = k;
                        int itemID = itemList[k].ItemId;
                        if (!hashTableItemIds.ContainsKey(itemID))
                        {
                            hashTable[itemID]        = itemID;
                            hashTableItemIds[itemID] = itemID;
                        }
                        if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount)
                        {
                            SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!";
                            return;
                        }
                    }
                }
            }

            objBll.UpdateVersion(Convert.ToInt32(strId));

            if (obj.IsComputerExam)
            {
                Response.Redirect("SelectEmployeeDetailNew.aspx?startmode=" + strStartMode + "&mode=" + strMode + "&id=" + strId);
            }
            else
            {
                Response.Write("<script>top.window.opener.form1.Refresh.value='true';top.window.opener.form1.submit();top.window.close();</script>");
            }
        }
Esempio n. 11
0
        private void AddResultToDB(string strId)
        {
            RandomExamSubjectBLL       subjectBLL          = new RandomExamSubjectBLL();
            RandomExamItemBLL          randomItemBLL       = new RandomExamItemBLL();
            RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL();
            RandomExamStrategyBLL      strategyBLL         = new RandomExamStrategyBLL();

            RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            IList <RandomExamItem>           randomExamItems           = new List <RandomExamItem>();

            RailExam.Model.RandomExamResultCurrent randomExamResult = new RailExam.Model.RandomExamResultCurrent();

            randomExamResult.RandomExamId    = int.Parse(strId);
            randomExamResult.AutoScore       = 0;
            randomExamResult.BeginDateTime   = DateTime.Parse(ViewState["BeginTime"].ToString());
            randomExamResult.CurrentDateTime = DateTime.Parse(ViewState["BeginTime"].ToString());
            randomExamResult.ExamTime        = 0;
            randomExamResult.EndDateTime     = DateTime.Parse(ViewState["BeginTime"].ToString());
            randomExamResult.Score           = 0;
            randomExamResult.OrganizationId  = int.Parse(ViewState["OrgID"].ToString());
            randomExamResult.Memo            = "";
            randomExamResult.StatusId        = 1;
            randomExamResult.AutoScore       = 0;
            randomExamResult.CorrectRate     = 0;
            randomExamResult.ExamineeId      = int.Parse(ViewState["EmployeeID"].ToString());

            int    nRandomExamResultPK = randomExamResultBLL.AddRandomExamResultCurrent(randomExamResult);
            string strSql = "select a.* from Computer_Room a "
                            + "inner join Computer_Server b on a.Computer_Server_ID=b.Computer_Server_ID "
                            + "where Computer_Server_No='" + PrjPub.ServerNo + "'";
            OracleAccess db             = new OracleAccess();
            DataSet      ds             = db.RunSqlDataSet(strSql);
            string       computerRoomID = string.Empty;

            if (ds.Tables[0].Rows.Count > 0)
            {
                computerRoomID = ds.Tables[0].Rows[0]["Computer_Room_ID"].ToString();
            }

            strSql = @"insert into Random_Exam_Result_Detail values("
                     + nRandomExamResultPK + "," + int.Parse(strId) + ","
                     + ViewState["EmployeeID"].ToString() + ",0,null,null,null,Random_Exam_Result_Detail_Seq.Nextval,"
                     + "0,null," + (computerRoomID == string.Empty ? "null" : computerRoomID) + ",null,null,null,null)";
            db.ExecuteNonQuery(strSql);

            ViewState["RandomExamResultID"] = nRandomExamResultPK;

            IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));

            Hashtable hashTableItemIds    = new Hashtable();
            Hashtable htRandomExamItemIds = new Hashtable();

            for (int i = 0; i < randomExamSubjects.Count; i++)
            {
                int nSubjectId = randomExamSubjects[i].RandomExamSubjectId;
                // int nItemCount = randomExamSubjects[i].ItemCount;

                IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                for (int j = 0; j < strategys.Count; j++)
                {
                    int nStrategyId = strategys[j].RandomExamStrategyId;
                    int nItemCount  = strategys[j].ItemCount;
                    IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, Convert.ToInt32(ViewState["Year"].ToString()));
                    Random    ObjRandom             = new Random();
                    Hashtable hashTable             = new Hashtable();
                    Hashtable hashTableCount        = new Hashtable();
                    while (hashTable.Count < nItemCount)
                    {
                        int k = ObjRandom.Next(itemList.Count);
                        hashTableCount[k] = k;
                        int itemID     = itemList[k].ItemId;
                        int examItemID = itemList[k].RandomExamItemId;
                        if (!hashTableItemIds.ContainsKey(itemID))
                        {
                            hashTable[examItemID]           = examItemID;
                            hashTableItemIds[itemID]        = itemID;
                            htRandomExamItemIds[examItemID] = examItemID;
                        }
                        if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount)
                        {
                            SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!";
                            return;
                        }
                    }
                }
            }

            string strAll = "";

            foreach (int key in htRandomExamItemIds.Keys)
            {
                if (strAll == "")
                {
                    strAll += htRandomExamItemIds[key].ToString();
                }
                else
                {
                    strAll += "," + htRandomExamItemIds[key].ToString();
                }
            }
            randomExamResultAnswerBLL.AddExamResultAnswerCurrent(nRandomExamResultPK, strAll);
        }