private void FillPage(int nID) { PaperStrategyBookChapterBLL paperStrategyBookChapterBLL = new PaperStrategyBookChapterBLL(); PaperStrategyBookChapter paperStrategyBookChapter = paperStrategyBookChapterBLL.GetPaperStrategyBookChapter(nID); if (paperStrategyBookChapter != null) { txtMemo.Text = paperStrategyBookChapter.Memo; txtChapterName.Text = paperStrategyBookChapter.RangeName; HfRangeName.Value = paperStrategyBookChapter.RangeName; txtSubjectName.Text = paperStrategyBookChapter.SubjectName; txtExCludeChapters.Text = paperStrategyBookChapter.ExcludeChapterId; if (string.IsNullOrEmpty(paperStrategyBookChapter.ExcludeChapterId) == false) { FillExcludeCategorysID(paperStrategyBookChapter.ExcludeChapterId); } txtNd1.Text = paperStrategyBookChapter.ItemDifficulty1Count.ToString(); txtNd2.Text = paperStrategyBookChapter.ItemDifficulty2Count.ToString(); txtNd3.Text = paperStrategyBookChapter.ItemDifficulty3Count.ToString(); txtNd4.Text = paperStrategyBookChapter.ItemDifficulty4Count.ToString(); txtNd5.Text = paperStrategyBookChapter.ItemDifficulty5Count.ToString(); txtNDR.Text = paperStrategyBookChapter.ItemDifficultyRandomCount.ToString(); txtScore.Text = paperStrategyBookChapter.UnitScore.ToString(); txtSeconds.Text = paperStrategyBookChapter.UnitLimitTime.ToString(); hfSubjectId.Value = paperStrategyBookChapter.StrategySubjectId.ToString(); HfRangeType.Value = paperStrategyBookChapter.RangeType.ToString(); HfChapterId.Value = paperStrategyBookChapter.RangeId.ToString(); ddlType.SelectedValue = paperStrategyBookChapter.ItemTypeId.ToString(); PaperStrategySubjectBLL paperStrategySubjectBLL = new PaperStrategySubjectBLL(); PaperStrategySubject paperStrategySubject = paperStrategySubjectBLL.GetPaperStrategySubject(int.Parse(hfSubjectId.Value)); if (paperStrategySubject != null) { labelTotalCount.Text = paperStrategySubject.ItemCount.ToString(); } } if (ViewState["mode"].ToString() == "ReadOnly") { SaveButton.Visible = false; CancelButton.Visible = true; ddlType.Enabled = false; txtNDR.Enabled = false; txtNd1.Enabled = false; txtNd2.Enabled = false; txtNd3.Enabled = false; txtNd4.Enabled = false; txtNd5.Enabled = false; txtSeconds.Enabled = false; txtMemo.Enabled = false; } }
protected void SaveButton_Click(object sender, EventArgs e) { if (txtNd1.Text == "") { txtNd1.Text = "0"; } if (txtNd2.Text == "") { txtNd2.Text = "0"; } if (txtNd3.Text == "") { txtNd3.Text = "0"; } if (txtNd4.Text == "") { txtNd4.Text = "0"; } if (txtNd5.Text == "") { txtNd5.Text = "0"; } if (txtNDR.Text == "") { txtNDR.Text = "0"; } if (txtScore.Text == "") { txtScore.Text = "0"; } if (txtSeconds.Text == "") { txtSeconds.Text = "0"; } PaperStrategyBookChapterBLL paperStrategyBookChapterBLL = new PaperStrategyBookChapterBLL(); PaperStrategyBookChapter paperStrategyBookChapter = new PaperStrategyBookChapter(); paperStrategyBookChapter.StrategySubjectId = int.Parse(hfSubjectId.Value); paperStrategyBookChapter.RangeType = int.Parse(HfRangeType.Value); paperStrategyBookChapter.RangeId = int.Parse(HfChapterId.Value); paperStrategyBookChapter.ItemTypeId = int.Parse(ddlType.SelectedValue); paperStrategyBookChapter.ItemDifficultyRandomCount = int.Parse(txtNDR.Text); paperStrategyBookChapter.ItemDifficulty1Count = int.Parse(txtNd1.Text); paperStrategyBookChapter.ItemDifficulty2Count = int.Parse(txtNd2.Text); paperStrategyBookChapter.ItemDifficulty3Count = int.Parse(txtNd3.Text); paperStrategyBookChapter.ItemDifficulty4Count = int.Parse(txtNd4.Text); paperStrategyBookChapter.ItemDifficulty5Count = int.Parse(txtNd5.Text); paperStrategyBookChapter.UnitScore = decimal.Parse(txtScore.Text); paperStrategyBookChapter.ExcludeChapterId = HfExCludeChaptersId.Value; paperStrategyBookChapter.UnitLimitTime = int.Parse(txtSeconds.Text); paperStrategyBookChapter.Memo = txtMemo.Text; paperStrategyBookChapter.RangeName = HfRangeName.Value; if (ViewState["mode"].ToString() == "Insert") { paperStrategyBookChapterBLL.AddPaperStrategyBookChapter(paperStrategyBookChapter); } else if (ViewState["mode"].ToString() == "Edit") { string strId = Request.QueryString.Get("id"); paperStrategyBookChapter.PaperStrategyBookChapterId = int.Parse(strId); paperStrategyBookChapterBLL.UpdatePaperStrategyBookChapter(paperStrategyBookChapter); } Response.Write("<script>var p = window.opener; if(p) p.document.form1.submit();window.close();</script>"); }
private void DeleteData(int nBookID) { PaperStrategyBookChapterBLL paperStrategyBookChapterBLL = new PaperStrategyBookChapterBLL(); paperStrategyBookChapterBLL.DeletePaperStrategyBookChapter(nBookID); }
protected void btnSave_Click(object sender, EventArgs e) { PaperStrategyBookChapterBLL psbcBll = new PaperStrategyBookChapterBLL(); int Ncount = psbcBll.GetBookChapterCount(int.Parse(Request.QueryString.Get("id"))); if (Ncount == 0) { SessionSet.PageMessage = "请添加策略!"; return; } string strPaperID = Request.QueryString.Get("Paperid"); if (!string.IsNullOrEmpty(strPaperID)) { int nStrategyId = int.Parse(Request.QueryString.Get("id")); int nPaperId = int.Parse(strPaperID); PaperStrategyBLL paperStrategyBLL = new PaperStrategyBLL(); RailExam.Model.PaperStrategy paperStrategy = paperStrategyBLL.GetPaperStrategy(nStrategyId); PaperStrategySubjectBLL paperStrategySubjectBLL = new PaperStrategySubjectBLL(); IList <PaperStrategySubject> paperStrategySubjects = paperStrategySubjectBLL.GetPaperStrategySubjectByPaperStrategyId(nStrategyId); int nStrategyMode = paperStrategy.StrategyMode; for (int i = 0; i < paperStrategySubjects.Count; i++) { //大题 PaperSubjectBLL paperSubjectBLL = new PaperSubjectBLL(); PaperSubject paperSubject = new PaperSubject(); paperSubject.ItemCount = paperStrategySubjects[i].ItemCount; paperSubject.ItemTypeId = paperStrategySubjects[i].ItemTypeId; paperSubject.Memo = paperStrategySubjects[i].Memo; paperSubject.OrderIndex = paperStrategySubjects[i].OrderIndex; paperSubject.PaperId = nPaperId; paperSubject.Remark = paperStrategySubjects[i].Remark; paperSubject.SubjectName = paperStrategySubjects[i].SubjectName; paperSubject.TotalScore = paperStrategySubjects[i].TotalScore; paperSubject.UnitScore = paperStrategySubjects[i].UnitScore; decimal nUnitScore = paperSubject.UnitScore; int nPaperSubjectId = paperSubjectBLL.AddPaperSubject(paperSubject); ItemBLL itemBLL = new ItemBLL(); if (nStrategyMode == 2) //教材章节模式 { PaperStrategyBookChapterBLL paperStrategyBookChapterBLL = new PaperStrategyBookChapterBLL(); IList <PaperStrategyBookChapter> paperStrategyBookChapters = paperStrategyBookChapterBLL.GetItemsByPaperStrategySubjectID(paperStrategySubjects[i].PaperStrategySubjectId); for (int k = 0; k < paperStrategyBookChapters.Count; k++) { //策略 int nChapterId = paperStrategyBookChapters[k].RangeId; int nRangeType = paperStrategyBookChapters[k].RangeType; int typeId = paperStrategyBookChapters[k].ItemTypeId; int nDifficultR = paperStrategyBookChapters[k].ItemDifficultyRandomCount; //int nDifficulty1 = paperStrategyBookChapters[k].ItemDifficulty1Count; //int nDifficulty2 = paperStrategyBookChapters[k].ItemDifficulty2Count; //int nDifficulty3 = paperStrategyBookChapters[k].ItemDifficulty3Count; //int nDifficulty4 = paperStrategyBookChapters[k].ItemDifficulty4Count; //int nDifficulty5 = paperStrategyBookChapters[k].ItemDifficulty5Count; decimal uScore = paperStrategyBookChapters[k].UnitScore; string strExcludeIDs = paperStrategyBookChapters[k].ExcludeChapterId; //难度1 //IList<RailExam.Model.Item> itemList = itemBLL.GetItemsByStrategy(nRangeType,1, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty1, nPaperId, nPaperSubjectId, nUnitScore); ////难度2 //itemList = itemBLL.GetItemsByStrategy(nRangeType,2, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty2, nPaperId, nPaperSubjectId, nUnitScore); ////难度3 //itemList = itemBLL.GetItemsByStrategy(nRangeType,3, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty3, nPaperId, nPaperSubjectId, nUnitScore); ////难度4 //itemList = itemBLL.GetItemsByStrategy(nRangeType,4, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty4, nPaperId, nPaperSubjectId, nUnitScore); ////难度5 //itemList = itemBLL.GetItemsByStrategy(nRangeType,5, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty5, nPaperId, nPaperSubjectId, nUnitScore); //随机难度 Random ObjRandom = new Random(); int ndr = ObjRandom.Next(1, 5); //IList<RailExam.Model.Item> itemList = itemBLL.GetItemsByStrategy(nRangeType, ndr, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficultR, nPaperId, nPaperSubjectId, nUnitScore); } } } int itemCount = 0; decimal totalScore = 0; PaperItemBLL paperBLL = new PaperItemBLL(); IList <RailExam.Model.PaperItem> PaperItems = paperBLL.GetItemsByPaperId(nPaperId); if (PaperItems.Count > 0) { itemCount = PaperItems.Count; totalScore = PaperItems[0].Score * PaperItems.Count; } btnPreview.Visible = true; this.btnedit.Visible = true; this.btnSave.Visible = false; NewButton.Visible = false; btnLast.Visible = false; SessionSet.PageMessage = "随机生成试卷共" + itemCount + "题," + totalScore + "分,如果试卷题数不等于设定的总题数请手工进行修改!"; ViewState["DeleteFlag"] = 1; } else { Response.Write("<script>top.window.opener.form1.Refresh.value='true';top.window.opener.form1.submit();top.window.close();</script>"); } }
protected void btnSave_Click(object sender, EventArgs e) { int nStrategyId = int.Parse(hfStrategyId.Value); int nPaperId = int.Parse(Request.QueryString.Get("id")); PaperStrategyBLL paperStrategyBLL = new PaperStrategyBLL(); RailExam.Model.PaperStrategy paperStrategy = paperStrategyBLL.GetPaperStrategy(nStrategyId); PaperStrategySubjectBLL paperStrategySubjectBLL = new PaperStrategySubjectBLL(); IList <PaperStrategySubject> paperStrategySubjects = paperStrategySubjectBLL.GetPaperStrategySubjectByPaperStrategyId(nStrategyId); int nStrategyMode = paperStrategy.StrategyMode; txtStrategyName.Text = paperStrategy.PaperStrategyName; for (int i = 0; i < paperStrategySubjects.Count; i++) { //大题 PaperSubjectBLL paperSubjectBLL = new PaperSubjectBLL(); PaperSubject paperSubject = new PaperSubject(); paperSubject.ItemCount = paperStrategySubjects[i].ItemCount; paperSubject.ItemTypeId = paperStrategySubjects[i].ItemTypeId; paperSubject.Memo = paperStrategySubjects[i].Memo; paperSubject.OrderIndex = paperStrategySubjects[i].OrderIndex; paperSubject.PaperId = nPaperId; paperSubject.Remark = paperStrategySubjects[i].Remark; paperSubject.SubjectName = paperStrategySubjects[i].SubjectName; paperSubject.TotalScore = paperStrategySubjects[i].TotalScore; paperSubject.UnitScore = paperStrategySubjects[i].UnitScore; decimal nUnitScore = paperSubject.UnitScore; int nPaperSubjectId = paperSubjectBLL.AddPaperSubject(paperSubject); ItemBLL itemBLL = new ItemBLL(); if (nStrategyMode == 2) //教材章节模式 { PaperStrategyBookChapterBLL paperStrategyBookChapterBLL = new PaperStrategyBookChapterBLL(); IList <PaperStrategyBookChapter> paperStrategyBookChapters = paperStrategyBookChapterBLL.GetItemsByPaperStrategySubjectID(paperStrategySubjects[i].PaperStrategySubjectId); for (int k = 0; k < paperStrategyBookChapters.Count; k++) { //策略 int nChapterId = paperStrategyBookChapters[k].RangeId; int typeId = paperStrategyBookChapters[k].ItemTypeId; int nRangeType = paperStrategyBookChapters[k].RangeType; int nDifficultR = paperStrategyBookChapters[k].ItemDifficultyRandomCount; //int nDifficulty1 = paperStrategyBookChapters[k].ItemDifficulty1Count; //int nDifficulty2 = paperStrategyBookChapters[k].ItemDifficulty2Count; //int nDifficulty3 = paperStrategyBookChapters[k].ItemDifficulty3Count; //int nDifficulty4 = paperStrategyBookChapters[k].ItemDifficulty4Count; //int nDifficulty5 = paperStrategyBookChapters[k].ItemDifficulty5Count; decimal uScore = paperStrategyBookChapters[k].UnitScore; string strExcludeIDs = paperStrategyBookChapters[k].ExcludeChapterId; ////难度1 //IList<RailExam.Model.Item> itemList = itemBLL.GetItemsByStrategy(nRangeType, 1, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty1, nPaperId, nPaperSubjectId, nUnitScore); ////难度2 //itemList = itemBLL.GetItemsByStrategy(nRangeType, 2, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty2, nPaperId, nPaperSubjectId, nUnitScore); ////难度3 //itemList = itemBLL.GetItemsByStrategy(nRangeType, 3, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty3, nPaperId, nPaperSubjectId, nUnitScore); ////难度4 //itemList = itemBLL.GetItemsByStrategy(nRangeType, 4, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty4, nPaperId, nPaperSubjectId, nUnitScore); ////难度5 //itemList = itemBLL.GetItemsByStrategy(nRangeType, 5, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty5, nPaperId, nPaperSubjectId, nUnitScore); //随机难度 Random ObjRandom = new Random(); int ndr = ObjRandom.Next(1, 5); //IList<RailExam.Model.Item> itemList = itemBLL.GetItemsByStrategy(nRangeType, ndr, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficultR, nPaperId, nPaperSubjectId, nUnitScore); } } else //试题辅助分类模式 { PaperStrategyItemCategoryBLL paperStrategyItemCategoryBLL = new PaperStrategyItemCategoryBLL(); IList <PaperStrategyItemCategory> paperStrategyItemCategorys = paperStrategyItemCategoryBLL.GetItemsByPaperSubjectId(paperStrategySubjects[i].PaperStrategySubjectId); for (int k = 0; k < paperStrategyItemCategorys.Count; k++) { //策略 int nChapterId = paperStrategyItemCategorys[k].ItemCategoryId; int typeId = paperStrategyItemCategorys[k].ItemTypeId; int nDifficultR = paperStrategyItemCategorys[k].ItemDifficultyRandomCount; //int nDifficulty1 = paperStrategyItemCategorys[k].ItemDifficulty1Count; //int nDifficulty2 = paperStrategyItemCategorys[k].ItemDifficulty2Count; //int nDifficulty3 = paperStrategyItemCategorys[k].ItemDifficulty3Count; //int nDifficulty4 = paperStrategyItemCategorys[k].ItemDifficulty4Count; //int nDifficulty5 = paperStrategyItemCategorys[k].ItemDifficulty5Count; decimal uScore = paperStrategyItemCategorys[k].UnitScore; string strExcludeIDs = paperStrategyItemCategorys[k].ExcludeCategorysId; ////难度1 //IList<RailExam.Model.Item> itemList = itemBLL.GetItemsByStrategyItem(1, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty1, nPaperId, nPaperSubjectId, nUnitScore); ////难度2 //itemList = itemBLL.GetItemsByStrategyItem(2, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty2, nPaperId, nPaperSubjectId, nUnitScore); ////难度3 //itemList = itemBLL.GetItemsByStrategyItem(3, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty3, nPaperId, nPaperSubjectId, nUnitScore); ////难度4 //itemList = itemBLL.GetItemsByStrategyItem(4, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty4, nPaperId, nPaperSubjectId, nUnitScore); ////难度5 //itemList = itemBLL.GetItemsByStrategyItem(5, nChapterId, typeId, strExcludeIDs); //SavePaperItem(itemList, nDifficulty5, nPaperId, nPaperSubjectId, nUnitScore); //随机难度 Random ObjRandom = new Random(); int ndr = ObjRandom.Next(1, 5); IList <RailExam.Model.Item> itemList = itemBLL.GetItemsByStrategyItem(ndr, nChapterId, typeId, strExcludeIDs); SavePaperItem(itemList, nDifficultR, nPaperId, nPaperSubjectId, nUnitScore); } } } int itemCount = 0; decimal totalScore = 0; PaperItemBLL paperBLL = new PaperItemBLL(); IList <RailExam.Model.PaperItem> PaperItems = paperBLL.GetItemsByPaperId(nPaperId); if (PaperItems.Count > 0) { itemCount = PaperItems.Count; totalScore = PaperItems[0].Score * PaperItems.Count; } SessionSet.PageMessage = "随机生成试卷共" + itemCount + "题," + totalScore + "分,如果试卷题数不等于设定的总题数请手工进行修改!"; this.btnSave.Visible = false; this.btnLast.Visible = false; btnPreview.Visible = true; btnEdit.Visible = true; }