// 로그인 화면을 출력하고 로그인 정보를 입력 받는다
        public void Login()
        {
            // 유저 또는 관리자 로그인
            while (true)
            {
                Data.Student student = LoginProcess();
                if (student == null)
                {
                    Console.Clear();
                    return;
                }

                switch (student.status)
                {
                case ConstNumber.LOGIN_ADMIN:
                    Menu.AdminScreen(DB, outputProcessor);
                    break;

                case ConstNumber.LOGIN_USER:
                    new Library.BookManagement(student, DB, outputProcessor).UserRentalSystem();
                    break;

                case ConstNumber.LOGIN_FAIL:
                    outputProcessor.PressAnyKey("로그인 실패");
                    break;
                }
            }
        }
        // 책 추가
        public void AddBook()
        {
            List <Data.Book> books;

            books = outputProcessor.APISearchScreen(DB);
            if (books == null)
            {
                return;
            }

            Data.Book book = outputProcessor.PrintBookList(books);
            if (book == null)
            {
                return;
            }
            book.Count = outputProcessor.InputBookCount();

            if (book != null && DB.InsertBook(book))
            {
                outputProcessor.PressAnyKey(book.Name + "이 등록되었습니다.");
                // 로그 기록
                DB.InsertLog("관리자", book.Name, "도서 추가");
            }
            else
            {
                outputProcessor.PressAnyKey("책 등록 실패");
            }
        }
Esempio n. 3
0
 // 멤버 추가
 public void AddMember()
 {
     Data.Student student;
     ConsoleUI.PrintRegistration();
     student = outputProcessor.MemberRegistrationScreen();
     if (student == null)
     {
         return;
     }
     if (DB.InsertMember(student))
     {
         outputProcessor.PressAnyKey(student.name + " 회원님이 등록되었습니다.");
         // 로그 기록
         DB.InsertLog("관리자", student.StudentNo, "회원 추가");
     }
     else
     {
         outputProcessor.PressAnyKey("회원 등록 실패");
     }
 }
Esempio n. 4
0
        // 입력 받은 정보로 책을 검색하여 사용자에게 보여주고 선택하게 한다
        public Data.Book SearchBook(string attribute, string keyword)
        {
            bool             coincide      = false;
            List <Data.Book> books         = DB.GetAllBooks();
            List <Data.Book> searchResults = new List <Data.Book>();

            // 전체 도서 목록에 대해 검사한다
            for (int idx = 0; idx < books.Count; idx++)
            {
                coincide = false;
                if (attribute.Equals("bookname"))
                {
                    coincide = books[idx].GetName().Contains(keyword);
                }
                else if (attribute.Equals("company"))
                {
                    coincide = books[idx].GetCompany().Contains(keyword);
                }
                else
                {
                    coincide = books[idx].GetWriter().Contains(keyword);
                }

                if (coincide)
                {
                    searchResults.Add(books[idx]);
                }
            }

            if (searchResults.Count == 0)
            {
                output.PressAnyKey("검색 결과가 없습니다.");
                return(null);
            }

            // 검색 결과 중 선택된 책을 반환
            return(output.PrintBookList(searchResults));
        }
Esempio n. 5
0
        // 강의 조회 화면, mode 매개변수를 통해 수강 신청, 관심 과목 담기 등에서 쓰일 수 있음
        public void LectureLookup(int mode)
        {
            int choice = ConstNumber.ESC;
            // 검색된 튜플 인덱스를 담는 리스트
            List <int> searchedTuple;

            while (true)
            {
                // 검색 조건 입력 받음
                string[] conditions = outputProcessor.LectureListHeaderScreen();
                // 검색 도중 중지되었다면 나감
                if (conditions == null)
                {
                    return;
                }
                Console.SetCursorPosition(0, 4);

                // 검색 조건에 맞는 강의 목록 출력
                // 수강 신청에서의 강의 조회
                if (mode == ConstNumber.REAL_CHOICE)
                {
                    searchedTuple = outputProcessor.LectureListScreen(allLectureData, conditions, student.appliedSubjects, 167);
                }
                // 관심과목 담기에서의 강의 조회
                else
                {
                    searchedTuple = outputProcessor.LectureListScreen(allLectureData, conditions, student.containedSubjects, 167);
                }

                // 검색된 강의가 없다면
                if (searchedTuple.Count == 0)
                {
                    outputProcessor.PressAnyKey("검색된 강의가 없습니다.");
                }
                else
                {
                    // 사용자에 의한 강의 선택
                    choice = outputProcessor.LectureChoice(searchedTuple.Count);
                }

                if (choice == ConstNumber.ESC)
                {
                    return;
                }
                else
                {
                    // 현재 선택된 강의의 학점
                    int presentCredit = allLectureData.ReturnCredit(searchedTuple[choice]);
                    // 수강신청, 관심과목 담기를 달리 함
                    // 수강 신청
                    if (mode == ConstNumber.REAL_CHOICE)
                    {
                        if (outputProcessor.YesOrNo("선택한 강의를 신청하시겠습니까?") == 1)
                        {
                            // 동일과목이 이미 수강신청되어 있는지 학수번호를 확인한다
                            if (CheckLectureNo(searchedTuple[choice]))
                            {
                                // 신청학점이 최대학점을 초과하지 않는지 확인한다
                                if ((student.appliedCredit + presentCredit) <= ConstNumber.MAX_APPLIED)
                                {
                                    // 신청 강의가 이미 신청된 강의들과 시간이 겹치지 않는지 확인하고 그렇지 않다면 추가한다
                                    if (AddTimeTable(allLectureData, student.timeTable, searchedTuple[choice]))
                                    {
                                        student.AddAppliedSubject(searchedTuple[choice], presentCredit);
                                    }
                                    else
                                    {
                                        outputProcessor.PressAnyKey("다른 강의와 시간이 겹칩니다.");
                                    }
                                }
                                else
                                {
                                    outputProcessor.PressAnyKey("최대 신청 가능 학점을 초과하였습니다.");
                                }
                            }
                            else
                            {
                                outputProcessor.PressAnyKey("이미 동일 과목이 신청되었습니다.");
                            }
                        }
                    }
                    // 관심과목 담기
                    else
                    {
                        if (outputProcessor.YesOrNo("선택한 강의를 담으시겠습니까?") == 1)
                        {
                            // 관심과목 담기 학점이 최대 학점을 초과하지 않는지 확인한다
                            if ((student.containedCredit + presentCredit) <= ConstNumber.MAX_INTERESTED)
                            {
                                student.AddContainedSubject(searchedTuple[choice], presentCredit);
                            }
                            else
                            {
                                outputProcessor.PressAnyKey("최대 담을 수 있는 학점을 초과하였습니다.");
                            }
                        }
                    }
                    if (searchedTuple.Count == 0)
                    {
                        return;
                    }
                }
            }
        }