public GetUDTXml(List <GraduateUDT> InsertArchiveList, string TableName, string RootName) { //建立學生ID 清單 List <string> list = new List <string>(); foreach (GraduateUDT each in InsertArchiveList) { if (!list.Contains(each.StudentID)) { list.Add(each.StudentID); } } //QueryHelper QueryHelper _queryhelper = new QueryHelper(); string sqlStr1 = "Select * From " + TableName + " where " + UDT_S.PopOneCondition("ref_student_id", list); //取得所有學生ID的 TableName 資料 dataTable = _queryhelper.Select(sqlStr1); //建立資料盒子 foreach (GraduateUDT each in InsertArchiveList) { if (!XmlUDTDic.ContainsKey(each.StudentID)) { XmlUdtHelp H = new XmlUdtHelp(each, RootName); //Mini盒子 XmlUDTDic.Add(each.StudentID, H); } } }
private void ImportWrittenInformation_Load(object sender, EventArgs e) { //註冊背景事件 BGW.DoWork += new DoWorkEventHandler(BGW_DoWork); BGW.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BGW_RunWorkerCompleted); BGW.ProgressChanged += new ProgressChangedEventHandler(BGW_ProgressChanged); BGW.WorkerReportsProgress = true; //我必需group by出目前的分類名稱有哪些 //取得所有學生GraduateUDT的UID資料 string TableName = Tn._GraduateUDT; DataTable dt = _queryhelper.Select("select UID from " + TableName.ToLower()); List <string> UDTkey = new List <string>(); foreach (DataRow each in dt.Rows) { UDTkey.Add("" + each[0]); } string sqlStr2 = string.Format("select ArchiveNote from {0} WHERE " + UDT_S.PopOneCondition("UID", UDTkey) + " group by ArchiveNote ORDER by ArchiveNote", TableName.ToLower()); dt = _queryhelper.Select(sqlStr2); if (dt.Rows.Count > 0) { List <string> NoteList = new List <string>(); foreach (DataRow each in dt.Rows) { comboBoxEx1.Items.Add("" + each[0]); } comboBoxEx1.SelectedIndex = 0; } }
/// <summary> /// 依據各別的DataTable建立UDT資料 /// (By 缺曠資料) /// </summary> public static void Attendance_ExtendMethod(this GetUDTXml xml, string Element) { foreach (DataRow dr in xml.dataTable.Rows) { //先判斷是否為Dic內存之資料 if (xml.XmlUDTDic.ContainsKey("" + dr[1])) { string student = "" + dr[1]; DSXmlHelper XmlDoc = xml.XmlUDTDic[student]._XmlHelper; #region Element XmlDoc.AddElement(Element); XmlDoc.SetAttribute(Element, "ID", "" + dr[0]); XmlDoc.AddElement(Element, "RefStudentID"); XmlDoc.SetText(Element + "/RefStudentID", "" + dr[1]); XmlDoc.AddElement(Element, "SchoolYear"); XmlDoc.SetText(Element + "/SchoolYear", "" + dr[2]); XmlDoc.AddElement(Element, "Semester"); XmlDoc.SetText(Element + "/Semester", "" + dr[3]); XmlDoc.AddElement(Element, "OccurDate"); XmlDoc.SetText(Element + "/OccurDate", UDT_S.ChangeTime("" + dr[4])); //XML XmlDoc.AddElement(Element, "Detail"); XmlDoc.AddXmlString(Element + "/Detail", "" + dr[5]); #endregion #region AttendanceRecord - 原生結構 //<Attendance ID="351287"> // <RefStudentID>53972</RefStudentID> // <SchoolYear>99</SchoolYear> // <Semester>2</Semester> // <OccurDate>2011-01-20 00:00:00</OccurDate> // <Detail> // <Attendance> // <Period AbsenceType="公假">一</Period> // <Period AbsenceType="公假">二</Period> // <Period AbsenceType="公假">三</Period> // <Period AbsenceType="公假">四</Period> // <Period AbsenceType="公假">午休</Period> // <Period AbsenceType="公假">五</Period> // </Attendance> // </Detail> //</Attendance> #endregion } } }
/// <summary> /// 更新照片封存資料 /// </summary> private List <PhotoDataUDT> UpdateStudentPhoto(List <GraduateUDT> UpdateArchiveList) { List <PhotoDataUDT> ArchiveList = new List <PhotoDataUDT>(); //取得照片資料(照片資料需取得後更新) List <string> list = new List <string>(); foreach (GraduateUDT each in UpdateArchiveList) { list.Add(each.UID); } string test1 = UDT_S.PopOneCondition("RefUDT_ID", list); List <PhotoDataUDT> PhotoArchiveList = _AccessHelper.Select <PhotoDataUDT>(test1); Dictionary <string, PhotoDataUDT> photoDic = new Dictionary <string, PhotoDataUDT>(); foreach (PhotoDataUDT each in PhotoArchiveList) { if (!photoDic.ContainsKey(each.StudentID)) { photoDic.Add(each.StudentID, each); } else { MsgBox.Show("一名學生有2筆照片資料!!\n" + each.StudentID); } } foreach (GraduateUDT udt in UpdateArchiveList) { if (photoDic.ContainsKey(udt.StudentID)) { photoDic[udt.StudentID].FreshmanPhoto = SetPhoto(udt.StudentID, true); //入學照片 photoDic[udt.StudentID].GraduatePhoto = SetPhoto(udt.StudentID, false); //入學照片 ArchiveList.Add(photoDic[udt.StudentID]); } else //如果不存在,表示前次封存無照片 { //封存入學/畢業照片 PhotoDataUDT photo = new PhotoDataUDT(); photo.StudentID = udt.StudentID; photo.RefUDT_ID = udt.UID; photo.FreshmanPhoto = SetPhoto(udt.StudentID, true); //入學照片 photo.GraduatePhoto = SetPhoto(udt.StudentID, false); //入學照片 ArchiveList.Add(photo); } } return(ArchiveList); }
private void BatchArchiveStudent_Load(object sender, EventArgs e) { //註冊背景事件 BGW.DoWork += new DoWorkEventHandler(BGW_DoWork); BGW.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BGW_RunWorkerCompleted); BGW.ProgressChanged += new ProgressChangedEventHandler(BGW_ProgressChanged); BGW.WorkerReportsProgress = true; //無論如何,先建立此Table..不然會爆阿... List <string> list1 = new List <string>() { "0" }; List <GraduateUDT> list2 = _AccessHelper.Select <GraduateUDT>(UDT_S.PopOneCondition("StudentID", list1)); string TableName = Tn._GraduateUDT; DataTable dt = _queryhelper.Select("select ArchiveNote from " + TableName.ToLower() + " group by ArchiveNote ORDER by ArchiveNote"); List <string> UDTArchiveNote = new List <string>(); foreach (DataRow each in dt.Rows) { UDTArchiveNote.Add("" + each[0]); } UDTArchiveNote.Sort(); comboBoxEx1.Items.AddRange(UDTArchiveNote.ToArray()); //if (UDTkey.Count != 0) //{ // string sqlStr2 = string.Format("select ArchiveNote from {0} WHERE " + UDT_S.PopOneCondition("UID", UDTkey) + " group by ArchiveNote ORDER by ArchiveNote", TableName.ToLower()); // dt = _queryhelper.Select(sqlStr2); // if (dt.Rows.Count > 0) // { // List<string> NoteList = new List<string>(); // foreach (DataRow each in dt.Rows) // { // comboBoxEx1.Items.Add("" + each[0]); // } // } //} }
void BGW_DoWork(object sender, DoWorkEventArgs e) { BGW.ReportProgress(0, "取得學生資訊"); MessageDic.Clear(); //取得選擇學生ID List <StudentRecord> StudentList = Student.SelectByIDs((List <string>)e.Argument); List <StudentRecord> NewStudentList = new List <StudentRecord>(); List <StudentRecord> LowStudentList = new List <StudentRecord>(); BGW.ReportProgress(6, "取得異動記錄"); //取得異動記錄 _GetUpdateRecord = new UpdateRecordHelp((List <string>)e.Argument); BGW.ReportProgress(13, "取得學生照片"); //取得學生新生/畢業照片 _GetPhotoRecord = new PhotoRecordHelp((List <string>)e.Argument); BGW.ReportProgress(17, "取得地址資料"); //取得地址資料 _GetAddressRecord = new AddressHelp((List <string>)e.Argument); BGW.ReportProgress(21, "取得電話資料"); //取得電話資料 _GetPhoneRecord = new PhoneHelp((List <string>)e.Argument); BGW.ReportProgress(24, "取得類別標記"); //取得學生類別資料 _GetTagHelp = new TagHelp((List <string>)e.Argument); BGW.ReportProgress(31, "比對索引資料"); //取得學生ID的已封存資料(用於更新) Dictionary <string, GraduateUDT> TestDic = GetUDTObj(); //判斷分類學生資料,是未封存過之學生 OR 已封存之學生 StudentList = SortStudent.sort(StudentList); foreach (StudentRecord student in StudentList) { if (!TestDic.ContainsKey(student.ID)) { NewStudentList.Add(student); //未封存過之學生 } else { LowStudentList.Add(student); //已封存之學生 } } //log StringBuilder sb = new StringBuilder(); sb.AppendLine("已進行學生電子檔案索引建立。"); sb.AppendLine("索引分類「" + _ArchiveNote + "」"); #region 新增 //新增之UDT資料 - 需要先進行儲存,才會知道該UDT之UID //封存書面資料 //封存缺曠 / 獎懲 / 異動 / 成績 - XML資料 BGW.ReportProgress(40, "開始新增索引"); if (NewStudentList.Count != 0) { //組合要新增的UDT資料 List <GraduateUDT> Uid_UDTList = InsertStudent(NewStudentList); BGW.ReportProgress(42, "開始新增索引"); MessageDic.Add("新增索引", Uid_UDTList.Count); //訊息 //InsertUDT資料 - 並且取得已新增的UDT ID List <string> UDT_id = _AccessHelper.InsertValues(Uid_UDTList.ToArray()); BGW.ReportProgress(43, "開始新增索引"); //重新取得有UID之資料 string test1 = UDT_S.PopOneCondition("UID", UDT_id); Uid_UDTList = _AccessHelper.Select <GraduateUDT>(test1); BGW.ReportProgress(49, "開始新增索引"); //準備Insert照片UDT資料 List <PhotoDataUDT> InsertPhoto = InsertStudentPhoto(Uid_UDTList); _AccessHelper.InsertValues(InsertPhoto.ToArray()); BGW.ReportProgress(54, "開始新增索引"); SetXmlData(Uid_UDTList); BGW.ReportProgress(59, "開始新增索引"); #region 新增封存Log sb.AppendLine("新增索引清單:"); BGW.ReportProgress(67, "開始新增索引"); foreach (StudentRecord student in NewStudentList) { sb.Append("班級「" + (student.Class != null ? student.Class.Name : "") + "」"); sb.Append("座號「" + (student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : "") + "」"); sb.AppendLine("姓名「" + student.Name + "」"); } BGW.ReportProgress(70, "開始新增索引"); #endregion } #endregion #region 更新 if (LowStudentList.Count != 0) { //取得要更新的UDT資料 List <GraduateUDT> UpdateArchiveList = UpdateStudent(LowStudentList, TestDic); BGW.ReportProgress(74, "開始更新索引"); _AccessHelper.UpdateValues(UpdateArchiveList.ToArray()); MessageDic.Add("更新索引", UpdateArchiveList.Count); BGW.ReportProgress(80, "開始更新索引"); //重新建立新照片 List <PhotoDataUDT> UpdatePhoto = UpdateStudentPhoto(UpdateArchiveList); _AccessHelper.UpdateValues(UpdatePhoto.ToArray()); BGW.ReportProgress(87, "開始更新索引"); //取得選擇學生的所有AllXMLDataUDT資料後刪除 List <string> list = new List <string>(); BGW.ReportProgress(91, "開始更新索引"); foreach (GraduateUDT each in UpdateArchiveList) { list.Add(each.UID); } //XML註解 //List<AllXMLDataUDT> records = _AccessHelper.Select<AllXMLDataUDT>(UDT_S.PopOneCondition("RefUDT_ID", list)); //_AccessHelper.DeletedValues(records.ToArray()); ////重新進行封存資料作業 //SetXmlData(UpdateArchiveList); #region 更新封存Log sb.AppendLine("更新索引清單:"); foreach (StudentRecord student in LowStudentList) { sb.Append("班級「" + (student.Class != null ? student.Class.Name : "") + "」"); sb.Append("座號「" + (student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : "") + "」"); sb.AppendLine("姓名「" + student.Name + "」"); } BGW.ReportProgress(96, "開始更新索引"); #endregion } #endregion BGW.ReportProgress(100, "索引建立完成"); ApplicationLog.Log("畢業生檔案檢索", "索引建立", sb.ToString()); }
private void DownLoadCounseling_Load(object sender, EventArgs e) { T.Interval = 1000; //每0.5秒 T.Tick += new EventHandler(T_Tick); BGW.DoWork += new DoWorkEventHandler(BGW_DoWork); BGW.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BGW_RunWorkerCompleted); BGW.ProgressChanged += new ProgressChangedEventHandler(BGW_ProgressChanged); BGW.WorkerReportsProgress = true; //書面資料Table string TableName = Tn._WriteCounselingUDT; string sqlStr2 = string.Format("select name,count(name) from {0} WHERE " + UDT_S.PopOneCondition("RefUDT_ID", GraduationAdmin.Instance.SelectedSource) + " group by name ", TableName.ToLower()); DataTable dt = _queryhelper.Select(sqlStr2); foreach (DataRow each in dt.Rows) { //由於each[0]是檔名,因此需要把" (共"這個當條件字串移除,以比對檔名 comboBoxEx1.Items.Add("" + each[0] + " (共" + each[1] + "張)"); } if (comboBoxEx1.Items.Count > 0) { comboBoxEx1.SelectedIndex = 0; } }
void BGW_DoWork(object sender, DoWorkEventArgs e) { string SelectPath = "" + e.Argument; AccessHelper _AccessHelper = new AccessHelper(); //取得UDT - KEY List <string> KeyList = GraduationAdmin.Instance.SelectedSource; List <GraduateUDT> GrList = _AccessHelper.Select <GraduateUDT>(UDT_S.PopOneCondition("UID", KeyList)); //取得學生封存資料 Dictionary <string, GraduateUDT> GrDic = new Dictionary <string, GraduateUDT>(); //建立索引 foreach (GraduateUDT each in GrList) { if (!GrDic.ContainsKey(each.UID)) { GrDic.Add(each.UID, each); } } StringBuilder sb = new StringBuilder(); sb.AppendLine("下載學生書面資料"); if (FileName == "*") //當FileName是*時,下載所有學生之書面資料 { sb.AppendLine("下載操作:「所有書面資料」"); List <WriteCounselingUDT> WrList = _AccessHelper.Select <WriteCounselingUDT>(UDT_S.PopOneCondition("RefUDT_ID", KeyList)); foreach (WriteCounselingUDT each in WrList) { if (!GrDic.ContainsKey(each.RefUDT_ID)) { return; } sb.Append("班級「" + GrDic[each.RefUDT_ID].ClassName + "」"); sb.Append("座號「" + (GrDic[each.RefUDT_ID].SeatNo.HasValue ? GrDic[each.RefUDT_ID].SeatNo.Value.ToString() : "") + "」"); sb.Append("姓名「" + GrDic[each.RefUDT_ID].Name + "」"); //因為是所有書面,所以特別註記了單一書面的名稱 sb.AppendLine("書面名稱「" + each.Name + "」"); SaveValue(SelectPath, GrDic[each.RefUDT_ID], each); } } else { sb.AppendLine("下載操作:「指定書面名稱:" + FileName + "」"); //需要下條件UID+FileName等於輸入內容,才回傳 T.Start(); List <WriteCounselingUDT> WrList = _AccessHelper.Select <WriteCounselingUDT>(UDT_S.PopTwoCondition("RefUDT_ID", FileName, KeyList)); foreach (WriteCounselingUDT each in WrList) { if (!GrDic.ContainsKey(each.RefUDT_ID)) { return; } if (each.Name != FileName) //當名稱相符才下載所有資料 { return; } sb.Append("班級「" + GrDic[each.RefUDT_ID].ClassName + "」"); sb.Append("座號「" + (GrDic[each.RefUDT_ID].SeatNo.HasValue ? GrDic[each.RefUDT_ID].SeatNo.Value.ToString() : "") + "」"); sb.AppendLine("姓名「" + GrDic[each.RefUDT_ID].Name + "」"); SaveValue(SelectPath, GrDic[each.RefUDT_ID], each); } } ApplicationLog.Log("畢業生檔案檢索.書面資料", "下載", sb.ToString()); T.Stop(); e.Result = SelectPath; //傳出選擇Pash }
public GetUpdateRecordUDTXml(List <GraduateUDT> InsertArchiveList) { List <string> list = new List <string>(); foreach (GraduateUDT each in InsertArchiveList) { if (!list.Contains(each.StudentID)) { list.Add(each.StudentID); } } //QueryHelper QueryHelper _queryhelper = new QueryHelper(); string sqlStr1 = "Select * From update_record where " + UDT_S.PopOneCondition("ref_student_id", list); //取得所有學生ID的異動資料 DataTable dt1 = _queryhelper.Select(sqlStr1); foreach (GraduateUDT each in InsertArchiveList) { if (!XmlUDTDic.ContainsKey(each.StudentID)) { XmlUdtHelp H = new XmlUdtHelp(each, "UpdateRecordList"); //Mini盒子 XmlUDTDic.Add(each.StudentID, H); } } foreach (DataRow dr in dt1.Rows) { //先判斷是否為Dic內存之資料 if (XmlUDTDic.ContainsKey("" + dr[1])) { string student = "" + dr[1]; DSXmlHelper XmlDoc = XmlUDTDic[student]._XmlHelper; #region Element XmlDoc.AddElement("UpdateRecord"); XmlDoc.SetAttribute("UpdateRecord", "ID", "" + dr[0]); XmlDoc.AddElement("UpdateRecord", "RefStudentID"); XmlDoc.SetText("UpdateRecord/RefStudentID", "" + dr[1]); XmlDoc.AddElement("UpdateRecord", "SchoolYear"); XmlDoc.SetText("UpdateRecord/SchoolYear", "" + dr[2]); XmlDoc.AddElement("UpdateRecord", "Semester"); XmlDoc.SetText("UpdateRecord/Semester", "" + dr[3]); XmlDoc.AddElement("UpdateRecord", "S_Name"); XmlDoc.SetText("UpdateRecord/S_Name", "" + dr[4]); XmlDoc.AddElement("UpdateRecord", "S_StudentNumber"); XmlDoc.SetText("UpdateRecord/S_StudentNumber", "" + dr[5]); XmlDoc.AddElement("UpdateRecord", "S_Gender"); XmlDoc.SetText("UpdateRecord/S_Gender", "" + dr[6]); XmlDoc.AddElement("UpdateRecord", "S_IDNumber"); XmlDoc.SetText("UpdateRecord/S_IDNumber", "" + dr[7]); XmlDoc.AddElement("UpdateRecord", "S_Birthdate"); XmlDoc.SetText("UpdateRecord/S_Birthdate", UDT_S.ChangeTime("" + dr[8])); XmlDoc.AddElement("UpdateRecord", "S_GradeYear"); XmlDoc.SetText("UpdateRecord/S_GradeYear", "" + dr[9]); XmlDoc.AddElement("UpdateRecord", "S_Dept"); XmlDoc.SetText("UpdateRecord/S_Dept", "" + dr[10]); XmlDoc.AddElement("UpdateRecord", "Update_Date"); XmlDoc.SetText("UpdateRecord/Update_Date", UDT_S.ChangeTime("" + dr[11])); XmlDoc.AddElement("UpdateRecord", "Update_Code"); XmlDoc.SetText("UpdateRecord/Update_Code", "" + dr[12]); XmlDoc.AddElement("UpdateRecord", "Update_Type"); XmlDoc.SetText("UpdateRecord/Update_Type", "" + dr[13]); XmlDoc.AddElement("UpdateRecord", "Update_Reason"); XmlDoc.SetText("UpdateRecord/Update_Reason", "" + dr[14]); XmlDoc.AddElement("UpdateRecord", "Update_Desc"); XmlDoc.SetText("UpdateRecord/Update_Desc", "" + dr[15]); XmlDoc.AddElement("UpdateRecord", "AD_Date"); XmlDoc.SetText("UpdateRecord/AD_Date", "" + dr[16]); XmlDoc.AddElement("UpdateRecord", "AD_Numbar"); XmlDoc.SetText("UpdateRecord/AD_Numbar", "" + dr[17]); XmlDoc.AddElement("UpdateRecord", "Last_AD_Date"); XmlDoc.SetText("UpdateRecord/Last_AD_Date", UDT_S.ChangeTime("" + dr[18])); XmlDoc.AddElement("UpdateRecord", "Last_AD_Numbar"); XmlDoc.SetText("UpdateRecord/Last_AD_Numbar", "" + dr[19]); XmlDoc.AddElement("UpdateRecord", "Comment"); XmlDoc.SetText("UpdateRecord/Comment", "" + dr[20]); //XML XmlDoc.AddElement("UpdateRecord", "ConText_Info"); XmlDoc.AddXmlString("UpdateRecord/ConText_Info", "" + dr[21]); XmlDoc.AddElement("UpdateRecord", "Last_Update_Date"); XmlDoc.SetText("UpdateRecord/Last_Update_Date", UDT_S.ChangeTime("" + dr[22])); #endregion #region UpdateRecord - 原生結構 //<UpdateRecord ID="100540" RefStudentID="54139"> // <SchoolYear>99</SchoolYear> // <Semester>2</Semester> // <Name>呂小鍾</Name> // <StudentNumber>712043</StudentNumber> // <Gender>男</Gender> // <IDNumber>J12254139</IDNumber> // <Birthdate>1993/08/15</Birthdate> // <GradeYear>3</GradeYear> // <Department>汽車科</Department> // <UpdateDate>2011/06/23</UpdateDate> // <UpdateCode>001</UpdateCode> // <UpdateType /> // <UpdateReason /> // <UpdateDescription>持國民中學畢業證明書者(含國中補校)</UpdateDescription> // <ADDate>1753/01/01</ADDate> // <ADNumber>澔字第1111111號</ADNumber> // <LastADDate /> // <LastADNumber /> // <Comment /> // <ContextInfo> // <ContextInfo> // <GraduateComment> // </GraduateComment> // <ClassType> 3</ClassType> // <SpecialStatus> // </SpecialStatus> // <GraduateSchool> 市立光華國中</GraduateSchool> // <GraduateSchoolYear> 99</GraduateSchoolYear> // <GraduateSchoolCode> 183503</GraduateSchoolCode> // <GraduateSchoolLocationCode> 18</GraduateSchoolLocationCode> // </ContextInfo> // </ContextInfo> //</UpdateRecord> #endregion } } }
void NoteView_SourceChanged(object sender, EventArgs e) { TestDic1.Clear(); TestDic2.Clear(); CategoryDic.Clear(); List <GraduateUDT> TestList = new List <GraduateUDT>(); if (Source.Count() != 0) { List <string> list = new List <string>(); foreach (string each in Source) { list.Add(each); } //取得資料 TestList = _AccessHelper.Select <GraduateUDT>(UDT_S.PopOneCondition("UID", list)); } //排序 TestList.Sort(SortClassName); foreach (GraduateUDT obj in TestList) { #region 建立依分類記錄 if (!string.IsNullOrEmpty(obj.ArchiveNote)) { if (!CategoryDic.ContainsKey(obj.ArchiveNote)) //有畢業年度 { CategoryDic.Add(obj.ArchiveNote, new NoteObj(obj.ArchiveNote)); } if (!CategoryDic[obj.ArchiveNote]._ClassNameList.ContainsKey(obj.ClassName)) //是否為已存在班級 { CategoryDic[obj.ArchiveNote]._ClassNameList.Add(obj.ClassName, new List <GraduateUDT>()); } CategoryDic[obj.ArchiveNote]._ClassNameList[obj.ClassName].Add(obj); } else { if (!CategoryDic.ContainsKey(NoArchive)) //有畢業年度 { CategoryDic.Add(NoArchive, new NoteObj(obj.ArchiveNote)); } if (!CategoryDic[NoArchive]._ClassNameList.ContainsKey(obj.ClassName)) //是否為已存在班級 { CategoryDic[NoArchive]._ClassNameList.Add(obj.ClassName, new List <GraduateUDT>()); } CategoryDic[NoArchive]._ClassNameList[obj.ClassName].Add(obj); } #endregion #region 建立依班級學生記錄 if (!TestDic1.ContainsKey(obj.ClassName)) { TestDic1.Add(obj.ClassName, new List <GraduateUDT>()); } TestDic1[obj.ClassName].Add(obj); #endregion #region 建立所有學生記錄 if (!TestDic2.ContainsKey(obj.UID)) { TestDic2.Add(obj.UID, obj); } #endregion } CategoryDic = SortCategoryDic(CategoryDic); advTree1.Nodes.Clear(); #region 增加Node //第一層Node DevComponents.AdvTree.Node Node1 = new DevComponents.AdvTree.Node(); Node1.Text = "依索引分類(" + TestDic2.Count() + ")"; Node1.Tag = "All"; advTree1.Nodes.Add(Node1); //加入 //分類Node foreach (string each1 in CategoryDic.Keys) { //Count該學年度有多少學生 int ClassStudentCount = 0; foreach (string each2 in CategoryDic[each1]._ClassNameList.Keys) { ClassStudentCount += CategoryDic[each1]._ClassNameList[each2].Count; } if (each1 != NoArchive) //如果是無分類者 { //增加分類Node DevComponents.AdvTree.Node Node2 = new DevComponents.AdvTree.Node(); Node2.Text = each1 + "(" + ClassStudentCount + ")"; Node2.Tag = each1; Node1.Nodes.Add(Node2); //班級名稱Node foreach (string each3 in CategoryDic[each1]._ClassNameList.Keys) { DevComponents.AdvTree.Node Node3 = new DevComponents.AdvTree.Node(); Node3.Text = each3 + "(" + CategoryDic[each1]._ClassNameList[each3].Count() + ")"; Node3.Tag = each3; Node2.Nodes.Add(Node3); } } } if (CategoryDic.ContainsKey(NoArchive)) { //Count該學年度有多少學生 int ClassStudentCount = 0; foreach (string each2 in CategoryDic[NoArchive]._ClassNameList.Keys) { ClassStudentCount += CategoryDic[NoArchive]._ClassNameList[each2].Count; } //增加無分類Node DevComponents.AdvTree.Node Node2 = new DevComponents.AdvTree.Node(); Node2.Text = NoArchive + "(" + ClassStudentCount + ")"; Node2.Tag = NoArchive; Node1.Nodes.Add(Node2); //班級名稱Node foreach (string each3 in CategoryDic[NoArchive]._ClassNameList.Keys) { DevComponents.AdvTree.Node Node3 = new DevComponents.AdvTree.Node(); Node3.Text = each3 + "(" + CategoryDic[NoArchive]._ClassNameList[each3].Count() + ")"; Node3.Tag = each3; Node2.Nodes.Add(Node3); } } #endregion List <string> _Source = new List <string>(); foreach (GraduateUDT each in TestList) { if (!_Source.Contains(each.UID)) { _Source.Add(each.UID); } } SetListPaneSource(_Source, false, false); }
/// <summary> /// 依學號匯入 /// </summary> private void InsertByIDNumber(Dictionary <string, string> FileDic) { if (FileDic.Count == 0) { return; } //新增與更新內容 List <WrittenInformationUDT> InsertUDTData = new List <WrittenInformationUDT>(); List <WrittenInformationUDT> UpDataUDTData = new List <WrittenInformationUDT>(); BGW.ReportProgress(10, "判斷是否為封存學生..."); //依照檔名,取得目前系統內該學號,是否為現存封存學生 //需新增條件 - 封存分類(11/11日) List <GraduateUDT> ExtantStudentUDT = _AccessHelper.Select <GraduateUDT>(UDT_S.PopOneCondition("StudentNumber", FileDic.Keys.ToList()) + " AND ArchiveNote='" + _Note + "'"); BGW.ReportProgress(15, "是否已有封存書面資料..."); Dictionary <string, WrittenInformationUDT> HaveWrittenDic = new Dictionary <string, WrittenInformationUDT>(); //取得該學生,是否有封存"學籍表"書面資料 List <string> list = new List <string>(); foreach (GraduateUDT each in ExtantStudentUDT) { list.Add(each.UID); } BGW.ReportProgress(18, "是否已有封存書面資料..."); if (ExtantStudentUDT.Count != 0) { List <WrittenInformationUDT> HaveWrittenList = _AccessHelper.Select <WrittenInformationUDT>(UDT_S.PopOneCondition("RefUDT_ID", list)); BGW.ReportProgress(25, "判斷書面資料..."); //RefUDT_ID / Record foreach (WrittenInformationUDT each in HaveWrittenList) { if (each.Name != WritleName) //不是本表單則跳開 { continue; } if (!HaveWrittenDic.ContainsKey(each.RefUDT_ID)) { HaveWrittenDic.Add(each.RefUDT_ID, each); } else { MsgBox.Show("學生有重覆2張不同之" + WritleName + "!!"); } } } StringBuilder sb = new StringBuilder(); sb.AppendLine("書面名稱「" + WritleName + "」"); int countTime = 35; BGW.ReportProgress(countTime); double count1 = ExtantStudentUDT.Count / 55; //百分之1的度量 double count = 0; foreach (GraduateUDT each in ExtantStudentUDT) { count++; if (count >= count1) { count = 0; //歸0 countTime++; //步進1 BGW.ReportProgress(countTime, "建立學生書面資料..."); } if (FileDic.ContainsKey(each.StudentNumber)) //匯入資料夾中,是否有該學號記錄 { //沒有相同的書面資料 if (!HaveWrittenDic.ContainsKey(each.UID)) { sb.Append("「新增」書面資料,"); sb.Append("班級「" + each.ClassName + "」"); sb.Append("座號「" + (each.SeatNo.HasValue ? each.SeatNo.Value.ToString() : "") + "」"); sb.AppendLine("姓名「" + each.Name + "」"); WrittenInformationUDT udt = new WrittenInformationUDT(); udt.RefUDT_ID = each.UID; udt.StudentID = each.StudentID; udt.Name = WritleName; udt.Format = Path.GetExtension(FileDic[each.StudentNumber]).ToLower(); udt.Date = DateTime.Today; //封存日期為今天 //依照副檔名,取得檔案內容 string base64 = InsertFormat(FileDic[each.StudentNumber]); if (base64 != "") //如果不是空值 { udt.Content = base64; InsertUDTData.Add(udt); } } else //如果有相同檔名 { sb.Append("「更新」書面資料,"); sb.Append("班級「" + each.ClassName + "」"); sb.Append("座號「" + (each.SeatNo.HasValue ? each.SeatNo.Value.ToString() : "") + "」"); sb.AppendLine("姓名「" + each.Name + "」"); WrittenInformationUDT udt = HaveWrittenDic[each.UID]; //書面之名稱 udt.Name = WritleName; //格式可調整如:DOC -> XLS udt.Format = Path.GetExtension(FileDic[each.StudentNumber]).ToLower(); //更新日期調整為今天 udt.Date = DateTime.Today; //依照副檔名,取得檔案內容 string base64 = InsertFormat(FileDic[each.StudentNumber]); if (base64 != "") { udt.Content = base64; UpDataUDTData.Add(udt); } } } } if (InsertUDTData.Count != 0) { BGW.ReportProgress(80, "開始新增上傳書面資料..."); _AccessHelper.InsertValues(InsertUDTData.ToArray()); } if (UpDataUDTData.Count != 0) { BGW.ReportProgress(90, "開始更新上傳書面資料..."); _AccessHelper.UpdateValues(UpDataUDTData.ToArray()); } BGW.ReportProgress(100, "上傳完成..."); ApplicationLog.Log("畢業生檔案檢索.書面資料", "上傳", sb.ToString()); }
public GetDisciplineUDTXml(List <GraduateUDT> InsertArchiveList) { //建立學生ID 清單 List <string> list = new List <string>(); foreach (GraduateUDT each in InsertArchiveList) { if (!list.Contains(each.StudentID)) { list.Add(each.StudentID); } } //QueryHelper QueryHelper _queryhelper = new QueryHelper(); string sqlStr1 = "Select * From discipline where " + UDT_S.PopOneCondition("ref_student_id", list); //取得所有學生ID的獎懲資料 DataTable dt1 = _queryhelper.Select(sqlStr1); foreach (GraduateUDT each in InsertArchiveList) { if (!XmlUDTDic.ContainsKey(each.StudentID)) { XmlUdtHelp H = new XmlUdtHelp(each, "DisciplineList"); //Mini盒子 XmlUDTDic.Add(each.StudentID, H); } } foreach (DataRow dr in dt1.Rows) { //先判斷是否為Dic內存之資料 if (XmlUDTDic.ContainsKey("" + dr[8])) { string student = "" + dr[8]; DSXmlHelper XmlDoc = XmlUDTDic[student]._XmlHelper; #region Element XmlDoc.AddElement("Discipline"); XmlDoc.SetAttribute("Discipline", "ID", "" + dr[0]); XmlDoc.AddElement("Discipline", "RefStudentID"); XmlDoc.SetText("Discipline/RefStudentID", "" + dr[8]); XmlDoc.AddElement("Discipline", "SchoolYear"); XmlDoc.SetText("Discipline/SchoolYear", "" + dr[1]); XmlDoc.AddElement("Discipline", "Semester"); XmlDoc.SetText("Discipline/Semester", "" + dr[2]); XmlDoc.AddElement("Discipline", "OccurDate"); XmlDoc.SetText("Discipline/OccurDate", UDT_S.ChangeTime("" + dr[4])); XmlDoc.AddElement("Discipline", "RegisterDate"); XmlDoc.SetText("Discipline/RegisterDate", UDT_S.ChangeTime("" + dr[12])); //0懲戒,1獎勵,2留察 XmlDoc.AddElement("Discipline", "MeritFlag"); XmlDoc.SetText("Discipline/MeritFlag", "" + dr[10]); XmlDoc.AddElement("Discipline", "Reason"); XmlDoc.SetText("Discipline/Reason", "" + dr[6]); //XML XmlDoc.AddElement("Discipline", "Detail"); XmlDoc.AddXmlString("Discipline/Detail", "" + dr[7]); #endregion #region DisciplineRecord - 原生Xml結構 //<Discipline ID="315122"> // <RefStudentID>57097</RefStudentID> // <Name>王小彥</Name> // <StudentNumber>J00114</StudentNumber> // <SeatNo>1</SeatNo> // <ClassName>普一甲</ClassName> // <Gender>女</Gender> // <SchoolYear>100</SchoolYear> // <Semester>1</Semester> // <OccurDate>2011/07/09</OccurDate> // <GradeYear /> // <Reason>群育:自動參加花燈創意比賽,熱心公務。</Reason> // <Type>1</Type> // <MeritFlag>1</MeritFlag> // <RegisterDate>2011/08/11</RegisterDate> // <Detail> // <Discipline> // <Merit A="0" B="0" C="1" /> // <Demerit A="0" B="1" C="0" ClearDate="" ClearReason="" Cleared="" /> // </Discipline> // </Detail> // </Discipline> #endregion } } }
public GetAttendanceUDTXml(List <GraduateUDT> InsertArchiveList) { //建立學生ID 清單 List <string> list = new List <string>(); foreach (GraduateUDT each in InsertArchiveList) { if (!list.Contains(each.StudentID)) { list.Add(each.StudentID); } } //QueryHelper QueryHelper _queryhelper = new QueryHelper(); string sqlStr1 = "Select * From attendance where " + UDT_S.PopOneCondition("ref_student_id", list); //取得所有學生ID的缺曠資料 DataTable dt1 = _queryhelper.Select(sqlStr1); foreach (GraduateUDT each in InsertArchiveList) { if (!XmlUDTDic.ContainsKey(each.StudentID)) { XmlUdtHelp H = new XmlUdtHelp(each, "AttendanceList"); //Mini盒子 XmlUDTDic.Add(each.StudentID, H); } } foreach (DataRow dr in dt1.Rows) { //先判斷是否為Dic內存之資料 if (XmlUDTDic.ContainsKey("" + dr[1])) { string student = "" + dr[1]; DSXmlHelper XmlDoc = XmlUDTDic[student]._XmlHelper; #region Element XmlDoc.AddElement("Attendance"); XmlDoc.SetAttribute("Attendance", "ID", "" + dr[0]); XmlDoc.AddElement("Attendance", "RefStudentID"); XmlDoc.SetText("Attendance/RefStudentID", "" + dr[1]); XmlDoc.AddElement("Attendance", "SchoolYear"); XmlDoc.SetText("Attendance/SchoolYear", "" + dr[2]); XmlDoc.AddElement("Attendance", "Semester"); XmlDoc.SetText("Attendance/Semester", "" + dr[3]); XmlDoc.AddElement("Attendance", "OccurDate"); XmlDoc.SetText("Attendance/OccurDate", UDT_S.ChangeTime("" + dr[4])); //XML XmlDoc.AddElement("Attendance", "Detail"); XmlDoc.AddXmlString("Attendance/Detail", "" + dr[5]); #endregion #region AttendanceRecord - 原生結構 //<Attendance ID="351287"> // <RefStudentID>53972</RefStudentID> // <SchoolYear>99</SchoolYear> // <Semester>2</Semester> // <OccurDate>2011-01-20 00:00:00</OccurDate> // <Detail> // <Attendance> // <Period AbsenceType="公假">一</Period> // <Period AbsenceType="公假">二</Period> // <Period AbsenceType="公假">三</Period> // <Period AbsenceType="公假">四</Period> // <Period AbsenceType="公假">午休</Period> // <Period AbsenceType="公假">五</Period> // </Attendance> // </Detail> //</Attendance> #endregion } } }
private void wizard1_FinishButtonClick(object sender, CancelEventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Title = "另存新檔"; saveFileDialog1.FileName = "" + _Title + ".xls"; saveFileDialog1.Filter = "Excel (*.xls)|*.xls|所有檔案 (*.*)|*.*"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { List <string> idlist = new List <string>(); #region 取得選取學生編號 List <GraduateUDT> GraduateList = _AccessHelper.Select <GraduateUDT>(UDT_S.PopOneCondition("UID", GraduationAdmin.Instance.SelectedSource));//取得UDT清單 foreach (GraduateUDT stu in GraduateList) { if (!idlist.Contains(stu.UID)) { idlist.Add(stu.UID); } } #endregion List <string> studentFieldList = new List <string>(); List <string> exportFieldList = new List <string>(_SelectedFields); #region 取得選取欄位 for (int index = 0; index < 5; index++) { if (listViewEx1.Items[index] != null && listViewEx1.Items[index].Checked) { studentFieldList.Add(listViewEx1.Items[index].Text.Trim()); } } #endregion List <List <string> > splitList = new List <List <string> >(); //把全部學生以_PackageLimint人分一包 #region 把全部學生以_PackageLimint人分一包 int count = 0; List <string> package = new List <string>(); foreach (string id in idlist) { if (count == 0) { count = (splitList.Count + 1) * 50; count = count > _PackageLimint ? _PackageLimint : count; package = new List <string>(_PackageLimint); splitList.Add(package); } package.Add(id); count--; } #endregion //兩條獨立讀取 Dictionary <List <string>, ManualResetEvent> Loader1 = new Dictionary <List <string>, ManualResetEvent>(); Dictionary <List <string>, ManualResetEvent> Loader2 = new Dictionary <List <string>, ManualResetEvent>(); //已讀取資料 Dictionary <ManualResetEvent, List <RowData> > Filler = new Dictionary <ManualResetEvent, List <RowData> >(); int i = 0; foreach (List <string> p in splitList) { ManualResetEvent handleEvent = new ManualResetEvent(false); if ((i & 1) == 0) { Loader1.Add(p, handleEvent); } else { Loader2.Add(p, handleEvent); } Filler.Add(handleEvent, new List <RowData>()); i++; } //在背景執行取得資料 BackgroundWorker bkwDataLoader = new BackgroundWorker(); bkwDataLoader.DoWork += new DoWorkEventHandler(bkwDataLoader_DoWork); bkwDataLoader.RunWorkerAsync(new object[] { Loader1, Filler, exportFieldList }); bkwDataLoader = new BackgroundWorker(); bkwDataLoader.DoWork += new DoWorkEventHandler(bkwDataLoader_DoWork); bkwDataLoader.RunWorkerAsync(new object[] { Loader2, Filler, exportFieldList }); //在背景計算不及格名單 BackgroundWorker bkwNotPassComputer = new BackgroundWorker(); bkwNotPassComputer.WorkerReportsProgress = true; bkwNotPassComputer.DoWork += new DoWorkEventHandler(bkwNotPassComputer_DoWork); bkwNotPassComputer.ProgressChanged += new ProgressChangedEventHandler(bkwNotPassComputer_ProgressChanged); bkwNotPassComputer.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bkwNotPassComputer_RunWorkerCompleted); bkwNotPassComputer.RunWorkerAsync(new object[] { saveFileDialog1.FileName, studentFieldList, exportFieldList, Filler }); this.Close(); } }
/// <summary> /// 依據各別的DataTable建立UDT資料 /// (By 獎懲資料) /// </summary> public static void Discipline_ExtendMethod(this GetUDTXml xml, string Element) { foreach (DataRow dr in xml.dataTable.Rows) { //先判斷是否為Dic內存之資料 if (xml.XmlUDTDic.ContainsKey("" + dr[8])) { string student = "" + dr[8]; DSXmlHelper XmlDoc = xml.XmlUDTDic[student]._XmlHelper; #region Element XmlDoc.AddElement(Element); XmlDoc.SetAttribute(Element, "ID", "" + dr[0]); XmlDoc.AddElement(Element, "RefStudentID"); XmlDoc.SetText(Element + "/RefStudentID", "" + dr[8]); XmlDoc.AddElement(Element, "SchoolYear"); XmlDoc.SetText(Element + "/SchoolYear", "" + dr[1]); XmlDoc.AddElement(Element, "Semester"); XmlDoc.SetText(Element + "/Semester", "" + dr[2]); XmlDoc.AddElement(Element, "OccurDate"); XmlDoc.SetText(Element + "/OccurDate", UDT_S.ChangeTime("" + dr[4])); XmlDoc.AddElement(Element, "RegisterDate"); XmlDoc.SetText(Element + "/RegisterDate", UDT_S.ChangeTime("" + dr[12])); //0懲戒,1獎勵,2留察 XmlDoc.AddElement(Element, "MeritFlag"); XmlDoc.SetText(Element + "/MeritFlag", "" + dr[10]); XmlDoc.AddElement(Element, "Reason"); XmlDoc.SetText(Element + "/Reason", "" + dr[6]); //XML XmlDoc.AddElement(Element, "Detail"); XmlDoc.AddXmlString(Element + "/Detail", "" + dr[7]); #endregion #region DisciplineRecord - 原生Xml結構 //<Discipline ID="315122"> // <RefStudentID>57097</RefStudentID> // <Name>王小彥</Name> // <StudentNumber>J00114</StudentNumber> // <SeatNo>1</SeatNo> // <ClassName>普一甲</ClassName> // <Gender>女</Gender> // <SchoolYear>100</SchoolYear> // <Semester>1</Semester> // <OccurDate>2011/07/09</OccurDate> // <GradeYear /> // <Reason>群育:自動參加花燈創意比賽,熱心公務。</Reason> // <Type>1</Type> // <MeritFlag>1</MeritFlag> // <RegisterDate>2011/08/11</RegisterDate> // <Detail> // <Discipline> // <Merit A="0" B="0" C="1" /> // <Demerit A="0" B="1" C="0" ClearDate="" ClearReason="" Cleared="" /> // </Discipline> // </Detail> // </Discipline> #endregion } } }
/// <summary> /// 依據各別的DataTable建立UDT資料 /// (By 異動資料) /// </summary> public static void Update_ExtendMethod(this GetUDTXml xml, string Element) { foreach (DataRow dr in xml.dataTable.Rows) { //先判斷是否為Dic內存之資料 if (xml.XmlUDTDic.ContainsKey("" + dr[1])) { string student = "" + dr[1]; DSXmlHelper XmlDoc = xml.XmlUDTDic[student]._XmlHelper; #region Element XmlDoc.AddElement(Element); XmlDoc.SetAttribute(Element, "ID", "" + dr[0]); XmlDoc.AddElement(Element, "RefStudentID"); XmlDoc.SetText(Element + "/RefStudentID", "" + dr[1]); XmlDoc.AddElement(Element, "SchoolYear"); XmlDoc.SetText(Element + "/SchoolYear", "" + dr[2]); XmlDoc.AddElement(Element, "Semester"); XmlDoc.SetText(Element + "/Semester", "" + dr[3]); XmlDoc.AddElement(Element, "S_Name"); XmlDoc.SetText(Element + "/S_Name", "" + dr[4]); XmlDoc.AddElement(Element, "S_StudentNumber"); XmlDoc.SetText(Element + "/S_StudentNumber", "" + dr[5]); XmlDoc.AddElement(Element, "S_Gender"); XmlDoc.SetText(Element + "/S_Gender", "" + dr[6]); XmlDoc.AddElement(Element, "S_IDNumber"); XmlDoc.SetText(Element + "/S_IDNumber", "" + dr[7]); XmlDoc.AddElement(Element, "S_Birthdate"); XmlDoc.SetText(Element + "/S_Birthdate", UDT_S.ChangeTime("" + dr[8])); XmlDoc.AddElement(Element, "S_GradeYear"); XmlDoc.SetText(Element + "/S_GradeYear", "" + dr[9]); XmlDoc.AddElement(Element, "S_Dept"); XmlDoc.SetText(Element + "/S_Dept", "" + dr[10]); XmlDoc.AddElement(Element, "Update_Date"); XmlDoc.SetText(Element + "/Update_Date", UDT_S.ChangeTime("" + dr[11])); XmlDoc.AddElement(Element, "Update_Code"); XmlDoc.SetText(Element + "/Update_Code", "" + dr[12]); XmlDoc.AddElement(Element, "Update_Type"); XmlDoc.SetText(Element + "/Update_Type", "" + dr[13]); XmlDoc.AddElement(Element, "Update_Reason"); XmlDoc.SetText(Element + "/Update_Reason", "" + dr[14]); XmlDoc.AddElement(Element, "Update_Desc"); XmlDoc.SetText(Element + "/Update_Desc", "" + dr[15]); XmlDoc.AddElement(Element, "AD_Date"); XmlDoc.SetText(Element + "/AD_Date", "" + dr[16]); XmlDoc.AddElement(Element, "AD_Numbar"); XmlDoc.SetText(Element + "/AD_Numbar", "" + dr[17]); XmlDoc.AddElement(Element, "Last_AD_Date"); XmlDoc.SetText(Element + "/Last_AD_Date", UDT_S.ChangeTime("" + dr[18])); XmlDoc.AddElement(Element, "Last_AD_Numbar"); XmlDoc.SetText(Element + "/Last_AD_Numbar", "" + dr[19]); XmlDoc.AddElement(Element, "Comment"); XmlDoc.SetText(Element + "/Comment", "" + dr[20]); //XML XmlDoc.AddElement(Element, "ConText_Info"); XmlDoc.AddXmlString(Element + "/ConText_Info", "" + dr[21]); XmlDoc.AddElement(Element, "Last_Update_Date"); XmlDoc.SetText(Element + "/Last_Update_Date", UDT_S.ChangeTime("" + dr[22])); #endregion #region UpdateRecord - 原生結構 //<UpdateRecord ID="100540" RefStudentID="54139"> // <SchoolYear>99</SchoolYear> // <Semester>2</Semester> // <Name>呂小鍾</Name> // <StudentNumber>712043</StudentNumber> // <Gender>男</Gender> // <IDNumber>J12254139</IDNumber> // <Birthdate>1993/08/15</Birthdate> // <GradeYear>3</GradeYear> // <Department>汽車科</Department> // <UpdateDate>2011/06/23</UpdateDate> // <UpdateCode>001</UpdateCode> // <UpdateType /> // <UpdateReason /> // <UpdateDescription>持國民中學畢業證明書者(含國中補校)</UpdateDescription> // <ADDate>1753/01/01</ADDate> // <ADNumber>澔字第1111111號</ADNumber> // <LastADDate /> // <LastADNumber /> // <Comment /> // <ContextInfo> // <ContextInfo> // <GraduateComment> // </GraduateComment> // <ClassType> 3</ClassType> // <SpecialStatus> // </SpecialStatus> // <GraduateSchool> 市立光華國中</GraduateSchool> // <GraduateSchoolYear> 99</GraduateSchoolYear> // <GraduateSchoolCode> 183503</GraduateSchoolCode> // <GraduateSchoolLocationCode> 18</GraduateSchoolLocationCode> // </ContextInfo> // </ContextInfo> //</UpdateRecord> #endregion } } }
/// <summary> /// 依學生學號資料 /// 取得學生的畢業生封存資料 /// </summary> private List <GraduateUDT> GetGraduateList(List <Campus.DocumentValidator.IRowStream> Rows) { //學號清單 List <string> StudentNumberList = new List <string>(); foreach (IRowStream Row in Rows) { string StudentNumber = Row.GetValue("學號"); if (!StudentNumberList.Contains(StudentNumber)) { StudentNumberList.Add(StudentNumber); } } //依學號取得學生UDT資料 List <GraduateUDT> importStudRecList = _accessHelper.Select <GraduateUDT>(UDT_S.PopOneCondition("StudentNumber", StudentNumberList)); foreach (GraduateUDT each in importStudRecList) { //包含於匯入資料"學號清單之學生 if (StudentNumberList.Contains(each.StudentNumber)) { //建立學號比對學生Record字典 if (!GraduateByStudentNumber.ContainsKey(each.StudentNumber)) { GraduateByStudentNumber.Add(each.StudentNumber, each); } } } return(importStudRecList); }
static public void Main() { #region 處理UDT Table沒有的問題 ConfigData cd = K12.Data.School.Configuration["畢業生檔案檢索UDT載入設定"]; bool checkClubUDT = false; string name = "畢業生UDT是否已載入_20200821"; //如果尚無設定值,預設為 if (string.IsNullOrEmpty(cd[name])) { cd[name] = "false"; } //檢查是否為布林 bool.TryParse(cd[name], out checkClubUDT); if (!checkClubUDT) { AccessHelper _accessHelper = new AccessHelper(); _accessHelper.Select <GraduateUDT>("UID = '00000'"); _accessHelper.Select <PhotoDataUDT>("UID = '00000'"); _accessHelper.Select <AllXMLDataUDT>("UID = '00000'"); _accessHelper.Select <WrittenInformationUDT>("UID = '00000'"); _accessHelper.Select <WriteCounselingUDT>("UID = '00000'"); cd[name] = "true"; cd.Save(); } #endregion //增加一個頁籤 MotherForm.AddPanel(GraduationAdmin.Instance); //設定一個學生資訊在上面 GraduationAdmin.Instance.SetDescriptionPaneBulider(new DescriptionPaneBulider <StudentDescription>()); //增加一個ListView GraduationAdmin.Instance.AddView(new ArchiveNoteView()); //依封存分類檢視 GraduationAdmin.Instance.AddView(new TagView()); //依學生類別檢視 GraduationAdmin.Instance.AddView(new GraduationYearView()); //依畢業年度檢視 #region 資料項目 //基本資料 GraduationAdmin.Instance.AddDetailBulider(new FISCA.Presentation.DetailBulider <GraduateDetailItem>()); //書面資料 GraduationAdmin.Instance.AddDetailBulider(new FISCA.Presentation.DetailBulider <WrittenInfomationItem>()); //書面資料(輔導) GraduationAdmin.Instance.AddDetailBulider(new FISCA.Presentation.DetailBulider <WriteCounselingItem>()); //連絡資料 GraduationAdmin.Instance.AddDetailBulider(new FISCA.Presentation.DetailBulider <InformationItem>()); //系統封存資料(XML) //GraduationAdmin.Instance.AddDetailBulider(new FISCA.Presentation.DetailBulider<StorageProjectsItem>()); //備註 GraduationAdmin.Instance.AddDetailBulider(new FISCA.Presentation.DetailBulider <RemarksItem>()); #endregion #region 功能按鈕 RibbonBarItem StudentItem = FISCA.Presentation.MotherForm.RibbonBarItems["學生", "畢業生"]; StudentItem["建立檔案索引"].Image = Properties.Resources.atm_lock_128; StudentItem["建立檔案索引"].Size = RibbonBarButton.MenuButtonSize.Large; StudentItem["建立檔案索引"].Enable = false; StudentItem["建立檔案索引"].Click += delegate { if (K12.Presentation.NLDPanels.Student.SelectedSource.Count > 0) { BatchArchiveStudent BAS = new BatchArchiveStudent(); BAS.ShowDialog(); } else { MsgBox.Show("請選擇學生。"); } }; K12.Presentation.NLDPanels.Student.SelectedSourceChanged += delegate { StudentItem["建立檔案索引"].Enable = Permissions.畢業封存權限 && K12.Presentation.NLDPanels.Student.SelectedSource.Count > 0; }; //StudentItem["永久移除學生資料"].Click += delegate //{ //}; List <string> GraduationList = new List <string>(); RibbonBarItem SystemLog = GraduationAdmin.Instance.RibbonBarItems["系統"]; SystemLog["取得索引資料"].Size = RibbonBarButton.MenuButtonSize.Large; SystemLog["取得索引資料"].Image = Properties.Resources.layers_zoom_64; SystemLog["取得索引資料"].Enable = Permissions.取得封存資料權限; SystemLog["取得索引資料"].Click += delegate { GetGraduationFrom g = new GetGraduationFrom(); g.ShowDialog(); GraduationList = g.UDTkey; }; RibbonBarItem Report = GraduationAdmin.Instance.RibbonBarItems["資料統計"]; Report["匯出"].Size = RibbonBarButton.MenuButtonSize.Large; Report["匯出"].Image = Properties.Resources.匯出; Report["匯出"]["匯出畢業生基本資料"].Enable = Permissions.匯出畢業生基本資料權限; Report["匯出"]["匯出畢業生基本資料"].Click += delegate { SmartSchool.API.PlugIn.Export.Exporter exporter = new ExportGraduation(); ExportStudentV2 wizard = new ExportStudentV2(exporter.Text, exporter.Image); exporter.InitializeExport(wizard); wizard.ShowDialog(); }; Report["匯入"].Size = RibbonBarButton.MenuButtonSize.Large; Report["匯入"].Image = Properties.Resources.匯入; Report["匯入"]["匯入畢業生基本資料(新增)"].Enable = Permissions.匯入畢業生基本資料權限; Report["匯入"]["匯入畢業生基本資料(新增)"].Click += delegate { ImportGraduation wizard = new ImportGraduation(); wizard.Execute(); foreach (string each in wizard.InsertListID) { if (!GraduationList.Contains(each)) { GraduationList.Add(each); } } GraduationAdmin.Instance.BGW.RunWorkerAsync(GraduationList); }; RibbonBarItem DownLoads = GraduationAdmin.Instance.RibbonBarItems["書面管理"]; DownLoads["上傳書面"].Size = RibbonBarButton.MenuButtonSize.Large; DownLoads["上傳書面"].Image = Properties.Resources.cabinet_up_128; DownLoads["上傳書面"].Enable = Permissions.傳書面資料權限; DownLoads["上傳書面"].Click += delegate { UploadWrittenInformation infDlg = new UploadWrittenInformation(); infDlg.ShowDialog(); }; DownLoads["下載書面"].Size = RibbonBarButton.MenuButtonSize.Large; DownLoads["下載書面"].Image = Properties.Resources.cabinet_down_128; DownLoads["下載書面"].Enable = Permissions.書面資料權限; DownLoads["下載書面"].Click += delegate { if (GraduationAdmin.Instance.SelectedSource.Count > 0) { DownLoadWritlenInformation DownLoad = new DownLoadWritlenInformation(); DownLoad.ShowDialog(); } else { MsgBox.Show("請選擇學生。"); } }; #endregion //2020/8/21 - 輔導書面 RibbonBarItem DownLoadCounseling = GraduationAdmin.Instance.RibbonBarItems["書面管理(輔導)"]; DownLoadCounseling["上傳輔導書面"].Size = RibbonBarButton.MenuButtonSize.Large; DownLoadCounseling["上傳輔導書面"].Image = Properties.Resources.new_cabinet_up_128; DownLoadCounseling["上傳輔導書面"].Enable = Permissions.傳書面資料輔導權限; DownLoadCounseling["上傳輔導書面"].Click += delegate { UploadCounseling infDlg = new UploadCounseling(); infDlg.ShowDialog(); }; DownLoadCounseling["下載輔導書面"].Size = RibbonBarButton.MenuButtonSize.Large; DownLoadCounseling["下載輔導書面"].Image = Properties.Resources.new_cabinet_down_128; DownLoadCounseling["下載輔導書面"].Enable = Permissions.書面資料輔導權限; DownLoadCounseling["下載輔導書面"].Click += delegate { if (GraduationAdmin.Instance.SelectedSource.Count > 0) { DownLoadCounseling DownLoad = new DownLoadCounseling(); DownLoad.ShowDialog(); } else { MsgBox.Show("請選擇學生。"); } }; RibbonBarItem tools = GraduationAdmin.Instance.RibbonBarItems["工具"]; tools["文件分割"].Image = Properties.Resources.windows_64; tools["文件分割"].Size = RibbonBarButton.MenuButtonSize.Large; //DownLoads["文件分割"]["Word文件"].Enable = Permissions.下載書面資料權限; tools["文件分割"]["Word文件"].Click += delegate { WordCut word = new WordCut(); word.ShowDialog(); }; #region 右鍵 GraduationAdmin.Instance.ListPaneContexMenu["更新畫面資料"].Enable = Permissions.更新畫面資料權限; GraduationAdmin.Instance.ListPaneContexMenu["更新畫面資料"].Click += delegate { FISCA.Presentation.MotherForm.SetStatusBarMessage("開始取得學生索引資料!!"); GraduationAdmin.Instance.BGW.RunWorkerAsync(GraduationList); }; GraduationAdmin.Instance.ListPaneContexMenu["刪除選擇資料"].Enable = Permissions.刪除選擇資料權限; GraduationAdmin.Instance.ListPaneContexMenu["刪除選擇資料"].Click += delegate { #region 刪除選擇資料 DialogResult dr = MsgBox.Show("您確定要刪除這些學生資料?\n將會一併將其它關聯資料刪除。", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2); if (dr == DialogResult.No) { return; } if (GraduationAdmin.Instance.SelectedSource.Count != 0) { BackgroundWorker BGW = new BackgroundWorker(); BGW.WorkerReportsProgress = true; BGW.DoWork += delegate { #region DoWork AccessHelper _AccessHelper = new AccessHelper(); BGW.ReportProgress(0, "刪除作業,取得學生索引..."); List <GraduateUDT> list1 = _AccessHelper.Select <GraduateUDT>(UDT_S.PopOneCondition("UID", GraduationAdmin.Instance.SelectedSource)); BGW.ReportProgress(10, "刪除作業,取得XML索引資料..."); List <AllXMLDataUDT> list2 = _AccessHelper.Select <AllXMLDataUDT>(UDT_S.PopOneCondition("RefUDT_ID", GraduationAdmin.Instance.SelectedSource)); BGW.ReportProgress(25, "刪除作業,取得學生照片索引資料..."); List <PhotoDataUDT> list3 = _AccessHelper.Select <PhotoDataUDT>(UDT_S.PopOneCondition("RefUDT_ID", GraduationAdmin.Instance.SelectedSource)); BGW.ReportProgress(34, "刪除作業,取得書面索引資料..."); List <WrittenInformationUDT> list4 = _AccessHelper.Select <WrittenInformationUDT>(UDT_S.PopOneCondition("RefUDT_ID", GraduationAdmin.Instance.SelectedSource)); BGW.ReportProgress(42, "系統歷程記錄準備."); DeleteAllData1 dad = new DeleteAllData1(list1); BGW.ReportProgress(47, "系統歷程記錄準備.."); dad.setAllXml(list2); BGW.ReportProgress(53, "系統歷程記錄準備..."); dad.setPhoto(list3); BGW.ReportProgress(57, "系統歷程記錄準備....."); dad.setWritten(list4); BGW.ReportProgress(62, "刪除學生索引基本資料..."); _AccessHelper.DeletedValues(list1.ToArray()); BGW.ReportProgress(75, "刪除XML索引資料..."); _AccessHelper.DeletedValues(list2.ToArray()); BGW.ReportProgress(79, "刪除學生照片索引資料..."); _AccessHelper.DeletedValues(list3.ToArray()); BGW.ReportProgress(84, "刪除書面資料..."); _AccessHelper.DeletedValues(list4.ToArray()); BGW.ReportProgress(95, "刪除作業,系統歷程記錄中..."); ApplicationLog.Log("刪除學生索引資料", "刪除", dad.GetString()); BGW.ReportProgress(100, "已刪除學生索引資料。"); #endregion }; BGW.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e) { FISCA.Presentation.MotherForm.SetStatusBarMessage(e.UserState.ToString(), e.ProgressPercentage); }; BGW.RunWorkerCompleted += delegate { #region RunWorkerCompleted MsgBox.Show("已刪除「" + GraduationAdmin.Instance.SelectedSource.Count + "」筆學生索引資料"); FISCA.Presentation.MotherForm.SetStatusBarMessage("已刪除學生索引資料。"); foreach (string each in GraduationAdmin.Instance.SelectedSource) { if (GraduationList.Contains(each)) { GraduationList.Remove(each); } } GraduationAdmin.Instance.BGW.RunWorkerAsync(GraduationList); #endregion }; BGW.RunWorkerAsync(); } else { MsgBox.Show("未刪除任何資料。"); FISCA.Presentation.MotherForm.SetStatusBarMessage("未刪除任何資料。"); } #endregion }; #endregion #region 限設定 Catalog detail; detail = RoleAclSource.Instance["畢業生檔案檢索"]["資料項目"]; detail.Add(new DetailItemFeature(Permissions.基本資料, "基本資料")); detail.Add(new DetailItemFeature(Permissions.聯絡資訊, "聯絡資訊")); detail.Add(new DetailItemFeature(Permissions.書面檔案, "書面檔案")); detail.Add(new DetailItemFeature(Permissions.書面檔案輔導, "書面檔案(輔導)")); //detail.Add(new DetailItemFeature(Permissions.系統封存, "系統封存")); detail.Add(new DetailItemFeature(Permissions.備註, "備註")); detail = RoleAclSource.Instance["畢業生檔案檢索"]["功能按鈕"]; //detail.Add(new ReportFeature(Permissions.畢業封存, "建立畢業生檔案索引")); detail.Add(new ReportFeature(Permissions.取得封存資料, "取得索引資料")); detail.Add(new ReportFeature(Permissions.匯出畢業生基本資料, "匯出畢業生基本資料")); detail.Add(new ReportFeature(Permissions.匯入畢業生基本資料, "匯入畢業生基本資料(新增)")); detail.Add(new ReportFeature(Permissions.傳書面資料, "上傳書面")); detail.Add(new ReportFeature(Permissions.書面資料, "下載書面")); detail.Add(new ReportFeature(Permissions.傳書面資料輔導, "上傳輔導書面")); detail.Add(new ReportFeature(Permissions.書面資料輔導, "下載輔導書面")); detail = RoleAclSource.Instance["畢業生檔案檢索"]["右鍵功能"]; detail.Add(new ReportFeature(Permissions.更新畫面資料, "更新畫面資料")); detail.Add(new ReportFeature(Permissions.刪除選擇資料, "刪除選擇資料")); detail = RoleAclSource.Instance["學生"]["功能按鈕"]; detail.Add(new ReportFeature(Permissions.畢業封存, "建立檔案索引(畢業生)")); #endregion }
void TagView_SourceChanged(object sender, EventArgs e) { TagDic.Clear(); TestDic1.Clear(); List <GraduateUDT> TestList = new List <GraduateUDT>(); if (Source.Count() != 0) { List <string> list = new List <string>(); foreach (string each in Source) { if (list.Contains(each)) { continue; } list.Add(each); } //取得資料 TestList = _AccessHelper.Select <GraduateUDT>(UDT_S.PopOneCondition("UID", list)); } //排序 TestList.Sort(SortClassName); foreach (GraduateUDT obj in TestList) { #region 依學生類別 if (!string.IsNullOrEmpty(obj.Tag)) { XmlElement xmlelement = DSXmlHelper.LoadXml(obj.Tag); foreach (XmlElement xmlE in xmlelement.SelectNodes("Tag")) { string Prefix = xmlE.GetAttribute("Prefix"); string Name = xmlE.GetAttribute("Name"); //第一層 if (!TagDic.ContainsKey(Prefix)) { TagDic.Add(Prefix, new Dictionary <string, List <string> >()); } //第二層 if (!TagDic[Prefix].ContainsKey(Name)) { TagDic[Prefix].Add(Name, new List <string>()); } TagDic[Prefix][Name].Add(obj.UID); } } else { if (!TagDic.ContainsKey(NoTag)) { TagDic.Add(NoTag, new Dictionary <string, List <string> >()); } if (!TagDic[NoTag].ContainsKey(NoTag)) { TagDic[NoTag].Add(NoTag, new List <string>()); } TagDic[NoTag][NoTag].Add(obj.UID); } #endregion #region 建立所有學生記錄 if (!TestDic1.ContainsKey(obj.UID)) { TestDic1.Add(obj.UID, obj); } #endregion } advTree1.Nodes.Clear(); DevComponents.AdvTree.Node Node1 = new DevComponents.AdvTree.Node(); Node1.Text = "依學生類別(" + TestDic1.Count() + ")"; Node1.Tag = "All"; advTree1.Nodes.Add(Node1); //加入 foreach (string each in TagDic.Keys) //前置詞 { if (each == NoTag) { continue; } if (!string.IsNullOrEmpty(each)) { List <string> list = new List <string>(); foreach (string each2 in TagDic[each].Keys) //標籤名稱 { foreach (string each3 in TagDic[each][each2]) { if (list.Contains(each3)) { continue; } list.Add(each3); } } DevComponents.AdvTree.Node Node2 = new DevComponents.AdvTree.Node(); Node2.Text = each + "(" + list.Count + ")"; Node2.Tag = each; Node1.Nodes.Add(Node2); //加入 foreach (string each2 in TagDic[each].Keys) //標籤名稱 { TagViewObj obj = new TagViewObj(each, each2); DevComponents.AdvTree.Node Node3 = new DevComponents.AdvTree.Node(); Node3.Text = each2 + "(" + TagDic[each][each2].Count + ")"; Node3.Tag = obj; Node2.Nodes.Add(Node3); //加入 } } else //如果是未分群組 { List <string> list = new List <string>(); foreach (string each2 in TagDic[each].Keys) //標籤名稱 { foreach (string each3 in TagDic[each][each2]) { if (list.Contains(each3)) { continue; } list.Add(each3); } } //DevComponents.AdvTree.Node Node2 = new DevComponents.AdvTree.Node(); //Node2.Text = each + "(" + list.Count + ")"; //Node2.Tag = each; //Node1.Nodes.Add(Node2); //加入 foreach (string each2 in TagDic[each].Keys) //標籤名稱 { TagViewObj obj = new TagViewObj(each, each2); DevComponents.AdvTree.Node Node3 = new DevComponents.AdvTree.Node(); Node3.Text = each2 + "(" + TagDic[each][each2].Count + ")"; Node3.Tag = obj; Node1.Nodes.Add(Node3); //加入 } } } if (TagDic.ContainsKey(NoTag)) { if (TagDic[NoTag].ContainsKey(NoTag)) { DevComponents.AdvTree.Node Node4 = new DevComponents.AdvTree.Node(); Node4.Text = NoTag + "(" + TagDic[NoTag][NoTag].Count + ")"; Node4.Tag = NoTag; Node1.Nodes.Add(Node4); //加入 } } //List<string> _Source = TestList.Select(x => x.UID).ToList(); //SetListPaneSource(_Source, false, false); }
private void dataGridViewX1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { DialogResult dr = MsgBox.Show("您確定於封存資料中,刪除選擇之書面記錄(輔導)?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2); if (dr == DialogResult.No) { MsgBox.Show("已中止刪除資料!"); e.Cancel = true; } else { //說明: //CurrentRow的TAG內存之UID / 是WriteCounselingUDT的UID //欲取得GraduateUDT資料,需要先取得WriteCounselingUDT //後由WriteCounselingUDT的RefUDT_ID取得GraduateUDT資料 List <string> uidList = new List <string>(); foreach (DataGridViewRow each in dataGridViewX1.SelectedRows) { string UID = "" + each.Cells[0].Tag; if (!string.IsNullOrEmpty(UID)) { uidList.Add(UID); } } //取得所選的書面資料 List <WriteCounselingUDT> listUDT2 = _AccessHelper.Select <WriteCounselingUDT>(UDT_S.PopOneCondition("UID", uidList)); if (listUDT2.Count > 0) { StringBuilder sb = new StringBuilder(); sb.Append("班級「" + _StudentUdt.ClassName + "」"); sb.Append("座號「" + (_StudentUdt.SeatNo.HasValue ? _StudentUdt.SeatNo.Value.ToString() : "") + "」"); sb.Append("姓名「" + _StudentUdt.Name + "」"); sb.AppendLine("學號「" + _StudentUdt.StudentNumber + "」"); foreach (WriteCounselingUDT each in listUDT2) { sb.AppendLine("已刪除書面(輔導)資料「" + each.Name + each.Format + "」"); } _AccessHelper.DeletedValues(listUDT2.ToArray()); ApplicationLog.Log("畢業生檔案檢索.書面資料(輔導)", "刪除", sb.ToString()); MsgBox.Show("已刪除所選書面資料(輔導)"); e.Cancel = true; OnPrimaryKeyChanged(null); } else { MsgBox.Show("刪除書面資料發生錯誤!"); e.Cancel = true; } } }
public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard) { wizard.ExportableFields.AddRange("學生系統編號", "學號", "身分證號", "索引分類", "畢業學年度", "畢業班級", "座號", "姓名", "性別", "國籍", "出生地", "生日", "英文姓名", "戶籍電話", "聯絡電話", "手機", "其它電話1", "其它電話2", "其它電話3", "戶籍地址郵遞區號", "戶籍地址", "聯絡地址郵遞區號", "聯絡地址", "其它地址郵遞區號", "其它地址", "備註"); wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e) { #region 收集資料(DicMerit) Dictionary <string, GraduateUDT> DicGraduate = new Dictionary <string, GraduateUDT>(); AccessHelper _AccessHelper = new AccessHelper(); List <GraduateUDT> GraduateList = _AccessHelper.Select <GraduateUDT>(UDT_S.PopOneCondition("UID", e.List));//取得UDT清單 //ListDiscipline.Sort(SortDate); foreach (GraduateUDT Record in GraduateList) { if (!DicGraduate.ContainsKey(Record.UID)) { DicGraduate.Add(Record.UID, Record); } } #endregion StringBuilder sb = new StringBuilder(); sb.AppendLine("匯出學生索引基本資料:"); foreach (string each in DicGraduate.Keys) { GraduateUDT udt = DicGraduate[each]; sb.Append("班級「" + udt.ClassName + "」"); sb.Append("座號「" + (udt.SeatNo.HasValue ? udt.SeatNo.Value.ToString() : "") + "」"); sb.Append("學號「" + udt.StudentNumber + "」"); sb.AppendLine("姓名「" + udt.Name + "」"); RowData row = new RowData(); row.ID = each; foreach (string field in e.ExportFields) { if (wizard.ExportableFields.Contains(field)) { switch (field) { case "學生系統編號": row.Add(field, "" + udt.StudentID); break; case "學號": row.Add(field, "" + udt.StudentNumber); break; case "身分證號": row.Add(field, "" + udt.IDNumber); break; case "索引分類": row.Add(field, "" + udt.ArchiveNote); break; case "畢業學年度": row.Add(field, udt.GraduateSchoolYear.HasValue ? udt.GraduateSchoolYear.Value.ToString() : ""); break; case "畢業班級": row.Add(field, "" + udt.ClassName); break; case "座號": row.Add(field, udt.SeatNo.HasValue ? udt.SeatNo.Value.ToString() : ""); break; case "姓名": row.Add(field, "" + udt.Name); break; case "性別": row.Add(field, "" + udt.Gender); break; case "國籍": row.Add(field, "" + udt.Nationality); break; case "出生地": row.Add(field, "" + udt.BirthPlace); break; case "生日": row.Add(field, udt.Birthday.HasValue ? udt.Birthday.Value.ToShortDateString() : ""); break; case "英文姓名": row.Add(field, "" + udt.EnglishName); break; case "戶籍電話": row.Add(field, "" + udt.Permanent); break; case "聯絡電話": row.Add(field, "" + udt.Contact); break; case "手機": row.Add(field, "" + udt.Cell); break; case "其它電話1": row.Add(field, "" + udt.Phone1); break; case "其它電話2": row.Add(field, "" + udt.Phone2); break; case "其它電話3": row.Add(field, "" + udt.Phone3); break; case "戶籍地址郵遞區號": row.Add(field, "" + udt.PermanentZipCode); break; case "戶籍地址": row.Add(field, "" + udt.PermanentAddress); break; case "聯絡地址郵遞區號": row.Add(field, "" + udt.MailingZipCode); break; case "聯絡地址": row.Add(field, "" + udt.MailingAddress); break; case "其它地址郵遞區號": row.Add(field, "" + udt.OtherZipCode); break; case "其它地址": row.Add(field, "" + udt.OtherAddresses); break; //case "其它地址2": row.Add(field, "" + udt.OtherAddresses2); break; //case "其它地址3": row.Add(field, "" + udt.OtherAddresses3); break; case "備註": row.Add(field, "" + udt.Remarks); break; } } } e.Items.Add(row); } ApplicationLog.Log("畢業生檔案檢索.匯出索引基本資料", "匯出", sb.ToString()); }; }
public List <AllXMLDataUDT> GenerateXml(string tableName, string fields, string forgeKey, string desc) { ParseTableName(tableName); ParseFieldName(fields); string forgeKeyName = ""; foreach (FieldInfo field in Fields) { if (field.DBName == forgeKey) { forgeKeyName = field.XmlName; break; } } if (string.IsNullOrEmpty(forgeKeyName)) { throw new ArgumentException(string.Format("{0} 不存在於Fields描述中。", forgeKey)); } string sqlStr1 = "Select " + GetSelectFields() + " From " + DBTableName + " where " + UDT_S.PopOneCondition(forgeKey, StudentDics.Keys.ToList()); DataTable dt = _queryhelper.Select(sqlStr1); //XmlHelper收集器 Dictionary <string, List <DSXmlHelper> > HelperDic = new Dictionary <string, List <DSXmlHelper> >(); foreach (DataRow row in dt.Rows) { string StudentID = "" + row[forgeKeyName]; if (!HelperDic.ContainsKey(StudentID)) { HelperDic.Add(StudentID, new List <DSXmlHelper>()); } //XmlTableName = RootElement ? DSXmlHelper h = new DSXmlHelper(); h.AddElement(XmlTableName); //建立該筆資料的Element foreach (FieldInfo field in Fields) { string RowValue = "" + row[field.XmlName]; //if (string.IsNullOrEmpty(RowValue)) // continue; if (field.IsAttribute) { h.SetAttribute(XmlTableName, field.XmlName, RowValue); } else { h.AddElement(XmlTableName, field.XmlName, RowValue, true); } } HelperDic[StudentID].Add(h); } List <AllXMLDataUDT> aUDTList = new List <AllXMLDataUDT>(); foreach (string each1 in HelperDic.Keys) { AllXMLDataUDT aUDT = new AllXMLDataUDT(); aUDT.Name = desc; aUDT.StudentID = each1; aUDT.RefUDT_ID = StudentDics[each1].UID; DSXmlHelper dh = new DSXmlHelper(XmlTableName + "List"); foreach (DSXmlHelper each2 in HelperDic[each1]) { dh.AddXmlString(".", each2.BaseElement.InnerXml); } aUDT.Content = dh.BaseElement.OuterXml; aUDTList.Add(aUDT); } return(aUDTList); }
//private Dictionary<DevComponents.AdvTree.Node, List<string>> items = new Dictionary<DevComponents.AdvTree.Node, List<string>>(); void ExtracurricularActivitiesView_SourceChanged(object sender, EventArgs e) { TestDic1.Clear(); TestDic2.Clear(); SchoolYearDic.Clear(); List <GraduateUDT> TestList = new List <GraduateUDT>(); if (Source.Count() != 0) { List <string> list = new List <string>(); foreach (string each in Source) { list.Add(each); } //取得資料 TestList = _AccessHelper.Select <GraduateUDT>(UDT_S.PopOneCondition("UID", list)); } //排序 TestList.Sort(SortClassName); foreach (GraduateUDT obj in TestList) { #region 建立依畢業學年度記錄 if (obj.GraduateSchoolYear.HasValue) { if (!SchoolYearDic.ContainsKey(obj.GraduateSchoolYear.Value)) //有畢業年度 { SchoolYearDic.Add(obj.GraduateSchoolYear.Value, new SchoolYearObj(obj.GraduateSchoolYear.Value)); } if (!SchoolYearDic[obj.GraduateSchoolYear.Value]._ClassNameList.ContainsKey(obj.ClassName)) //是否為已存在班級 { SchoolYearDic[obj.GraduateSchoolYear.Value]._ClassNameList.Add(obj.ClassName, new List <GraduateUDT>()); } SchoolYearDic[obj.GraduateSchoolYear.Value]._ClassNameList[obj.ClassName].Add(obj); } else //沒有學年度,加入0學年度 { if (!SchoolYearDic.ContainsKey(0)) //有畢業年度 { SchoolYearDic.Add(0, new SchoolYearObj(0)); } if (!SchoolYearDic[0]._ClassNameList.ContainsKey(obj.ClassName)) //是否為已存在班級 { SchoolYearDic[0]._ClassNameList.Add(obj.ClassName, new List <GraduateUDT>()); } SchoolYearDic[0]._ClassNameList[obj.ClassName].Add(obj); } #endregion #region 建立依班級學生記錄 if (!TestDic1.ContainsKey(obj.ClassName)) { TestDic1.Add(obj.ClassName, new List <GraduateUDT>()); } TestDic1[obj.ClassName].Add(obj); #endregion #region 建立所有學生記錄 if (!TestDic2.ContainsKey(obj.UID)) { TestDic2.Add(obj.UID, obj); } #endregion } SchoolYearDic = SortSchoolYearDic(SchoolYearDic); advTree1.Nodes.Clear(); #region 增加Node //第一層Node DevComponents.AdvTree.Node Node1 = new DevComponents.AdvTree.Node(); Node1.Text = "依畢業年(" + TestDic2.Count() + ")"; Node1.Tag = "All"; advTree1.Nodes.Add(Node1); //加入 //advTree1.SelectedNode = Node1; //預設選擇 //學年度Node foreach (int each1 in SchoolYearDic.Keys) { //Count該學年度有多少學生 int ClassStudentCount = 0; foreach (string each2 in SchoolYearDic[each1]._ClassNameList.Keys) { ClassStudentCount += SchoolYearDic[each1]._ClassNameList[each2].Count; } if (each1 != 0) //如果是無畢業年度者 { //增加學年度Node DevComponents.AdvTree.Node Node2 = new DevComponents.AdvTree.Node(); Node2.Text = each1 + "學年度畢業生(" + ClassStudentCount + ")"; Node2.Tag = each1; Node1.Nodes.Add(Node2); //班級名稱Node foreach (string each3 in SchoolYearDic[each1]._ClassNameList.Keys) { DevComponents.AdvTree.Node Node3 = new DevComponents.AdvTree.Node(); Node3.Text = each3 + "(" + SchoolYearDic[each1]._ClassNameList[each3].Count() + ")"; Node3.Tag = each3; Node2.Nodes.Add(Node3); } } } //未分學年度 if (SchoolYearDic.ContainsKey(0)) { //Count該學年度有多少學生 int ClassStudentCount = 0; foreach (string each2 in SchoolYearDic[0]._ClassNameList.Keys) { ClassStudentCount += SchoolYearDic[0]._ClassNameList[each2].Count; } //增加未分學年度Node DevComponents.AdvTree.Node Node2 = new DevComponents.AdvTree.Node(); Node2.Text = "未分學年度(" + ClassStudentCount + ")"; Node2.Tag = 0; Node1.Nodes.Add(Node2); //班級名稱Node foreach (string each3 in SchoolYearDic[0]._ClassNameList.Keys) { DevComponents.AdvTree.Node Node3 = new DevComponents.AdvTree.Node(); Node3.Text = each3 + "(" + SchoolYearDic[0]._ClassNameList[each3].Count() + ")"; Node3.Tag = each3; Node2.Nodes.Add(Node3); } } #endregion List <string> _Source = TestList.Select(x => x.UID).ToList(); SetListPaneSource(_Source, false, false); }