public void PrintTable(List <Teacher> teachers) { Console.Clear(); List <Subject> subjects = handler.GetSubjects(); table.PrintLine(); table.PrintRow("ID", "Tên", "Chức vụ", "Bộ môn"); table.PrintLine(); foreach (var item in teachers) { table.PrintRow( item.ID, item.Name, teacherHandler.GetPosition(item.Position), subjects[subjectHandler.GetSubIndex(item.SubjectID)].Name); } table.PrintLine(); }
} //checked public void Search() { bool exit = false; while (!exit) { Console.Clear(); Console.CursorVisible = true; List <Term> rooms = this.teacher.Role == (int)UserPermission.HeadSection ? handler.GetList(this.teacher.SubjectID) : handler.GetListTerm(); List <Subject> subjects = subjectHandler.GetSubjects(); Console.Write("Từ khóa: "); string searcher = Console.ReadLine(); Table table = new Table(100); table.PrintLine(); table.PrintRow("ID", "Ten HP", "so tin chi", "bo mon"); table.PrintLine(); for (int i = 0; i < rooms.Count; i++) { if (rooms[i].ID.Contains(searcher) || rooms[i].Name.Contains(searcher) || rooms[i].SubjectId.Contains(searcher) || rooms[i].CreditNum.ToString().Contains(searcher)) { table.PrintRow( rooms[i].ID, rooms[i].Name, rooms[i].CreditNum.ToString(), subjects[subjectHandler.GetSubIndex(rooms[i].SubjectId)].Name ); } } table.PrintLine(); Console.Write("Nhấn esc để thoát"); ConsoleKeyInfo keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.Escape) { exit = true; } Console.CursorVisible = false; } } // checked
public string GetId(bool acceptNull = false) { while (true) { Console.Write("Mã bộ môn: "); string id = Console.ReadLine(); if (acceptNull && id == "") { return(id); } if (!handler.CheckIdSyntax(id)) { Console.WriteLine("Mã gồm 2 kí tự là số 0-9"); } else if (handler.GetSubIndex(id) >= 0) { Console.WriteLine("Đã tồn tại"); } else { return(id); } } }