private void DeleteData(int nBookID) { RandomExamSubjectBLL paperStrategySubjectBLL = new RandomExamSubjectBLL(); RandomExamSubject paperStrategySubject = paperStrategySubjectBLL.GetRandomExamSubject(int.Parse(Request.QueryString.Get("id"))); if (paperStrategySubject != null) { RandomExamResultBLL reBll = new RandomExamResultBLL(); IList <RailExam.Model.RandomExamResult> examResults = reBll.GetRandomExamResultByExamID(paperStrategySubject.RandomExamId); if (Pub.HasPaper(Convert.ToInt32(paperStrategySubject.RandomExamId))) { SessionSet.PageMessage = "该考试已生成试卷,取题范围不能被删除!"; return; } if (examResults.Count > 0) { SessionSet.PageMessage = "已有考生参加考试,取题范围不能被删除!"; return; } } RandomExamStrategyBLL paperStrategyBookChapterBLL = new RandomExamStrategyBLL(); paperStrategyBookChapterBLL.DeleteRandomExamStrategy(nBookID); OracleAccess db = new OracleAccess(); string strSql = "delete from Random_Exam_Strategy where Is_Mother_Item=1 and Mother_ID=" + nBookID; db.ExecuteNonQuery(strSql); strSql = "delete from Random_Exam_Item_Select where RANDOM_EXAM_STRATEGY_ID=" + nBookID; db.ExecuteNonQuery(strSql); }
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; } }
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; } }