public IList <RandomExamStrategy> GetRandomExamStrategysByExamID(int RandomExamID) { SystemVersionDAL systemVersionDal = new SystemVersionDAL(); int usePlace = systemVersionDal.GetUsePlace(); IList <RandomExamStrategy> items = new List <RandomExamStrategy>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_Random_Exam_Strategy_F"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_RANDOM_EXAM_ID", DbType.Int32, RandomExamID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { RandomExamStrategy item = CreateModelObject(dataReader); if (usePlace == 3) { item.MaxItemDifficultyID = Convert.ToInt32(dataReader[GetMappingFieldName("MaxItemDifficultyID")].ToString()); item.MaxItemDifficultyName = dataReader[GetMappingFieldName("MaxItemDifficultyName")].ToString(); } items.Add(item); } } return(items); }
public RandomExamStrategy GetRandomExamStrategy(int ExamStrategyId) { SystemVersionDAL systemVersionDal = new SystemVersionDAL(); int usePlace = systemVersionDal.GetUsePlace(); RandomExamStrategy item = null; Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_Random_Exam_Strategy_g"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_Random_Exam_Strategy_Id", DbType.Int32, ExamStrategyId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { item = CreateModelObject(dataReader); if (usePlace == 3) { item.MaxItemDifficultyID = Convert.ToInt32(dataReader[GetMappingFieldName("MaxItemDifficultyID")].ToString()); item.MaxItemDifficultyName = dataReader[GetMappingFieldName("MaxItemDifficultyName")].ToString(); } break; } } return(item); }
public IList <RandomExamStrategy> GetTotalRandomExamStrategys(int SubjectID) { SystemVersionDAL systemVersionDal = new SystemVersionDAL(); int usePlace = systemVersionDal.GetUsePlace(); IList <RandomExamStrategy> items = new List <RandomExamStrategy>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_Random_Exam_Strategy_Q_T"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_subject_id", DbType.Int32, SubjectID); db.AddInParameter(dbCommand, "p_range_id", DbType.Int32, 0); db.AddInParameter(dbCommand, "p_range_type", DbType.Int32, 0); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { RandomExamStrategy item = CreateModelObject(dataReader); if (usePlace == 3) { item.MaxItemDifficultyID = Convert.ToInt32(dataReader[GetMappingFieldName("MaxItemDifficultyID")].ToString()); item.MaxItemDifficultyName = dataReader[GetMappingFieldName("MaxItemDifficultyName")].ToString(); } item.TotalItemCount = Convert.ToInt32(dataReader[GetMappingFieldName("TotalItemCount")].ToString()); item.SelectCount = Convert.ToInt32(dataReader[GetMappingFieldName("SelectCount")].ToString()); items.Add(item); } } return(items); }
public void AddRandomExamStrategy(RandomExamStrategy item) { Database db = DatabaseFactory.CreateDatabase(); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); int nRecordAffected = 0; try { string sqlCommand = "USP_Random_Exam_Strategy_I"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); //db.AddOutParameter(dbCommand, "p_Random_Exam_Strategy_Id", DbType.Int32, 4); db.AddInParameter(dbCommand, "p_Random_Exam_Strategy_Id", DbType.Int32, item.RandomExamStrategyId); db.AddInParameter(dbCommand, "p_subject_id", DbType.Int32, item.SubjectId); db.AddInParameter(dbCommand, "p_Range_type", DbType.Int32, item.RangeType); db.AddInParameter(dbCommand, "p_Range_id", DbType.Int32, item.RangeId); db.AddInParameter(dbCommand, "p_item_type_id", DbType.Int32, item.ItemTypeId); db.AddInParameter(dbCommand, "p_range_name", DbType.String, item.RangeName); db.AddInParameter(dbCommand, "p_exclude_chapters_id", DbType.String, item.ExcludeChapterId); db.AddInParameter(dbCommand, "p_Item_Count", DbType.Int32, item.ItemCount); db.AddInParameter(dbCommand, "p_Item_diff", DbType.Int32, item.ItemDifficultyID); db.AddInParameter(dbCommand, "p_is_mother_item", DbType.Int32, item.IsMotherItem?1:0); db.AddInParameter(dbCommand, "p_mother_id", DbType.Int32, item.MotherID); db.AddInParameter(dbCommand, "p_memo", DbType.String, item.Memo); db.ExecuteNonQuery(dbCommand, transaction); //nRecordAffected = Convert.ToInt32(db.GetParameterValue(dbCommand, "p_Random_Exam_Strategy_Id")); transaction.Commit(); } catch (System.SystemException ex) { transaction.Rollback(); throw ex; } connection.Close(); //return nRecordAffected; }
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); } }
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>"); }
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; } }
public int UpdateRandomExamStrategy(RandomExamStrategy randomExamStrategy) { return(dal.UpdateRandomExamStrategy(randomExamStrategy)); }
public void AddRandomExamStrategy(RandomExamStrategy randomExamStrategy) { dal.AddRandomExamStrategy(randomExamStrategy); }