コード例 #1
0
        public decimal?GetScore(RatingStudent student)
        {
            ItemWeightCollection exists = new ItemWeightCollection();

            foreach (string each in Items.Keys)
            {
                if (student.Scores[ThisToken].Contains(each))
                {
                    exists.Add(each, Items[each]);
                }
            }

            if (exists.Count <= 0)
            {
                return(null);
            }

            if (Method == CalcMethod.加權平均)
            {
                return(加權平均(student, exists));
            }
            else if (Method == CalcMethod.加權總分)
            {
                return(加權總分(student, exists));
            }
            else if (Method == CalcMethod.合計總分)
            {
                return(合計總分(student, exists));
            }
            else
            {
                return(算術平均(student, exists));
            }
        }
コード例 #2
0
        /// <summary>
        /// 把使用者已選擇的科目資訊(權重)更新到 SelectedSubjects 變數。
        /// </summary>
        /// <returns>true 為資料正確沒有發生任何錯誤。</returns>
        private bool RefreshSelectedSubjects()
        {
            bool result = true;

            SelectedSubjects = new ItemWeightCollection();
            foreach (DataGridViewRow each in dgv.Rows)
            {
                if (each.IsNewRow)
                {
                    continue;
                }
                string value = "" + each.Cells[chCheck.Index].Value;
                bool   b;
                if (bool.TryParse(value, out b) && b == true)
                {
                    string  subject   = "" + each.Cells[chSubject.Index].Value;
                    string  strPeriod = "" + each.Cells[chPeriod.Index].Value;
                    decimal period;

                    if (decimal.TryParse(strPeriod, out period) && period > 0)
                    {
                        each.Cells[chPeriod.Index].ErrorText = string.Empty;
                        SelectedSubjects.Add(subject, period);
                    }
                    else
                    {
                        each.Cells[chPeriod.Index].ErrorText = "計算比例必須是大於 0 的數字。";
                        result = false;
                    }
                }
            }

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// 把使用者已選擇的科目資訊(權重)更新到 SelectedSubjects 變數。
        /// </summary>
        /// <returns>true 為資料正確沒有發生任何錯誤。</returns>
        private bool RefreshSelectedSubjects()
        {
            bool result = true;

            SelectedSubjects = new ItemWeightCollection();
            foreach (DataGridViewRow each in dgv.Rows)
            {
                if (each.IsNewRow)
                {
                    continue;
                }
                string value = "" + each.Cells[chCheck.Index].Value;
                bool   b;
                if (bool.TryParse(value, out b) && b == true)
                {
                    string subject = "" + each.Cells[chSubject.Index].Value;
                    SelectedSubjects.Add(subject, 1);
                    result = true;
                }
            }

            return(result);
        }