/// <summary> /// 透過班級職業名稱取得人數百分比 /// </summary> /// <param name="ClassName"></param> /// <param name="JobName"></param> /// <param name="PJT"></param> /// <param name="isGetGradeYear"></param> /// <param name="RoundRange"></param> /// <returns></returns> public decimal GetParentJobCountPercentage(string ClassName, string JobName, ParentJobType PJT, bool isGetGradeYear, int RoundRange) { decimal returnValue = 0; int tmpParentJobCount = GetParentJobCount(ClassName, JobName, PJT, isGetGradeYear); int tmpClassCount = GetGradeClassStudCount(ClassName, isGetGradeYear); if (tmpClassCount > 0) { returnValue = Math.Round(((decimal)tmpParentJobCount / (decimal)tmpClassCount) * 100, RoundRange, MidpointRounding.AwayFromZero); } return(returnValue); }
/// <summary> /// 透過班級職業名稱取得人數 /// </summary> /// <param name="ClassName"></param> /// <param name="JobName"></param> /// <param name="PJT"></param> /// <param name="isGetGradeYear"></param> /// <returns></returns> public int GetParentJobCount(string ClassName, string JobName, ParentJobType PJT, bool isGetGradeYear) { int returnValue = 0; if (isGetGradeYear) { ClassName += "_年級"; } if (PJT == ParentJobType.父親) { if (_FatherJobCountDic.ContainsKey(ClassName)) { if (_FatherJobCountDic[ClassName].ContainsKey(JobName)) { returnValue = _FatherJobCountDic[ClassName][JobName]; } } } if (PJT == ParentJobType.母親) { if (_MotherJobCountDic.ContainsKey(ClassName)) { if (_MotherJobCountDic[ClassName].ContainsKey(JobName)) { returnValue = _MotherJobCountDic[ClassName][JobName]; } } } if (PJT == ParentJobType.監護人) { if (_CustodianJobCountDic.ContainsKey(ClassName)) { if (_CustodianJobCountDic[ClassName].ContainsKey(JobName)) { returnValue = _CustodianJobCountDic[ClassName][JobName]; } } } return(returnValue); }
// 計算底層 private void AddParentJobBaseByClassName(string ClassName, string JobName, ParentJobType PJT) { if (PJT == ParentJobType.父親) { if (_FatherJobCountDic.ContainsKey(ClassName)) { if (_FatherJobCountDic[ClassName].ContainsKey(JobName)) { _FatherJobCountDic[ClassName][JobName]++; } else { _FatherJobCountDic[ClassName].Add(JobName, 1); } } else { Dictionary <string, int> tmpDic = new Dictionary <string, int>(); tmpDic.Add(JobName, 1); _FatherJobCountDic.Add(ClassName, tmpDic); } } if (PJT == ParentJobType.母親) { if (_MotherJobCountDic.ContainsKey(ClassName)) { if (_MotherJobCountDic[ClassName].ContainsKey(JobName)) { _MotherJobCountDic[ClassName][JobName]++; } else { _MotherJobCountDic[ClassName].Add(JobName, 1); } } else { Dictionary <string, int> tmpDic = new Dictionary <string, int>(); tmpDic.Add(JobName, 1); _MotherJobCountDic.Add(ClassName, tmpDic); } } if (PJT == ParentJobType.監護人) { if (_CustodianJobCountDic.ContainsKey(ClassName)) { if (_CustodianJobCountDic[ClassName].ContainsKey(JobName)) { _CustodianJobCountDic[ClassName][JobName]++; } else { _CustodianJobCountDic[ClassName].Add(JobName, 1); } } else { Dictionary <string, int> tmpDic = new Dictionary <string, int>(); tmpDic.Add(JobName, 1); _CustodianJobCountDic.Add(ClassName, tmpDic); } } }