private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { txbSubId.Text = subjectViewInfo.SUBJECTID.ToString() + "."; txbSubContent.Text = subjectViewInfo.CONTENT; int count = 0; //该题目总票数 int AnswerID_count = 0; // 达到答案级别的 票数 //构造一个答案组,并统计通过率 foreach (T_SYS_DICTIONARY i in _oanswer) { V_SSubjectAnswerResult v = null; if (subAnswerResult != null) { v = subAnswerResult.LstAnswer.FirstOrDefault(ee => decimal.Parse(ee.AnswerCode) == i.DICTIONARYVALUE); } if (v == null) { v = new V_SSubjectAnswerResult(); } else { if (int.Parse(AnswerID) >= int.Parse(v.AnswerCode)) { AnswerID_count = +v.Count; } count += v.Count; } SurveyAnswer_sat_1 sa = new SurveyAnswer_sat_1(i, v.Count); spAnswerList.Children.Add(sa); } //题目答案统计结果 decimal d = decimal.Round(AnswerID_count / (count == 0 ? 1 : count) * 100, 1); if (d >= PercentAge) { txtSubResult.Text = "结果:通过(" + d.ToString() + "%)"; } else { txtSubResult.Text = "结果:不通过(" + d.ToString() + "%)"; } //回传到方案 统计 SatisfactionResultEventArgs ev = new SatisfactionResultEventArgs(); ev.Count = count; ev.AnswerID_count = AnswerID_count; if (event_SatisfactionResult != null) { event_SatisfactionResult(this, ev); } }
private void SumResult(object sender, SatisfactionResultEventArgs e) { Count += e.Count; AnswerID_count += e.AnswerID_count; //----------------- //该调查统计结果 decimal d = decimal.Round(Convert.ToDecimal(AnswerID_count) / Convert.ToDecimal((Count == 0 ? 1 : Count)) * 100, 1); if (d >= distribute.PERCENTAGE) { txtResult.Text = "通过( " + AnswerID_count.ToString() + "/" + Count.ToString() + " = " + d.ToString() + "% )"; } else { txtResult.Text = "不通过( " + AnswerID_count.ToString() + "/" + Count.ToString() + " = " + d.ToString() + "% )"; } }