/// <summary> /// 取得學生獎懲資料 /// </summary> /// <param name="StudentIDList"></param> /// <returns></returns> public static Dictionary<string, List<DAO.AB_StudDateString>> GetStudentMDRecDict(List<string> StudentIDList) { Dictionary<string, List<DAO.AB_StudDateString>> retVal = new Dictionary<string, List<DAO.AB_StudDateString>>(); // 讀取獎勵 List<MeritRecord> MeritList = Merit.SelectByStudentIDs(StudentIDList); // 讀取懲戒 List<DemeritRecord> DemeritList = Demerit.SelectByStudentIDs(StudentIDList); List<DAO.AB_StudDateString> dataList = new List<DAO.AB_StudDateString>(); List<string> tempString = new List<string>(); // 解析獎勵資料 foreach (MeritRecord rec in MeritList) { tempString.Clear(); DAO.AB_StudDateString ass = new DAO.AB_StudDateString(); ass.StudentID = rec.RefStudentID; ass.Date = rec.OccurDate; if (rec.MeritA.HasValue && rec.MeritA.Value>0) tempString.Add("大功:" + rec.MeritA.Value); if (rec.MeritB.HasValue && rec.MeritB.Value>0) tempString.Add("小功:" + rec.MeritB.Value); if (rec.MeritC.HasValue && rec.MeritC.Value>0) tempString.Add("獎勵:" + rec.MeritC.Value); if (rec.MeritFlag == "2") tempString.Add("留校察看"); if (tempString.Count > 0) ass.Text1 = string.Join(",", tempString.ToArray()); ass.Text2 = rec.Reason; dataList.Add(ass); } // 解析懲戒 foreach (DemeritRecord rec in DemeritList) { tempString.Clear(); DAO.AB_StudDateString ass = new DAO.AB_StudDateString(); ass.StudentID = rec.RefStudentID; ass.Date = rec.OccurDate; if (rec.DemeritA.HasValue && rec.DemeritA.Value>0) tempString.Add("大過:" + rec.DemeritA.Value); if (rec.DemeritB.HasValue && rec.DemeritB.Value>0) tempString.Add("小過:" + rec.DemeritB.Value); if (rec.DemeritC.HasValue && rec.DemeritC.Value>0) tempString.Add("警告:" + rec.DemeritC.Value); if (rec.ClearDate.HasValue) tempString.Add("銷過日期:" + rec.ClearDate.Value + ",銷過事由:" + rec.ClearReason); if (tempString.Count > 0) ass.Text1 = string.Join(",", tempString.ToArray()); ass.Text2 = rec.Reason; dataList.Add(ass); } // 放入回傳資料並依日期排序 foreach (string str in StudentIDList) retVal.Add(str, (from data in dataList where data.StudentID == str orderby data.Date select data).ToList()); return retVal; }
/// <summary> /// 取得學生異動資料 /// </summary> /// <param name="StudentIDList"></param> /// <returns></returns> public static Dictionary<string, List<DAO.AB_StudDateString>> GetStudentUpdateRecDict(List<string> StudentIDList) { Dictionary<string, List<DAO.AB_StudDateString>> retVal = new Dictionary<string, List<DAO.AB_StudDateString>>(); // 取得異動資料 List<UpdateRecordRecord> updateRecList = UpdateRecord.SelectByStudentIDs(StudentIDList); List<DAO.AB_StudDateString> dataList = new List<DAO.AB_StudDateString>(); // 轉換格式 foreach (UpdateRecordRecord rec in updateRecList) { DAO.AB_StudDateString ass = new DAO.AB_StudDateString(); ass.StudentID = rec.StudentID; ass.Date = DateTime.Parse(rec.UpdateDate); ass.Text1 = rec.UpdateCode; switch (rec.UpdateCode) { case "1": ass.Text1 = "新生"; break; case "2": ass.Text1 = "畢業"; break; case "3": ass.Text1 = "轉入"; break; case "4": ass.Text1 = "轉出"; break; case "5": ass.Text1 = "休學"; break; case "6": ass.Text1 = "復學"; break; case "7": ass.Text1 = "中輟"; break; case "8": ass.Text1 = "續讀"; break; case "9": ass.Text1 = "更正學籍"; break; } ass.Text2 = rec.UpdateDescription; dataList.Add(ass); } // 加入回傳值 foreach (string str in StudentIDList) retVal.Add(str, (from data in dataList where data.StudentID == str orderby data.Date select data).ToList()); return retVal; }