private void buttonX3_Click(object sender, EventArgs e) { if (MsgBox.Show("您確定要刪除此學年成績?", "", MessageBoxButtons.YesNo) == DialogResult.No) { return; } foreach (XmlElement var in QueryScore.GetSchoolYearEntryScoreBySchoolYearGradeYear(int.Parse(listView1.SelectedItems[0].SubItems[0].Text), int.Parse(listView1.SelectedItems[0].SubItems[1].Text), _CurrentID).GetContent().GetElements("SchoolYearEntryScore")) { RemoveScore.DeleteSchoolYearEntityScore(var.SelectSingleNode("@ID").InnerText); } foreach (XmlElement var in QueryScore.GetSchoolYearSubjectScoreBySchoolYearGradeYear(int.Parse(listView1.SelectedItems[0].SubItems[0].Text), int.Parse(listView1.SelectedItems[0].SubItems[1].Text), _CurrentID).GetContent().GetElements("SchoolYearSubjectScore")) { RemoveScore.DeleteSchoolYearSubjectScore(var.SelectSingleNode("@ID").InnerText); } // 刪除學年成績 log StringBuilder deleteDesc = new StringBuilder(""); deleteDesc.AppendLine("學生姓名:" + Student.Instance.Items[_CurrentID].Name + " "); deleteDesc.AppendLine("刪除 " + listView1.SelectedItems[0].SubItems[0].Text + " 學年度 學年成績"); CurrentUser.Instance.AppLog.Write(EntityType.Student, EntityAction.Delete, _CurrentID, deleteDesc.ToString(), Title, ""); EventHub.Instance.InvokScoreChanged(_CurrentID); }
private void buttonX1_Click(object sender, EventArgs e) { dataGridViewX1.EndEdit(); if (!ValidateAll()) { return; } #region 新增修改科目成績資料 XmlDocument doc = new XmlDocument(); XmlElement subjectScoreInfo = doc.CreateElement("SchoolYearSubjectScore"); afterXml.AddElement("SubjectGradeYear", "GradeYear", comboBoxEx3.Text); foreach (DataGridViewRow row in dataGridViewX1.Rows) { if (row.IsNewRow) { break; } XmlElement subjectElement = doc.CreateElement("Subject"); subjectElement.SetAttribute("科目", "" + row.Cells[0].Value); subjectElement.SetAttribute("學年成績", "" + row.Cells[1].Value); subjectElement.SetAttribute("結算成績", "" + row.Cells[2].Value); subjectElement.SetAttribute("補考成績", "" + row.Cells[3].Value); subjectElement.SetAttribute("重修成績", "" + row.Cells[4].Value); subjectElement.SetAttribute("校部定", "" + row.Cells[5].Value); subjectElement.SetAttribute("必選修", "" + row.Cells[6].Value); subjectElement.SetAttribute("識別學分數", "" + row.Cells[7].Value); subjectScoreInfo.AppendChild(subjectElement); afterXml.AddElement("SubjectCollection", subjectElement); } if (_SubjectScoreID != "") { if (subjectScoreInfo.SelectNodes("Subject").Count == 0) { RemoveScore.DeleteSchoolYearSubjectScore(_SubjectScoreID); } else { EditScore.UpdateSchoolYearSubjectScore(_SubjectScoreID, comboBoxEx3.Text, subjectScoreInfo); } } else if (subjectScoreInfo.SelectNodes("Subject").Count > 0) { AddScore.InsertSchoolYearSubjectScore(_StudentID, comboBoxEx1.Text, comboBoxEx3.Text, subjectScoreInfo); } #endregion #region 新增修改分項成績資料 XmlElement entryScoreInfo; XmlElement entryElement; double test = 0; #region 行為類 if (double.TryParse(textBoxX2.Text, out test)) { entryScoreInfo = doc.CreateElement("SchoolYearEntryScore"); entryElement = doc.CreateElement("Entry"); entryElement.SetAttribute("分項", "德行"); entryElement.SetAttribute("成績", textBoxX2.Text); entryScoreInfo.AppendChild(entryElement); afterXml.AddElement("EntryCollection", entryElement); if (_EntryScoreID2 != "") { EditScore.UpdateSchoolYearEntryScore(_EntryScoreID2, comboBoxEx3.Text, entryScoreInfo); } else { AddScore.InsertSchoolYearEntryScore(_StudentID, comboBoxEx1.Text, comboBoxEx3.Text, "行為", entryScoreInfo); } } else { if (_EntryScoreID2 != "") { RemoveScore.DeleteSchoolYearEntityScore(_EntryScoreID2); } } #endregion #region 學習類 if (double.TryParse(textBoxX1.Text, out test) || double.TryParse(textBoxX3.Text, out test) || double.TryParse(textBoxX5.Text, out test) || double.TryParse(textBoxX4.Text, out test) || double.TryParse(textBoxX6.Text, out test) || double.TryParse(textBoxX7.Text, out test)) { entryScoreInfo = doc.CreateElement("SchoolYearEntryScore"); if (double.TryParse(textBoxX1.Text, out test)) { entryElement = doc.CreateElement("Entry"); entryElement.SetAttribute("分項", "學業"); entryElement.SetAttribute("成績", textBoxX1.Text); entryScoreInfo.AppendChild(entryElement); afterXml.AddElement("EntryCollection", entryElement); } if (double.TryParse(textBoxX3.Text, out test)) { entryElement = doc.CreateElement("Entry"); entryElement.SetAttribute("分項", "體育"); entryElement.SetAttribute("成績", textBoxX3.Text); entryScoreInfo.AppendChild(entryElement); afterXml.AddElement("EntryCollection", entryElement); } if (double.TryParse(textBoxX5.Text, out test)) { entryElement = doc.CreateElement("Entry"); entryElement.SetAttribute("分項", "健康與護理"); entryElement.SetAttribute("成績", textBoxX5.Text); entryScoreInfo.AppendChild(entryElement); afterXml.AddElement("EntryCollection", entryElement); } if (double.TryParse(textBoxX4.Text, out test)) { entryElement = doc.CreateElement("Entry"); entryElement.SetAttribute("分項", "國防通識"); entryElement.SetAttribute("成績", textBoxX4.Text); entryScoreInfo.AppendChild(entryElement); afterXml.AddElement("EntryCollection", entryElement); } if (double.TryParse(textBoxX6.Text, out test)) { entryElement = doc.CreateElement("Entry"); entryElement.SetAttribute("分項", "實習科目"); entryElement.SetAttribute("成績", textBoxX6.Text); entryScoreInfo.AppendChild(entryElement); afterXml.AddElement("EntryCollection", entryElement); } if (double.TryParse(textBoxX7.Text, out test)) { entryElement = doc.CreateElement("Entry"); entryElement.SetAttribute("分項", "專業科目"); entryElement.SetAttribute("成績", textBoxX7.Text); entryScoreInfo.AppendChild(entryElement); afterXml.AddElement("EntryCollection", entryElement); } if (_EntryScoreID1 != "") { EditScore.UpdateSchoolYearEntryScore(_EntryScoreID1, comboBoxEx3.Text, entryScoreInfo); } else { AddScore.InsertSchoolYearEntryScore(_StudentID, comboBoxEx1.Text, comboBoxEx3.Text, "學習", entryScoreInfo); } } else { if (_EntryScoreID1 != "") { RemoveScore.DeleteSchoolYearEntityScore(_EntryScoreID1); } } #endregion #endregion #region 處理Log StringBuilder desc = new StringBuilder(""); desc.AppendLine("學生姓名:" + Student.Instance.Items[_StudentID].Name + " "); desc.AppendLine(comboBoxEx1.Text + " 學年度 "); #region 處理成績年級log if (beforeXml.GetText("SubjectGradeYear/GradeYear") != afterXml.GetText("SubjectGradeYear/GradeYear")) { desc.AppendLine("成績年級由「" + beforeXml.GetText("SubjectGradeYear/GradeYear") + "」變更為「" + afterXml.GetText("SubjectGradeYear/GradeYear") + "」"); } #endregion #region 處理科目成績log foreach (XmlElement var in beforeXml.GetElements("SubjectCollection/Subject")) { if (!beforeData.ContainsKey(var.GetAttribute("科目"))) { beforeData.Add(var.GetAttribute("科目"), var.GetAttribute("結算成績") == "" ? var.GetAttribute("學年成績") : var.GetAttribute("結算成績")); } } foreach (XmlElement var in afterXml.GetElements("SubjectCollection/Subject")) { if (!afterData.ContainsKey(var.GetAttribute("科目"))) { afterData.Add(var.GetAttribute("科目"), var.GetAttribute("結算成績")); } } desc.AppendLine("學年科目成績:"); foreach (string var in beforeData.Keys) { if (!afterData.ContainsKey(var)) { desc.AppendLine("刪除科目「" + var + "」"); } else { if (beforeData[var] != afterData[var]) { desc.AppendLine("科目「" + var + "」的「結算成績」由「" + beforeData[var] + "」變更為「" + afterData[var] + "」"); } foreach (string key in new string[] { "補考成績", "重修成績" }) { string bk = beforeXml.GetElement("SubjectCollection/Subject[@科目='" + var + "']").GetAttribute(key); string ak = afterXml.GetElement("SubjectCollection/Subject[@科目='" + var + "']").GetAttribute(key); if (bk != ak) { desc.AppendLine("科目「" + var + "」的「" + key + "」由「" + bk + "」變更為「" + ak + "」"); } } afterData.Remove(var); } } foreach (string var in afterData.Keys) { desc.AppendLine("新增科目「" + var + "」"); if (afterData[var] != "") { desc.AppendLine("科目「" + var + "」的「學年成績」由「」變更為「" + afterData[var] + "」"); } foreach (string key in new string[] { "補考成績", "重修成績" }) { string ak = afterXml.GetElement("SubjectCollection/Subject[@科目='" + var + "']").GetAttribute(key); if (ak != "") { desc.AppendLine("科目「" + var + "」的「" + key + "」由「」變更為「" + ak + "」"); } } } beforeData.Clear(); afterData.Clear(); #endregion #region 處理分項成績log foreach (XmlElement var in beforeXml.GetElements("EntryCollection/Entry")) { if (!beforeData.ContainsKey(var.GetAttribute("分項"))) { beforeData.Add(var.GetAttribute("分項"), var.GetAttribute("成績")); } if (!afterData.ContainsKey(var.GetAttribute("分項"))) { afterData.Add(var.GetAttribute("分項"), ""); } } foreach (XmlElement var in afterXml.GetElements("EntryCollection/Entry")) { if (!afterData.ContainsKey(var.GetAttribute("分項"))) { afterData.Add(var.GetAttribute("分項"), var.GetAttribute("成績")); } else { afterData[var.GetAttribute("分項")] = var.GetAttribute("成績"); } if (!beforeData.ContainsKey(var.GetAttribute("分項"))) { beforeData.Add(var.GetAttribute("分項"), ""); } } desc.AppendLine("學年分項成績:"); foreach (string var in afterData.Keys) { if (beforeData[var] != afterData[var]) { desc.AppendLine("「" + var + "成績」由「" + beforeData[var] + "」變更為「" + afterData[var] + "」"); } } #endregion CurrentUser.Instance.AppLog.Write(EntityType.Student, entityAction, _StudentID, desc.ToString(), Text, afterXml.GetRawXml()); #endregion EventHub.Instance.InvokScoreChanged(_StudentID); this.Close(); }
private void M030104_ItemClick(object sender, ItemClickEventArgs e) { RemoveScore remove = new RemoveScore(); remove.ShowDialog(); }
private void removeScore_ItemClicked(object sender, EventArgs e) { RemoveScore removeScore = new RemoveScore(); removeScore.Show(); }
private void removeScoreToolStripMenuItem_Click(object sender, EventArgs e) { Form removeScore = new RemoveScore(); removeScore.ShowDialog(); }