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); } }
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; } }