private void InitializeDateRange() { #region 日期定義 K12.Data.Configuration.ConfigData DateConfig = K12.Data.School.Configuration["Attendance_BatchEditor"]; string date = DateConfig["MutiEditor"]; if (date == "") { DSXmlHelper helper = new DSXmlHelper("xml"); helper.AddElement("Date"); helper.AddText("Date", DateTime.Today.ToShortDateString()); helper.AddElement("Locked"); helper.AddText("Locked", "false"); date = helper.BaseElement.OuterXml; DateConfig["MutiEditor"] = date; DateConfig.Save(); //儲存此預設檔 } XmlElement loadXml = DSXmlHelper.LoadXml(date); checkBoxX1.Checked = bool.Parse(loadXml.SelectSingleNode("Locked").InnerText); if (checkBoxX1.Checked) //如果是鎖定,就取鎖定日期 { dateTimeInput1.Text = loadXml.SelectSingleNode("Date").InnerText; } else //如果沒有鎖定,就取當天 { dateTimeInput1.Text = DateTime.Today.ToShortDateString(); } _currentDate = dateTimeInput1.Value; #endregion }
private void btnPrint_Click(object sender, EventArgs e) { Utility.MorItemDict = Utility.GetDLBehaviorConfigNameDict(); // 回寫畫面預設值與使用全域值 Global.TransferName = txtTransName.Text; Global.RegManagerName = txtRegName.Text; K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["學籍表_相關資料"]; cd["TransName"] = txtTransName.Text; cd["RegName"] = txtRegName.Text; cd.Save(); Report report = new Report(); List <JHStudentRecord> list = new List <JHStudentRecord>(); List <JHStudentRecord> studList = new List <JHStudentRecord>(); List <JHStudentRecord> studListN = new List <JHStudentRecord>(); if (_EnterType == EnterType.Student) { list = JHSchool.Data.JHStudent.SelectByIDs(K12.Presentation.NLDPanels.Student.SelectedSource); } else { foreach (JHClassRecord cla in JHClass.SelectByIDs(K12.Presentation.NLDPanels.Class.SelectedSource)) { studList.Clear(); studListN.Clear(); // 取得一般生 foreach (JHStudentRecord studRec in cla.Students.Where(x => x.Status == K12.Data.StudentRecord.StudentStatus.一般)) { // 如果有座號依座號排序 if (studRec.SeatNo.HasValue) { studList.Add(studRec); } else // 沒有座號依學號 { studListN.Add(studRec); } } // sort if (studList.Count > 0) { list.AddRange(studList.OrderBy(x => x.SeatNo.Value)); } if (studListN.Count > 0) { list.AddRange(studListN.OrderBy(x => x.StudentNumber)); } } } list.Sort(SortStudentByClassSeatNo); report.SetStudents(list); report.GenerateReport(); this.DialogResult = DialogResult.OK; }
public MainForm(EnterType enterType) { InitializeComponent(); this.MaximumSize = this.Size; this.MinimumSize = this.Size; this.Text = Global.ReportName; _enterType = enterType; _config = new Config(Global.ReportName); _error = new EnhancedErrorProvider(); _error.BlinkRate = 0; InitializeSemester(); InitializeDate(); _worker = new BackgroundWorker(); _worker.DoWork += delegate { #region 取得試別 _exams = JHExam.SelectAll(); //List<string> examIDs = new List<string>(); //foreach (JHExamRecord exam in _exams) //{ // examIDs.Add(exam.ID); // _ecMapping.Add(exam.ID, new List<string>()); //} #endregion }; _worker.RunWorkerCompleted += delegate { //Campus.Configuration.Config.App.Sync("新竹個人評量成績單試別"); //Campus.Configuration.ConfigData cd = Campus.Configuration.Config.App["新竹個人評量成績單試別"]; //string str = cd["新竹個人評量成績單試別"]; K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["新竹個人評量成績單試別"]; string str = cd["新竹個人評量成績單試別"]; cbExam.DisplayMember = "Name"; foreach (var exam in _exams) { cbExam.Items.Add(exam); } int idx = cbExam.FindString(str); if (idx < 0) { cbExam.SelectedIndex = 0; } else { cbExam.SelectedIndex = idx; } cbExam.Enabled = true; btnNext.Enabled = true; LoadSubjectName(); }; _worker.RunWorkerAsync(); }
public Searchday(string ConfigText) { InitializeComponent(); _ConfigText = ConfigText; cd = K12.Data.School.Configuration[_ConfigText]; DSXmlHelper dsx = new DSXmlHelper("WeekSetup"); foreach (ListViewItem each in listView1.Items) { dsx.AddElement("Day"); dsx.SetAttribute("Day", "Detail", each.Text); } string cdIN = cd["星期設定"]; XmlElement day; if (cdIN != "") { day = XmlHelper.LoadXml(cdIN); } else { day = dsx.BaseElement; } //if (day == null) //{ // DSXmlHelper dsx = new DSXmlHelper("WeekSetup"); // foreach(ListViewItem each in listView1.Items) // { // dsx.AddElement("Day"); // dsx.SetAttribute("Day", "Detail", each.Text); // } // day = dsx.BaseElement; //} List <string> list = new List <string>(); foreach (XmlNode each in day.SelectNodes("Day")) { XmlElement each2 = each as XmlElement; list.Add(each2.GetAttribute("Detail")); } foreach (ListViewItem each in listView1.Items) { if (list.Contains(each.Text)) { each.Checked = true; } } }
double counter = 0; //上傳成績時,算筆數用的。 /// <summary> /// 載入學號長度值 /// </summary> private void LoadConfigData() { int val = 7; cd = School.Configuration[_StudentNumberLenght]; Global.StudentNumberLenght = intStudentNumberLenght.Value; if (int.TryParse(cd[_StudentNumberLenghtName], out val)) { intStudentNumberLenght.Value = val; } }
/// <summary> /// 取的登入系統是高中或國中 /// </summary> /// <returns></returns> public static SystemType GetSystemType() { K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["ischool_Metadata"]; if (cd["EducationalSystem"] == "SeniorHighSchool") { return(SystemType.高中); } else { return(SystemType.中); } }
/// <summary> /// 建構子 /// </summary> public GetConfigData() { //取得系統設定之節次內容 GetAbsenceList(); cd = K12.Data.School.Configuration[ConfigDataString]; PrintData = cd.GetXml("列印設定", null); //<Print> // <PrintMode bool=\"false\"></PrintMode> // <PrintTemp Temp=\"\"></PrintTemp> //</Print> if (PrintData == null) //如果沒有設定檔 { DSXmlHelper XmlPrint = new DSXmlHelper("Print"); XmlPrint.AddElement("PrintMode"); XmlPrint.SetAttribute("PrintMode", "bool", "false"); XmlPrint.AddElement("PrintTemp"); XmlPrint.SetAttribute("PrintTemp", "Temp", ""); XmlPrint.AddElement("PrintClassSet"); XmlPrint.SetAttribute("PrintClassSet", "Class", "True"); PrintData = XmlPrint.BaseElement; } AttendanceData = cd.GetXml("假別設定", null); //<AttendanceType> // <AttendanceList List=\"曠課\"></AttendanceList> // <AttendanceList List=\"事假\"></AttendanceList> // <AttendanceList List=\"病假\"></AttendanceList> // <AttendanceList List=\"喪假\"></AttendanceList> // <AttendanceList List=\"公假\"></AttendanceList> // <AttendanceList List=\"婚假\"></AttendanceList> // <AttendanceList List=\"測假\"></AttendanceList> // <AttendanceList List=\"新假\"></AttendanceList> //</AttendanceType> if (AttendanceData == null) //如果沒有設定檔 { DSXmlHelper XmlAttendance = new DSXmlHelper("AttendanceType"); foreach (string each in AllAbsence) { XmlAttendance.AddElement("AttendanceList"); XmlAttendance.SetAttribute("AttendanceList", "List", each); } AttendanceData = XmlAttendance.BaseElement; } Reset(); }
public MainForm(EnterType enterType) { InitializeComponent(); this.Text = Global.ReportName; this.MinimumSize = this.Size; this.MaximumSize = this.Size; _EnterType = enterType; // 讀取畫面上承辦人員與註冊組長預設值 K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["學籍表_相關資料"]; // 承辦人員 txtTransName.Text = cd["TransName"]; // 註冊組長 txtRegName.Text = cd["RegName"]; }
public PerformanceDegreeMapper() { _DegreeToDesc = new Dictionary <int, string>(); _DescToDegree = new Dictionary <string, int>(); K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["DLBehaviorConfig"]; #region xml ref //<DailyBehavior Name="日常行為表現"> // <Item Name="愛整潔" Index="抽屜乾淨"></Item> // <Item Name="有禮貌" Index="懂得向老師,學長敬禮"></Item> // <Item Name="守秩序" Index="自習時間能夠安靜自習"></Item> // <Item Name="責任心" Index="打掃時間,徹底整理自己打掃範圍"></Item> // <Item Name="公德心" Index="不亂丟垃圾"></Item> // <Item Name="友愛關懷" Index="懂得關心同學朋友"></Item> // <Item Name="團隊合作" Index="團體活動能夠遵守相關規定"></Item> // <PerformanceDegree> // <Mapping Degree="5" Desc="完全符合"></Mapping> // <Mapping Degree="4" Desc="大部份符合"></Mapping> // <Mapping Degree="3" Desc="部份符合"></Mapping> // <Mapping Degree="2" Desc="尚再努力"></Mapping> // <Mapping Degree="1" Desc="需再努力"></Mapping> // </PerformanceDegree> //</DailyBehavior> #endregion string cdKey = "DailyBehavior"; if (cd.Contains(cdKey) && !string.IsNullOrEmpty(cd[cdKey])) { XmlElement dailyBehavior = XmlHelper.LoadXml(cd[cdKey]); foreach (XmlElement item in dailyBehavior.SelectNodes("PerformanceDegree/Mapping")) { int degree = int.Parse(item.GetAttribute("Degree")); string desc = item.GetAttribute("Desc"); if (!_DegreeToDesc.ContainsKey(degree)) { _DegreeToDesc.Add(degree, desc); } if (!_DescToDegree.ContainsKey(desc)) { _DescToDegree.Add(desc, degree); } } } }
public ProveReport() { InitializeComponent(); K12.Data.Configuration.ConfigData conf = K12.Data.School.Configuration[顯示成績Config]; if (conf["顯示成績"] == "") { 顯示成績 = "False"; checkBoxX1.Checked = false; } else { 顯示成績 = "True"; checkBoxX1.Checked = true; } }
private void SaveDateSetting() { #region 儲存日期資料 K12.Data.Configuration.ConfigData DateConfig = K12.Data.School.Configuration["Attendance_BatchEditor"]; DSXmlHelper helper = new DSXmlHelper("xml"); helper.AddElement("Date"); helper.AddText("Date", dateTimeInput1.Value.ToShortDateString()); helper.AddElement("Locked"); helper.AddText("Locked", checkBoxX1.Checked.ToString()); DateConfig["MutiEditor"] = helper.BaseElement.OuterXml; DateConfig.Save(); //儲存此預設檔 #endregion }
private void UpdateRecord_FormClosing(object sender, FormClosingEventArgs e) { XmlElement pref = new XmlDocument().CreateElement("異動資料檢視_異動代碼"); foreach (string code in _typeForm.CodeList) { XmlElement codeElement = pref.OwnerDocument.CreateElement("Code"); codeElement.InnerText = code; pref.AppendChild(codeElement); } //SmartSchool.Customization.Data.SystemInformation.Preference["異動資料檢視_異動代碼"] = pref; K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["異動資料檢視"]; cd["異動代碼"] = pref.OuterXml; cd.Save(); }
double counter = 0; //上傳成績時,算筆數用的。 /// <summary> /// 載入學號長度值 /// </summary> private void LoadConfigData() { cd = School.Configuration[_ExamScoreReaderConfig]; int val1 = 7; Global.StudentNumberLenght = StudentNumberMax; //if (int.TryParse(cd[_StudentNumberLenghtName], out val1)) // intStudentNumberLenght.Value = val1; bool val2 = false; Global.StudentDocRemove = val2; //預設是不移除 if (bool.TryParse(cd[_StudentDotIsClear], out val2)) { checkBoxX1.Checked = val2; } }
private void ApplyPreference() { K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["異動資料檢視"]; // ConfigData cd = User.Configuration["異動資料檢視"]; if (cd.Contains("異動代碼")) { XmlElement pref = Framework.XmlHelper.LoadXml(cd["異動代碼"]); foreach (DataGridViewRow row in dgvUpdateCode.Rows) { if (pref.SelectSingleNode(string.Format("Code[.='{0}']", "" + row.Cells[colCode.Index].Value)) != null) { row.Cells[colCheck.Index].Value = true; _codeList.Add("" + row.Cells[colCode.Index].Value); } } } }
public DegreeMapper() { #region 等第對照表 K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["ESL等第對照表"]; if (string.IsNullOrEmpty(cd["xml"])) { cd["xml"] = K12.Data.XmlHelper.LoadXml(Properties.Resources.預設ESL等第對照表).OuterXml; cd.Save(); } if (cd.Contains("xml") && !string.IsNullOrEmpty(cd["xml"])) { XmlElement element = K12.Data.XmlHelper.LoadXml(cd["xml"]); foreach (XmlElement each in element.SelectNodes("ScoreMapping")) { string degree = each.GetAttribute("EngName"); decimal score; if (!decimal.TryParse(each.GetAttribute("Score"), out score)) { score = 0; } if (!_decimalToString.ContainsKey(score)) { _decimalToString.Add(score, degree); } if (!_stringToDecimal.ContainsKey(degree)) { _stringToDecimal.Add(degree, score); } } _scoreList = new List <decimal>(); _scoreList.AddRange(_decimalToString.Keys); _scoreList.Sort(delegate(decimal a, decimal b) { return(b.CompareTo(a)); }); } #endregion }
private void LoadAbsense() { #region 處理星期設定檔 WeekDay.Clear(); nowWeekDay.Clear(); K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["缺曠批次登錄_星期設定_ByMany"]; string cdIN = cd["星期設定"]; XmlElement day; if (cdIN != "") { day = XmlHelper.LoadXml(cdIN); } else { day = null; } if (day != null) { foreach (XmlNode each in day.SelectNodes("Day")) { XmlElement each2 = each as XmlElement; WeekDay.Add(each2.GetAttribute("Detail")); } } else { WeekDay.AddRange(new string[] { "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" }); } nowWeekDay = ChengDayOfWeel(WeekDay); #endregion SearchDateRange(); GetAbsense(); chkHasData_CheckedChanged(null, null); }
public EffortMapper() { #region 努力程度文字對照 K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["努力程度對照表"]; if (cd.Contains("xml") && !string.IsNullOrEmpty(cd["xml"])) { XmlElement element = K12.Data.XmlHelper.LoadXml(cd["xml"]); foreach (XmlElement each in element.SelectNodes("Effort")) { int code = int.Parse(each.GetAttribute("Code")); string text = each.GetAttribute("Name"); decimal score; if (!decimal.TryParse(each.GetAttribute("Score"), out score)) { score = 0; } if (!_effortList.ContainsKey(score)) { _effortList.Add(score, text); } if (!_effortText.ContainsKey(code)) { _effortText.Add(code, text); } } _scoreList = new List <decimal>(); _scoreList.AddRange(_effortList.Keys); _scoreList.Sort(delegate(decimal a, decimal b) { return(b.CompareTo(a)); }); } #endregion }
private void ImportStudQuizDataSelectQuizNameForm_Load(object sender, EventArgs e) { // 預設用學號 rbClassSeatNo.Checked = false; rbStudentNumber.Checked = true; K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration[_ConfigData_Name]; bool b1, b2; if (bool.TryParse(cd[_ConfigData_ItemSnum], out b1)) { rbStudentNumber.Checked = b1; } if (bool.TryParse(cd[_ConfigData_ItemSeatNo], out b2)) { rbClassSeatNo.Checked = b2; } _QuizDataList = _UDTTransfer.GetAllQuizData(); List <string> NameList = _QuizDataList.Select(x => x.QuizName).ToList(); cbxQuizName.Items.AddRange(NameList.ToArray()); }
/// <summary> /// 取得系統內設定自訂欄位資料項目與型態 /// </summary> /// <returns></returns> public static Dictionary <string, string> GetUserConfigData() { K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration[CounselUserDefineDataRootName]; return(CounselXMLToDictP1(cd[CounselUserDefineDataName])); }
/// <summary> /// 取得日常生活表現設定名稱 /// </summary> /// <returns></returns> internal static Dictionary <string, string> GetDLBehaviorConfigNameDict() { Dictionary <string, string> retVal = new Dictionary <string, string>(); try { DLBehaviorConfigItemNameDict.Clear(); // 包含新竹與高雄 K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["DLBehaviorConfig"]; if (!string.IsNullOrEmpty(cd["DailyBehavior"])) { string key = "日常行為表現"; //日常行為表現 XElement e1 = XElement.Parse(cd["DailyBehavior"]); string name = e1.Attribute("Name").Value; retVal.Add(key, name); // 日常生活表現子項目 List <string> items = ParseItems(e1); if (items.Count > 0) { DLBehaviorConfigItemNameDict.Add(key, items); } } if (!string.IsNullOrEmpty(cd["OtherRecommend"])) { //其它表現 XElement e2 = XElement.Parse(cd["OtherRecommend"]); string name = e2.Attribute("Name").Value; retVal.Add("其它表現", name); } if (!string.IsNullOrEmpty(cd["DailyLifeRecommend"])) { //日常生活表現具體建議 XElement e3 = XElement.Parse(cd["DailyLifeRecommend"]); string name = e3.Attribute("Name").Value; retVal.Add("日常生活表現具體建議", name); // 高雄 retVal.Add("綜合評語", name); // 新竹 } if (!string.IsNullOrEmpty(cd["GroupActivity"])) { string key = "團體活動表現"; //團體活動表現 XElement e4 = XElement.Parse(cd["GroupActivity"]); string name = e4.Attribute("Name").Value; retVal.Add(key, name); // 團體活動表現 List <string> items = ParseItems(e4); if (items.Count > 0) { DLBehaviorConfigItemNameDict.Add(key, items); } } if (!string.IsNullOrEmpty(cd["PublicService"])) { string key = "公共服務表現"; //公共服務表現 XElement e5 = XElement.Parse(cd["PublicService"]); string name = e5.Attribute("Name").Value; retVal.Add(key, name); List <string> items = ParseItems(e5); if (items.Count > 0) { DLBehaviorConfigItemNameDict.Add(key, items); } } if (!string.IsNullOrEmpty(cd["SchoolSpecial"])) { string key = "校內外特殊表現"; //校內外特殊表現,新竹沒有子項目,高雄有子項目 XElement e6 = XElement.Parse(cd["SchoolSpecial"]); string name = e6.Attribute("Name").Value; retVal.Add(key, name); List <string> items = ParseItems(e6); if (items.Count > 0) { DLBehaviorConfigItemNameDict.Add(key, items); } } } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("日常生活表現設定檔解析失敗!" + ex.Message); } return(retVal); }
/// <summary> /// Constructor /// 傳入一個課程。 /// </summary> /// <param name="course"></param> public CourseScoreInputForm(CourseRecord course) { InitializeComponent(); prlp = new PermRecLogProcess(); _course = course; #region 設定小標題 TeacherRecord first = course.GetFirstTeacher(); TeacherRecord second = course.GetSecondTeacher(); TeacherRecord third = course.GetThirdTeacher(); StringBuilder builder = new StringBuilder(""); if (first != null) { builder.Append(first.Name + ","); } if (second != null) { builder.Append(second.Name + ","); } if (third != null) { builder.Append(third.Name + ","); } string teachers = builder.ToString(); if (!string.IsNullOrEmpty(teachers)) { teachers = teachers.Substring(0, teachers.Length - 1); } lblCourseName.Text = course.Name + (!string.IsNullOrEmpty(teachers) ? " (" + teachers + ")" : ""); #endregion #region 取得努力程度對照表 K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["努力程度對照表"]; if (!string.IsNullOrEmpty(cd["xml"])) { XmlElement element = XmlHelper.LoadXml(cd["xml"]); foreach (XmlElement each in element.SelectNodes("Effort")) { int code = int.Parse(each.GetAttribute("Code")); decimal score; if (!decimal.TryParse(each.GetAttribute("Score"), out score)) { score = 0; } if (!_effortList.ContainsKey(score)) { _effortList.Add(score, code); } } _scoreList = new List <decimal>(); _scoreList.AddRange(_effortList.Keys); _scoreList.Sort(delegate(decimal a, decimal b) { return(b.CompareTo(a)); }); } #endregion #region 取得文字評量代碼表 cd = K12.Data.School.Configuration["文字描述代碼表"]; if (!string.IsNullOrEmpty(cd["xml"])) { XmlHelper helper = new XmlHelper(XmlHelper.LoadXml(cd["xml"])); foreach (XmlElement item in helper.GetElements("Item")) { string code = item.GetAttribute("Code"); string content = item.GetAttribute("Content"); if (!_textMapping.ContainsKey(code)) { _textMapping.Add(code, content); } } } #endregion }
void BGW_DoWork(object sender, DoWorkEventArgs e) { K12.Data.Configuration.ConfigData conf = K12.Data.School.Configuration[顯示成績Config]; conf["顯示成績"] = 顯示成績; conf.Save(); List <string> StudentIDList = K12.Presentation.NLDPanels.Student.SelectedSource; _doc = new Document(); _doc.Sections.Clear(); //清空此Document //取得設定檔 Campus.Report.ReportConfiguration ConfigurationInCadre = new Campus.Report.ReportConfiguration(CadreConfig); if (ConfigurationInCadre.Template == null) { //如果範本為空,則建立一個預設範本 Campus.Report.ReportConfiguration ConfigurationInCadre_1 = new Campus.Report.ReportConfiguration(CadreConfig); if (顯示成績 == "True") { ConfigurationInCadre_1.Template = new Campus.Report.ReportTemplate(Properties.Resources.社團參與證明單_score, Campus.Report.TemplateType.Word); } else { ConfigurationInCadre_1.Template = new Campus.Report.ReportTemplate(Properties.Resources.社團參與證明單, Campus.Report.TemplateType.Word); } _template = new Document(ConfigurationInCadre_1.Template.GetStream()); } else { //如果已有範本,則取得樣板 _template = new Document(ConfigurationInCadre.Template.GetStream()); } List <StudentRecord> StudList = Student.SelectByIDs(StudentIDList); //取得學生的 社團學期成績,與其它資料 //$K12.ResultScore.Shinmin //結算後,相關記錄會放在學生的社團學期成績 #region 社團學期成績 _StudentResultDic.Clear(); FISCA.UDT.AccessHelper _A = new FISCA.UDT.AccessHelper(); List <ResultScoreRecord> ResultList = _A.Select <ResultScoreRecord>(string.Format("ref_student_id in ('{0}')", string.Join("','", StudentIDList))); List <string> CLUBIDList = new List <string>(); List <string> StudentOkList = new List <string>(); foreach (ResultScoreRecord each in ResultList) { //if (string.IsNullOrEmpty(each.CadreName)) // continue; //if (!CLUBIDList.Contains(each.RefClubID)) //{ // if (each.RefClubID != "") // { // CLUBIDList.Add(each.RefClubID); // } //} if (!_StudentResultDic.ContainsKey(each.RefStudentID)) { _StudentResultDic.Add(each.RefStudentID, new List <ResultScoreRecord>()); } _StudentResultDic[each.RefStudentID].Add(each); if (!StudentOkList.Contains(each.RefStudentID)) { StudentOkList.Add(each.RefStudentID); } } #endregion if (StudentOkList.Count != 0) { // 入學照片 _PhotoPDict.Clear(); _PhotoPDict = K12.Data.Photo.SelectFreshmanPhoto(StudentOkList); // 畢業照片 _PhotoGDict.Clear(); _PhotoGDict = K12.Data.Photo.SelectGraduatePhoto(StudentOkList); } foreach (StudentRecord student in StudList) { List <string> name = new List <string>(); List <object> value = new List <object>(); if (_StudentResultDic.ContainsKey(student.ID)) { } else { continue; } name.Add("資料"); if (_StudentResultDic.ContainsKey(student.ID)) { value.Add(_StudentResultDic[student.ID]); //重點欄位 } else { value.Add(new List <ResultScoreRecord>()); } #region MailMerge name.Add("學校名稱"); value.Add(School.ChineseName); if (student.Class != null) { name.Add("班級"); value.Add(student.Class.Name); } else { name.Add("班級"); value.Add(""); } name.Add("座號"); value.Add(student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : ""); name.Add("姓名"); value.Add(student.Name); name.Add("學號"); value.Add(student.StudentNumber); name.Add("校長"); if (K12.Data.School.Configuration["學校資訊"].PreviousData != null) { if (K12.Data.School.Configuration["學校資訊"].PreviousData.SelectSingleNode("ChancellorChineseName") != null) { value.Add(K12.Data.School.Configuration["學校資訊"].PreviousData.SelectSingleNode("ChancellorChineseName").InnerText); } else { value.Add(""); } } else { value.Add(""); } if (_PhotoPDict.ContainsKey(student.ID)) { name.Add("新生照片1"); value.Add(_PhotoPDict[student.ID]); name.Add("新生照片2"); value.Add(_PhotoPDict[student.ID]); } if (_PhotoGDict.ContainsKey(student.ID)) { name.Add("畢業照片1"); value.Add(_PhotoGDict[student.ID]); name.Add("畢業照片2"); value.Add(_PhotoGDict[student.ID]); } #endregion //取得範本樣式 Document PageOne = (Document)_template.Clone(true); //PageOne.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(MailMerge_MergeField); PageOne.MailMerge.FieldMergingCallback = new MailMerge_MergeField(); PageOne.MailMerge.Execute(name.ToArray(), value.ToArray()); _doc.Sections.Add(_doc.ImportNode(PageOne.FirstSection, true)); } e.Result = _doc; }
public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard) { //學生資訊 key: studentID Dictionary <string, JHStudentRecord> students = new Dictionary <string, JHStudentRecord>(); //學生修課資訊 studentID -> List:SCAttendRecord Dictionary <string, List <JHSCAttendRecord> > scattends = new Dictionary <string, List <JHSCAttendRecord> >(); //學生修習的課程 courseID -> CourseRecord Dictionary <string, JHCourseRecord> courses = new Dictionary <string, JHCourseRecord>(); //所有課程(依學年度學期分開) schoolYear_semester -> (courseName -> CourseRecord) Dictionary <string, Dictionary <string, JHCourseRecord> > allcourses = new Dictionary <string, Dictionary <string, JHSchool.Data.JHCourseRecord> >(); //學生修習的課程對應的評量設定細節 Dictionary <string, List <JHAEIncludeRecord> > courseAe = new Dictionary <string, List <JHSchool.Data.JHAEIncludeRecord> >(); //學生的評量成績記錄 Dictionary <string, List <JHSCETakeRecord> > existSces = new Dictionary <string, List <JHSchool.Data.JHSCETakeRecord> >(); //所有試別 Dictionary <string, JHExamRecord> exams = new Dictionary <string, JHSchool.Data.JHExamRecord>(); // 取得努力程度對照 K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["努力程度對照表"]; if (!string.IsNullOrEmpty(cd["xml"])) { XmlElement element = XmlHelper.LoadXml(cd["xml"]); foreach (XmlElement each in element.SelectNodes("Effort")) { int code = int.Parse(each.GetAttribute("Code")); decimal score; if (!decimal.TryParse(each.GetAttribute("Score"), out score)) { score = 0; } if (!_EffortDict.ContainsKey(score)) { _EffortDict.Add(score, code); } } _ScoreList.AddRange(_EffortDict.Keys); _ScoreList.Reverse(); } wizard.PackageLimit = 3000; // 2018.09.05 [ischoolKingdom] Vicky依據 [02-01][03] 匯入評量成績 項目,移除文字描述。 wizard.ImportableFields.AddRange("學年度", "學期", "課程名稱", "評量名稱", "分數評量", "努力程度"); wizard.RequiredFields.AddRange("學年度", "學期", "課程名稱", "評量名稱"); wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e) { #region 取得學生資訊 foreach (JHStudentRecord stu in JHStudent.SelectByIDs(e.List)) { if (!students.ContainsKey(stu.ID)) { students.Add(stu.ID, stu); } } #endregion #region 取得修課記錄 MultiThreadWorker <string> loader1 = new MultiThreadWorker <string>(); loader1.MaxThreads = 3; loader1.PackageSize = 250; loader1.PackageWorker += delegate(object sender1, PackageWorkEventArgs <string> e1) { foreach (JHSCAttendRecord record in JHSCAttend.SelectByStudentIDAndCourseID(e1.List, new string[] { })) { if (!scattends.ContainsKey(record.RefStudentID)) { scattends.Add(record.RefStudentID, new List <JHSchool.Data.JHSCAttendRecord>()); } scattends[record.RefStudentID].Add(record); if (!courses.ContainsKey(record.RefCourseID)) { courses.Add(record.RefCourseID, null); } } }; loader1.Run(e.List); #endregion #region 取得課程資訊 MultiThreadWorker <string> loader2 = new MultiThreadWorker <string>(); loader2.MaxThreads = 3; loader2.PackageSize = 250; loader2.PackageWorker += delegate(object sender2, PackageWorkEventArgs <string> e2) { foreach (JHCourseRecord record in JHCourse.SelectByIDs(new List <string>(e2.List))) { if (courses.ContainsKey(record.ID)) { courses[record.ID] = record; } } }; loader2.Run(courses.Keys); foreach (JHCourseRecord course in JHCourse.SelectAll()) { string key = course.SchoolYear + "_" + course.Semester; if (!allcourses.ContainsKey(key)) { allcourses.Add(key, new Dictionary <string, JHSchool.Data.JHCourseRecord>()); } if (!allcourses[key].ContainsKey(course.Name)) { allcourses[key].Add(course.Name, course); } } #endregion #region 取得目前評量成績記錄 MultiThreadWorker <string> loader3 = new MultiThreadWorker <string>(); loader3.MaxThreads = 3; loader3.PackageSize = 250; loader3.PackageWorker += delegate(object sender3, PackageWorkEventArgs <string> e3) { foreach (JHSCETakeRecord sce in JHSCETake.SelectByStudentIDs(e3.List)) { if (!existSces.ContainsKey(sce.RefSCAttendID)) { existSces.Add(sce.RefSCAttendID, new List <JHSchool.Data.JHSCETakeRecord>()); } existSces[sce.RefSCAttendID].Add(sce); } }; loader3.Run(e.List); #endregion #region 取得評量設定 foreach (JHAEIncludeRecord ae in JHAEInclude.SelectAll()) { if (!courseAe.ContainsKey(ae.RefAssessmentSetupID)) { courseAe.Add(ae.RefAssessmentSetupID, new List <JHSchool.Data.JHAEIncludeRecord>()); } courseAe[ae.RefAssessmentSetupID].Add(ae); } #endregion #region 取得試別 foreach (JHExamRecord exam in JHExam.SelectAll()) { if (!exams.ContainsKey(exam.ID)) { exams.Add(exam.ID, exam); } } #endregion }; wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e) { int i = -1; decimal d = -1; #region 檢查學生是否存在 JHStudentRecord student = null; if (students.ContainsKey(e.Data.ID)) { student = students[e.Data.ID]; } else { e.ErrorMessage = "壓根就沒有這個學生" + e.Data.ID; return; } #endregion #region 驗證各個欄位格式 bool inputFormatPass = true; foreach (string field in e.SelectFields) { string value = e.Data[field]; switch (field) { default: break; case "學年度": case "學期": if (value == "" || !int.TryParse(value, out i)) { inputFormatPass &= false; e.ErrorFields.Add(field, "必須填入整數"); } break; case "課程名稱": if (value == "") { inputFormatPass &= false; e.ErrorFields.Add(field, "必須填入課程名稱"); } break; case "評量名稱": if (value == "") { inputFormatPass &= false; e.ErrorFields.Add(field, "必須填入評量名稱"); } break; case "分數評量": if (value != "" && !decimal.TryParse(value, out d)) { inputFormatPass &= false; e.ErrorFields.Add(field, "必須填入空白或數值"); } break; case "努力程度": if (value != "" && !int.TryParse(value, out i)) { inputFormatPass &= false; e.ErrorFields.Add(field, "必須填入空白或整數"); } else { // 2020/10/15 加入檢查,當分數與努力轉換後努力程度不同,需要顯示警告 if (value != "") { int x = ConvertEffort(d); if (x != i) { e.WarningFields.Add(field, "努力程度與使用分數轉換後不一致"); } } } break; // 2018.09.05 [ischoolKingdom] Vicky依據 [02-01][03] 匯入評量成績 項目,移除文字描述。 //case "文字描述": // break; } } #endregion //輸入格式正確才會針對情節做檢驗 #region 驗證各種情節 if (inputFormatPass) { string errorMessage = ""; string sy = e.Data["學年度"]; string se = e.Data["學期"]; string key = e.Data.ID + "_" + sy + "_" + se; string courseName = e.Data["課程名稱"]; string semsKey = sy + "_" + se; string examName = e.Data["評量名稱"]; //int schoolyear = Framework.Int.ParseInt(sy); //int semester = Framework.Int.ParseInt(se); #region 檢查課程是否存在系統中 bool noCourse = false; if (!allcourses.ContainsKey(semsKey)) { noCourse = true; errorMessage += (errorMessage == "" ? "" : "\n") + " 系統中找不到該課程"; } else if (!allcourses[semsKey].ContainsKey(courseName)) { noCourse = true; errorMessage += (errorMessage == "" ? "" : "\n") + " 系統中找不到該課程"; } else { } #endregion #region 檢查學生是否有修此課程 & 評量是否存在 bool attended = false; JHCourseRecord attendCourse = null; if (scattends.ContainsKey(e.Data.ID)) { foreach (JHSCAttendRecord record in scattends[e.Data.ID]) { bool HasRec = false; // 當有學年度學期課程名稱相同 if (courses[record.RefCourseID].Name == courseName && courses[record.RefCourseID].SchoolYear.HasValue && courses[record.RefCourseID].Semester.HasValue) { if ((courses[record.RefCourseID].SchoolYear.Value.ToString().Trim() == sy.Trim()) && courses[record.RefCourseID].Semester.Value.ToString().Trim() == se.Trim()) { HasRec = true; } } if (HasRec && courses.ContainsKey(record.RefCourseID)) { attendCourse = courses[record.RefCourseID]; } } } else //學生沒修半堂課 { } if (attendCourse == null && !noCourse) { if (!e.ErrorFields.ContainsKey("無修課記錄")) { e.ErrorFields.Add("無修課記錄", "學生在此學期並無修習此課程"); } } else if (attendCourse != null) { #region 驗證評量是否存在 if (string.IsNullOrEmpty(attendCourse.RefAssessmentSetupID)) { if (!e.ErrorFields.ContainsKey("無評量設定")) { e.ErrorFields.Add("無評量設定", "課程(" + attendCourse.Name + ")無評量設定"); } } else { if (!courseAe.ContainsKey(attendCourse.RefAssessmentSetupID)) { if (!e.ErrorFields.ContainsKey("無評量設定")) { e.ErrorFields.Add("無評量設定", "課程(" + attendCourse.Name + ")無評量設定"); } } else { bool examValid = false; foreach (JHAEIncludeRecord ae in courseAe[attendCourse.RefAssessmentSetupID]) { if (!exams.ContainsKey(ae.RefExamID)) { continue; } // 2016/7/26,穎驊新增,由於高雄國中希望可以加入匯出匯入"平時評量的功能",因此必須要在原本的Exam.Name驗證 // 加上 ||examName =="平時評量" ,避免平時評量的欄位被擋掉 if (exams[ae.RefExamID].Name == examName || examName == "平時評量") { examValid = true; } } if (!examValid) { if (!e.ErrorFields.ContainsKey("評量名稱無效")) { e.ErrorFields.Add("評量名稱無效", "評量名稱(" + examName + ")不存在系統中"); } } } } #endregion } #endregion e.ErrorMessage = errorMessage; } #endregion }; wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e) { Dictionary <string, List <RowData> > id_Rows = new Dictionary <string, List <RowData> >(); #region 分包裝 foreach (RowData data in e.Items) { if (!id_Rows.ContainsKey(data.ID)) { id_Rows.Add(data.ID, new List <RowData>()); } id_Rows[data.ID].Add(data); } #endregion List <KH.JHSCETakeRecord> insertList = new List <KH.JHSCETakeRecord>(); List <KH.JHSCETakeRecord> updateList = new List <KH.JHSCETakeRecord>(); // 檢查是否有努力程度欄位 bool isHasEffortField = false; //交叉比對各學生資料 #region 交叉比對各學生資料 foreach (string id in id_Rows.Keys) { JHStudentRecord studentRec = students[id]; foreach (RowData data in id_Rows[id]) { string examName = data["評量名稱"]; string courseName = data["課程名稱"]; string SchoolYear = data["學年度"]; string Semester = data["學期"]; if (isHasEffortField == false) { if (data.ContainsKey("努力程度")) { // 有努力程度這欄位 isHasEffortField = true; } } // 2016/7/26,穎驊新增bool值避免 在有"平時評量"的評量名稱Row 進入算評量成績的判斷式 bool isOrdinarilyScore = false; if (!scattends.ContainsKey(id)) { continue; } foreach (JHSCAttendRecord record in scattends[id]) { if (!courses.ContainsKey(record.RefCourseID)) { continue; } JHCourseRecord course = courses[record.RefCourseID]; //if (course.Name != courseName) continue; string sy = "", ss = ""; if (course.SchoolYear.HasValue) { sy = course.SchoolYear.Value.ToString(); } if (course.Semester.HasValue) { ss = course.Semester.Value.ToString(); } if (SchoolYear != sy || Semester != ss || course.Name != courseName) { continue; } KH.JHSCETakeRecord currentSCE = null; if (SchoolYear == sy && Semester == ss && course.Name == courseName) { // 2016/7/26,穎驊新增,由於高雄國中希望可以加入匯出匯入"平時評量的功能",在原本的Code努力尋找見縫插針的位子, //因為"平時評量"與一般的"評量成績"處理邏輯要分開 //後來決定這邊是最佳位子,邏輯為,當程序在一條一條讀取Excel Row時,讀到欄位"評量名稱"值為 "平時評量" //則進入我們處理平時評量的程序,如果欄位"評量名稱"值非為 "平時評量" 則使用它原本的邏輯處理 // 上面的CODE會幫忙進行學年、學期、課程的驗證,確保是同一門課程成績資料, //而 JHSCAttendRecord record內意外發現剛好有 平時評量OrdinarilyScore的欄位 //因此只要指定欄位為新的Excel 內的值,最後 使用JHSCAttend.Update(record) 更新即可 if (data.ContainsKey("評量名稱")) { if (data["評量名稱"] == "平時評量") { if (data.ContainsKey("分數評量")) { if (data["分數評量"] != null && data["分數評量"] != "") { decimal d; // 使用TryParse 的轉換,是因為可能會有Row 的分數評量欄位是空的(EX: 社團成績) ,直接Parse會爆 if (decimal.TryParse(data["分數評量"], out d)) { record.OrdinarilyScore = d; } } // 當分數評量是空白 if (data["分數評量"] != null && data["分數評量"].Trim() == "") { record.OrdinarilyScore = null; } } if (data.ContainsKey("努力程度")) { if (data["努力程度"] != null && data["努力程度"] != "") { int i; if (int.TryParse(data["努力程度"], out i)) { record.OrdinarilyEffort = i; } } if (data["努力程度"] != null && data["努力程度"].Trim() == "") { record.OrdinarilyEffort = null; } } // 2018.09.05 [ischoolKingdom] Vicky依據 [02-01][03] 匯入評量成績 項目,移除文字描述。 //if (data["文字描述"] != null) //{ // record.Text = data["文字描述"].ToString(); //} // 2020/10/15 宏安與小組會議討論,當沒有努力程度欄位,會使用成績轉換努力程度 if (isHasEffortField == false) { if (record.OrdinarilyScore.HasValue) { record.OrdinarilyEffort = ConvertEffort(record.OrdinarilyScore.Value); } else { record.OrdinarilyEffort = null; } } JHSCAttend.Update(record); isOrdinarilyScore = true; currentSCE = null; } else { if (existSces.ContainsKey(record.ID)) { foreach (KH.JHSCETakeRecord sce in existSces[record.ID].AsKHJHSCETakeRecords()) { if (!exams.ContainsKey(sce.RefExamID)) { continue; } if (exams[sce.RefExamID].Name == examName) { currentSCE = sce; } } } } } } // 2016/7/26,穎驊新增bool值避免 在有"平時評量"的評量名稱Row 進入算評量成績的判斷式 if (currentSCE != null && isOrdinarilyScore == false) { //bool changed = false; #region 填入資料 foreach (string field in e.ImportFields) { string value = data[field]; switch (field) { case "分數評量": if ("" + currentSCE.Score != value) { decimal d; if (decimal.TryParse(value, out d)) { currentSCE.Score = d; } else { currentSCE.Score = null; } // changed = true; } break; case "努力程度": if ("" + currentSCE.Effort != value) { int i; if (int.TryParse(value, out i)) { currentSCE.Effort = i; } else { currentSCE.Effort = null; } // changed = true; } break; // 2018.09.05 [ischoolKingdom] Vicky依據 [02-01][03] 匯入評量成績 項目,移除文字描述。 //case "文字描述": // if (currentSCE.Text != value) // { // currentSCE.Text = value; // changed = true; // } // break; } } #endregion // if (changed) updateList.Add(currentSCE); } // 2016/7/26,穎驊新增bool值避免 在有"平時評量"的評量名稱Row 進入算評量成績的判斷式 if (currentSCE == null && isOrdinarilyScore == false) { KH.JHSCETakeRecord newSCE = new KH.JHSCETakeRecord(new JHSCETakeRecord()); newSCE.RefStudentID = id; newSCE.RefSCAttendID = record.ID; newSCE.RefCourseID = record.RefCourseID; foreach (JHExamRecord exam in exams.Values) { if (exam.Name == examName) { newSCE.RefExamID = exam.ID; break; } } #region 填入資料 foreach (string field in e.ImportFields) { string value = data[field]; switch (field) { case "分數評量": if (value != "") { decimal d; if (decimal.TryParse(value, out d)) { newSCE.Score = d; } else { newSCE.Score = null; } } else { newSCE.Score = null; } break; case "努力程度": if (value != "") { int i; if (int.TryParse(value, out i)) { newSCE.Effort = i; } else { newSCE.Effort = null; } } else { newSCE.Effort = null; } break; // 2018.09.05 [ischoolKingdom] Vicky依據 [02-01][03] 匯入評量成績 項目,移除文字描述。 //case "文字描述": // newSCE.Text = value; // break; } } #endregion if (newSCE.RefExamID != "") { insertList.Add(newSCE); } } } } } try { // 解析並填入轉換空白的努力程度 // 2020/10/15 透過宏安討論,當沒有努力程度欄位才會使用成績轉換,如果有努力程度欄位不會使用成績轉換。 foreach (KH.JHSCETakeRecord rec in updateList) { //// 當努力程度沒有值卻有成績。 //if ((rec.Effort.HasValue == false) && rec.Score.HasValue) //{ // rec.Effort = ConvertEffort(rec.Score.Value); //} if (isHasEffortField == false) { if (rec.Score.HasValue) { rec.Effort = ConvertEffort(rec.Score.Value); } else { rec.Effort = null; } } } foreach (KH.JHSCETakeRecord rec in insertList) { //// 當努力程度沒有值卻有成績。 //if ((rec.Effort.HasValue == false) && rec.Score.HasValue) //{ // rec.Effort = ConvertEffort(rec.Score.Value); //} if (isHasEffortField == false) { if (rec.Score.HasValue) { rec.Effort = ConvertEffort(rec.Score.Value); } else { rec.Effort = null; } } } if (updateList.Count > 0) { #region 分批次兩路上傳 List <List <KH.JHSCETakeRecord> > updatePackages = new List <List <KH.JHSCETakeRecord> >(); List <List <KH.JHSCETakeRecord> > updatePackages2 = new List <List <KH.JHSCETakeRecord> >(); { List <KH.JHSCETakeRecord> package = null; int count = 0; foreach (KH.JHSCETakeRecord var in updateList) { if (count == 0) { package = new List <KH.JHSCETakeRecord>(30); count = 30; if ((updatePackages.Count & 1) == 0) { updatePackages.Add(package); } else { updatePackages2.Add(package); } } package.Add(var); count--; } } Thread threadUpdateSemesterSubjectScore = new Thread(new ParameterizedThreadStart(Update)); threadUpdateSemesterSubjectScore.IsBackground = true; threadUpdateSemesterSubjectScore.Start(updatePackages); Thread threadUpdateSemesterSubjectScore2 = new Thread(new ParameterizedThreadStart(Update)); threadUpdateSemesterSubjectScore2.IsBackground = true; threadUpdateSemesterSubjectScore2.Start(updatePackages2); threadUpdateSemesterSubjectScore.Join(); threadUpdateSemesterSubjectScore2.Join(); #endregion } } catch (Exception ex) { } if (insertList.Count > 0) { #region 分批次兩路上傳 List <List <KH.JHSCETakeRecord> > insertPackages = new List <List <KH.JHSCETakeRecord> >(); List <List <KH.JHSCETakeRecord> > insertPackages2 = new List <List <KH.JHSCETakeRecord> >(); { List <KH.JHSCETakeRecord> package = null; int count = 0; foreach (KH.JHSCETakeRecord var in insertList) { if (count == 0) { package = new List <KH.JHSCETakeRecord>(30); count = 30; if ((insertPackages.Count & 1) == 0) { insertPackages.Add(package); } else { insertPackages2.Add(package); } } package.Add(var); count--; } } Thread threadInsertSemesterSubjectScore = new Thread(new ParameterizedThreadStart(Insert)); threadInsertSemesterSubjectScore.IsBackground = true; threadInsertSemesterSubjectScore.Start(insertPackages); Thread threadInsertSemesterSubjectScore2 = new Thread(new ParameterizedThreadStart(Insert)); threadInsertSemesterSubjectScore2.IsBackground = true; threadInsertSemesterSubjectScore2.Start(insertPackages2); threadInsertSemesterSubjectScore.Join(); threadInsertSemesterSubjectScore2.Join(); #endregion } FISCA.LogAgent.ApplicationLog.Log("成績系統.匯入匯出", "匯入評量成績", "總共匯入" + (insertList.Count + updateList.Count) + "筆評量成績。"); #endregion }; }
private void btnRun_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cbxQuizName.Text)) { FISCA.Presentation.Controls.MsgBox.Show("請選擇匯入測驗名稱."); return; } // 儲存畫面選項設定 K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration[_ConfigData_Name]; cd[_ConfigData_ItemSnum] = rbStudentNumber.Checked.ToString(); cd[_ConfigData_ItemSeatNo] = rbClassSeatNo.Checked.ToString(); cd.Save(); foreach (DAO.UDT_QuizDef qd in _QuizDataList.Where(x => x.QuizName == cbxQuizName.Text).ToList()) { // 動態 XML XElement elmRoot = null; // 當選學號需要動態加入 if (rbStudentNumber.Checked) { elmRoot = XElement.Parse(Properties.Resources.ImportStudQuizDataVal_SNum); } // 當選班級座號需要動態加入 if (rbClassSeatNo.Checked) { elmRoot = XElement.Parse(Properties.Resources.ImportStudQuizDataVa_CSeatNo); } foreach (XElement elm1 in Utility.ConvertStringToXelm1(qd.QuizDataField).Elements("Field")) { XElement elm = new XElement("Field"); elm.SetAttributeValue("Required", "True"); elm.SetAttributeValue("Name", elm1.Attribute("name").Value); elmRoot.Element("FieldList").Add(elm); } Global._ImportStudQuizDataValElement = elmRoot; //// 取得該試別所有測驗 //List<DAO.UDT_StudQuizDataDef> studQuizList = _UDTTransfer.GetStudQuizDataByQuizID(qd.UID); //List<string> sidlist = (from data in studQuizList select data.StudentID.ToString()).ToList (); //foreach (K12.Data.StudentRecord stud in K12.Data.Student.SelectByIDs(sidlist)) //{ // if (!Global._HasStudQuizDataDictTemp.ContainsKey(stud.StudentNumber)) // Global._HasStudQuizDataDictTemp.Add(stud.StudentNumber, stud.ID); //} // 依測驗ID取得已有資料的學生學號 Global._HasStudQuizDataDictTemp = Utility.GetHasCounselStudQuizDataStudNumberByQuizID(qd.UID); ImportExport.ImportStudQuizData isqd = new ImportExport.ImportStudQuizData(); isqd.SetQuizID(qd.UID); isqd.SetQuizName(qd.QuizName); List <string> dataFieldList = (from data in Utility.ConvertStringToXelm1(qd.QuizDataField).Elements("Field") select data.Attribute("name").Value).ToList(); isqd.SetDataFieldNameList(dataFieldList); isqd.Execute(); } this.Close(); }
/// <summary> /// 取的 xml 內大項目名稱 /// </summary> /// <returns></returns> public static Dictionary <string, string> GetDLBehaviorConfigNameDict() { Dictionary <string, string> retVal = new Dictionary <string, string>(); try { // 包含新竹與高雄 K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["DLBehaviorConfig"]; if (!string.IsNullOrEmpty(cd["DailyBehavior"])) { string key = "DailyBehavior"; //日常行為表現 XElement e1 = XElement.Parse(cd["DailyBehavior"]); string name = e1.Attribute("Name").Value; retVal.Add(key, name); } if (!string.IsNullOrEmpty(cd["OtherRecommend"])) { //其它表現 XElement e2 = XElement.Parse(cd["OtherRecommend"]); string name = e2.Attribute("Name").Value; retVal.Add("OtherRecommend", name); } if (!string.IsNullOrEmpty(cd["DailyLifeRecommend"])) { //日常生活表現具體建議 XElement e3 = XElement.Parse(cd["DailyLifeRecommend"]); string name = e3.Attribute("Name").Value; retVal.Add("DailyLifeRecommend", name); // 高雄 } if (!string.IsNullOrEmpty(cd["GroupActivity"])) { string key = "GroupActivity"; //團體活動表現 XElement e4 = XElement.Parse(cd["GroupActivity"]); string name = e4.Attribute("Name").Value; retVal.Add(key, name); } if (!string.IsNullOrEmpty(cd["PublicService"])) { string key = "PublicService"; //公共服務表現 XElement e5 = XElement.Parse(cd["PublicService"]); string name = e5.Attribute("Name").Value; retVal.Add(key, name); } if (!string.IsNullOrEmpty(cd["SchoolSpecial"])) { string key = "SchoolSpecial"; //校內外特殊表現,新竹沒有子項目,高雄有子項目 XElement e6 = XElement.Parse(cd["SchoolSpecial"]); string name = e6.Attribute("Name").Value; retVal.Add(key, name); } } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("日常生活表現設定檔解析失敗!" + ex.Message); } return(retVal); }
private void btnNext_Click(object sender, EventArgs e) { if (!IsValid()) { return; } // 取得畫面賞用者所選的課程ID Global._selectCourseIDList.Clear(); foreach (ListViewItem lv in lvSubject.CheckedItems) { foreach (KeyValuePair <string, string> str in Global._CourseIDSubjectDict) { if (str.Value == lv.Text) { Global._selectCourseIDList.Add(str.Key); } } } // 儲存試別 //Campus.Configuration.ConfigData cd = Campus.Configuration.Config.App["高雄個人評量成績單試別"]; //cd["高雄個人評量成績單試別"] = cbExam.Text; //cd.Save(); K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["高雄個人評量成績單試別"]; cd["高雄個人評量成績單試別"] = cbExam.Text; cd.Save(); ReportConfiguration rc = new ReportConfiguration(Global.ReportName); rc.SetString("缺曠獎懲統計開始日期", txtSDate.Text); rc.SetString("缺曠獎懲統計結束日期", txtEDate.Text); rc.SetString("成績校正日期", txtCorrect.Text); rc.Save(); JHExamRecord exam = cbExam.SelectedItem as JHExamRecord; DateTime from = DateTime.Parse(txtSDate.Text); DateTime to = DateTime.Parse(txtEDate.Text); List <JHStudentRecord> students = GetStudents(); students.Sort(delegate(JHStudentRecord x, JHStudentRecord y) { JHClassRecord c1 = x.Class; JHClassRecord c2 = y.Class; if (x.Class == null) { return(-1); } if (y.Class == null) { return(1); } if (c1.ID == c2.ID) { int seatNo1 = x.SeatNo.HasValue ? x.SeatNo.Value : int.MinValue; int seatNo2 = y.SeatNo.HasValue ? y.SeatNo.Value : int.MinValue; if (seatNo1 == seatNo2) { return(x.StudentNumber.CompareTo(y.StudentNumber)); } else { return(seatNo1.CompareTo(seatNo2)); } } else { return(c1.Name.CompareTo(c2.Name)); } }); _config.SetExam(exam); _config.SetDateRange(from, to); _config.SetStudents(students); _config.SchoolYear = iptSchoolYear.Value; _config.Semester = iptSemester.Value; _config.Load(); Report report = new Report(_config); report.Generate(); this.DialogResult = DialogResult.OK; }
private void CourseAttendance_Load(object sender, EventArgs e) { form_loaded = false; config = K12.Data.School.Configuration["台大EMBA缺課通知寄件人資訊"]; if (config != null) { this.txtSenderEMail.Text = config["SenderEMail"]; this.txtSenderName.Text = config["SenderName"]; this.txtCC.Text = config["CC"]; this.from_email = config["SenderEMail"]; this.from_name = config["SenderName"]; string[] ccs = config["CC"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string cc in ccs) { if (cc.Trim().Length > 0) this.validated_cc.Add(cc); } } this.SetConf(); this.InitSemesterCourses(); }
public OnlineRollCall() { InitializeComponent(); /// 取得上次設定的資料 AccessHelper access = new AccessHelper(); List <AbsenceUDT> SettingData = access.Select <AbsenceUDT>(); // 取得假別對照表 K12.Data.Configuration.ConfigData _attendType = K12.Data.School.Configuration["假別對照表"]; XDocument attendType = XDocument.Parse(_attendType.PreviousData.OuterXml); List <XElement> absenceList = attendType.Element("AbsenceList").Elements("Absence").ToList(); // 取得節次對照表 K12.Data.Configuration.ConfigData _period = K12.Data.School.Configuration["節次對照表"]; XDocument period = XDocument.Parse(_period.PreviousData.OuterXml); List <XElement> periodList = period.Element("Periods").Elements("Period").ToList(); _endRowIndex = periodList.Count(); #region Init DataGridView #region col int index = 2; foreach (XElement absence in absenceList) { DataGridViewCheckBoxColumn CheckBoxColumn = new DataGridViewCheckBoxColumn(); CheckBoxColumn.Name = absence.Attribute("Abbreviation").Value; // Abbr CheckBoxColumn.HeaderText = absence.Attribute("Name").Value; // Name CheckBoxColumn.Width = 42; dataGridViewX1.Columns.Insert(index, CheckBoxColumn); // 紀錄缺曠類別第幾個欄位 abIndexDic.Add(index++, absence.Attribute("Name").Value); } DataGridViewComboBoxColumn dgvcbx = new DataGridViewComboBoxColumn(); dgvcbx.Items.Add("班導師"); dgvcbx.Items.Add("授課教師"); dgvcbx.Name = "actor"; dgvcbx.HeaderText = "點名對象"; dataGridViewX1.Columns.Insert(index, dgvcbx); #endregion #region row int row = 0; int _actor = dataGridViewX1.Columns["actor"].Index; int _starTime = dataGridViewX1.Columns["star_time"].Index; int _endTime = dataGridViewX1.Columns["end_time"].Index; foreach (XElement p in periodList) { DataGridViewRow datarow = new DataGridViewRow(); datarow.CreateCells(dataGridViewX1); datarow.Cells[0].Value = p.Attribute("Name").Value; List <string> abbrList = new List <string>(); int column = 0; foreach (AbsenceUDT data in SettingData) { // 節次符合 if (data.Period == p.Attribute("Name").Value&& data.Absence != null) { for (int i = 2; i < abIndexDic.Count() + 2; i++) { string search = data.Absence; // 在上設定中搜尋到相同缺曠類別設定,checkbox勾起來 if (search.IndexOf("\"Name\":\"" + abIndexDic[i] + "\"") > 0) { datarow.Cells[i].Value = true; abbrList.Add(dataGridViewX1.Columns[i].Name); //datarow.Cells[1].Value += dataGridViewX1.Columns[i].Name + " "; } } datarow.Cells[_actor].Value = data.Actor == "" ? "授課教師" : data.Actor; datarow.Cells[_starTime].Value = data.StarTime.ToString() == "0001/1/1 上午 12:00:00" ? "00:00:00" : data.StarTime.ToString("%H:mm:ss"); datarow.Cells[_endTime].Value = data.EndTime.ToString() == "0001/1/1 上午 12:00:00" ? "00:00:00" : data.EndTime.ToString("%H:mm:ss"); } datarow.Cells[1].Value = string.Join("、", abbrList); column++; } row++; dataGridViewX1.Rows.Add(datarow); } dataGridViewX1.Rows[0].Cells[_starTime].ReadOnly = false; dataGridViewX1.Rows[0].Cells[_starTime].Style.BackColor = Color.White; #endregion #endregion initFinish = true; }
/// <summary> /// 取得系統內設定自訂欄位資料項目與型態 /// </summary> /// <returns></returns> public static Dictionary <string, string> GetUserConfigData() { K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["ischoolUserDefineData"]; return(XMLToDictP1(cd["UserConfigData"])); }