/// <summary> /// 自定义题型的出现顺序,方法比较弱智 /// </summary> /// <param name="tpi"></param> /// <returns></returns> private TestPaperItem[] _getItemCoutomOrder(TestPaperItem[] tpi) { if (tpi == null) { return(tpi); } //按照自己的思路排列顺序,方法有些笨 int[] order = { 1, 2, 5, 3, 4 }; List <TestPaperItem> list = new List <TestPaperItem>(); for (int i = 0; i < order.Length; i++) { for (int j = 0; j < tpi.Length; j++) { TestPaperItem t = tpi[j]; if (order[i] == t.TPI_Type) { list.Add(t); break; } } } return(list.ToArray()); }
public TestPaperItem[] GetItemForAll(TestPaper tp) { TestPaperItem[] tpi = null; if (tp != null && !string.IsNullOrWhiteSpace(tp.Tp_FromConfig)) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(tp.Tp_FromConfig, false); XmlNodeList nodes = xmlDoc.SelectNodes("Config/All/Items/TestPaperItem"); tpi = new TestPaperItem[nodes.Count]; for (int i = 0; i < nodes.Count; i++) { tpi[i] = new TestPaperItem(); tpi[i].FromXML(nodes[i].OuterXml); } } if (tpi == null) { tpi = Gateway.Default.From <TestPaperItem>() .Where(TestPaperItem._.Tp_UID == tp.Tp_UID && TestPaperItem._.TPI_Count > 0) .OrderBy(TestPaperItem._.TPI_Type.Asc) .ToArray <TestPaperItem>(); } return(_getItemCoutomOrder(tpi)); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEnter_Click(object sender, EventArgs e) { Song.Entities.TestPaper mm = id != 0 ? Business.Do <ITestPaper>().PagerSingle(id) : new Song.Entities.TestPaper(); try { //试卷名称 mm.Tp_Name = tbName.Text.Trim(); //是否使用与推荐 mm.Tp_IsUse = cbIsUse.Checked; mm.Tp_IsRec = cbIsRec.Checked; //类型 mm.Tp_Type = 1; //专业,难度 mm.Sbj_ID = Convert.ToInt32(ddlSubject.SelectedValue); mm.Sbj_Name = ddlSubject.SelectedText; mm.Cou_ID = Convert.ToInt32(ddlCourse.SelectedValue); mm.Tp_Diff = Convert.ToInt32(ddlDiff.SelectedValue); mm.Tp_Diff2 = Convert.ToInt32(ddlDiff2.SelectedValue); //时长与总分 mm.Tp_Span = Convert.ToInt32(tbSpan.Text); mm.Tp_Total = Convert.ToInt32(tbTotal.Text); mm.Tp_PassScore = Convert.ToInt32(tbPassScore_.Text); //简介 mm.Tp_Intro = tbIntro.Text; //UID mm.Tp_UID = getUID(); //图片 if (fuLoad.PostedFile.FileName != "") { try { fuLoad.UpPath = _uppath; fuLoad.IsMakeSmall = false; fuLoad.IsConvertJpg = true; fuLoad.SaveAndDeleteOld(mm.Tp_Logo); fuLoad.File.Server.ChangeSize(200, 200, false); mm.Tp_Logo = fuLoad.File.Server.FileName; // imgShow.Src = fuLoad.File.Server.VirtualPath; } catch (Exception ex) { this.Alert(ex.Message); } } } catch (Exception ex) { Message.Alert(ex); } //确定操作 try { //各项题型占比 Song.Entities.TestPaperItem[] tpi = new TestPaperItem[5]; for (int i = 0; i < tpi.Length; i++) { Song.Entities.TestPaperItem pi = new TestPaperItem(); //几道题 TextBox tbCount = (TextBox)this.getWebControl("tbItem" + (i + 1) + "Count"); //占多少分数比 TextBox tbScore = (TextBox)this.getWebControl("tbItem" + (i + 1) + "Score"); TextBox tbNumber = (TextBox)this.getWebControl("tbItem" + (i + 1) + "Number"); pi.TPI_Count = Convert.ToInt32(tbCount.Text.Trim() == "" ? "0" : tbCount.Text); pi.TPI_Percent = Convert.ToInt32(tbScore.Text.Trim() == "" ? "0" : tbScore.Text); pi.TPI_Number = Convert.ToInt32(tbNumber.Text.Trim() == "" ? "0" : tbNumber.Text); pi.TPI_Type = i + 1; tpi[i] = pi; } //if (id == 0) //id = Business.Do<ITestPaper>().PagerAdd(mm, tpi); //else //Business.Do<ITestPaper>().PagerSave(mm, tpi); Master.AlertCloseAndRefresh("操作成功!"); } catch (Exception ex) { Master.Alert(ex.Message); } }