//数据加载(修改进入) private void DataLoadForEdit(int itemID) { //加载主题数据 ItemBLL itemBLL = new ItemBLL(); RailExam.Model.Item mainItem = itemBLL.GetItem(itemID); if (mainItem != null) { DataLoadForEditOnMain(mainItem); //主题加载完之后加载第一小题 txtTestCount_TextChanged(null, null); this.dropTestNo.SelectedValue = "1"; //保存当前变化前的题号 this.hfTestNoBefore.Value = "1"; IList <RailExam.Model.Item> subItemList = itemBLL.GetItemsByParentItemID(itemID); foreach (RailExam.Model.Item item in subItemList) { if (item.ItemIndex.ToString() == "1") { //加载第一题 DataLoadForEditOnSubsidiary(item); break; } } } }
public void BindItem(bool search) { if (!search) { ddlItem.Items.Clear(); ddlItem.Items.Add(new ListItem("Select", "")); if (ddlItemType.SelectedValue != string.Empty) { DataTable dtItem = ItemBLL.GetItem(new Guid(ddlItemType.SelectedValue)); ddlItem.DataSource = dtItem; ddlItem.DataTextField = "Description"; ddlItem.DataValueField = "ID"; ddlItem.DataBind(); } } else { ddlSItem.Items.Clear(); ddlSItem.Items.Add(new ListItem("Select", "")); if (ddlSItemType.SelectedValue != string.Empty) { DataTable dtItem = ItemBLL.GetItem(new Guid(ddlSItemType.SelectedValue)); ddlSItem.DataSource = dtItem; ddlSItem.DataTextField = "Description"; ddlSItem.DataValueField = "ID"; ddlSItem.DataBind(); } } }
public IActionResult Detail(int itemNo) { if (HttpContext.Session.GetString("USER_LOGIN_KEY") != null) { return(RedirectToAction("Signin", "Account")); } var item = _itemBll.GetItem(itemNo); return(View(item)); }
public void FixedAssetdItem() { DataTable dtItem = ItemBLL.GetItem(new Guid("45874e2b-da53-46c9-a5ae-1638d540f682"));// temporary ddlItem.DataSource = dtItem; ddlItem.DataTextField = "Description"; ddlItem.DataValueField = "ID"; ddlItem.DataBind(); ddlSItem.DataTextField = "Description"; ddlSItem.DataValueField = "ID"; ddlSItem.DataBind(); }
//修改数据 private void DataUpdate(int testNo) { this.hfTestNoBefore.Value = testNo.ToString(); ItemBLL itemBLL = new ItemBLL(); string itemID = Request["id"].ToString(); RailExam.Model.Item mainItem = itemBLL.GetItem(Int32.Parse(itemID)); //修改主题 mainItem.Content = this.txtContent.Text; mainItem.OutDateDate = Convert.ToDateTime(this.dateOut.DateValue); mainItem.UsageId = Int32.Parse(this.dropPurpose.SelectedValue); mainItem.StatusId = Int32.Parse(this.dropStatus.SelectedValue); mainItem.CreatePerson = this.txtCreater.Text; mainItem.CreateTime = Convert.ToDateTime(this.dateCreate.DateValue); mainItem.Memo = this.txtMemo.Text; mainItem.KeyWord = this.txtKeyWord.Text; try { itemBLL.UpdateItem(mainItem); } catch (Exception) { this.ClientScript.RegisterStartupScript(this.GetType(), "OK", "alert('主题修改不成功');", true); return; } //修改小题 IList <RailExam.Model.Item> subItemList = itemBLL.GetItemsByParentItemID(Int32.Parse(itemID)); foreach (RailExam.Model.Item item in subItemList) { if (item.ItemIndex.ToString() == testNo.ToString()) { string selectAnswer = String.Empty; //存储选项 TextBox[] txts = { this.txtA, this.txtB, this.txtC, this.txtD, this.txtE, this.txtF, this.txtG, this.txtH, this.txtI, this.txtJ, this.txtK, this.txtL }; for (int i = 0; i < 12; i++) { if (!String.IsNullOrEmpty(txts[i].Text)) { selectAnswer += String.IsNullOrEmpty(selectAnswer) ? txts[i].Text : "|" + txts[i].Text; } else { break; } } item.SelectAnswer = selectAnswer; //存储答案 RadioButton[] radioes = { this.radioA, this.radioB, this.radioC, this.radioD, this.radioE, this.radioF, this.radioG, this.radioH, this.radioI, this.radioJ, this.radioK, this.radioL }; for (int i = 0; i < 12; i++) { if (radioes[i].Checked) { item.StandardAnswer = Convert.ToString(i); break; } } item.Content = String.IsNullOrEmpty(this.txtSubContent.Text) ? this.txtContent.Text : this.txtSubContent.Text; item.Memo = this.txtMemo.Text; item.KeyWord = this.txtKeyWord.Text; item.ParentItemId = Int32.Parse(itemID); try { itemBLL.UpdateItem(item); this.ClientScript.RegisterStartupScript(this.GetType(), "OK", "alert('第" + testNo + "小题已修改');", true); } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "OK", "alert('第" + testNo + "小题修改不成功');", true); } //找到并修改了需要修改的小题后,就可跳出循环了 break; } } string strSql = "update Item set Status_ID=" + mainItem.StatusId + " where Item_ID=" + mainItem.ItemId + " or Parent_Item_ID=" + mainItem.ItemId; OracleAccess db = new OracleAccess(); db.ExecuteNonQuery(strSql); }
private void FillPaperNoAnswer() { if (ViewState["SelectItem"].ToString() == "") { SessionSet.PageMessage = "您输入的条件没有找到试题!"; return; } ItemBLL itemBLL = new ItemBLL(); IList <RailExam.Model.Item> Items = new List <RailExam.Model.Item>(); string[] strSelectItem = ViewState["SelectItem"].ToString().Split(new char[] { '|' }); for (int n = 0; n < strSelectItem.Length; n++) { RailExam.Model.Item item = itemBLL.GetItem(int.Parse(strSelectItem[n])); Items.Add(item); } decimal decTotalScore1 = 0; decimal decTotalScore2 = 0; int n1 = 0; int n2 = 0; for (int i = 0; i < Items.Count; i++) { RailExam.Model.Item item = Items[i]; if (item.TypeId == 1) { decTotalScore1 += item.Score; n1 += 1; } else { decTotalScore2 += item.Score; n2 += 1; } } if (Items != null) { string strHtml1 = "<table class='ExamContent'><tr><td class='ExamBigTitle' > 一、单选(共" + n1 + "题)</td></tr> "; string strHtml2 = "<table class='ExamContent'><tr><td class='ExamBigTitle' > 二、多选(共" + n2 + "题)</td></tr> "; int k1 = 0; int k2 = 0; for (int j = 0; j < Items.Count; j++) { RailExam.Model.Item item = Items[j]; if (item.TypeId == PrjPub.ITEMTYPE_SINGLECHOOSE) { k1 += 1; strHtml1 += "<tr><td id='Item" + j + "' class='ExamItem' > " + k1 + ". " + item.Content + " </td></tr>"; string[] strAnswer = item.SelectAnswer.Split(new char[] { '|' }); for (int n = 0; n < strAnswer.Length; n++) { string strN = intToString(n + 1); string strij = "-1-" + item.ItemId + "-" + j.ToString() + "-" + n.ToString(); string strName = "1" + j.ToString(); strHtml1 += "<tr><td class='ExamItemAnswer'> <input type='Radio' onclick='CheckStyle(this)' id='RAnswer" + strij + "' name='RAnswer" + strName + "'> " + strN + "." + strAnswer[n] + "</td></tr>"; } } else if (item.TypeId == PrjPub.ITEMTYPE_MULTICHOOSE) { k2 += 1; strHtml2 += "<tr><td class='ExamItem'> " + k2 + ". " + item.Content + " </td></tr>"; string[] strAnswer = item.SelectAnswer.Split(new char[] { '|' }); for (int n = 0; n < strAnswer.Length; n++) { string strN = intToString(n + 1); string strij = "-2-" + +item.ItemId + "-" + j.ToString() + "-" + n.ToString(); string strName = "2" + j.ToString(); strHtml2 += "<tr><td class='ExamItemAnswer'> <input type='checkbox' id='RAnswer" + strij + "' name='RAnswer" + strName + "'> " + strN + "." + strAnswer[n] + "</td></tr>"; } } } strHtml1 += " </table> "; strHtml2 += " </table> "; if (k1 > 0) { Response.Write(strHtml1); } if (k2 > 0) { Response.Write(strHtml2); } Response.Write("<div class='ExamButton'><input class='button' type='button' onclick='SaveRecord()' value='提 交'/></div>"); } }
private void FillPaperWithAnswer() { if (ViewState["IsShow"].ToString() == "True") { return; } decimal decTotalResultScore = 0; int rightNum = 0; int sumNum = 0; string strAllAnswer = ViewState["Answers"].ToString(); string[] strAllAnswers = strAllAnswer.Split(new char[] { '$' }); Hashtable hashTable = new Hashtable(); for (int i = 0; i < strAllAnswers.Length; i++) { string str2 = strAllAnswers[i]; string[] str3 = str2.Split(new char[] { '|' }); string strItemId = str3[0]; string strTrueAnswer = str2.Substring(strItemId.Length + 1); hashTable[int.Parse(strItemId)] = strTrueAnswer; } ItemBLL itemBLL = new ItemBLL(); IList <RailExam.Model.Item> Items = new List <RailExam.Model.Item>(); string[] strSelectItem = ViewState["SelectItem"].ToString().Split(new char[] { '|' }); for (int n = 0; n < strSelectItem.Length; n++) { RailExam.Model.Item item = itemBLL.GetItem(int.Parse(strSelectItem[n])); Items.Add(item); } ViewState["SelectItem"] = ""; decimal decTotalScore1 = 0; decimal decTotalScore2 = 0; int nCount1 = 0; int nCount2 = 0; for (int i = 0; i < Items.Count; i++) { RailExam.Model.Item item = Items[i]; if (item.TypeId == 1) { decTotalScore1 += item.Score; nCount1 += 1; } else { decTotalScore2 += item.Score; nCount2 += 1; } } if (Items != null) { string strHtml1 = "<table class='ExamContent'><tr><td class='ExamBigTitle'> 一、单选(共" + nCount1 + "题)</td></tr> "; string strHtml2 = "<table class='ExamContent'><tr><td class='ExamBigTitle'> 二、多选(共" + nCount2 + "题)</td></tr> "; sumNum = nCount1 + nCount2; int k1 = 0; int k2 = 0; for (int j = 0; j < Items.Count; j++) { RailExam.Model.Item item = Items[j]; if (item.TypeId == 1) { k1 += 1; strHtml1 += "<tr><td class='ExamItem'> " + k1 + ". " + item.Content + " </td></tr>"; string[] strAnswer = item.SelectAnswer.Split(new char[] { '|' }); for (int n = 0; n < strAnswer.Length; n++) { string strN = intToString(n + 1); string strij = "-1-" + item.ItemId + "-" + j.ToString() + "-" + n.ToString(); string strName = "1" + j.ToString(); strHtml1 += "<tr><td class='ExamItemAnswer'> <input type='Radio' id='RAnswer" + strij + "' name='RAnswer" + strName + "'> " + strN + "." + strAnswer[n] + "</td></tr>"; } string[] strRightAnswers = item.StandardAnswer.Split(new char[] { '|' }); string strRightAnswer = ""; for (int n1 = 0; n1 < strRightAnswers.Length; n1++) { string strN1 = intToString(int.Parse(strRightAnswers[n1]) + 1); if (n1 == 0) { strRightAnswer += strN1; } else { strRightAnswer += "," + strN1; } } string strhashValue = hashTable[item.ItemId].ToString(); string strUserAnswer = ""; if (strhashValue != "") { string[] strUserAnswers = strhashValue.ToString().Split(new char[] { '|' }); for (int n2 = 0; n2 < strUserAnswers.Length; n2++) { string strN2 = intToString(int.Parse(strUserAnswers[n2]) + 1); if (n2 == 0) { strUserAnswer += strN2; } else { strUserAnswer += "," + strN2; } } } if (strUserAnswer == strRightAnswer) { decTotalResultScore += item.Score; rightNum = rightNum + 1; } if (strUserAnswer == strRightAnswer) { strHtml1 += "<tr><td class='ExamAnswer'> ★标准答案:" + "<span id='span-" + item.ItemId + "-0' name='span-" + item.ItemId + "'>" + strRightAnswer + "</span> ★考生答案:" + "<span id='span-" + item.ItemId + "-1' name='span-" + item.ItemId + "'>" + strUserAnswer + "</span></td></tr>"; } else { strHtml1 += "<tr><td class='ExamAnswerZero'> ★标准答案:" + "<span id='span-" + item.ItemId + "-0' name='span-" + item.ItemId + "'>" + strRightAnswer + "</span> ★考生答案:" + "<span id='span-" + item.ItemId + "-1' name='span-" + item.ItemId + "'>" + strUserAnswer + "</span></td></tr>"; } } else { k2 += 1; strHtml2 += "<tr><td class='ExamItem'> " + k2 + ". " + item.Content + " </td></tr>"; string[] strAnswer = item.SelectAnswer.Split(new char[] { '|' }); for (int n = 0; n < strAnswer.Length; n++) { string strN = intToString(n + 1); string strij = "-2-" + +item.ItemId + "-" + j.ToString() + "-" + n.ToString(); string strName = "2" + j.ToString(); strHtml2 += "<tr><td class='ExamItemAnswer'> <input type='checkbox' id='RAnswer" + strij + "' name='RAnswer" + strName + "'> " + strN + "." + strAnswer[n] + "</td></tr>"; } string[] strRightAnswers = item.StandardAnswer.Split(new char[] { '|' }); string strRightAnswer = ""; for (int n1 = 0; n1 < strRightAnswers.Length; n1++) { string strN1 = intToString(int.Parse(strRightAnswers[n1]) + 1); if (n1 == 0) { strRightAnswer += strN1; } else { strRightAnswer += "," + strN1; } } string strhashValue = hashTable[item.ItemId].ToString(); string strUserAnswer = ""; if (strhashValue != "") { string[] strUserAnswers = strhashValue.ToString().Split(new char[] { '|' }); for (int n2 = 0; n2 < strUserAnswers.Length; n2++) { string strN2 = intToString(int.Parse(strUserAnswers[n2]) + 1); if (n2 == 0) { strUserAnswer += strN2; } else { strUserAnswer += "," + strN2; } } } if (strUserAnswer == strRightAnswer) { decTotalResultScore += item.Score; rightNum = rightNum + 1; } if (strUserAnswer == strRightAnswer) { strHtml2 += "<tr><td class='ExamAnswer'> ★标准答案:" + "<span id='span-" + item.ItemId + "-0' name='span-" + item.ItemId + "'>" + strRightAnswer + "</span> ★考生答案:" + "<span id='span-" + item.ItemId + "-1' name='span-" + item.ItemId + "'>" + strUserAnswer + "</span></td></tr>"; } else { strHtml2 += "<tr><td class='ExamAnswerZero'> ★标准答案:" + "<span id='span-" + item.ItemId + "-0' name='span-" + item.ItemId + "'>" + strRightAnswer + "</span> ★考生答案:" + "<span id='span-" + item.ItemId + "-1' name='span-" + item.ItemId + "'>" + strUserAnswer + "</span></td></tr>"; } } } strHtml1 += " </table> "; strHtml2 += " </table> "; if (k1 > 0) { Response.Write(strHtml1); } if (k2 > 0) { Response.Write(strHtml2); } double decn = 0; if (sumNum > 0) { decn = rightNum * 0.01 * 10000 / sumNum; } Response.Write("<table class='ExamContent'><tr><td class='ExamJudge'>★正确题数:" + rightNum + " 正确率:" + decn.ToString("0.00") + "%</td></tr></table>"); string strA = "总题数:" + sumNum + ",正确题数:" + rightNum + ",正确率:" + decn.ToString("0.00") + "%"; SessionSet.PageMessage = strA; } ViewState["IsShow"] = "True"; }
private void SavePaperItem(IList <RailExam.Model.Item> itemList, int nDifficulty, int nPaperId, int nPaperSubjectId, decimal nUnitScore) { if (itemList.Count > 0) { PaperItemBLL paperItemBLL = new PaperItemBLL(); IList <PaperItem> paperItems = new List <PaperItem>(); if (itemList.Count > nDifficulty) { Random ObjRandom = new Random(); Hashtable hashTable = new Hashtable(); while (hashTable.Count < nDifficulty) { int i = ObjRandom.Next(itemList.Count); hashTable[itemList[i].ItemId] = itemList[i].ItemId; } ItemBLL itemBLL = new ItemBLL(); //把hashtable里的试题加到考试表 foreach (int key in hashTable.Keys) { string strItemId = hashTable[key].ToString(); RailExam.Model.Item item = itemBLL.GetItem(int.Parse(strItemId)); PaperItem paperItem = new PaperItem(); paperItem.PaperId = nPaperId; paperItem.PaperSubjectId = nPaperSubjectId; paperItem.AnswerCount = item.AnswerCount; paperItem.BookId = item.BookId; paperItem.CategoryId = item.CategoryId; paperItem.ChapterId = item.ChapterId; paperItem.CompleteTime = item.CompleteTime; paperItem.Content = item.Content; paperItem.CreatePerson = item.CreatePerson; paperItem.CreateTime = item.CreateTime; paperItem.Description = item.Description; paperItem.DifficultyId = item.DifficultyId; paperItem.ItemId = item.ItemId; paperItem.Memo = item.Memo; paperItem.OrderIndex = 0; paperItem.OrganizationId = item.OrganizationId; paperItem.OutDateDate = item.OutDateDate; paperItem.Score = nUnitScore; paperItem.SelectAnswer = item.SelectAnswer; paperItem.Source = item.Source; paperItem.StandardAnswer = item.StandardAnswer; paperItem.StatusId = item.StatusId; paperItem.TypeId = item.TypeId; paperItem.UsedCount = item.UsedCount; paperItem.Version = item.Version; paperItems.Add(paperItem); } } else //直接把这些试题加到考试表 { foreach (RailExam.Model.Item item in itemList) { PaperItem paperItem = new PaperItem(); paperItem.PaperId = nPaperId; paperItem.PaperSubjectId = nPaperSubjectId; paperItem.AnswerCount = item.AnswerCount; paperItem.BookId = item.BookId; paperItem.CategoryId = item.CategoryId; paperItem.ChapterId = item.ChapterId; paperItem.CompleteTime = item.CompleteTime; paperItem.Content = item.Content; paperItem.CreatePerson = item.CreatePerson; paperItem.CreateTime = item.CreateTime; paperItem.Description = item.Description; paperItem.DifficultyId = item.DifficultyId; paperItem.ItemId = item.ItemId; paperItem.Memo = item.Memo; paperItem.OrderIndex = 0; paperItem.OrganizationId = item.OrganizationId; paperItem.OutDateDate = item.OutDateDate; paperItem.Score = nUnitScore; paperItem.SelectAnswer = item.SelectAnswer; paperItem.Source = item.Source; paperItem.StandardAnswer = item.StandardAnswer; paperItem.StatusId = item.StatusId; paperItem.TypeId = item.TypeId; paperItem.UsedCount = item.UsedCount; paperItem.Version = item.Version; paperItems.Add(paperItem); } } if (paperItems.Count > 0) { paperItemBLL.AddPaperItem(paperItems); } } }
public ItemDTO GetItem(string id) { return(itemBLL.GetItem(int.Parse(id))); }