public void Statistic() { Console.Clear(); bool exit = false; while (!exit) { string subId = user.SubjectID; List <Assignment> assignments = handler.GetList(); List <Teacher> teachers = teacherHandler.GetList(subId); Table table = new Table(90); table.PrintLine(); table.PrintRow("ID", "Tên", "Số giờ dạy", "Số giờ vượt", "Số giờ chuẩn"); table.PrintLine(); foreach (var teacher in teachers) { int workTime = handler.GetWorkTime(assignments, teacher.ID); float standardTime = handler.GetStandardTime(teacher.Position); float exceedTime = (float)workTime - standardTime; table.PrintRow(teacher.ID, teacher.Name, workTime.ToString(), exceedTime.ToString(), standardTime.ToString()); } table.PrintLine(); Console.WriteLine("nhấn esc để thoát"); ConsoleKeyInfo keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.Escape) { Console.Clear(); exit = true; } } }
} //checked public void PrintTable(List <Class> classes) { Console.Clear(); List <Teacher> teachers = teacherHandler.GetList(); List <Major> majors = majorHandler.GetMajors(); List <Subject> subjects = subjectHandler.GetSubjects(); Table table = new Table(90); table.PrintLine(); table.PrintRow("Lớp", "Sĩ số", "Bộ môn", "Chuyên ngành", "Giảng viên CN", "Niên khóa"); table.PrintLine(); foreach (var c in classes) { string tcName = teacherHandler.GetInfo(c.TeacherId, teachers).Name; string majorName = majorHandler.GetMajor(c.MajorID, majors).Name; string subjectName = subjectHandler.GetSubject(c.SubjectID, subjects).Name; table.PrintRow(c.ID, c.Population.ToString(), subjectName, majorName, tcName, c.StartYear + "-" + c.EndYear); } table.PrintLine(); } // checked
public void Add() { bool exit = true; List <Teacher> teachers = this.teacher.Role == (int)UserPermission.HeadSection ? teacherHandler.GetList(this.teacher.SubjectID) : teacherHandler.GetList(); while (exit) { Console.Clear(); Console.CursorVisible = true; PrintTable(teachers); string id = GetId(); string name = GetName(); string subId = this.teacher.Role == (int)UserPermission.HeadSection ? this.teacher.SubjectID : GetSubjectId(); int position = GetPosition(); int role = teacherHandler.GetRole(position); Teacher teacher = new Teacher(id, name, position, subId, role); teacherHandler.Add(teacher); teachers.Add(teacher); PrintTable(teachers); Console.Write("bạn có muốn nhập tiếp?(y/n): "); string exitStr = Console.ReadLine(); if (exitStr == "n") { exit = false; } } }