private int MoralScoreSort(MoralScoreRecord x, MoralScoreRecord y) { string xx = x.SchoolYear.ToString() + x.Semester.ToString(); string yy = y.SchoolYear.ToString() + y.Semester.ToString(); return(xx.CompareTo(yy)); }
private int SortMoralScore(MoralScoreRecord x1, MoralScoreRecord x2) { string schoolyear1 = x1.SchoolYear.ToString().PadLeft(5, '0'); schoolyear1 += x1.Semester.ToString().PadLeft(5, '0'); string schoolyear2 = x2.SchoolYear.ToString().PadLeft(5, '0'); schoolyear2 += x2.Semester.ToString().PadLeft(5, '0'); return(schoolyear1.CompareTo(schoolyear2)); }
/// <summary> /// Constructor,為修改模式使用 /// </summary> /// <param name="demeritRecord"></param> public MoralScoreRecordEditor(MoralScoreRecord updateRecord) { UpdateRecord = updateRecord; Remove = false; RefStudentID = UpdateRecord.RefStudentID; ID = UpdateRecord.ID; SchoolYear = updateRecord.SchoolYear; Semester = updateRecord.Semester; TextScore = updateRecord.TextScore; }
public static MoralScoreRecordEditor GetEditor(this MoralScoreRecord record) { return(new MoralScoreRecordEditor(record)); }
/// <summary> /// 自動修正選擇資料 /// </summary> /// <param name="EntityIDs">修正資料的ID</param> public void ExecuteAutoCorrect(IEnumerable <string> EntityIDs) { StringBuilder sb_Help = new StringBuilder(); sb_Help.AppendLine("錯誤資料情境說明:"); sb_Help.AppendLine("懲戒明細 =警告(0/2)<-未銷過/已銷過"); sb_Help.AppendLine("懲戒非明細=警告(2)<---一般生之非明細資料應該為0"); sb_Help.AppendLine("懲戒統計 =警告(2)<---自動統計數值不正確"); sb_Help.AppendLine(""); sb_Help.AppendLine("自動修正功能將會修正為:"); sb_Help.AppendLine("懲戒明細 =警告(0/2)<-未銷過/已銷過"); sb_Help.AppendLine("懲戒非明細=警告(0)<---非明細已被修正為0(減去銷過支數)"); sb_Help.AppendLine("懲戒統計 =警告(0)<---統計值等於(未銷過明細)即為正確狀態"); sb_Help.AppendLine(""); sb_Help.AppendLine("您確定要進行資料修正?"); DialogResult dr = MsgBox.Show(sb_Help.ToString(), "進行自動修正前您必須瞭解...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (dr == DialogResult.No) { return; } //Log StringBuilder sb = new StringBuilder(); List <MoralScoreRecord> list = new List <MoralScoreRecord>(); //如果是null / 表示修正所有資料 if (K12.Data.Utility.Utility.IsNullOrEmpty(EntityIDs)) { sb.AppendLine("已進行:懲戒明細不等於自動統計檢查"); sb.AppendLine("自動修正「所有」之錯誤資料"); sb.AppendLine("詳細資料如下:"); sb.AppendLine(""); foreach (DemeritDetailClearedButSummaryNotClearedRATRecord APeach in RATRecords) { List <string> strList = APeach.自動統計鍵值.Split(',').ToList();//系統編號+學年度+學期 if (Dic.ContainsKey(strList[0])) { sb.AppendLine("學生:「" + Dic[strList[0]].StudentRecord.Name + "」學年度:「" + strList[1] + "」學期:「" + strList[2] + "」"); MoralScoreRecord msr = setInitialSummary(sb, strList[1], strList[2], Dic[strList[0]]); if (msr != null) { list.Add(msr); } } } } else //將傳入的ID以逗號分割,並且取得缺曠編號 { sb.AppendLine("已進行懲戒明細不等於自動統計檢查"); sb.AppendLine("自動修正「已選擇」之錯誤項目"); sb.AppendLine("詳細資料如下:"); sb.AppendLine(""); foreach (string Entityeach in EntityIDs) { List <string> strList = Entityeach.Split(',').ToList();//系統編號+學年度+學期 if (Dic.ContainsKey(strList[0])) { sb.AppendLine("學生:「" + Dic[strList[0]].StudentRecord.Name + "」學年度:「" + strList[1] + "」學期:「" + strList[2] + "」"); MoralScoreRecord msr = setInitialSummary(sb, strList[1], strList[2], Dic[strList[0]]); if (msr != null) { list.Add(msr); } } } } try { MoralScore.Update(list); //更新InitialSummary資料 } catch (Exception ex) { MsgBox.Show("自動修正失敗\n" + ex.Message); return; } ApplicationLog.Log("資料合理性檢查", "懲戒明細不等於自動統計檢查", sb.ToString()); MsgBox.Show("自動修正已完成。\n\n請重新執行資料合理性檢查\n以確保資料清單正確性\n避免對資料進行重覆修正。"); }