public void QuickAdd(SuggestSubjectCount sData) { UDTSubjectDef newData = new UDTSubjectDef(); newData.SchoolYear = _SchoolYear; newData.Semester = _Semester; newData.Month = _Month; newData.Credit = sData.Credit; newData.SubjectName = sData.SubjectName; newData.SubjecLevel = sData.Level; newData.DeptName = sData.DeptName; if (CheckCanAddData(newData)) { int rowIdx = dgData.Rows.Add(); dgData.Rows[rowIdx].Cells[colCredit.Index].Value = newData.Credit; dgData.Rows[rowIdx].Cells[colDept.Index].Value = newData.DeptName; dgData.Rows[rowIdx].Cells[colSubjectName.Index].Value = newData.SubjectName; if (newData.SubjecLevel.HasValue) dgData.Rows[rowIdx].Cells[colSubjectLevel.Index].Value = newData.SubjecLevel.Value; dgData.Rows[rowIdx].Tag = newData; ReloadRowCount(); } }
/// <summary> /// 取得目前期間內資料庫建議科別人數統計 /// </summary> /// <returns></returns> public static List<SuggestSubjectCount> GetSuggestSubjectCountList() { Dictionary<string, SuggestSubjectCount> ValDict = new Dictionary<string, SuggestSubjectCount>(); QueryHelper qh1 = new QueryHelper(); string strSQL1 = "select dept.name,$shinmin.retake.suggest_list.subject_content from $shinmin.retake.time_list inner join $shinmin.retake.suggest_list on $shinmin.retake.time_list.uid=$shinmin.retake.suggest_list.ref_time_list_id inner join student on $shinmin.retake.suggest_list.ref_student_id = student.id left join class on student.ref_class_id=class.id left join dept on class.ref_dept_id=dept.id where $shinmin.retake.time_list.active='true';"; DataTable dt1 = qh1.Select(strSQL1); foreach (DataRow dr in dt1.Rows) { string dpName = dr[0].ToString(); string subjcontent = dr["subject_content"].ToString(); XElement elmSubj = XElement.Parse(subjcontent); foreach (XElement elm in elmSubj.Elements("Subject")) { SuggestSubjectCount ssc = new SuggestSubjectCount(); ssc.DeptName = dpName; int cc; if (int.TryParse(elm.Attribute("Credit").Value, out cc)) ssc.Credit = cc; ssc.SubjectName = elm.Attribute("Name").Value; int ll; if(int.TryParse(elm.Attribute("Level").Value,out ll)) ssc.Level=ll; string key=ssc.GetKey(); if(ValDict.ContainsKey(key)) ValDict[key].Count++; else ValDict.Add(key,ssc); } } return ValDict.Values.ToList(); }