Ejemplo n.º 1
0
        private void CalculateLiteratureDomainScore()
        {
            decimal chTotal = 0, enTotal = 0;
            decimal chCredit = 0, enCredit = 0;

            PeriodCredit pc = new PeriodCredit();

            if (ValidTextBox(textBoxX25) && ValidTextBox(textBoxX1))
            {
                pc.Parse(textBoxX25.Text);
                chCredit = pc.Credit;
                chTotal  = decimal.Parse(textBoxX1.Text) * chCredit;
            }

            if (ValidTextBox(textBoxX26) && ValidTextBox(textBoxX2))
            {
                pc.Parse(textBoxX26.Text);
                enCredit = pc.Credit;
                enTotal  = decimal.Parse(textBoxX2.Text) * enCredit;
            }

            decimal total = 0;

            if (chCredit + enCredit > 0)
            {
                total = (chTotal + enTotal) / (chCredit + enCredit);
            }
            if (total > 0)
            {
                labelX14.Text = "" + _calculator.ParseDomainScore(total);
            }
        }
Ejemplo n.º 2
0
        private void CalculateCourseLearnScore()
        {
            PeriodCredit pc = new PeriodCredit();
            //int pc = 0;
            decimal total = 0;

            foreach (DataGridViewRow row in dgv.Rows)
            {
                if ("" + row.Cells[chsDomain.Index].Value == "彈性課程")
                {
                    PeriodCredit temp = new PeriodCredit();
                    temp.Parse("" + row.Cells[chsPeriodCredit.Index].Value);
                    pc.Credit += temp.Credit;
                    pc.Period += temp.Period;
                    total     += temp.Credit * decimal.Parse("" + row.Cells[chsScore.Index].Value);
                }
            }

            if (pc.Credit > 0)
            {
                textBoxX33.Text = "" + _calculator.ParseLearnDomainScore(total / pc.Credit);
                _elasticPC      = pc;
                _elasticTotal   = total;
                if (_learnDomainPC.Credit > 0)
                {
                    textBoxX35.Text = "" + _calculator.ParseLearnDomainScore((_learnDomainTotal + total) / (_learnDomainPC + pc).Credit);
                }
            }
        }
Ejemplo n.º 3
0
        public SubjectRow(string name)
        {
            SubjectName  = name;
            Display      = false;
            _printPeriod = true;
            _printCredit = true;
            _pc          = new PeriodCredit();

            Scores = new Dictionary <string, ScoreData>();
        }
Ejemplo n.º 4
0
 private void EvalDomainScore(ref PeriodCredit pc, ref decimal total, TextBox scoreTextBox, TextBox pcTextBox)
 {
     if (ValidTextBox(scoreTextBox) && ValidTextBox(pcTextBox))
     {
         PeriodCredit temp = new PeriodCredit();
         temp.Parse(pcTextBox.Text);
         total     += decimal.Parse(scoreTextBox.Text) * temp.Credit;
         pc.Credit += temp.Credit;
         pc.Period += temp.Period;
     }
 }
Ejemplo n.º 5
0
        private void txtPeriodCredit_TextChanged(object sender, EventArgs e)
        {
            PeriodCredit pc = new PeriodCredit();

            if (!pc.Parse(txtPeriodCredit.Text))
            {
                _error.SetError(txtPeriodCredit, pc.Error);
            }
            else
            {
                _error.SetError(txtPeriodCredit, "");
            }
        }
Ejemplo n.º 6
0
        internal void SetPeriodCredit(decimal?period, decimal?credit)
        {
            PeriodCredit pc = new PeriodCredit();

            if (period.HasValue)
            {
                pc.Period = period.Value;
            }
            if (credit.HasValue)
            {
                pc.Credit = credit.Value;
            }
            _pc = pc;
        }
Ejemplo n.º 7
0
        private K12.Data.DomainScore GetDomainScore(string p, TextBoxX pc, TextBoxX score, TextBoxX effort, TextBoxX text)
        {
            PeriodCredit temp = new PeriodCredit();

            temp.Parse(pc.Text);
            K12.Data.DomainScore domain = new K12.Data.DomainScore();
            domain.Domain = p;
            domain.Period = temp.Period;
            domain.Credit = temp.Credit;
            domain.Effort = int.Parse(effort.Text);
            domain.Score  = decimal.Parse(score.Text);
            domain.Text   = text.Text;
            return(domain);
        }
Ejemplo n.º 8
0
        private K12.Data.DomainScore GetElasticDomain()
        {
            K12.Data.DomainScore domain = new K12.Data.DomainScore();
            domain.Domain = "彈性課程";
            domain.Score  = decimal.Parse(txtElastic.Text);

            PeriodCredit pc   = new PeriodCredit();
            PeriodCredit temp = new PeriodCredit();
            //int pc = 0;
            int    effort = 0;
            int    count  = 0;
            string text   = "";

            foreach (DataGridViewRow row in dgv.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }

                // 修改彈性課程處理方式,當領域名稱是空白,當作彈性課程。
                //if ("" + row.Cells[chsDomain.Index].Value == "彈性課程")
                if ("" + row.Cells[chsDomain.Index].Value == "")
                {
                    count++;
                    temp.Parse("" + row.Cells[chsPeriodCredit.Index].Value);
                    pc.Credit += temp.Credit;
                    pc.Period += temp.Period;
                    effort    += int.Parse("" + row.Cells[chsEffort.Index].Value);
                    if (!string.IsNullOrEmpty("" + row.Cells[chsText.Index].Value))
                    {
                        text += "" + row.Cells[chsSubject.Index].Value + ":" + row.Cells[chsText.Index].Value;
                    }
                }
            }

            domain.Period = pc.Period;
            domain.Credit = pc.Credit;
            if (count == 0)
            {
                domain.Effort = 0;
            }
            else
            {
                domain.Effort = (int)decimal.Round((decimal)effort / (decimal)count, 0, MidpointRounding.AwayFromZero);
            }
            domain.Text = text;
            return(domain);
        }
Ejemplo n.º 9
0
        private bool ValidPCTextBox(TextBox tb)
        {
            bool valid = true;

            errorProvider.SetError(tb, "");
            PeriodCredit pc = new PeriodCredit();

            if (!pc.Parse(tb.Text))
            {
                errorProvider.SetIconPadding(tb, -17);
                errorProvider.SetError(tb, pc.Error);
                valid = false;
            }

            return(valid);
        }
        private K12.Data.DomainScore GetDomainScore(string p, TextBoxX pc, TextBoxX score, TextBoxX effort, TextBoxX text)
        {
            PeriodCredit temp = new PeriodCredit();

            temp.Parse(pc.Text);
            K12.Data.DomainScore domain = new K12.Data.DomainScore();
            domain.Domain = p;
            domain.Period = temp.Period;
            domain.Credit = temp.Credit;
            //domain.Effort = int.Parse(effort.Text);
            domain.Effort      = 1;
            domain.Score       = decimal.Parse(score.Text);
            domain.ScoreOrigin = decimal.Parse(score.Text); // 2018.09.22 [ischoolKingdom] Vicky依據 [J成績][HC][03] 快速新增學期成績修正,將語文領域的子領域兩個項目欄位拿掉,僅保留輸入語文領域成績的單一功能。
            domain.Text        = text.Text;
            return(domain);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 計算學習領域成績
        /// </summary>
        private void CalculateLearnDomainScore()
        {
            PeriodCredit pc = new PeriodCredit();
            //int pc = 0;
            decimal total = 0;

            if (!string.IsNullOrEmpty(labelX14.Text))
            {
                PeriodCredit literpc = new PeriodCredit();
                PeriodCredit temp    = new PeriodCredit();
                //int literpc = 0;
                if (ValidTextBox(textBoxX25))
                {
                    temp.Parse(textBoxX25.Text);
                    literpc.Credit += temp.Credit;
                    literpc.Period += temp.Period;
                    //literpc += int.Parse(textBoxX25.Text);
                }
                if (ValidTextBox(textBoxX26))
                {
                    temp.Parse(textBoxX26.Text);
                    literpc.Credit += temp.Credit;
                    literpc.Period += temp.Period;
                    //literpc += int.Parse(textBoxX26.Text);
                }

                if (literpc.Credit > 0)
                {
                    pc    += literpc;
                    total += decimal.Parse(labelX14.Text) * literpc.Credit;
                }
            }

            EvalDomainScore(ref pc, ref total, textBoxX3, textBoxX27);
            EvalDomainScore(ref pc, ref total, textBoxX4, textBoxX28);
            EvalDomainScore(ref pc, ref total, textBoxX5, textBoxX29);
            EvalDomainScore(ref pc, ref total, textBoxX6, textBoxX30);
            EvalDomainScore(ref pc, ref total, textBoxX7, textBoxX31);
            EvalDomainScore(ref pc, ref total, textBoxX8, textBoxX32);

            if (pc.Credit > 0)
            {
                textBoxX34.Text   = "" + _calculator.ParseLearnDomainScore(total / pc.Credit);
                _learnDomainPC    = pc;
                _learnDomainTotal = total;
            }
        }
Ejemplo n.º 12
0
        private K12.Data.DomainScore GetDomainScore(string p, TextBoxX pc, TextBoxX score, TextBoxX Oriscore, TextBoxX effort, TextBoxX text)
        {
            PeriodCredit temp = new PeriodCredit();

            temp.Parse(pc.Text);
            K12.Data.DomainScore domain = new K12.Data.DomainScore();
            domain.Domain = p;
            domain.Period = temp.Period;
            domain.Credit = temp.Credit;
            domain.Effort = int.Parse(effort.Text);
            domain.Score  = decimal.Parse(score.Text);
            //2018/4/16 穎驊因應高雄項目[02-03][06]學期成績,快速新增功能如無原始成績,則結算學期領域成績時快速新增的成績都會變成"0"分
            // 新增原始成績登錄
            domain.ScoreOrigin = decimal.Parse(Oriscore.Text);
            domain.Text        = text.Text;
            return(domain);
        }
        private K12.Data.DomainScore GetElasticDomain()
        {
            K12.Data.DomainScore domain = new K12.Data.DomainScore();
            domain.Domain      = "彈性課程";
            domain.Score       = decimal.Parse(textBoxX33.Text);
            domain.ScoreOrigin = decimal.Parse(textBoxX33.Text); // 2018.09.22 [ischoolKingdom] Vicky依據 [J成績][HC][03] 快速新增學期成績修正,輸入成績一併存入原始成績。

            PeriodCredit pc   = new PeriodCredit();
            PeriodCredit temp = new PeriodCredit();
            //int pc = 0;
            //int effort = 0;
            int    count = 0;
            string text  = "";

            foreach (DataGridViewRow row in dgv.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }
                if ("" + row.Cells[chsDomain.Index].Value == "彈性課程" || "" + row.Cells[chsDomain.Index].Value == "")
                {
                    count++;
                    temp.Parse("" + row.Cells[chsPeriodCredit.Index].Value);
                    pc.Credit += temp.Credit;
                    pc.Period += temp.Period;
                    //effort += int.Parse("" + row.Cells[chsEffort.Index].Value);
                    if (!string.IsNullOrEmpty("" + row.Cells[chsText.Index].Value))
                    {
                        text += "" + row.Cells[chsSubject.Index].Value + ":" + row.Cells[chsText.Index].Value;
                    }
                }
            }

            domain.Period = pc.Period;
            domain.Credit = pc.Credit;
            //domain.Effort = (int)decimal.Round((decimal)effort / (decimal)count, 0, MidpointRounding.AwayFromZero);
            domain.Effort = 1;
            domain.Text   = text;
            return(domain);
        }
Ejemplo n.º 14
0
        private string GetPCDisplay(string p)
        {
            PeriodCredit pc = new PeriodCredit();

            pc.Parse(p);
            if (PrintPeriod && PrintCredit)
            {
                return(pc.ToString());
            }
            else if (PrintPeriod)
            {
                return("" + pc.Period);
            }
            else if (PrintCredit)
            {
                return("" + pc.Credit);
            }
            else
            {
                return(string.Empty);
            }
        }
        /// <summary>
        /// 計算學習領域成績
        /// </summary>
        private void CalculateLearnDomainScore()
        {
            PeriodCredit pc = new PeriodCredit();
            //int pc = 0;
            decimal total = 0;

            EvalDomainScore(ref pc, ref total, textBoxScore1, textBoxPC1); // 2018.09.22 [ischoolKingdom] Vicky依據 [J成績][HC][03] 快速新增學期成績修正,將語文領域的子領域兩個項目欄位拿掉,僅保留輸入語文領域成績的單一功能。
            EvalDomainScore(ref pc, ref total, textBoxScore2, textBoxPC2);
            EvalDomainScore(ref pc, ref total, textBoxScore3, textBoxPC3);
            EvalDomainScore(ref pc, ref total, textBoxScore4, textBoxPC4);
            EvalDomainScore(ref pc, ref total, textBoxScore5, textBoxPC5);
            EvalDomainScore(ref pc, ref total, textBoxScore6, textBoxPC6);
            EvalDomainScore(ref pc, ref total, textBoxScore7, textBoxPC7);
            EvalDomainScore(ref pc, ref total, textBoxScore8, textBoxPC8);

            if (pc.Credit > 0)
            {
                textBoxX34.Text   = "" + _calculator.ParseLearnDomainScore(total / pc.Credit);
                _learnDomainPC    = pc;
                _learnDomainTotal = total;
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 計算學習領域成績
        /// </summary>
        private void CalculateLearnDomainScore()
        {
            PeriodCredit pc = new PeriodCredit();
            //int pc = 0;
            decimal total = 0;

            EvalDomainScore(ref pc, ref total, txtScore1, txtPC1);
            EvalDomainScore(ref pc, ref total, txtScore2, txtPC2);
            EvalDomainScore(ref pc, ref total, txtScore3, txtPC3);
            EvalDomainScore(ref pc, ref total, txtScore4, txtPC4);
            EvalDomainScore(ref pc, ref total, txtScore5, txtPC5);
            EvalDomainScore(ref pc, ref total, txtScore6, txtPC6);
            EvalDomainScore(ref pc, ref total, txtScore7, txtPC7);
            EvalDomainScore(ref pc, ref total, txtScore8, txtPC8);
            EvalDomainScore(ref pc, ref total, txtScore10, txtPC10);
            if (pc.Credit > 0)
            {
                txtLearnDomain.Text = "" + _calculator.ParseLearnDomainScore(total / pc.Credit);
                _learnDomainPC      = pc;
                _learnDomainTotal   = total;
            }
        }
Ejemplo n.º 17
0
        public System.Xml.XmlElement GetSource()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<GraduationPlan/>");
            int rowIndex = 0;

            //掃每一列資料
            foreach (DataGridViewRow row in dgv.Rows)
            {
                //有表示科目欄有填寫
                if (_RowSubject.ContainsKey(row))
                {
                    rowIndex++;
                    //節數
                    List <decimal> Periods = new List <decimal>();
                    //權數
                    List <decimal> Credits = new List <decimal>();

                    //記錄每個級別所包含的學期
                    List <int> Semesters = new List <int>();
                    //記錄每個級別所包含的學年度
                    List <int> GradeYears = new List <int>();
                    //未加級別前的科目名稱
                    string subjectName = _RowSubject[row];
                    //int countLevel = 0;
                    //掃描開課學期
                    for (int i = _CreditStartIndex; i < _CreditStartIndex + 8; i++)
                    {
                        if (row.Cells[i].Value != null)
                        {
                            string       orig = ("" + row.Cells[i].Value).Trim();
                            PeriodCredit pc   = new PeriodCredit();
                            if (pc.Parse(orig))
                            {
                                Credits.Add(pc.Credit);
                                Periods.Add(pc.Period);
                            }

                            Semesters.Add((i - _CreditStartIndex + 2) % 2 + 1);
                            GradeYears.Add((i - _CreditStartIndex + 2) / 2);
                        }
                    }

                    //int startLevel = 0;
                    ////如果有填數開始級別則以開始級別開始算
                    //if (row.Cells[_StartLevelIndex].Value != null)
                    //    int.TryParse("" + row.Cells[_StartLevelIndex].Value, out startLevel);
                    //這個row中包含的數個科目級別
                    XmlElement parentElement;
                    //全組資料(回填用)
                    XmlElement grouping;

                    //這個row中包含的數個科目級別
                    parentElement = doc.CreateElement("Subject");
                    //全組資料(回填用)
                    grouping = doc.CreateElement("Grouping");
                    grouping.SetAttribute("RowIndex", rowIndex.ToString());
                    grouping.SetAttribute("startLevel", row.Cells[_StartLevelIndex].Value == null ? "" : row.Cells[_StartLevelIndex].Value.ToString());
                    parentElement.AppendChild(grouping);
                    //建立新Element加入至doc
                    parentElement.SetAttribute("SubjectName", subjectName);
                    parentElement.SetAttribute("Category", row.Cells[_CategoryIndex].Value == null ? "" : row.Cells[_CategoryIndex].Value.ToString());
                    parentElement.SetAttribute("Domain", row.Cells[_DomainIndex].Value == null ? "" : row.Cells[_DomainIndex].Value.ToString());
                    parentElement.SetAttribute("RequiredBy", row.Cells[_RequiredByIndex].Value == null ? "" : row.Cells[_RequiredByIndex].Value.ToString());
                    parentElement.SetAttribute("Required", row.Cells[_RequiredIndex].Value == null ? "" : row.Cells[_RequiredIndex].Value.ToString());

                    bool b;
                    bool.TryParse(row.Cells[_NotIncludedInCreditIndex].Value == null ? "false" : row.Cells[_NotIncludedInCreditIndex].Value.ToString(), out b);
                    parentElement.SetAttribute("NotIncludedInCredit", b.ToString());
                    bool.TryParse(row.Cells[_CalcFlagIndex].Value == null ? "false" : row.Cells[_CalcFlagIndex].Value.ToString(), out b);
                    parentElement.SetAttribute("CalcFlag", b.ToString());

                    #region 填入分項類別
                    //switch ("" + row.Cells[_EntryIndex].Value)
                    //{
                    //    default:
                    //    case "學業":
                    //        parentElement.SetAttribute("Entry", "學業");
                    //        break;
                    //    case "體育":
                    //        parentElement.SetAttribute("Entry", "體育");
                    //        break;
                    //    case "國防通識(軍訓)":
                    //        parentElement.SetAttribute("Entry", "國防通識");
                    //        break;
                    //    case "健康與護理":
                    //        parentElement.SetAttribute("Entry", "健康與護理");
                    //        break;
                    //    case "實習科目":
                    //        parentElement.SetAttribute("Entry", "實習科目");
                    //        break;
                    //}
                    #endregion


                    #region 計算科目級別
                    List <int> levelList = ProcessLevels(row);
                    if (levelList.Count == 0)
                    {
                        throw new Exception("輸入資料無法計算學分數");
                    }
                    if (levelList.Count == 1 && levelList[0] == 0)
                    {
                        XmlElement element = (XmlElement)parentElement.CloneNode(true);
                        element.SetAttribute("FullName", subjectName);
                        element.SetAttribute("Level", row.Cells[_StartLevelIndex].Value == null ? "" : row.Cells[_StartLevelIndex].Value.ToString());

                        element.SetAttribute("Credit", Credits[0].ToString());
                        element.SetAttribute("Period", Periods[0].ToString());
                        element.SetAttribute("GradeYear", GradeYears[0].ToString());
                        element.SetAttribute("Semester", Semesters[0].ToString());

                        doc.DocumentElement.AppendChild(element);
                    }
                    else
                    {
                        int index = 0;
                        //沒輸入開始級別,第一筆沒有級別,第二筆以後從2開始
                        XmlElement element = (XmlElement)parentElement.CloneNode(true);
                        if (levelList[0] == 0)
                        {
                            #region 單獨處理第一筆

                            element.SetAttribute("FullName", subjectName);
                            element.SetAttribute("Level", "");

                            element.SetAttribute("Credit", Credits[0].ToString());
                            element.SetAttribute("Period", Periods[0].ToString());
                            element.SetAttribute("GradeYear", GradeYears[0].ToString());
                            element.SetAttribute("Semester", Semesters[0].ToString());

                            doc.DocumentElement.AppendChild(element);
                            #endregion
                            //接下來從第二筆開始
                            index = 1;
                        }
                        for (int i = index; i < levelList.Count; i++)
                        {
                            element = (XmlElement)parentElement.CloneNode(true);

                            element.SetAttribute("FullName", subjectName + " " + GetNumber(levelList[i]));
                            element.SetAttribute("Level", (levelList[i]).ToString());

                            element.SetAttribute("Credit", Credits[i].ToString());
                            element.SetAttribute("Period", Periods[i].ToString());
                            element.SetAttribute("GradeYear", GradeYears[i].ToString());
                            element.SetAttribute("Semester", Semesters[i].ToString());

                            doc.DocumentElement.AppendChild(element);
                        }
                    }
                    #region OldWay
                    //if (countLevel == 0)
                    //    throw new Exception("輸入資料無法計算學分數");
                    //if (countLevel == 1 && startLevel == 0)
                    //{
                    //    XmlElement element = (XmlElement)parentElement.CloneNode(true);
                    //    element.SetAttribute("FullName", subjectName);
                    //    element.SetAttribute("Level", row.Cells[_StartLevelIndex].Value == null ? "" : row.Cells[_StartLevelIndex].Value.ToString());

                    //    element.SetAttribute("Credit", Credits[0].ToString());
                    //    element.SetAttribute("GradeYear", GradeYears[0].ToString());
                    //    element.SetAttribute("Semester", Semesters[0].ToString());

                    //    doc.DocumentElement.AppendChild(element);
                    //}
                    //else//countLevel>1
                    //{
                    //    //沒輸入開始級別,第一筆沒有級別,第二筆以後從2開始
                    //    if (startLevel == 0)
                    //    {
                    //        #region 單獨處理第一筆
                    //        XmlElement element = (XmlElement)parentElement.CloneNode(true);

                    //        element.SetAttribute("FullName", subjectName);
                    //        element.SetAttribute("Level", "");

                    //        element.SetAttribute("Credit", Credits[0].ToString());
                    //        element.SetAttribute("GradeYear", GradeYears[0].ToString());
                    //        element.SetAttribute("Semester", Semesters[0].ToString());

                    //        doc.DocumentElement.AppendChild(element);
                    //        #endregion
                    //        //填入開始級別
                    //        startLevel = 1;
                    //        for (int i = 1; i < countLevel; i++)
                    //        {
                    //            #region 第二筆之後
                    //            element = (XmlElement)parentElement.CloneNode(true);

                    //            element.SetAttribute("FullName", subjectName + " " + GetNumber(i + startLevel));
                    //            element.SetAttribute("Level", (i + startLevel).ToString());

                    //            element.SetAttribute("Credit", Credits[i].ToString());
                    //            element.SetAttribute("GradeYear", GradeYears[i].ToString());
                    //            element.SetAttribute("Semester", Semesters[i].ToString());

                    //            doc.DocumentElement.AppendChild(element);
                    //            #endregion
                    //        }
                    //    }
                    //    else
                    //    {
                    //        //填入開始級別
                    //        for (int i = 0; i < countLevel; i++)
                    //        {
                    //            XmlElement element = (XmlElement)parentElement.CloneNode(true);

                    //            element.SetAttribute("FullName", subjectName + " " + GetNumber(i + startLevel));
                    //            element.SetAttribute("Level", (i + startLevel).ToString());

                    //            element.SetAttribute("Credit", Credits[i].ToString());
                    //            element.SetAttribute("GradeYear", GradeYears[i].ToString());
                    //            element.SetAttribute("Semester", Semesters[i].ToString());

                    //            doc.DocumentElement.AppendChild(element);
                    //        }
                    //    }
                    //}
                    #endregion
                    #endregion .
                }
            }
            return(doc.DocumentElement);
        }
Ejemplo n.º 18
0
        private void dataGridViewX1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            DataGridViewCell cell = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex];

            cell.ErrorText = "";

            #region 數字欄位輸入格式檢查
            if (!string.IsNullOrEmpty("" + e.FormattedValue) && e.ColumnIndex >= _CreditStartIndex && e.ColumnIndex < _CreditStartIndex + 6)
            {
                string orig = ("" + e.FormattedValue).Trim();

                PeriodCredit pc = new PeriodCredit();
                if (!pc.Parse(orig))
                {
                    cell.ErrorText = pc.Error;
                }
                //if (orig.IndexOf("/") > 0)
                //{
                //    string period = "" + orig.Split('/')[0]; //節數
                //    string credit = "" + orig.Split('/')[1]; //權數

                //    if (string.IsNullOrEmpty(period) || string.IsNullOrEmpty(credit))
                //        cell.ErrorText = "必須輸入節數/權數";
                //    else if (!int.TryParse(period, out i) && !int.TryParse(credit, out i))
                //        cell.ErrorText = "節數/權數必須是數字";
                //    else if (!int.TryParse(period, out i))
                //        cell.ErrorText = "節數必須是數字";
                //    else if (!int.TryParse(credit, out i))
                //        cell.ErrorText = "權數必須是數字";
                //}
                //else
                //{
                //    if (!int.TryParse("" + e.FormattedValue, out i))
                //        cell.ErrorText = "必須輸入數字";
                //}
            }
            #endregion

            #region 檢查科目名稱頭尾不可有空白
            if (e.ColumnIndex == _SubjectNameIndex && ("" + e.FormattedValue != ("" + e.FormattedValue).Trim()))
            {
                cell.ErrorText = "科目名稱頭尾不可有空白字元";
            }
            #endregion

            dgv.UpdateCellErrorText(e.ColumnIndex, e.RowIndex);

            #region 學分數檢查 OLD
            //if ("" + dataGridViewX1.Rows[e.RowIndex].Cells[_SubjectNameIndex].FormattedValue != "")
            //{
            //    bool pass = false;
            //    #region 若是正輸入的欄位則用驗證值檢查否則用欄位上的值檢察
            //    for (int i = 0; i < 8; i++)
            //    {
            //        int x = 0;
            //        if (i + _CreditStartIndex == e.ColumnIndex && (int.TryParse(e.FormattedValue.ToString(), out x)))
            //        {
            //            pass = true;
            //            break;
            //        }
            //        else if (int.TryParse("" + dataGridViewX1.Rows[e.RowIndex].Cells[i + _CreditStartIndex].FormattedValue, out x))
            //        {
            //            pass = true;
            //            break;
            //        }
            //    }
            //    #endregion
            //    if (!pass)
            //    {
            //        dataGridViewX1.Rows[e.RowIndex].Cells[_SubjectNameIndex].ErrorText = "必須輸入學分數";
            //        dataGridViewX1.UpdateCellErrorText(_SubjectNameIndex, e.RowIndex);
            //    }
            //    else if (dataGridViewX1.Rows[e.RowIndex].Cells[_SubjectNameIndex].ErrorText == "必須輸入學分數")
            //    {
            //        dataGridViewX1.Rows[e.RowIndex].Cells[_SubjectNameIndex].ErrorText = "";
            //        dataGridViewX1.UpdateCellErrorText(_SubjectNameIndex, e.RowIndex);
            //    }
            //}
            #endregion
        }
Ejemplo n.º 19
0
        public void SetSource(System.Xml.XmlElement source)
        {
            _defaultValues = new Dictionary <DataGridViewCell, object>();
            _RowSubject    = new Dictionary <DataGridViewRow, string>();
            _DirtyCells    = new List <DataGridViewCell>();
            dgv.Rows.Clear();
            _RawDeleted = _IsDirty = false;
            Dictionary <string, DataGridViewRow> rowDictionary = new Dictionary <string, DataGridViewRow>();

            if (source != null)
            {
                foreach (XmlNode node in source.SelectNodes("Subject"))
                {
                    DataGridViewRow row;
                    XmlElement      element   = (XmlElement)node;
                    XmlNode         groupNode = element.SelectSingleNode("Grouping");
                    //檢查是否符合群組設定
                    if (groupNode != null && groupNode.SelectSingleNode("@RowIndex") != null)
                    {
                        #region 以第一筆資料為主填入各級別學年度學期學分數
                        XmlElement groupElement = (XmlElement)groupNode;
                        if (!rowDictionary.ContainsKey(groupElement.Attributes["RowIndex"].InnerText))
                        {
                            row = new DataGridViewRow();
                            row.CreateCells(dgv, "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
                            dgv.Rows.Add(row);
                            //row.Cells[_CategoryIndex].Value = element.Attributes["Category"].InnerText;

                            row.Cells[_DomainIndex].Value = element.GetAttribute("Domain");
                            //row.Cells[_DomainIndex].Value = string.Empty;
                            //string domain = element.GetAttribute("Domain");
                            //if (_domainList.Contains(domain))
                            //    row.Cells[_DomainIndex].Value = domain;
                            //else
                            //{
                            //    _IsDirty = true;
                            //    if (IsDirtyChanged != null)
                            //        IsDirtyChanged.Invoke(this, new EventArgs());
                            //}

                            //row.Cells[_RequiredByIndex].Value = element.Attributes["RequiredBy"].InnerText;
                            //row.Cells[_RequiredIndex].Value = element.Attributes["Required"].InnerText;
                            row.Cells[_SubjectNameIndex].Value = element.Attributes["SubjectName"].InnerText;

                            row.Cells[_CalcFlagIndex].Value = bool.Parse(element.GetAttribute("CalcFlag"));
                            ////舊版沒有下面這兩個 Attributes
                            //if (element.HasAttribute("NotIncludedInCredit") && element.HasAttribute("NotIncludedInCalc") && element.Attributes["NotIncludedInCredit"].Value != "" && element.Attributes["NotIncludedInCalc"].Value != "")
                            //{
                            //    row.Cells[_NotIncludedInCreditIndex].Value = bool.Parse(element.Attributes["NotIncludedInCredit"].Value);
                            //    row.Cells[_NotIncludedInCalcIndex].Value = bool.Parse(element.Attributes["NotIncludedInCalc"].Value);
                            //}

                            //if (element.HasAttribute("Entry"))
                            //{
                            //    switch (element.GetAttribute("Entry"))
                            //    {
                            //        default:
                            //        case "學業":
                            //            row.Cells[_EntryIndex].Value = "學業";
                            //            break;
                            //        case "體育":
                            //            row.Cells[_EntryIndex].Value = "體育";
                            //            break;
                            //        case "國防通識":
                            //            row.Cells[_EntryIndex].Value = "國防通識(軍訓)";
                            //            break;
                            //        case "健康與護理":
                            //            row.Cells[_EntryIndex].Value = "健康與護理";
                            //            break;
                            //        case "實習科目":
                            //            row.Cells[_EntryIndex].Value = "實習科目";
                            //            break;
                            //    }
                            //}
                            //else
                            //{
                            //    row.Cells[_EntryIndex].Value = "學業";
                            //}

                            row.Cells[_StartLevelIndex].Value = element.Attributes["Level"].InnerText;
                            rowDictionary.Add(groupElement.Attributes["RowIndex"].InnerText, row);
                            //呼叫結束編輯處理函式
                            dataGridViewX1_CellEndEdit(this, new DataGridViewCellEventArgs(_SubjectNameIndex, row.Index));
                        }
                        else
                        {
                            row = rowDictionary[groupElement.Attributes["RowIndex"].InnerText];
                        }
                        //填入自動開課資料(年級學期學分數)
                        int gradeyear = 0;
                        int semester  = 0;
                        int cellIndex = 0;
                        if (int.TryParse(element.Attributes["GradeYear"].InnerText, out gradeyear) && int.TryParse(element.Attributes["Semester"].InnerText, out semester))
                        {
                            string credit = element.GetAttribute("Credit");
                            string period = element.GetAttribute("Period");

                            cellIndex = (gradeyear - 1) * 2 + semester + _CreditStartIndex - 1;
                            DataGridViewCell cell = row.Cells[cellIndex];

                            PeriodCredit pc = new PeriodCredit();
                            if (pc.Parse(period + "/" + credit))
                            {
                                cell.Value = pc.ToString();
                            }
                            else
                            {
                                cell.Value     = string.Empty;
                                cell.ErrorText = pc.Error;
                            }

                            //if (string.IsNullOrEmpty(period)) period = credit;

                            //if (credit.CompareTo(period) == 0) //節數與權數相等,則不需要用'/'
                            //    row.Cells[(gradeyear - 1) * 2 + semester + _CreditStartIndex - 1].Value = credit;
                            //else
                            //    row.Cells[(gradeyear - 1) * 2 + semester + _CreditStartIndex - 1].Value = period + "/" + credit;
                        }
                        //呼叫結束編輯處理函式
                        dataGridViewX1_CellEndEdit(this, new DataGridViewCellEventArgs(cellIndex, row.Index));
                        #endregion
                    }
                    else
                    {
                        #region 以該科別的開始級別做為開始級別
                        row = new DataGridViewRow();
                        row.CreateCells(dgv, "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
                        dgv.Rows.Add(row);
                        //row.Cells[_CategoryIndex].Value = element.Attributes["Category"].InnerText;
                        row.Cells[_DomainIndex].Value = element.GetAttribute("Domain");
                        //row.Cells[_DomainIndex].Value = string.Empty;
                        //string domain = element.GetAttribute("Domain");
                        //if (_domainList.Contains(domain))
                        //    row.Cells[_DomainIndex].Value = domain;
                        //else
                        //{
                        //    _IsDirty = true;
                        //    if (IsDirtyChanged != null)
                        //        IsDirtyChanged.Invoke(this, new EventArgs());
                        //}

                        //row.Cells[_RequiredByIndex].Value = element.Attributes["RequiredBy"].InnerText;
                        //row.Cells[_RequiredIndex].Value = element.Attributes["Required"].InnerText;
                        row.Cells[_SubjectNameIndex].Value = element.Attributes["SubjectName"].InnerText;
                        //row.Cells[_NotIncludedInCreditIndex].Value = element.Attributes["NotIncludedInCredit"].InnerText == "True" ? true : false;
                        row.Cells[_CalcFlagIndex].Value = element.GetAttribute("CalcFlag") == "True" ? true : false;
                        //if (element.HasAttribute("Entry"))
                        //{
                        //    switch (element.GetAttribute("Entry"))
                        //    {
                        //        default:
                        //        case "學業":
                        //            row.Cells[_EntryIndex].Value = "學業";
                        //            break;
                        //        case "體育":
                        //            row.Cells[_EntryIndex].Value = "體育";
                        //            break;
                        //        case "國防通識":
                        //            row.Cells[_EntryIndex].Value = "國防通識(軍訓)";
                        //            break;
                        //        case "健康與護理":
                        //            row.Cells[_EntryIndex].Value = "健康與護理";
                        //            break;
                        //        case "實習科目":
                        //            row.Cells[_EntryIndex].Value = "實習科目";
                        //            break;
                        //    }
                        //}
                        //else
                        //    row.Cells[_EntryIndex].Value = "學業";

                        row.Cells[_StartLevelIndex].Value = element.Attributes["Level"].InnerText;
                        //填入自動開課資料(年級學期學分數)
                        int gradeyear = 0;
                        int semester  = 0;
                        int cellIndex = 0;
                        if (int.TryParse(element.Attributes["GradeYear"].InnerText, out gradeyear) && int.TryParse(element.Attributes["Semester"].InnerText, out semester))
                        {
                            string period = element.GetAttribute("Period");
                            string credit = element.GetAttribute("Credit");
                            if (string.IsNullOrEmpty(period))
                            {
                                period = credit;
                            }

                            cellIndex = (gradeyear - 1) * 2 + semester + _CreditStartIndex - 1;
                            DataGridViewCell cell = row.Cells[cellIndex];

                            PeriodCredit pc = new PeriodCredit();
                            if (pc.Parse(period + "/" + credit))
                            {
                                cell.Value = pc.ToString();
                            }
                            else
                            {
                                cell.Value     = string.Empty;
                                cell.ErrorText = pc.Error;
                            }

                            //if (credit.CompareTo(period) == 0) //節數與權數相等,則不需要用'/'
                            //    row.Cells[(gradeyear - 1) * 2 + semester + _CreditStartIndex - 1].Value = credit;
                            //else
                            //    row.Cells[(gradeyear - 1) * 2 + semester + _CreditStartIndex - 1].Value = period + "/" + credit;
                        }
                        #endregion
                        //呼叫結束編輯處理函式
                        dataGridViewX1_CellEndEdit(this, new DataGridViewCellEventArgs(_SubjectNameIndex, row.Index));
                    }
                }
            }
            if (this.IsValidated)
            {
            }
            dgv.CurrentCell = dgv.FirstDisplayedCell;
            if (dgv.CurrentCell != null)
            {
                dgv.BeginEdit(true);
            }
            ValidateSameSubject();
        }
Ejemplo n.º 20
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            #region DoWork
            object[] objs         = (object[])e.Argument;
            int      schoolyear   = Framework.Int.Parse(objs[0] as string);
            int      semester     = Framework.Int.Parse(objs[1] as string);
            string   domain       = objs[2] as string;
            string   subject      = objs[3] as string;
            string   periodcredit = objs[4] as string;
            string   required     = objs[5] as string;

            PeriodCredit pc = new PeriodCredit();
            pc.Parse(periodcredit);

            double total   = _classes.Count;
            double counter = 0;
            if (total == 0)
            {
                total = 1;
            }
            else
            {
                total *= 2;
            }
            _worker.ReportProgress(1, "正在檢查班級課程…");

            _classes.Sort(SortClassesByClassName);

            #region 檢查重複開課
            List <string> errors = new List <string>();

            List <string> classIDs = new List <string>();
            foreach (JHClassRecord cla in _classes)
            {
                classIDs.Add(cla.ID);
            }

            Dictionary <string, List <JHCourseRecord> > classExistCourses = new Dictionary <string, List <JHCourseRecord> >();
            List <JHCourseRecord> orphanCourse = new List <JHCourseRecord>();

            foreach (JHCourseRecord course in JHCourse.SelectBySchoolYearAndSemester(schoolyear, semester))
            {
                if (!classIDs.Contains(course.RefClassID))
                {
                    orphanCourse.Add(course);
                    continue;
                }

                if (!classExistCourses.ContainsKey(course.RefClassID))
                {
                    classExistCourses.Add(course.RefClassID, new List <JHCourseRecord>());
                }
                classExistCourses[course.RefClassID].Add(course);
            }

            foreach (JHClassRecord cla in _classes)
            {
                if (!classExistCourses.ContainsKey(cla.ID))
                {
                    continue;
                }

                foreach (JHCourseRecord course in classExistCourses[cla.ID])
                {
                    if (course.Subject == subject)
                    {
                        errors.Add(cla.Name + ":已有相同科目(" + subject + ")的課程。");
                    }
                }

                foreach (JHCourseRecord course in orphanCourse)
                {
                    if (course.Name == cla.Name + " " + subject)
                    {
                        errors.Add(cla.Name + ":已有相同課程名稱(" + course.Name + ")的課程。");
                    }
                }
            }

            if (errors.Count > 0)
            {
                e.Result = errors;
                return;
            }
            #endregion

            #region 開課
            Dictionary <string, string> classNewCourse = new Dictionary <string, string>();

            DSXmlHelper req = new DSXmlHelper("UpdateRequest");

            foreach (JHClassRecord cla in _classes)
            {
                JHCourseRecord newCourse = new JHCourseRecord();
                newCourse.CalculationFlag = "1";
                newCourse.Period          = pc.Period;
                newCourse.Credit          = pc.Credit;
                newCourse.Domain          = domain;
                newCourse.Subject         = subject;
                newCourse.Name            = cla.Name + " " + subject;
                newCourse.SchoolYear      = schoolyear;
                newCourse.Semester        = semester;
                newCourse.RefClassID      = cla.ID;

                //建立Course時也將CourseExtendRecord建立
                string             course_id = JHCourse.Insert(newCourse);
                CourseExtendRecord courseEx  = new CourseExtendRecord();
                courseEx.Ref_course_id = int.Parse(course_id);
                courseEx.GradeYear     = cla.GradeYear == null ? -1 : int.Parse(cla.GradeYear + "");
                courseEx.Save();

                classNewCourse.Add(cla.ID, course_id);
                req.AddElement("Course");
                req.AddElement("Course", "Field");
                req.AddElement("Course/Field", "IsRequired", required.Replace("修", ""));
                req.AddElement("Course", "Condition");
                req.AddElement("Course/Condition", "ID", classNewCourse[cla.ID]);

                counter++;
                _worker.ReportProgress((int)(counter * 100d / total), "正在進行開課…");
            }

            //更新必選修
            if (classNewCourse.Count > 0)
            {
                JHSchool.Feature.Legacy.EditCourse.UpdateCourse(new DSRequest(req));
            }

            #endregion

            #region 加入學生修課

            foreach (JHClassRecord cla in _classes)
            {
                List <JHSCAttendRecord> scattends = new List <JHSchool.Data.JHSCAttendRecord>();
                foreach (JHStudentRecord stu in cla.Students)
                {
                    JHSCAttendRecord scattend = new JHSchool.Data.JHSCAttendRecord();
                    scattend.RefCourseID  = classNewCourse[cla.ID];
                    scattend.RefStudentID = stu.ID;

                    scattends.Add(scattend);
                }

                if (scattends.Count > 0)
                {
                    JHSCAttend.Insert(scattends);
                }

                counter++;
                _worker.ReportProgress((int)(counter * 100d / total), "正在加入學生修課…");
            }
            #endregion

            // 加這主要是重新整理
            Course.Instance.SyncDataBackground(classNewCourse.Values);

            e.Result = string.Empty;

            #endregion
        }
Ejemplo n.º 21
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!inputed)
            {
                MsgBox.Show("尚未輸入成績");
                return;
            }

            if (!IsValid())
            {
                return;
            }

            try
            {
                int schoolYear = int.Parse(cboSchoolYear.Text);
                int semester   = int.Parse(cboSemester.Text);
                //int gradeYear = 0;

                //SemesterScoreRecordEditor editor = new SemesterScoreRecordEditor(_student, schoolYear, semester, gradeYear);
                JHSemesterScoreRecord newRecord = new JHSemesterScoreRecord();
                newRecord.RefStudentID = _student.ID;
                newRecord.SchoolYear   = schoolYear;
                newRecord.Semester     = semester;

                List <string> checkSubjName = new List <string>();

                // 檢查科目名稱是否相同,因為科目名稱重複會造成新增錯誤,科目名稱是唯一值。
                foreach (DataGridViewRow row in dgv.Rows)
                {
                    if (row.Cells[chsSubject.Index].Value != null)
                    {
                        string tmpSubjName = "" + row.Cells[chsSubject.Index].Value;
                        if (checkSubjName.Contains(tmpSubjName))
                        {
                            FISCA.Presentation.Controls.MsgBox.Show("科目名稱重複,無法儲存。");
                            return;
                        }
                        else
                        {
                            checkSubjName.Add(tmpSubjName);
                        }
                    }
                }


                if (CheckDomainValid(txtPC1, txtScore1, txtEffort1))
                {
                    newRecord.Domains.Add("國語文", GetDomainScore("國語文", txtPC1, txtScore1, txtEffort1, txtText1));
                }
                if (CheckDomainValid(txtPC2, txtScore2, txtEffort2))
                {
                    newRecord.Domains.Add("英語", GetDomainScore("英語", txtPC2, txtScore2, txtEffort2, txtText2));
                }
                if (CheckDomainValid(txtPC3, txtScore3, txtEffort3))
                {
                    newRecord.Domains.Add("數學", GetDomainScore("數學", txtPC3, txtScore3, txtEffort3, txtText3));
                }
                if (CheckDomainValid(txtPC4, txtScore4, txtEffort4))
                {
                    newRecord.Domains.Add("社會", GetDomainScore("社會", txtPC4, txtScore4, txtEffort4, txtText4));
                }
                if (CheckDomainValid(txtPC5, txtScore5, txtEffort5))
                {
                    newRecord.Domains.Add("藝術與人文", GetDomainScore("藝術與人文", txtPC5, txtScore5, txtEffort5, txtText5));
                }
                if (CheckDomainValid(txtPC6, txtScore6, txtEffort6))
                {
                    newRecord.Domains.Add("自然與生活科技", GetDomainScore("自然與生活科技", txtPC6, txtScore6, txtEffort6, txtText6));
                }
                if (CheckDomainValid(txtPC7, txtScore7, txtEffort7))
                {
                    newRecord.Domains.Add("健康與體育", GetDomainScore("健康與體育", txtPC7, txtScore7, txtEffort7, txtText7));
                }
                if (CheckDomainValid(txtPC8, txtScore8, txtEffort8))
                {
                    newRecord.Domains.Add("綜合活動", GetDomainScore("綜合活動", txtPC8, txtScore8, txtEffort8, txtText8));
                }

                foreach (DataGridViewRow row in dgv.Rows)
                {
                    if (row.IsNewRow)
                    {
                        continue;
                    }

                    PeriodCredit pc = new PeriodCredit();
                    pc.Parse("" + row.Cells[chsPeriodCredit.Index].Value);
                    K12.Data.SubjectScore subject = new K12.Data.SubjectScore();
                    subject.Domain  = "" + row.Cells[chsDomain.Index].Value;
                    subject.Subject = "" + row.Cells[chsSubject.Index].Value;
                    subject.Period  = pc.Period;
                    subject.Credit  = pc.Credit;
                    subject.Score   = decimal.Parse("" + row.Cells[chsScore.Index].Value);
                    subject.Effort  = int.Parse("" + row.Cells[chsEffort.Index].Value);
                    subject.Text    = "" + row.Cells[chsText.Index].Value;

                    newRecord.Subjects.Add(subject.Subject, subject);
                }

                if (!string.IsNullOrEmpty(txtElastic.Text))
                {
                    newRecord.Domains.Add("彈性課程", GetElasticDomain());
                }
                if (!string.IsNullOrEmpty(txtLearnDomain.Text))
                {
                    newRecord.LearnDomainScore = decimal.Parse(txtLearnDomain.Text);
                }
                if (!string.IsNullOrEmpty(txtCourseLearn.Text))
                {
                    newRecord.CourseLearnScore = decimal.Parse(txtCourseLearn.Text);
                }

                JHSemesterScore.Insert(newRecord);
                SaveLog(newRecord);
            }
            catch (Exception ex)
            {
                MsgBox.Show("儲存失敗");
                this.DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }

            this.DialogResult = DialogResult.OK;
        }
Ejemplo n.º 22
0
 public SubjectRow(string name)
 {
     SubjectName = name;
     Display     = false;
     _pc         = new PeriodCredit();
 }
Ejemplo n.º 23
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!inputed)
            {
                MsgBox.Show("尚未輸入成績");
                return;
            }

            // 驗證所有權數欄位
            ValidAllPCTextBox();

            if (!IsValid())
            {
                return;
            }

            try
            {
                int schoolYear = int.Parse(cboSchoolYear.Text);
                int semester   = int.Parse(cboSemester.Text);
                //int gradeYear = 0;

                //SemesterScoreRecordEditor editor = new SemesterScoreRecordEditor(_student, schoolYear, semester, gradeYear);
                JHSemesterScoreRecord newRecord = new JHSemesterScoreRecord();
                newRecord.RefStudentID = _student.ID;
                newRecord.SchoolYear   = schoolYear;
                newRecord.Semester     = semester;

                List <string> checkSubjName = new List <string>();

                // 檢查科目名稱是否相同,因為科目名稱重複會造成新增錯誤,科目名稱是唯一值。
                foreach (DataGridViewRow row in dgv.Rows)
                {
                    if (row.Cells[chsSubject.Index].Value != null)
                    {
                        string tmpSubjName = "" + row.Cells[chsSubject.Index].Value;
                        if (checkSubjName.Contains(tmpSubjName))
                        {
                            FISCA.Presentation.Controls.MsgBox.Show("科目名稱重複,無法儲存。");
                            return;
                        }
                        else
                        {
                            checkSubjName.Add(tmpSubjName);
                        }
                    }
                }

                //2018/4/16 穎驊因應高雄項目[02-03][06]學期成績,快速新增功能如無原始成績,則結算學期領域成績時快速新增的成績都會變成"0"分
                // 新增原始成績登錄、語文領域,另外看來以前不流行 datagridView 這土法煉鋼有點驚人呀!!。

                //2018/5/22 穎驊再次註解,恩正說不必新增原始成績欄位給屬用者輸入,直接抓分數就好,所以將上一版的輸入格拿掉

                if (CheckDomainValid(txtPC1, txtScore1, txtScore1, txtEffort1))
                {
                    newRecord.Domains.Add("國語文", GetDomainScore("國語文", txtPC1, txtScore1, txtScore1, txtEffort1, txtText1));
                }
                if (CheckDomainValid(txtPC2, txtScore2, txtScore2, txtEffort2))
                {
                    newRecord.Domains.Add("英語", GetDomainScore("英語", txtPC2, txtScore2, txtScore2, txtEffort2, txtText2));
                }
                if (CheckDomainValid(txtPC3, txtScore3, txtScore3, txtEffort3))
                {
                    newRecord.Domains.Add("數學", GetDomainScore("數學", txtPC3, txtScore3, txtScore3, txtEffort3, txtText3));
                }
                if (CheckDomainValid(txtPC4, txtScore4, txtScore4, txtEffort4))
                {
                    newRecord.Domains.Add("社會", GetDomainScore("社會", txtPC4, txtScore4, txtScore4, txtEffort4, txtText4));
                }
                //if (CheckDomainValid(txtPC5, txtScore5, txtScore5, txtEffort5))
                //    newRecord.Domains.Add("藝術與人文", GetDomainScore("藝術與人文", txtPC5, txtScore5, txtScore5, txtEffort5, txtText5));
                //if (CheckDomainValid(txtPC6, txtScore6, txtScore6, txtEffort6))
                //    newRecord.Domains.Add("自然與生活科技", GetDomainScore("自然與生活科技", txtPC6, txtScore6, txtScore6, txtEffort6, txtText6));
                if (CheckDomainValid(txtPC5, txtScore5, txtScore5, txtEffort5))
                {
                    newRecord.Domains.Add("自然科學", GetDomainScore("自然科學", txtPC5, txtScore5, txtScore5, txtEffort5, txtText5));
                }
                if (CheckDomainValid(txtPC6, txtScore6, txtScore6, txtEffort6))
                {
                    newRecord.Domains.Add("藝術", GetDomainScore("藝術", txtPC6, txtScore6, txtScore6, txtEffort6, txtText6));
                }
                if (CheckDomainValid(txtPC7, txtScore7, txtScore7, txtEffort7))
                {
                    newRecord.Domains.Add("健康與體育", GetDomainScore("健康與體育", txtPC7, txtScore7, txtScore7, txtEffort7, txtText7));
                }
                if (CheckDomainValid(txtPC8, txtScore8, txtScore8, txtEffort8))
                {
                    newRecord.Domains.Add("綜合活動", GetDomainScore("綜合活動", txtPC8, txtScore8, txtScore8, txtEffort8, txtText8));
                }
                if (CheckDomainValid(txtPC9, txtScore9, txtScore9, txtEffort9))
                {
                    newRecord.Domains.Add("語文", GetDomainScore("語文", txtPC9, txtScore9, txtScore9, txtEffort9, txtText9));
                }
                if (CheckDomainValid(txtPC10, txtScore10, txtScore10, txtEffort10))
                {
                    newRecord.Domains.Add("科技", GetDomainScore("科技", txtPC10, txtScore10, txtScore10, txtEffort10, txtText10));
                }

                foreach (DataGridViewRow row in dgv.Rows)
                {
                    if (row.IsNewRow)
                    {
                        continue;
                    }

                    PeriodCredit pc = new PeriodCredit();
                    pc.Parse("" + row.Cells[chsPeriodCredit.Index].Value);
                    K12.Data.SubjectScore subject = new K12.Data.SubjectScore();
                    subject.Domain      = "" + row.Cells[chsDomain.Index].Value;
                    subject.Subject     = "" + row.Cells[chsSubject.Index].Value;
                    subject.Period      = pc.Period;
                    subject.Credit      = pc.Credit;
                    subject.Score       = decimal.Parse("" + row.Cells[chsScore.Index].Value);
                    subject.ScoreOrigin = decimal.Parse("" + row.Cells[chsScore.Index].Value); // 2018/5/22 穎華聽從恩正建議,原始成績直接抓取成績即可
                    subject.Effort      = int.Parse("" + row.Cells[chsEffort.Index].Value);
                    subject.Text        = "" + row.Cells[chsText.Index].Value;

                    newRecord.Subjects.Add(subject.Subject, subject);
                }

                if (!string.IsNullOrEmpty(txtElastic.Text))
                {
                    newRecord.Domains.Add("彈性課程", GetElasticDomain());
                }
                if (!string.IsNullOrEmpty(txtLearnDomain.Text))
                {
                    newRecord.LearnDomainScore = decimal.Parse(txtLearnDomain.Text);
                }
                if (!string.IsNullOrEmpty(txtCourseLearn.Text))
                {
                    newRecord.CourseLearnScore = decimal.Parse(txtCourseLearn.Text);
                }

                JHSemesterScore.Insert(newRecord);
                SaveLog(newRecord);
            }
            catch (Exception ex)
            {
                MsgBox.Show("儲存失敗");
                this.DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }

            this.DialogResult = DialogResult.OK;
        }
Ejemplo n.º 24
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!inputed)
            {
                MsgBox.Show("尚未輸入成績");
                return;
            }

            if (!IsValid())
            {
                return;
            }

            try
            {
                int schoolYear = int.Parse(cboSchoolYear.Text);
                int semester   = int.Parse(cboSemester.Text);
                //int gradeYear = 0;

                //SemesterScoreRecordEditor editor = new SemesterScoreRecordEditor(_student, schoolYear, semester, gradeYear);
                JHSemesterScoreRecord newRecord = new JHSemesterScoreRecord();
                newRecord.RefStudentID = _student.ID;
                newRecord.SchoolYear   = schoolYear;
                newRecord.Semester     = semester;

                K12.Data.DomainScore liter    = new K12.Data.DomainScore();
                PeriodCredit         literpc1 = new PeriodCredit();
                PeriodCredit         literpc2 = new PeriodCredit();
                literpc1.Parse(textBoxX25.Text);
                literpc2.Parse(textBoxX26.Text);
                //if (!int.TryParse(textBoxX25.Text, out literpc1))
                //    literpc1 = 0;
                //if (!int.TryParse(textBoxX26.Text, out literpc2))
                //    literpc2 = 0;
                int effort1, effort2;
                if (!int.TryParse(textBoxX17.Text, out effort1))
                {
                    effort1 = 0;
                }
                if (!int.TryParse(textBoxX18.Text, out effort2))
                {
                    effort2 = 0;
                }

                liter.Period = literpc1.Period + literpc2.Period;
                liter.Credit = literpc1.Credit + literpc2.Credit;
                liter.Domain = "語文";
                //liter.Effort = (int)((effort1 + effort2) / 2);
                liter.Effort = 1;
                decimal d;
                liter.Score = decimal.TryParse(labelX14.Text, out d) ? (decimal?)d : null;
                liter.Text  = textBoxX9.Text + " " + textBoxX10.Text;

                newRecord.Domains.Add("語文", liter);

                if (CheckDomainValid(textBoxX27, textBoxX3, textBoxX19))
                {
                    newRecord.Domains.Add("數學", GetDomainScore("語文", textBoxX27, textBoxX3, textBoxX19, textBoxX11));
                }
                if (CheckDomainValid(textBoxX28, textBoxX4, textBoxX20))
                {
                    newRecord.Domains.Add("社會", GetDomainScore("社會", textBoxX28, textBoxX4, textBoxX20, textBoxX12));
                }
                if (CheckDomainValid(textBoxX29, textBoxX5, textBoxX21))
                {
                    newRecord.Domains.Add("藝術與人文", GetDomainScore("藝術與人文", textBoxX29, textBoxX5, textBoxX21, textBoxX13));
                }
                if (CheckDomainValid(textBoxX30, textBoxX6, textBoxX22))
                {
                    newRecord.Domains.Add("自然與生活科技", GetDomainScore("自然與生活科技", textBoxX30, textBoxX6, textBoxX22, textBoxX14));
                }
                if (CheckDomainValid(textBoxX31, textBoxX7, textBoxX23))
                {
                    newRecord.Domains.Add("健康與體育", GetDomainScore("健康與體育", textBoxX31, textBoxX7, textBoxX23, textBoxX15));
                }
                if (CheckDomainValid(textBoxX32, textBoxX8, textBoxX24))
                {
                    newRecord.Domains.Add("綜合活動", GetDomainScore("綜合活動", textBoxX32, textBoxX8, textBoxX24, textBoxX16));
                }

                if (textBoxX25.Enabled)
                {
                    K12.Data.SubjectScore subject1 = new K12.Data.SubjectScore();
                    subject1.Domain  = "語文";
                    subject1.Subject = textBoxX36.Text;
                    subject1.Score   = decimal.Parse(textBoxX1.Text);
                    //subject1.Effort = int.Parse(textBoxX17.Text);
                    subject1.Effort = 1;
                    subject1.Text   = textBoxX9.Text;
                    //subject1.Period = subject1.Credit = int.Parse(textBoxX25.Text);
                    subject1.Period = literpc1.Period;
                    subject1.Credit = literpc1.Credit;
                    newRecord.Subjects.Add(subject1.Subject, subject1);
                }

                if (textBoxX26.Enabled)
                {
                    K12.Data.SubjectScore subject2 = new K12.Data.SubjectScore();
                    subject2.Domain  = "語文";
                    subject2.Subject = textBoxX37.Text;
                    subject2.Score   = decimal.Parse(textBoxX2.Text);
                    subject2.Effort  = int.Parse(textBoxX18.Text);
                    subject2.Text    = textBoxX10.Text;
                    //subject2.Period = subject2.Credit = int.Parse(textBoxX26.Text);
                    subject2.Period = literpc2.Period;
                    subject2.Credit = literpc2.Credit;
                    newRecord.Subjects.Add(subject2.Subject, subject2);
                }

                foreach (DataGridViewRow row in dgv.Rows)
                {
                    if (row.IsNewRow)
                    {
                        continue;
                    }
                    PeriodCredit pc = new PeriodCredit();
                    pc.Parse("" + row.Cells[chsPeriodCredit.Index].Value);
                    K12.Data.SubjectScore subject = new K12.Data.SubjectScore();
                    subject.Domain  = "" + row.Cells[chsDomain.Index].Value;
                    subject.Subject = "" + row.Cells[chsSubject.Index].Value;
                    subject.Period  = pc.Period;
                    subject.Credit  = pc.Credit;
                    subject.Score   = decimal.Parse("" + row.Cells[chsScore.Index].Value);
                    //subject.Effort = int.Parse("" + row.Cells[chsEffort.Index].Value);
                    subject.Effort = 1;
                    subject.Text   = "" + row.Cells[chsText.Index].Value;

                    newRecord.Subjects.Add(subject.Subject, subject);
                }

                if (!string.IsNullOrEmpty(textBoxX33.Text))
                {
                    newRecord.Domains.Add("彈性課程", GetElasticDomain());
                }
                if (!string.IsNullOrEmpty(textBoxX34.Text))
                {
                    newRecord.LearnDomainScore = decimal.Parse(textBoxX34.Text);
                }
                if (!string.IsNullOrEmpty(textBoxX35.Text))
                {
                    newRecord.CourseLearnScore = decimal.Parse(textBoxX35.Text);
                }

                JHSemesterScore.Insert(newRecord);
                SaveLog(newRecord);
            }
            catch (Exception ex)
            {
                MsgBox.Show("儲存失敗");
                this.DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }

            this.DialogResult = DialogResult.OK;
        }
Ejemplo n.º 25
0
        // 按儲存前 驗證所有權數欄位
        private void ValidAllPCTextBox()
        {
            List <TextBox> textBoxList = new List <TextBox>();

            textBoxList.Add(txtPC1);
            textBoxList.Add(txtPC2);
            textBoxList.Add(txtPC3);
            textBoxList.Add(txtPC4);
            textBoxList.Add(txtPC5);
            textBoxList.Add(txtPC6);
            textBoxList.Add(txtPC7);
            textBoxList.Add(txtPC8);
            textBoxList.Add(txtPC9);
            textBoxList.Add(txtPC10);

            // 這方法很蠢, 但目前暫時也沒更好的寫法
            #region 配對分數的權重 關係 有分數資料 才要驗
            if (txtScore1.Text != "")
            {
                txtPC1.Tag = "hasValue";
            }
            else
            {
                txtPC1.Tag = "";
            }

            if (txtScore2.Text != "")
            {
                txtPC2.Tag = "hasValue";
            }
            else
            {
                txtPC2.Tag = "";
            }

            if (txtScore3.Text != "")
            {
                txtPC3.Tag = "hasValue";
            }
            else
            {
                txtPC3.Tag = "";
            }

            if (txtScore4.Text != "")
            {
                txtPC4.Tag = "hasValue";
            }
            else
            {
                txtPC4.Tag = "";
            }

            if (txtScore5.Text != "")
            {
                txtPC5.Tag = "hasValue";
            }
            else
            {
                txtPC5.Tag = "";
            }

            if (txtScore6.Text != "")
            {
                txtPC6.Tag = "hasValue";
            }
            else
            {
                txtPC6.Tag = "";
            }

            if (txtScore7.Text != "")
            {
                txtPC7.Tag = "hasValue";
            }
            else
            {
                txtPC7.Tag = "";
            }

            if (txtScore8.Text != "")
            {
                txtPC8.Tag = "hasValue";
            }
            else
            {
                txtPC8.Tag = "";
            }

            if (txtScore9.Text != "")
            {
                txtPC9.Tag = "hasValue";
            }
            else
            {
                txtPC9.Tag = "";
            }

            if (txtScore10.Text != "")
            {
                txtPC10.Tag = "hasValue";
            }
            else
            {
                txtPC10.Tag = "";
            }
            #endregion

            foreach (TextBox tb in textBoxList)
            {
                // 對應的欄位有分數才要驗證
                if ("" + tb.Tag != "hasValue")
                {
                    continue;
                }

                errorProvider.SetError(tb, "");
                PeriodCredit pc = new PeriodCredit();
                if (!pc.Parse(tb.Text))
                {
                    errorProvider.SetIconPadding(tb, -17);
                    errorProvider.SetError(tb, pc.Error);
                }
            }
        }
Ejemplo n.º 26
0
        private void dgv_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewCell cell = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex];

            if (cell.OwningRow.IsNewRow)
            {
                return;
            }

            #region 證驗科目
            if (cell.OwningColumn == chsSubject)
            {
                cell.ErrorText = "";
                if (string.IsNullOrEmpty("" + cell.Value))
                {
                    cell.ErrorText = "科目不能為空白";
                }
            }
            #endregion

            #region 驗證成績
            if (cell.OwningColumn == chsScore)
            {
                cell.ErrorText = "";
                if (!string.IsNullOrEmpty("" + cell.Value))
                {
                    decimal d;
                    if (!decimal.TryParse("" + cell.Value, out d))
                    {
                        cell.ErrorText = "成績必須為數字";
                    }
                    else
                    {
                        cell.ErrorText = "";

                        #region  及格變紅色
                        if (d < 60)
                        {
                            cell.Style.ForeColor = Color.Red;
                        }
                        else
                        {
                            cell.Style.ForeColor = Color.Black;
                        }
                        #endregion

                        if (d > 100 || d < 0)
                        {
                            cell.Style.ForeColor = Color.Green;
                        }

                        #region 自動換算出努力程度
                        if (_effortScoreList.Count > 0)
                        {
                            cell.OwningRow.Cells[chsEffort.Index].Value     = GenerateEffortCode(d);
                            cell.OwningRow.Cells[chsEffort.Index].ErrorText = "";
                        }
                        #endregion
                    }
                }
                else
                {
                    cell.ErrorText = "成績不能為空白";
                }
            }
            #endregion

            #region 驗證努力程度
            if (cell.OwningColumn == chsEffort)
            {
                cell.ErrorText = "";
                if (!string.IsNullOrEmpty("" + cell.Value))
                {
                    int i;
                    if (!int.TryParse("" + cell.Value, out i))
                    {
                        cell.ErrorText = "努力程度必須為整數";
                    }
                }
                else
                {
                    cell.ErrorText = "努力程度不能為空白";
                }
            }
            #endregion

            #region 驗證節數權數
            if (cell.OwningColumn == chsPeriodCredit)
            {
                cell.ErrorText = "";
                PeriodCredit pc = new PeriodCredit();
                if (!pc.Parse("" + cell.Value))
                {
                    cell.ErrorText = pc.Error;
                }
            }
            #endregion

            if (!HasDataGridViewError())
            {
                CalculateCourseLearnScore();
            }
        }
Ejemplo n.º 27
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            #region DoWork
            object[] objs         = (object[])e.Argument;
            int      schoolyear   = Framework.Int.Parse(objs[0] as string);
            int      semester     = Framework.Int.Parse(objs[1] as string);
            string   domain       = objs[2] as string;
            string   subject      = objs[3] as string;
            string   periodcredit = objs[4] as string;

            PeriodCredit pc = new PeriodCredit();
            pc.Parse(periodcredit);

            double total   = _classes.Count;
            double counter = 0;
            if (total == 0)
            {
                total = 1;
            }
            else
            {
                total *= 2;
            }
            _worker.ReportProgress(1, "正在檢查班級課程…");

            _classes.Sort(SortClassesByClassName);

            #region 檢查重複開課
            List <string> errors = new List <string>();

            List <string> classIDs = new List <string>();
            foreach (JHClassRecord cla in _classes)
            {
                classIDs.Add(cla.ID);
            }

            Dictionary <string, List <Data.JHCourseRecord> > classExistCourses = new Dictionary <string, List <JHSchool.Data.JHCourseRecord> >();
            List <Data.JHCourseRecord> orphanCourse = new List <JHSchool.Data.JHCourseRecord>();

            foreach (Data.JHCourseRecord course in Data.JHCourse.SelectBySchoolYearAndSemester(schoolyear, semester))
            {
                if (!classIDs.Contains(course.RefClassID))
                {
                    orphanCourse.Add(course);
                    continue;
                }

                if (!classExistCourses.ContainsKey(course.RefClassID))
                {
                    classExistCourses.Add(course.RefClassID, new List <JHSchool.Data.JHCourseRecord>());
                }
                classExistCourses[course.RefClassID].Add(course);
            }

            foreach (JHClassRecord cla in _classes)
            {
                if (!classExistCourses.ContainsKey(cla.ID))
                {
                    continue;
                }

                foreach (Data.JHCourseRecord course in classExistCourses[cla.ID])
                {
                    if (course.Subject == subject)
                    {
                        errors.Add(cla.Name + ":已有相同科目(" + subject + ")的課程。");
                    }
                }

                foreach (Data.JHCourseRecord course in orphanCourse)
                {
                    if (course.Name == cla.Name + " " + subject)
                    {
                        errors.Add(cla.Name + ":已有相同課程名稱(" + course.Name + ")的課程。");
                    }
                }
            }

            if (errors.Count > 0)
            {
                e.Result = errors;
                return;
            }
            #endregion

            #region 開課
            Dictionary <string, string> classNewCourse = new Dictionary <string, string>();

            foreach (JHClassRecord cla in _classes)
            {
                Data.JHCourseRecord newCourse = new JHSchool.Data.JHCourseRecord();
                newCourse.CalculationFlag = "1";
                newCourse.Period          = pc.Period;
                newCourse.Credit          = pc.Credit;
                newCourse.Domain          = domain;
                newCourse.Subject         = subject;
                newCourse.Name            = cla.Name + " " + subject;
                newCourse.SchoolYear      = schoolyear;
                newCourse.Semester        = semester;
                newCourse.RefClassID      = cla.ID;

                classNewCourse.Add(cla.ID, Data.JHCourse.Insert(newCourse));
                counter++;
                _worker.ReportProgress((int)(counter * 100d / total), "正在進行開課…");
            }
            #endregion

            #region 加入學生修課

            foreach (JHClassRecord cla in _classes)
            {
                List <Data.JHSCAttendRecord> scattends = new List <JHSchool.Data.JHSCAttendRecord>();
                foreach (Data.JHStudentRecord stu in cla.Students)
                {
                    Data.JHSCAttendRecord scattend = new JHSchool.Data.JHSCAttendRecord();
                    scattend.RefCourseID  = classNewCourse[cla.ID];
                    scattend.RefStudentID = stu.ID;

                    scattends.Add(scattend);
                }

                if (scattends.Count > 0)
                {
                    Data.JHSCAttend.Insert(scattends);
                }

                counter++;
                _worker.ReportProgress((int)(counter * 100d / total), "正在加入學生修課…");
            }
            #endregion

            e.Result = string.Empty;

            #endregion
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!inputed)
            {
                MsgBox.Show("尚未輸入成績");
                return;
            }

            if (!IsValid())
            {
                return;
            }

            try
            {
                int schoolYear = int.Parse(cboSchoolYear.Text);
                int semester   = int.Parse(cboSemester.Text);
                //int gradeYear = 0;

                //SemesterScoreRecordEditor editor = new SemesterScoreRecordEditor(_student, schoolYear, semester, gradeYear);
                JHSemesterScoreRecord newRecord = new JHSemesterScoreRecord();
                newRecord.RefStudentID = _student.ID;
                newRecord.SchoolYear   = schoolYear;
                newRecord.Semester     = semester;

                // 2018.09.22 [ischoolKingdom] Vicky依據 [J成績][HC][03] 快速新增學期成績修正,將語文領域的子領域兩個項目欄位拿掉,僅保留輸入語文領域成績的單一功能。
                if (CheckDomainValid(textBoxPC1, textBoxScore1, textBoxEffort1))
                {
                    newRecord.Domains.Add("語文", GetDomainScore("語文", textBoxPC1, textBoxScore1, textBoxEffort1, textBoxText1));
                }
                if (CheckDomainValid(textBoxPC2, textBoxScore2, textBoxEffort2))
                {
                    newRecord.Domains.Add("數學", GetDomainScore("數學", textBoxPC2, textBoxScore2, textBoxEffort2, textBoxText2));
                }
                if (CheckDomainValid(textBoxPC3, textBoxScore3, textBoxEffort3))
                {
                    newRecord.Domains.Add("社會", GetDomainScore("社會", textBoxPC3, textBoxScore3, textBoxEffort3, textBoxText3));
                }
                //if (CheckDomainValid(textBoxPC4, textBoxScore4, textBoxEffort4))
                //    newRecord.Domains.Add("藝術與人文", GetDomainScore("藝術與人文", textBoxPC4, textBoxScore4, textBoxEffort4, textBoxText4));
                //if (CheckDomainValid(textBoxPC5, textBoxScore5, textBoxEffort5))
                //    newRecord.Domains.Add("自然與生活科技", GetDomainScore("自然與生活科技", textBoxPC5, textBoxScore5, textBoxEffort5, textBoxText5));
                if (CheckDomainValid(textBoxPC4, textBoxScore4, textBoxEffort4))
                {
                    newRecord.Domains.Add("藝術", GetDomainScore("藝術", textBoxPC4, textBoxScore4, textBoxEffort4, textBoxText4));
                }
                if (CheckDomainValid(textBoxPC5, textBoxScore5, textBoxEffort5))
                {
                    newRecord.Domains.Add("自然科學", GetDomainScore("自然科學", textBoxPC5, textBoxScore5, textBoxEffort5, textBoxText5));
                }
                if (CheckDomainValid(textBoxPC6, textBoxScore6, textBoxEffort6))
                {
                    newRecord.Domains.Add("健康與體育", GetDomainScore("健康與體育", textBoxPC6, textBoxScore6, textBoxEffort6, textBoxText6));
                }
                if (CheckDomainValid(textBoxPC7, textBoxScore7, textBoxEffort7))
                {
                    newRecord.Domains.Add("綜合活動", GetDomainScore("綜合活動", textBoxPC7, textBoxScore7, textBoxEffort7, textBoxText7));
                }
                if (CheckDomainValid(textBoxPC8, textBoxScore8, textBoxEffort8))
                {
                    newRecord.Domains.Add("科技", GetDomainScore("科技", textBoxPC8, textBoxScore8, textBoxEffort8, textBoxText8));
                }

                foreach (DataGridViewRow row in dgv.Rows)
                {
                    if (row.IsNewRow)
                    {
                        continue;
                    }
                    PeriodCredit pc = new PeriodCredit();
                    pc.Parse("" + row.Cells[chsPeriodCredit.Index].Value);
                    K12.Data.SubjectScore subject = new K12.Data.SubjectScore();
                    subject.Domain  = "" + row.Cells[chsDomain.Index].Value;
                    subject.Subject = "" + row.Cells[chsSubject.Index].Value;
                    subject.Period  = pc.Period;
                    subject.Credit  = pc.Credit;
                    subject.Score   = decimal.Parse("" + row.Cells[chsScore.Index].Value);
                    // 2018.09.22 [ischoolKingdom] Vicky 依據 [J成績][HC][03]快速新增學期成績修正 項目,使輸入成績一併儲存至原始成績。
                    subject.ScoreOrigin = decimal.Parse("" + row.Cells[chsScore.Index].Value);
                    //subject.Effort = int.Parse("" + row.Cells[chsEffort.Index].Value);
                    subject.Effort = 1;
                    subject.Text   = "" + row.Cells[chsText.Index].Value;

                    newRecord.Subjects.Add(subject.Subject, subject);
                }

                if (!string.IsNullOrEmpty(textBoxX33.Text))
                {
                    newRecord.Domains.Add("彈性課程", GetElasticDomain());
                }
                if (!string.IsNullOrEmpty(textBoxX34.Text))
                {
                    newRecord.LearnDomainScore = decimal.Parse(textBoxX34.Text);
                }
                if (!string.IsNullOrEmpty(textBoxX35.Text))
                {
                    newRecord.CourseLearnScore = decimal.Parse(textBoxX35.Text);
                }

                JHSemesterScore.Insert(newRecord);
                SaveLog(newRecord);
            }
            catch (Exception ex)
            {
                MsgBox.Show("儲存失敗");
                this.DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }

            this.DialogResult = DialogResult.OK;
        }