public Version1(ISemester semester, List <IGroup> groups, List <IClassRoom> classRooms, List <IPlanOfLessons> planOfLessons, List <ITeacher> teachers, List <ITimeLessons> timeLessons) { this.semester = semester ?? throw new ArgumentNullException(nameof(semester)); if (groups == null || groups.Count == 0) { throw new ArgumentNullException(nameof(groups)); } if (classRooms == null || classRooms.Count == 0) { throw new ArgumentNullException(nameof(classRooms)); } if (planOfLessons == null || planOfLessons.Count == 0) { throw new ArgumentNullException(nameof(planOfLessons)); } if (teachers == null || teachers.Count == 0) { throw new ArgumentNullException(nameof(teachers)); } if (timeLessons == null || timeLessons.Count == 0) { throw new ArgumentNullException(nameof(timeLessons)); } this.groups = groups; this.classRooms = classRooms; this.planOfLessons = planOfLessons; this.teachers = teachers; this.timeLessons = timeLessons; }
public FillPaper(ISubject subject, IPaper paper, IExamType examType, ISession session, ISemester semester) { _subject = subject; _paper = paper; _examType = examType; _session = session; _semester = semester; }
public static ISemester GetInstance() { if (_provider == null) { _provider = new BaseSemesterProvider(); } return(_provider); }
public PaperViewModel(IExamType Examtype, ISession session, IPaper paper, ISemester semester, ISubject subject) { _examType = Examtype; _session = session; _paper = paper; _semester = semester; _subject = subject; }
public AddpapersController(IExamType examType, ISession session, ISemester semester, IFillPaper fillPaper, IVersion version) { _examType = examType; _session = session; _semester = semester; _fillPaper = fillPaper; _version = version; }
public MutiEditor(List <StudentRecord> students) { InitializeComponent(); //設計工具產生的 _students = students; _absenceList = new Dictionary <string, AbsenceInfo>(); _semesterProvider = SemesterProvider.GetInstance(); _hiddenRows = new List <DataGridViewRow>(); }
public TestSingleEditor(List <string> studentList) { InitializeComponent(); //設計工具產生的 _errorProvider = new ErrorProvider(); _studentList = studentList; _absenceList = new Dictionary <string, AbsenceInfo>(); _semesterProvider = SemesterProvider.GetInstance(); _hiddenRows = new List <DataGridViewRow>(); }
public void ConstructorTest_SemesterToNULL_CallArgumentNullException() { Reset(); semester = null; Assert.ThrowsException <ArgumentNullException>(() => { return(new Version1(semester, groups, classRooms, planOfLessons, teachers, timeLessons)); }); }
public void FreeTest_HZ() { Reset(); List <IDaysOfStudy> daysOfStudies = new List <IDaysOfStudy>(); for (int i = 0; i < 10; i++) { var temp = A.Fake <IDaysOfStudy>(); temp.Date = DateTime.Now.Date.AddDays(i); temp.Study = HowDays.WorkingDay; daysOfStudies.Add(temp); } List <ITimeLessons> timeLessons = new List <ITimeLessons>(); for (int i = 0; i < 6; i++) { var temp = A.Fake <ITimeLessons>(); temp.NumberLessons = i + 1; timeLessons.Add(temp); } ISemester semester = A.Fake <ISemester>(); semester.DaysOfStudies = daysOfStudies.ToArray(); Version1 version1 = new Version1(semester, groups, classRooms, planOfLessons, teachers, timeLessons); var frees = version1.Free(); int ind1 = 0; foreach (var free in frees) { Assert.AreEqual(daysOfStudies[ind1++].Date.Date, free.dateTime); int ind2 = 0; foreach (var lesson in free.Lessons) { Assert.AreEqual(timeLessons[ind2++].NumberLessons, lesson.numberLesson); Assert.AreEqual(null, lesson.infoLesson); } } }
public void Reset() { semester = A.Fake <ISemester>(); groups = new List <IGroup> { A.Fake <IGroup>() }; classRooms = new List <IClassRoom> { A.Fake <IClassRoom>() }; planOfLessons = new List <IPlanOfLessons> { A.Fake <IPlanOfLessons>() }; teachers = new List <ITeacher> { A.Fake <ITeacher>() }; timeLessons = new List <ITimeLessons> { A.Fake <ITimeLessons>() }; }
//儲存 private void btnSave_Click(object sender, EventArgs e) { #region Save if (!IsValid()) { FISCA.Presentation.Controls.MsgBox.Show("資料驗證失敗,請修正後再行儲存", "驗證失敗", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } List <SHAttendanceRecord> InsertHelper = new List <SHAttendanceRecord>(); //新增 List <SHAttendanceRecord> updateHelper = new List <SHAttendanceRecord>(); //更新 List <string> deleteList = new List <string>(); //清空 //List<string> synclist = new List<string>(); ISemester semester = SemesterProvider.GetInstance(); foreach (DataGridViewRow row in dataGridView.Rows) { RowTag tag = row.Tag as RowTag; semester.SetDate(tag.Date); ////log 紀錄修改後的資料 日期部分 if (row.Cells[0].Tag is string) { if (!LOG[row.Cells[0].Tag.ToString()].afterData.ContainsKey(tag.Date.ToShortDateString())) { LOG[row.Cells[0].Tag.ToString()].afterData.Add(tag.Date.ToShortDateString(), new Dictionary <string, string>()); } } else { SHAttendanceRecord attRecord = row.Cells[0].Tag as SHAttendanceRecord; if (!LOG[attRecord.RefStudentID].afterData.ContainsKey(tag.Date.ToShortDateString())) { LOG[attRecord.RefStudentID].afterData.Add(tag.Date.ToShortDateString(), new Dictionary <string, string>()); } } if (tag.IsNew) { #region IsNew string studentID = row.Cells[0].Tag as string; SHAttendanceRecord attRecord = new SHAttendanceRecord(); bool hasContent = false; for (int i = _startIndex; i < dataGridView.Columns.Count; i++) { DataGridViewCell cell = row.Cells[i]; if (string.IsNullOrEmpty(("" + cell.Value).Trim())) { continue; } PeriodInfo pinfo = dataGridView.Columns[i].Tag as PeriodInfo; AbsenceCellInfo acInfo = cell.Tag as AbsenceCellInfo; AbsenceInfo ainfo = acInfo.AbsenceInfo; K12.Data.AttendancePeriod ap = new K12.Data.AttendancePeriod(); ap.Period = pinfo.Name; ap.AbsenceType = ainfo.Name; attRecord.PeriodDetail.Add(ap); hasContent = true; //log 紀錄修改後的資料 缺曠明細部分 if (!LOG[studentID].afterData[tag.Date.ToShortDateString()].ContainsKey(pinfo.Name)) { LOG[studentID].afterData[tag.Date.ToShortDateString()].Add(pinfo.Name, ainfo.Name); } } if (hasContent) { attRecord.RefStudentID = studentID; attRecord.SchoolYear = int.Parse("" + row.Cells[ColumnIndex["學年度"]].Value); attRecord.Semester = int.Parse("" + row.Cells[ColumnIndex["學期"]].Value); attRecord.OccurDate = DateTime.Parse(tag.Date.ToShortDateString()); InsertHelper.Add(attRecord); } #endregion } else // 若是原本就有紀錄的 { #region 是舊的 SHAttendanceRecord attRecord = row.Cells[0].Tag as SHAttendanceRecord; attRecord.PeriodDetail.Clear(); //清空 bool hasContent = false; for (int i = _startIndex; i < dataGridView.Columns.Count; i++) { DataGridViewCell cell = row.Cells[i]; if (string.IsNullOrEmpty(("" + cell.Value).Trim())) { continue; } PeriodInfo pinfo = dataGridView.Columns[i].Tag as PeriodInfo; AbsenceCellInfo acInfo = cell.Tag as AbsenceCellInfo; AbsenceInfo ainfo = acInfo.AbsenceInfo; K12.Data.AttendancePeriod ap = new K12.Data.AttendancePeriod(); ap.Period = pinfo.Name; ap.AbsenceType = ainfo.Name; attRecord.PeriodDetail.Add(ap); hasContent = true; //log 紀錄修改後的資料 缺曠明細部分 if (!LOG[attRecord.RefStudentID].afterData[tag.Date.ToShortDateString()].ContainsKey(pinfo.Name)) { LOG[attRecord.RefStudentID].afterData[tag.Date.ToShortDateString()].Add(pinfo.Name, ainfo.Name); } } if (hasContent) { attRecord.SchoolYear = int.Parse("" + row.Cells[ColumnIndex["學年度"]].Value); attRecord.Semester = int.Parse("" + row.Cells[ColumnIndex["學期"]].Value); updateHelper.Add(attRecord); } else { deleteList.Add(tag.Key); //log 紀錄被刪除的資料 LOG[attRecord.RefStudentID].afterData.Remove(tag.Date.ToShortDateString()); LOG[attRecord.RefStudentID].deleteData.Add(tag.Date.ToShortDateString()); } #endregion } } #region InsertHelper if (InsertHelper.Count > 0) { try { SHAttendance.Insert(InsertHelper); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("缺曠紀錄新增失敗 : " + ex.Message, "新增失敗", MessageBoxButtons.OK, MessageBoxIcon.Error); } //log 寫入log foreach (string each in LOG.Keys) { foreach (string date in LOG[each].afterData.Keys) { if (!LOG[each].beforeData.ContainsKey(date) && LOG[each].afterData[date].Count > 0) { StringBuilder desc = new StringBuilder(""); desc.AppendLine("學生「" + K12.Data.Student.SelectByID(each).Name + "」"); desc.AppendLine("日期「" + date + "」"); foreach (string period in LOG[each].afterData[date].Keys) { desc.AppendLine("節次「" + period + "」設為「" + LOG[each].afterData[date][period] + "」"); } ApplicationLog.Log("學務系統.缺曠資料", "批次新增缺曠資料", "student", each, desc.ToString()); //Log部份 //CurrentUser.Instance.AppLog.Write(EntityType.Student, EntityAction.Insert, _student.ID, desc.ToString(), this.Text, ""); } } } } #endregion #region updateHelper if (updateHelper.Count > 0) { try { SHAttendance.Update(updateHelper); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("缺曠紀錄更新失敗 : " + ex.Message, "更新失敗", MessageBoxButtons.OK, MessageBoxIcon.Error); } //log 寫入log foreach (string each in LOG.Keys) { foreach (string date in LOG[each].afterData.Keys) { if (LOG[each].beforeData.ContainsKey(date) && LOG[each].afterData[date].Count > 0) { bool dirty = false; StringBuilder desc = new StringBuilder(""); desc.AppendLine("學生「" + K12.Data.Student.SelectByID(each).Name + "」 "); desc.AppendLine("日期「" + date + "」 "); foreach (string period in LOG[each].beforeData[date].Keys) { if (!LOG[each].afterData[date].ContainsKey(period)) { LOG[each].afterData[date].Add(period, ""); } } foreach (string period in LOG[each].afterData[date].Keys) { if (LOG[each].beforeData[date].ContainsKey(period)) { if (LOG[each].beforeData[date][period] != LOG[each].afterData[date][period]) { dirty = true; desc.AppendLine("節次「" + period + "」由「" + LOG[each].beforeData[date][period] + "」變更為「" + LOG[each].afterData[date][period] + "」"); } } else { dirty = true; desc.AppendLine("節次「" + period + "」由「」變更為「" + LOG[each].afterData[date][period] + "」 "); } } if (dirty) { //Log部份 ApplicationLog.Log("學務系統.缺曠資料", "批次修改缺曠資料", "student", each, desc.ToString()); //CurrentUser.Instance.AppLog.Write(EntityType.Student, EntityAction.Update, _student.ID, desc.ToString(), this.Text, ""); } } } } } #endregion #region deleteList if (deleteList.Count > 0) { try { SHAttendance.Delete(deleteList); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("缺曠紀錄刪除失敗 : " + ex.Message, "刪除失敗", MessageBoxButtons.OK, MessageBoxIcon.Error); } //log 寫入被刪除的資料的log foreach (string each in LOG.Keys) { StringBuilder desc = new StringBuilder(""); desc.AppendLine("學生「" + K12.Data.Student.SelectByID(each).Name + "」"); foreach (string date in LOG[each].deleteData) { desc.AppendLine("刪除「" + date + "」缺曠紀錄 "); } //Log部份 ApplicationLog.Log("學務系統.缺曠資料", "批次刪除缺曠資料", "student", each, desc.ToString()); //CurrentUser.Instance.AppLog.Write(EntityType.Student, EntityAction.Delete, _student.ID, desc.ToString(), this.Text, ""); } } #endregion //觸發變更事件 //Attendance.Instance.SyncDataBackground(_studentList); FISCA.Presentation.Controls.MsgBox.Show("儲存缺曠資料成功!", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); #endregion }