public GetJHSchoolNames() { InitializeComponent(); List <SchoolListEntity> schoolLists = new List <SchoolListEntity>(); // 讀取國中小資料 foreach (SchoolRecord SchoolRec in School.SelectJuniorSchools()) { SchoolListEntity sle = new SchoolListEntity(); sle.code = SchoolRec.Code; sle.county = SchoolRec.County; sle.Name = SchoolRec.Name; schoolLists.Add(sle); } // 國中 foreach (SchoolListEntity sle in schoolLists) { if (sle.Name.LastIndexOf("附設國") > 0) { if (otherList.ContainsKey(sle.county)) { otherList[sle.county].Add(sle); } else { List <SchoolListEntity> tmpSle = new List <SchoolListEntity>(); tmpSle.Add(sle); otherList.Add(sle.county, tmpSle); } } else { if (JuniroList.ContainsKey(sle.county)) { JuniroList[sle.county].Add(sle); } else { List <SchoolListEntity> tmpSle = new List <SchoolListEntity>(); tmpSle.Add(sle); JuniroList.Add(sle.county, tmpSle); } } // 放入全部 if (AllList.ContainsKey(sle.county)) { AllList[sle.county].Add(sle); } else { List <SchoolListEntity> tmpSle = new List <SchoolListEntity>(); tmpSle.Add(sle); AllList.Add(sle.county, tmpSle); } } schoolLists.Clear(); foreach (SchoolRecord SchoolRec in School.SelectElementarySchools()) { SchoolListEntity sle = new SchoolListEntity(); sle.Name = SchoolRec.Name; sle.code = SchoolRec.Code; sle.county = SchoolRec.County; schoolLists.Add(sle); } //國小 foreach (SchoolListEntity sle in schoolLists) { if (ElementaryList.ContainsKey(sle.county)) { ElementaryList[sle.county].Add(sle); } else { List <SchoolListEntity> tmpSle = new List <SchoolListEntity>(); tmpSle.Add(sle); ElementaryList.Add(sle.county, tmpSle); } if (AllList.ContainsKey(sle.county)) { AllList[sle.county].Add(sle); } else { List <SchoolListEntity> tmpSle = new List <SchoolListEntity>(); tmpSle.Add(sle); AllList.Add(sle.county, tmpSle); } } // 放入 List View foreach (KeyValuePair <string, List <SchoolListEntity> > lst in AllList) { ListViewItem lvi = new ListViewItem(); lvi.SubItems[0].Text = lst.Key; lstCounty.Items.Add(lvi); lvi = null; } lstCounty.Sorting = SortOrder.Ascending; lstCounty.Sort(); chkJH1.Checked = true; }
public GetJHSchoolNames() { InitializeComponent(); List <SchoolListEntity> schoolLists = new List <SchoolListEntity>(); // 讀取國中小資料 //ConfigData cd = Global.Configuration["SchoolListJunior"]; XmlDocument doc = new XmlDocument(); doc.LoadXml(Properties.Resources.jh); //doc.LoadXml(cd["XmlData"]); foreach (XmlElement xe in doc.SelectSingleNode("SchoolList")) { SchoolListEntity sle = new SchoolListEntity(); sle.Name = xe.GetAttribute("Name"); sle.code = xe.GetAttribute("Code"); sle.county = xe.GetAttribute("County"); schoolLists.Add(sle); } // 國中 foreach (SchoolListEntity sle in schoolLists) { if (sle.Name.LastIndexOf("附設國") > 0) { if (otherList.ContainsKey(sle.county)) { otherList[sle.county].Add(sle); } else { List <SchoolListEntity> tmpSle = new List <SchoolListEntity>(); tmpSle.Add(sle); otherList.Add(sle.county, tmpSle); } } else { if (JuniroList.ContainsKey(sle.county)) { JuniroList[sle.county].Add(sle); } else { List <SchoolListEntity> tmpSle = new List <SchoolListEntity>(); tmpSle.Add(sle); JuniroList.Add(sle.county, tmpSle); } } // 放入全部 if (AllList.ContainsKey(sle.county)) { AllList[sle.county].Add(sle); } else { List <SchoolListEntity> tmpSle = new List <SchoolListEntity>(); tmpSle.Add(sle); AllList.Add(sle.county, tmpSle); } } schoolLists.Clear(); //ConfigData cd1 = Global.Configuration["SchoolListElementary"]; XmlDocument doc1 = new XmlDocument(); doc1.LoadXml(Properties.Resources.eh); //doc1.LoadXml(cd1["XmlData"]); foreach (XmlElement xe in doc1.SelectSingleNode("SchoolList")) { SchoolListEntity sle = new SchoolListEntity(); sle.Name = xe.GetAttribute("Name"); sle.code = xe.GetAttribute("Code"); sle.county = xe.GetAttribute("County"); schoolLists.Add(sle); } //國小 foreach (SchoolListEntity sle in schoolLists) { if (ElementaryList.ContainsKey(sle.county)) { ElementaryList[sle.county].Add(sle); } else { List <SchoolListEntity> tmpSle = new List <SchoolListEntity>(); tmpSle.Add(sle); ElementaryList.Add(sle.county, tmpSle); } if (AllList.ContainsKey(sle.county)) { AllList[sle.county].Add(sle); } else { List <SchoolListEntity> tmpSle = new List <SchoolListEntity>(); tmpSle.Add(sle); AllList.Add(sle.county, tmpSle); } } // 放入 List View foreach (KeyValuePair <string, List <SchoolListEntity> > lst in AllList) { ListViewItem lvi = new ListViewItem(); lvi.SubItems[0].Text = lst.Key; lstCounty.Items.Add(lvi); lvi = null; } lstCounty.Sorting = SortOrder.Ascending; lstCounty.Sort(); chkJH1.Checked = true; }