private void SetValues(择题 o) { _显示模板_TextBox.Text = o.题.显示模板; _选项_StackPanel.Children.Clear(); _答案格子_StackPanel.Children.Clear(); var options = o.项.OrderBy(a => a.项序号); foreach (var c in options) { 添加选项(c.项序号, c.显示模板); } 添加选项(o.项.Last().项序号 + 1); var gs = from answer in o.答案 group answer by answer.格子序号 into g orderby g.Key select g; foreach (var g in gs) { var sp = 添加答案格子组(g.Key); sp.Children.Clear(); var answers = g.ToList(); for (int i = 0; i < answers.Count; i++) { 添加答案格子(sp, i + 1, answers[i].项序号.ToString()); } 添加答案格子(sp, answers.Count + 1); } _预览_Button_Click(); }
public 题_选择_修改(择题 o) : this() { _选择题 = o; _s = new 务.题Client(); _s.题_选择_修改Completed += new EventHandler <务.题_选择_修改CompletedEventArgs>(_s_题_修改Completed); SetValues(o); }
void _s_题_选择_获取Completed() { if (_题_选择_答案 == null || _题_选择_选项 == null) { return; } var data = new 择题 { 题 = _题, 项 = _题_选择_选项, 答案 = _题_选择_答案 }; var f = new 题_选择_修改(data) { ParentLayoutRoot = this.LayoutRoot }; f.Closed += f_Closed; f.ShowDialog(); }
/// <summary> /// 将控件内容填充到 选择题 容器 并返回 /// </summary> private 择题 GetValues() { var result = new 择题 { 题 = _选择题.题, 项 = new List <题.题_选择_选项>(), 答案 = new List <题.题_选择_答案>() }; //result.题.更新时间 = DateTime.Now; result.题.显示模板 = _显示模板_TextBox.Text.Trim(); for (int i = 0; i < _选项_StackPanel.Children.Count; i++) { var sp = (StackPanel)_选项_StackPanel.Children[i]; var idx = int.Parse(((TextBlock)sp.Children[0]).Text); var txt = ((TextBox)sp.Children[1]).Text; if (i == _选项_StackPanel.Children.Count - 1 && txt.Length == 0) { continue; } result.项.Add(new 题.题_选择_选项 { 项序号 = idx, 显示模板 = txt }); } for (int i = 0; i < _答案格子_StackPanel.Children.Count; i++) { var sp = (StackPanel)_答案格子_StackPanel.Children[i]; var idx = int.Parse(((TextBlock)sp.Children[0]).Text); var csp = (StackPanel)sp.Children[1]; foreach (var uie in csp.Children) { var txt = ((TextBox)uie).Text; if (txt.Length == 0) { continue; } result.答案.Add(new 题.题_选择_答案 { 格子序号 = idx, 项序号 = int.Parse(txt) }); } } return(result); }
private void _提交_Button_Click(object sender, RoutedEventArgs e) { 择题 result = null; try { result = GetValues(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (result != null) { _提交_Button.IsEnabled = false; _s.题_选择_修改Async(result.题.GetBytes(), result.项.GetBytes(), result.答案.GetBytes()); } }
void EnableControls() { if (_selected_row == null) { _修改_Button.IsEnabled = _删除_Button.IsEnabled = _加入试卷_Button.IsEnabled = false; _考核意图_TextBox.Text = ""; _备注_TextBox.Text = ""; _预览_RichTextBox.Blocks.Clear(); } else { _修改_Button.IsEnabled = _删除_Button.IsEnabled = _加入试卷_Button.IsEnabled = true; _考核意图_TextBox.Text = _selected_row.考核意图; _备注_TextBox.Text = _selected_row.备注; _DataGrid.IsEnabled = false; #region 生成预览 switch (_selected_row.类型编号) { case 1: { _选择题 = new 择题 { 题 = _selected_row }; _选择题_数据获取次数 = 0; _s.题_选择_选项_获取Async(query.题.题_选择_选项.New(where : o => o.题编号 == _选择题.题.题编号).GetBytes()); _s.题_选择_答案_获取Async(query.题.题_选择_答案.New(where : o => o.题编号 == _选择题.题.题编号).GetBytes()); } break; case 2: { _填空题 = new 填空题 { 题 = _selected_row }; _s.题_填空_答案_获取Async(query.题.题_填空_答案.New(where : o => o.题编号 == _填空题.题.题编号).GetBytes()); } break; case 3: { _判断题 = new 判断题 { 题 = _selected_row }; _s.题_判断_答案_获取Async(query.题.题_判断_答案.New(where : o => o.题编号 == _判断题.题.题编号).GetBytes()); } break; case 4: { _问答题 = new 问答题 { 题 = _selected_row }; _s.题_问答_答案_获取Async(query.题.题_问答_答案.New(where : o => o.题编号 == _问答题.题.题编号).GetBytes()); } break; case 5: { } break; } #endregion } }