示例#1
0
        protected void btnExClude_Click(object sender, EventArgs e)
        {
            string       strSql;
            OracleAccess db = new OracleAccess();

            string strID = Request.QueryString.Get("id") == null ? "null" : Request.QueryString.Get("id");

            //先在Random_Exam_Item_Select中删除所选教材章节的试题
            strSql = "delete from Random_Exam_Item_Select where RANDOM_EXAM_STRATEGY_ID=" + hfKeyID.Value;
            db.ExecuteNonQuery(strSql);

            //再在Random_Exam_Item_Select中插入所选教材章节的试题
            if (HfExCludeChaptersId.Value != "")
            {
                strSql = "insert into Random_Exam_Item_Select " +
                         " select Random_Exam_Item_Select_Seq.nextval,a.Item_ID," + hfExamID.Value + @"," + hfKeyID.Value + "," + hfSubjectId.Value +
                         @" from Item a  inner join Book_Chapter b on a.Chapter_ID=b.Chapter_ID " + GetSelectSql() + " and  instr(','||'" + HfExCludeChaptersId.Value + "'||',',','||a.CHAPTER_ID||',' )=0 ";
            }
            else
            {
                strSql = "insert into Random_Exam_Item_Select " +
                         " select Random_Exam_Item_Select_Seq.nextval,a.Item_ID," + hfExamID.Value + @"," + hfKeyID.Value + "," + hfSubjectId.Value +
                         @" from Item a inner join Book_Chapter b on a.Chapter_ID=b.Chapter_ID " + GetSelectSql();
            }
            db.ExecuteNonQuery(strSql);

            strSql              = "select * from Random_Exam_Item_Select where RANDOM_EXAM_STRATEGY_ID=" + hfKeyID.Value;
            lblTotalCount.Text  = db.RunSqlDataSet(strSql).Tables[0].Rows.Count.ToString();
            lblSelectCount.Text = db.RunSqlDataSet(strSql).Tables[0].Rows.Count.ToString();

            if (strID != "null")
            {
                RandomExamStrategyBLL randomExamStrategyBll = new RandomExamStrategyBLL();
                RandomExamStrategy    randomExamStrategy    =
                    randomExamStrategyBll.GetRandomExamStrategy(Convert.ToInt32(strID));
                randomExamStrategy.RangeType        = int.Parse(HfRangeType.Value);
                randomExamStrategy.RangeId          = int.Parse(HfChapterId.Value);
                randomExamStrategy.ItemTypeId       = int.Parse(ddlType.SelectedValue);
                randomExamStrategy.RangeName        = HfRangeName.Value;
                randomExamStrategy.ExcludeChapterId = HfExCludeChaptersId.Value;
                randomExamStrategyBll.UpdateRandomExamStrategy(randomExamStrategy);
            }
        }
示例#2
0
        protected void SaveButton_Click(object sender, ImageClickEventArgs e)
        {
            if (txtNDR.Text == "")
            {
                txtNDR.Text = "0";
            }

            RandomExamStrategyBLL      paperStrategyBookChapterBLL = new RandomExamStrategyBLL();
            RandomExamStrategy         paperStrategyBookChapter;
            IList <RandomExamStrategy> objList = new List <RandomExamStrategy>();


            int    sumCount        = 0;
            string strErrorMessage = "";

            #region 原母题

            /*
             * if (mother2.Visible)
             * {
             *  foreach (GridViewRow gridRow in Grid1.Rows)
             *  {
             *      Label lblName = (Label) gridRow.FindControl("ChapterName");
             *      HiddenField chapterId = (HiddenField) gridRow.FindControl("hfChapterId");
             *      Label lblMaxCount = (Label) gridRow.FindControl("hfMaxItemCount");
             *      TextBox txtCount = (TextBox) gridRow.FindControl("txtItemCount");
             *
             *      int maxCount = Convert.ToInt32(lblMaxCount.Text);
             *      int nCount;
             *      try
             *      {
             *          nCount = Convert.ToInt32(txtCount.Text);
             *
             *          if (nCount < 0)
             *          {
             *              strErrorMessage = "【" + lblName.Text + "】选题数必须为正整数!";
             *              break;
             *          }
             *      }
             *      catch
             *      {
             *          strErrorMessage = "【" + lblName.Text + "】选题数必须为正整数!";
             *          break;
             *      }
             *
             *      if (nCount > maxCount)
             *      {
             *          strErrorMessage = "【" + lblName.Text + "】选题数必须小于最大题数!";
             *          break;
             *      }
             *
             *      sumCount += nCount;
             *
             *      paperStrategyBookChapter = new RandomExamStrategy();
             *
             *      paperStrategyBookChapter.SubjectId = int.Parse(hfSubjectId.Value);
             *      paperStrategyBookChapter.RangeType = 4;
             *      paperStrategyBookChapter.RangeId = int.Parse(chapterId.Value);
             *      paperStrategyBookChapter.ItemTypeId = int.Parse(ddlType.SelectedValue);
             *      paperStrategyBookChapter.ExcludeChapterId = "";
             *      paperStrategyBookChapter.Memo = "";
             *      paperStrategyBookChapter.RangeName = lblName.Text;
             *      paperStrategyBookChapter.ItemCount = nCount;
             *      paperStrategyBookChapter.ItemDifficultyID = 3;
             *      paperStrategyBookChapter.IsMotherItem = true;
             *      objList.Add(paperStrategyBookChapter);
             *
             *      if (("," + HfExCludeChaptersId + ",").IndexOf("," + chapterId.Value + ",") <= 0)
             *      {
             *          if (HfExCludeChaptersId.Value == "")
             *          {
             *              HfExCludeChaptersId.Value = chapterId.Value;
             *          }
             *          else
             *          {
             *              HfExCludeChaptersId.Value += "," + chapterId.Value;
             *          }
             *      }
             *  }
             * }*/
            #endregion

            if (!string.IsNullOrEmpty(strErrorMessage))
            {
                SessionSet.PageMessage = strErrorMessage;
                return;
            }

            int totalCount  = int.Parse(lblTotalCount.Text);
            int selectCount = int.Parse(lblSelectCount.Text);
            int leaveCount  = int.Parse(labelLeaveCount.Text);
            int nowCount;

            try
            {
                nowCount = Convert.ToInt32(txtNDR.Text);
            }
            catch (Exception)
            {
                SessionSet.PageMessage = "选择题数必须为数字!";
                return;
            }

            if (nowCount > selectCount)
            {
                SessionSet.PageMessage = "选择题数必须小于等于可选题数!";
                return;
            }

            if (nowCount > leaveCount)
            {
                SessionSet.PageMessage = "选择题数必须小于等于还剩题数!";
                return;
            }

            //if(totalCount- sumCount <0)
            //{
            //    SessionSet.PageMessage = "组题策略的选题数必须大于母题取题数之和!";
            //    return;
            //}

            paperStrategyBookChapter                  = new RandomExamStrategy();
            paperStrategyBookChapter.SubjectId        = int.Parse(hfSubjectId.Value);
            paperStrategyBookChapter.RangeType        = int.Parse(HfRangeType.Value);
            paperStrategyBookChapter.RangeId          = int.Parse(HfChapterId.Value);
            paperStrategyBookChapter.ItemTypeId       = int.Parse(ddlType.SelectedValue);
            paperStrategyBookChapter.ExcludeChapterId = HfExCludeChaptersId.Value;
            paperStrategyBookChapter.Memo             = txtMemo.Text;
            paperStrategyBookChapter.RangeName        = HfRangeName.Value;
            paperStrategyBookChapter.ItemCount        = nowCount;
            paperStrategyBookChapter.IsMotherItem     = false;
            paperStrategyBookChapter.ItemDifficultyID = 3;

            if (ViewState["mode"].ToString() == "Insert")
            {
                paperStrategyBookChapter.RandomExamStrategyId = Convert.ToInt32(hfKeyID.Value);
                paperStrategyBookChapterBLL.AddRandomExamStrategy(paperStrategyBookChapter);

                #region 原母题

                /*
                 * foreach (RandomExamStrategy obj in objList)
                 * {
                 *  obj.MotherID = key;
                 *  paperStrategyBookChapterBLL.AddRandomExamStrategy(obj);
                 * }
                 */

                #endregion
            }
            else if (ViewState["mode"].ToString() == "Edit")
            {
                string strId = Request.QueryString.Get("id");

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

                paperStrategyBookChapter.RandomExamStrategyId = int.Parse(strId);
                paperStrategyBookChapterBLL.UpdateRandomExamStrategy(paperStrategyBookChapter);

                #region 原母题

                /*
                 * OracleAccess db = new OracleAccess();
                 * string strSql = "delete from Random_Exam_Strategy where Is_Mother_Item=1 and Mother_ID=" + strId;
                 * db.ExecuteNonQuery(strSql);
                 *
                 * foreach (RandomExamStrategy obj in objList)
                 * {
                 *  obj.MotherID = int.Parse(strId);
                 *  paperStrategyBookChapterBLL.AddRandomExamStrategy(obj);
                 * }*/
                #endregion
            }

            //Response.Write("<script>var p = window.opener; if(p) p.document.form1.submit();window.close();</script>");

            Response.Write("<script>window.returnValue='true';window.close();</script>");
        }