Пример #1
0
        public void CRUD()
        {
            Console.Clear();
            List <Class>      classes     = classHandler.GetList(user.SubjectID);
            List <Term>       terms       = termHandler.GetList(user.SubjectID);
            List <Teacher>    teachers    = teacherHandler.GetList(user.SubjectID);
            List <Assignment> assignments = handler.GetList(classes, terms);

            handler.Combine(assignments);

            int  left     = Console.CursorLeft;
            bool exit     = false;
            int  position = 0;

            PrintSelectorTable(assignments, position);
            while (!exit)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                switch (key.Key)
                {
                case ConsoleKey.UpArrow:
                    if (position > 0)
                    {
                        position--;
                        PrintSelectorTable(assignments, position);
                    }
                    Console.CursorLeft = left;
                    break;

                case ConsoleKey.DownArrow:
                    if (position < assignments.Count - 1)
                    {
                        position++;
                        PrintSelectorTable(assignments, position);
                    }
                    Console.CursorLeft = left;
                    break;

                case ConsoleKey.Enter:
                    if (assignments[position].TeacherID == null)
                    {
                        Add(position, assignments, teachers);
                        PrintSelectorTable(assignments, position);
                    }
                    else
                    {
                        CRUD(position, assignments, teachers);
                        PrintSelectorTable(assignments, position);
                    }
                    break;

                case ConsoleKey.Escape:
                    Console.Clear();
                    exit = true;
                    break;
                }
            }
        }
Пример #2
0
        } // checked

        public void Search()
        {
            Console.CursorVisible = true;
            bool exit = false;

            while (!exit)
            {
                Console.Clear();
                Console.Write("Từ khóa: ");
                string       input   = Console.ReadLine();
                List <Class> classes = this.teacher.Role == (int)UserPermission.HeadSection ? classHandler.GetList(teacher.SubjectID) : classHandler.GetClasses();
                List <Class> result  = new List <Class>();
                foreach (var c in classes)
                {
                    if (c.ID.ToLower().Contains(input) ||
                        c.Population.ToString().Contains(input) ||
                        c.SubjectID.Contains(input) ||
                        c.MajorID.Contains(input) ||
                        c.TeacherId.Contains(input) ||
                        c.StartYear.ToString().Contains(input) ||
                        c.EndYear.ToString().Contains(input))
                    {
                        result.Add(c);
                    }
                }
                PrintTable(result);
                Console.Write("Nhấn esc để thoát");
                ConsoleKeyInfo keyInfo = Console.ReadKey();
                if (keyInfo.Key == ConsoleKey.Escape)
                {
                    Console.CursorVisible = false;
                    exit = true;
                }
            }
        } // checked