public void ReadAssignment() { List <Assignment> assignments = assignmentHandler.GetList(this.user.Account); List <Term> terms = termsHandler.GetListTerm(); Teacher teacher = TeacherHandler.GetInfor(user.Account); Console.WriteLine("Giảng viên: ", teacher.Name); Table table = new Table(90); bool exit = false; while (!exit) { Console.Clear(); table.PrintLine(); table.PrintRow("Học phần", "Lớp", "Học kỳ", "Năm học"); table.PrintLine(); foreach (Assignment assignment in assignments) { table.PrintRow(termsHandler.GetTerm(assignment.TermID, terms).Name, assignment.ClassID, assignment.Semester.ToString(), assignment.Year); } table.PrintLine(); Console.WriteLine("Nhấn esc để thoát"); ConsoleKeyInfo keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.Escape) { exit = true; } } }
public IUIable GetUI(int mode) { TeacherHandler handler = new TeacherHandler(); Teacher teacher = handler.GetInfor(user.Account); teacher.Role = user.Role; teacher.Password = user.Password; switch (mode) { case 0: return(new AssignmentUI(teacher)); case 1: return(new ClassUI(teacher)); case 2: return(new TermUI(teacher)); case 3: return(new TeacherUI(teacher)); case 4: return(new MajorUI(teacher)); case 5: return(new UserUI(teacher)); default: return(new LoginUI()); } }
public IUIable GetUI(int mode) // remove this part to bussin { TeacherHandler handler = new TeacherHandler(); Teacher teacher = handler.GetInfor(user.Account); teacher.Role = (int)UserPermission.Admin; teacher.Password = user.Password; switch (mode) { case 0: return(new TeacherUI(teacher)); case 1: return(new UserUI(teacher)); case 2: return(new ClassUI(teacher)); case 3: return(new SubjectUI()); case 4: return(new MajorUI(teacher)); case 5: return(new TermUI(teacher)); default: return(new LoginUI()); } }
public void Update() { Console.CursorVisible = true; bool exit = false; List <Teacher> teachers = this.teacher.Role == (int)UserPermission.HeadSection ? teacherHandler.GetList(this.teacher.SubjectID) : teacherHandler.GetList(); while (!exit) { PrintTable(teachers); string id = GetId2(); string name = GetName(true); string subId = this.teacher.Role == (int)UserPermission.HeadSection ? this.teacher.SubjectID : GetSubjectId(true); int position = GetPosition(true); Teacher oldInfo = teacherHandler.GetInfor(id); oldInfo.Account = oldInfo.ID; oldInfo.Password = CRUD.GetList()[CRUD.GetIndex(oldInfo.ID)].Password; Teacher newInfo = new Teacher(); if (name != "") { newInfo.Name = name; } else { newInfo.Name = oldInfo.Name; } if (position != -1) { newInfo.Position = position; newInfo.Role = teacherHandler.GetRole(position); } else { newInfo.Position = oldInfo.Position; newInfo.Role = oldInfo.Role; } if (subId != "") { newInfo.SubjectID = subId; } else { newInfo.SubjectID = oldInfo.SubjectID; } newInfo.ID = id; newInfo.Account = id; newInfo.Password = oldInfo.Password; teacherHandler.Update(id, newInfo); teachers[teacherHandler.GetIndex(id, teachers)] = newInfo; PrintTable(teachers); Console.Write("bạn có muốn tiếp tục?: "); ConsoleKeyInfo keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.Escape) { Console.CursorVisible = false; exit = true; } } }