コード例 #1
0
 public FitInfo(KeyBoStudent s)
 {
     _studentID = s.ID;
     _class     = s.ClassName;
     _seatno    = s.SeatNo;
     _name      = s.Name;
 }
コード例 #2
0
        private string GetMeValue(string fitValue, string fitname, KeyBoStudent student, Dictionary <int, Dictionary <int, string> > dic)
        {
            if (fitValue == "免測")
            {
                return("免測");
            }


            if (student.Age != null)
            {
                if (dic.ContainsKey(student.Age.鑑測年齡))
                {
                    int fitParseIntValue;
                    if (int.TryParse(fitValue, out fitParseIntValue))
                    {
                        if (dic[student.Age.鑑測年齡].ContainsKey(fitParseIntValue))
                        {
                            return(dic[student.Age.鑑測年齡][fitParseIntValue]);
                        }
                        else
                        {
                            FitInfo info = new FitInfo(student);
                            info._info = string.Format("{0}:「{1}」不在表定範圍!!", fitname, fitValue);
                            FitInfoList.Add(info);
                        }
                    }
                    else
                    {
                        FitInfo info = new FitInfo(student);
                        info._info = string.Format("{0}:「{1}」並非數字!!", fitname, fitValue);
                        FitInfoList.Add(info);
                    }
                }
                else
                {
                    FitInfo info = new FitInfo(student);
                    info._info = string.Format("{0}:鑑測年齡未落在「13~23歲」範圍內", fitname);
                    FitInfoList.Add(info);
                }
            }
            else
            {
                FitInfo info = new FitInfo(student);
                info._info = string.Format("{0}:沒有年齡資料!!", fitname);
                FitInfoList.Add(info);
            }

            return("");
        }
コード例 #3
0
        /// <summary>
        /// 取得狀態為 一般,輟學 學生清單
        /// </summary>
        public static Dictionary <string, KeyBoStudent> GetStudentList(List <string> StudentIDList)
        {
            Dictionary <string, KeyBoStudent> dic = new Dictionary <string, KeyBoStudent>();

            StringBuilder sb = new StringBuilder();

            sb.Append("select student.id,student.name,student.student_number,student.seat_no,student.birthdate,student.gender,student.ref_class_id,class.class_name from student ");
            sb.Append("left join class on student.ref_class_id=class.id ");
            sb.Append(string.Format("where student.id in ('{0}')", string.Join("','", StudentIDList)));

            DataTable dt = tool._Q.Select(sb.ToString());

            foreach (DataRow row in dt.Rows)
            {
                KeyBoStudent stud = new KeyBoStudent(row);

                if (!dic.ContainsKey(stud.ID))
                {
                    dic.Add(stud.ID, stud);
                }
            }

            return(dic);
        }
コード例 #4
0
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            //取得學生資料
            Dictionary <string, KeyBoStudent> _student = tool.GetStudentList(K12.Presentation.NLDPanels.Student.SelectedSource);

            FitInfoList = new List <FitInfo>();

            //取得體適能資料
            List <StudentFitnessRecord> SFitnessList = tool._A.Select <StudentFitnessRecord>(string.Format("ref_student_id in ('{0}') and school_year={1}", string.Join("','", K12.Presentation.NLDPanels.Student.SelectedSource), intSchoolYear.Value.ToString()));

            foreach (StudentFitnessRecord each in SFitnessList)
            {
                #region 每一筆資料

                if (_student.ContainsKey(each.StudentID))
                {
                    KeyBoStudent student = _student[each.StudentID];
                    student.sfr     = each;                 //記錄LOG
                    student.sfr_Log = each.CopyExtension(); //記錄LOG

                    #region 說明

                    //換算實際監測日期的年齡
                    //(一)體適能檢測之年齡計算方式,以7個月為界,
                    //檢測年月與出生年月相減,所得月分達7個月以上,則進升一歲。
                    //舉例如下:
                    //1.民國88年3月出生,於民國101年10月進行檢測,
                    //年齡計算為101(年)-88(年)=13;10(月)-3(月)=7,因達7個月,故進升1歲,其年齡為14歲。

                    //2.民國88年5月出生,於民國101年10月進行檢測,
                    //年齡計算為101(年)-88(年)=13;10(月)-5(月)=5,因未達7個月,故其年齡為13歲。

                    //(二)受測學生超過16歲者,以16歲之門檻標準計分
                    //(2015/2/26 new)
                    //3.未滿13歲者均以13歲之常模進行鑑測(103+學年度之資料)

                    #endregion


                    //DateTime dt1 = new DateTime(1999, 11, 2); //生日
                    //DateTime dt2 = new DateTime(2014, 12, 12); //測驗

                    //student.Birthdate = dt1;
                    //each.TestDate = dt2;

                    if (each.TestDate != null)
                    {
                        if (student.Birthdate.HasValue)
                        {
                            if (each.TestDate > student.Birthdate)
                            {
                                #region 邏輯核心

                                student.Age = getAge2(student.Birthdate.Value, each.TestDate);

                                if (student.Age.月 >= 7)
                                {
                                    //大於7個月則年齡加一
                                    student.Age.鑑測年齡++;
                                }
                                //當資料學年度,是大於102時
                                //採用13足歲之規則
                                //if (each.SchoolYear >= 103)
                                //{
                                //    //new - 凡未滿13歲均以13歲為基準進行換算
                                //    //2020/04/16 - 因高雄反映只有13歲以下”男生”的心肺適能常模固定用13歲去算,詢問其他縣市也是相同作法,故把此判斷註解,並調整男生模組對照表
                                //    //if (student.Age.年 < 13)
                                //    //{
                                //    //    student.Age.鑑測年齡 = 13;
                                //    //}
                                //    //else
                                //    //{
                                //    //    if (student.Age.月 >= 7)
                                //    //    {
                                //    //        //大於7個月則年齡加一
                                //    //        student.Age.鑑測年齡++;
                                //    //    }
                                //    //}
                                //}
                                //else
                                //{
                                //    if (student.Age.月 >= 7)
                                //    {
                                //        //大於7個月則年齡加一
                                //        student.Age.鑑測年齡++;
                                //    }
                                //}
                            }
                            else
                            {
                                //沒有年齡,表示該體適能資料無法換算
                                FitInfo info = new FitInfo(student);
                                info._info = "測驗日期不可能在出生之前!";
                                FitInfoList.Add(info);
                            }

                            #endregion
                        }
                        else
                        {
                            //沒有年齡,表示該體適能資料無法換算
                            FitInfo info = new FitInfo(student);
                            info._info = "沒有生日!";
                            FitInfoList.Add(info);
                        }
                    }
                    else
                    {
                        //沒有測驗日期
                        //沒有年齡,表示該體適能資料無法換算
                        FitInfo info = new FitInfo(student);
                        info._info = "未輸入體適能測驗日期!!";
                        FitInfoList.Add(info);
                    }
                }

                #endregion
            }

            List <StudentFitnessRecord> UpdateList = new List <StudentFitnessRecord>();


            //取得對照表,整理為可對照清單
            XmlElement      xml = DSXmlHelper.LoadXml(Properties.Resources.Sports_Fitness_Comparison);
            SuperComparison _sc = new SuperComparison(xml);

            foreach (StudentFitnessRecord sfr in SFitnessList)
            {
                //包含這位學生
                if (_student.ContainsKey(sfr.StudentID))
                {
                    KeyBoStudent student = _student[sfr.StudentID];

                    if (student.Gender == "男")
                    {
                        if (CheckPreferred) //2019/6/14 - 擇優覆蓋
                        {
                            if (GetMeValue(sfr.SitUp.Trim(), "仰臥起坐", student, _sc.Boy_仰臥起坐) == "免測")
                            {
                                sfr.SitUpDegree = "免測";
                            }
                            else
                            {
                                //資料是否存在
                                string SitUpDegreeA = sfr.SitUpDegree.Trim();
                                string SitUpDegreeB = GetMeValue(sfr.SitUp.Trim(), "仰臥起坐", student, _sc.Boy_仰臥起坐);
                                sfr.SitUpDegree = CompareFitness(SitUpDegreeA, SitUpDegreeB);
                            }



                            if (GetMeValue(sfr.SitAndReach.Trim(), "坐姿體前彎", student, _sc.Boy_坐姿體前彎) == "免測")
                            {
                                sfr.SitAndReachDegree = "免測";
                            }
                            else
                            {
                                string SitAndReachDegreeA = sfr.SitAndReachDegree.Trim();
                                string SitAndReachDegreeB = GetMeValue(sfr.SitAndReach.Trim(), "坐姿體前彎", student, _sc.Boy_坐姿體前彎);
                                sfr.SitAndReachDegree = CompareFitness(SitAndReachDegreeA, SitAndReachDegreeB);
                            }

                            if (GetMeValue(sfr.StandingLongJump.Trim(), "立定跳遠", student, _sc.Boy_立定跳遠) == "免測")
                            {
                                sfr.StandingLongJumpDegree = "免測";
                            }
                            else
                            {
                                string StandingLongJumpDegreeA = sfr.StandingLongJumpDegree.Trim();
                                string StandingLongJumpDegreeB = GetMeValue(sfr.StandingLongJump.Trim(), "立定跳遠", student, _sc.Boy_立定跳遠);
                                sfr.StandingLongJumpDegree = CompareFitness(StandingLongJumpDegreeA, StandingLongJumpDegreeB);
                            }

                            if (GetMeValue(dotorsec(sfr.Cardiorespiratory.Trim()), "心肺適能", student, _sc.Boy_心肺適能) == "免測")
                            {
                                sfr.CardiorespiratoryDegree = "免測";
                            }
                            else
                            {
                                string CardiorespiratoryDegreeA = sfr.CardiorespiratoryDegree.Trim();
                                string CardiorespiratoryDegreeB = GetMeValue(dotorsec(sfr.Cardiorespiratory.Trim()), "心肺適能", student, _sc.Boy_心肺適能);
                                sfr.CardiorespiratoryDegree = CompareFitness(CardiorespiratoryDegreeA, CardiorespiratoryDegreeB);
                            }
                        }
                        else if (CheckCover)
                        {
                            //全部覆蓋
                            sfr.SitUpDegree             = GetMeValue(sfr.SitUp.Trim(), "仰臥起坐", student, _sc.Boy_仰臥起坐);
                            sfr.SitAndReachDegree       = GetMeValue(sfr.SitAndReach.Trim(), "坐姿體前彎", student, _sc.Boy_坐姿體前彎);
                            sfr.StandingLongJumpDegree  = GetMeValue(sfr.StandingLongJump.Trim(), "立定跳遠", student, _sc.Boy_立定跳遠);
                            sfr.CardiorespiratoryDegree = GetMeValue(dotorsec(sfr.Cardiorespiratory.Trim()), "心肺適能", student, _sc.Boy_心肺適能);
                        }
                        else
                        {
                            //如果有內容,則不予處理
                            if (string.IsNullOrEmpty(sfr.SitUpDegree))
                            {
                                sfr.SitUpDegree = GetMeValue(sfr.SitUp.Trim(), "仰臥起坐", student, _sc.Boy_仰臥起坐);
                            }

                            if (string.IsNullOrEmpty(sfr.SitAndReachDegree))
                            {
                                sfr.SitAndReachDegree = GetMeValue(sfr.SitAndReach.Trim(), "坐姿體前彎", student, _sc.Boy_坐姿體前彎);
                            }

                            if (string.IsNullOrEmpty(sfr.StandingLongJumpDegree))
                            {
                                sfr.StandingLongJumpDegree = GetMeValue(sfr.StandingLongJump.Trim(), "立定跳遠", student, _sc.Boy_立定跳遠);
                            }

                            if (string.IsNullOrEmpty(sfr.CardiorespiratoryDegree))
                            {
                                sfr.CardiorespiratoryDegree = GetMeValue(dotorsec(sfr.Cardiorespiratory.Trim()), "心肺適能", student, _sc.Boy_心肺適能);
                            }
                        }

                        UpdateList.Add(sfr);
                    }
                    else if (student.Gender == "女")
                    {
                        if (CheckPreferred) //2019/6/14 - 擇優覆蓋
                        {
                            //資料是否存在

                            if (GetMeValue(sfr.SitUp, "仰臥起坐", student, _sc.Girl_仰臥起坐) == "免測")
                            {
                                sfr.SitUpDegree = "免測";
                            }
                            else
                            {
                                string SitUpDegreeA = sfr.SitUpDegree.Trim();
                                string SitUpDegreeB = GetMeValue(sfr.SitUp, "仰臥起坐", student, _sc.Girl_仰臥起坐);
                                sfr.SitUpDegree = CompareFitness(SitUpDegreeA, SitUpDegreeB);
                            }

                            if (GetMeValue(sfr.SitAndReach.Trim(), "坐姿體前彎", student, _sc.Girl_坐姿體前彎) == "免測")
                            {
                                sfr.SitAndReachDegree = "免測";
                            }
                            else
                            {
                                string SitAndReachA = sfr.SitAndReachDegree.Trim();
                                string SitAndReachB = GetMeValue(sfr.SitAndReach, "坐姿體前彎", student, _sc.Girl_坐姿體前彎);
                                sfr.SitAndReachDegree = CompareFitness(SitAndReachA, SitAndReachB);
                            }

                            if (GetMeValue(sfr.StandingLongJump, "立定跳遠", student, _sc.Girl_立定跳遠) == "免測")
                            {
                                sfr.StandingLongJumpDegree = "免測";
                            }
                            else
                            {
                                string StandingLongJumpA = sfr.StandingLongJumpDegree.Trim();
                                string StandingLongJumpB = GetMeValue(sfr.StandingLongJump, "立定跳遠", student, _sc.Girl_立定跳遠);
                                sfr.StandingLongJumpDegree = CompareFitness(StandingLongJumpA, StandingLongJumpB);
                            }

                            if (GetMeValue(dotorsec(sfr.Cardiorespiratory), "心肺適能", student, _sc.Girl_心肺適能) == "免測")
                            {
                                sfr.CardiorespiratoryDegree = "免測";
                            }
                            else
                            {
                                string CardiorespiratoryA = sfr.CardiorespiratoryDegree.Trim();
                                string CardiorespiratoryB = GetMeValue(dotorsec(sfr.Cardiorespiratory), "心肺適能", student, _sc.Girl_心肺適能);
                                sfr.CardiorespiratoryDegree = CompareFitness(CardiorespiratoryA, CardiorespiratoryB);
                            }
                        }
                        else if (CheckCover)
                        {
                            sfr.SitUpDegree             = GetMeValue(sfr.SitUp, "仰臥起坐", student, _sc.Girl_仰臥起坐);
                            sfr.SitAndReachDegree       = GetMeValue(sfr.SitAndReach, "坐姿體前彎", student, _sc.Girl_坐姿體前彎);
                            sfr.StandingLongJumpDegree  = GetMeValue(sfr.StandingLongJump, "立定跳遠", student, _sc.Girl_立定跳遠);
                            sfr.CardiorespiratoryDegree = GetMeValue(dotorsec(sfr.Cardiorespiratory), "心肺適能", student, _sc.Girl_心肺適能);
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(sfr.SitUpDegree))
                            {
                                sfr.SitUpDegree = GetMeValue(sfr.SitUp, "仰臥起坐", student, _sc.Girl_仰臥起坐);
                            }

                            if (string.IsNullOrEmpty(sfr.SitAndReachDegree))
                            {
                                sfr.SitAndReachDegree = GetMeValue(sfr.SitAndReach, "坐姿體前彎", student, _sc.Girl_坐姿體前彎);
                            }

                            if (string.IsNullOrEmpty(sfr.StandingLongJumpDegree))
                            {
                                sfr.StandingLongJumpDegree = GetMeValue(sfr.StandingLongJump, "立定跳遠", student, _sc.Girl_立定跳遠);
                            }

                            if (string.IsNullOrEmpty(sfr.CardiorespiratoryDegree))
                            {
                                sfr.CardiorespiratoryDegree = GetMeValue(dotorsec(sfr.Cardiorespiratory), "心肺適能", student, _sc.Girl_心肺適能);
                            }
                        }


                        UpdateList.Add(sfr);
                    }
                    else
                    {
                        //性別未定將不予處理
                        FitInfo info = new FitInfo(student);
                        info._info = "學生沒有設定性別!!";
                        FitInfoList.Add(info);
                    }
                }
            }

            #region Log處理

            StringBuilder sbLog = new StringBuilder();
            if (CheckCover)
            {
                sbLog.AppendLine("體適能常模轉換:(使用者設定為「常模有值覆蓋」)");
            }
            else
            {
                sbLog.AppendLine("體適能常模轉換:(使用者設定為「常模有值略過」)");
            }

            foreach (string each in _student.Keys)
            {
                KeyBoStudent student = _student[each];

                StudentFitnessRecord sfr1    = student.sfr;
                StudentFitnessRecord sfr_log = student.sfr_Log;

                if (sfr1 != null && sfr_log != null)
                {
                    StringBuilder sb_123 = new StringBuilder();

                    StringBuilder sb_name   = new StringBuilder();
                    string        AgeString = "";
                    string        Age鑑測     = "";

                    if (student.Age != null)
                    {
                        AgeString = string.Format("{0}歲{1}個月又{2}天", student.Age.年, student.Age.月, student.Age.日);
                        Age鑑測     = "" + student.Age.鑑測年齡;
                    }
                    else
                    {
                        AgeString = "無相關資訊";
                        Age鑑測     = "無相關資訊";
                    }

                    sb_name.AppendLine(string.Format("班級「{0}」座號「{1}」學生「{2}」\n實際年齡「{3}」鑑測年齡「{4}」", student.ClassName, student.SeatNo, student.Name, AgeString, Age鑑測));

                    if (sfr1.SitUpDegree != sfr_log.SitUpDegree)
                    {
                        sb_123.AppendLine(string.Format("仰臥起坐「{0}」由「{1}」換算為「{2}」", sfr1.SitUp, sfr_log.SitUpDegree, sfr1.SitUpDegree));
                    }

                    if (sfr1.SitAndReachDegree != sfr_log.SitAndReachDegree)
                    {
                        sb_123.AppendLine(string.Format("坐姿體前彎「{0}」由「{1}」換算為「{2}」", sfr1.SitAndReach, sfr_log.SitAndReachDegree, sfr1.SitAndReachDegree));
                    }

                    if (sfr1.StandingLongJumpDegree != sfr_log.StandingLongJumpDegree)
                    {
                        sb_123.AppendLine(string.Format("立定跳遠「{0}」由「{1}」換算為「{2}」", sfr1.StandingLongJump, sfr_log.StandingLongJumpDegree, sfr1.StandingLongJumpDegree));
                    }

                    if (sfr1.CardiorespiratoryDegree != sfr_log.CardiorespiratoryDegree)
                    {
                        sb_123.AppendLine(string.Format("心肺適能「{0}」由「{1}」換算為「{2}」", sfr1.Cardiorespiratory, sfr_log.CardiorespiratoryDegree, sfr1.CardiorespiratoryDegree));
                    }

                    sb_123.AppendLine("");

                    sbLog.AppendLine(sb_name.ToString() + sb_123.ToString());
                }
                else
                {
                    FitInfo info = new FitInfo(student);
                    info._info = "沒有體適能資料!";
                    FitInfoList.Add(info);
                }
            }

            #endregion

            if (UpdateList.Count > 0)
            {
                tool._A.UpdateValues(UpdateList);
                FISCA.LogAgent.ApplicationLog.Log("體適能", "常模換算", sbLog.ToString());
            }

            e.Result = FitInfoList;
        }