Exemple #1
0
        public List <BookVO> SearchBook(string searchType, string searchBy, string user)
        {
            string searchName;
            string searchAuthor;
            string searchPublisher;

            if (searchBy.Equals("도서명"))
            {
                switch (searchType)
                {
                case "registerSearch":
                    print.Search("등록할 책 이름");
                    break;

                case "editSearch":
                    print.Search("편집할 책 이름");
                    break;

                case "removeSearch":
                    print.Search("삭제할 책 이름");
                    break;

                case "justSearch":
                    print.Search("검색할 책 이름");
                    break;

                case "rentBook":
                    print.Search("대여할 책 이름");
                    break;
                }
                searchName = Console.ReadLine();
                if (errorCheck.BookName(searchName))
                {
                    print.FormErrorMsg("도서제목");
                    if (user.Equals("admin"))
                    {
                        adminMenu.BookManagementMenu();
                    }
                    else
                    {
                        userMenu.MainMenu();
                    }
                }
                bookList = dao.SelectAll(bookList, searchBy, searchName); //db에 있는 인덱스값 그대로 불러옴
            }

            else if (searchBy.Equals("출판사명"))
            {
                switch (searchType)
                {
                case "editSearch":
                    print.Search("편집할 책 출판사명");
                    break;

                case "removeSearch":
                    print.Search("삭제할 책의 출판사명");
                    break;

                case "justSearch":
                    print.Search("검색할 책 출판사명");
                    break;

                case "rentBook":
                    print.Search("대여할 책 출판사명");
                    break;
                }

                searchPublisher = Console.ReadLine();
                if (errorCheck.BookPublisher(searchPublisher))
                {
                    print.FormErrorMsg("출판사명");
                    if (user.Equals("admin"))
                    {
                        adminMenu.BookManagementMenu();
                    }
                    else
                    {
                        userMenu.MainMenu();
                    }
                }

                bookList = dao.SelectAll(bookList, searchBy, searchPublisher);
            }

            else if (searchBy.Equals("저자명"))
            {
                switch (searchType)
                {
                case "editSearch":
                    print.Search("편집할 책 저자명");
                    break;

                case "removeSearch":
                    print.Search("삭제할 책의 저자명");
                    break;

                case "justSearch":
                    print.Search("검색할 책 저자명");
                    break;

                case "rentBook":
                    print.Search("대여할 책 저자명");
                    break;
                }

                searchAuthor = Console.ReadLine();
                if (errorCheck.BookAuthor("저자명"))
                {
                    print.FormErrorMsg("저자명");
                    if (user.Equals("admin"))
                    {
                        adminMenu.BookManagementMenu();
                    }
                    else
                    {
                        userMenu.MainMenu();
                    }
                }
                bookList = dao.SelectAll(bookList, searchBy, searchAuthor);
            }

            if (errorCheck.IsValidBook(bookList) == false) //검색 에러
            {
                print.ErrorMsg("입력한 도서 없음");
                if (searchType.Equals("justSearch"))
                {
                    if (user.Equals("admin"))
                    {
                        adminMenu.BookManagementMenu();
                    }
                    else
                    {
                        userMenu.BookSearchMenu();
                    }
                }
                return(null);
            }

            if (searchType.Equals("justSearch"))
            {
                print.PrintBooks(bookList);
                print.PreviousCheck();
                if (user.Equals("admin"))
                {
                    adminMenu.BookSearchMenu();
                }
                else
                {
                    userMenu.BookSearchMenu();
                }
                return(null);
            }
            return(bookList);
        }
Exemple #2
0
        public BookVO RegisterBook()
        {
            string name;
            string author;
            string publisher;
            string price;
            string publishDate;
            string count;
            string isbn;
            string description;

            Console.Clear();
            while (true)
            {
                Console.Write("\n\n\t도서 제목 입력(16자이내) : ");
                name = Console.ReadLine();
                if (errorCheck.BookName(name) == false)
                {
                    break;
                }

                FormErrorMsg("도서제목");
            }

            while (true)
            {
                Console.Write("\n\n\t저자 입력(10자이내) : ");
                author = Console.ReadLine();
                if (errorCheck.BookAuthor(author) == false)
                {
                    break;
                }

                FormErrorMsg("저자");
            }

            while (true)
            {
                Console.Write("\n\n\t도서 가격 입력(숫자만) : ");
                price = Console.ReadLine();
                if (errorCheck.BookPrice(price) == false)
                {
                    break;
                }

                FormErrorMsg("가격");
            }

            while (true)
            {
                Console.Write("\n\n\t출판일자(yyyymmdd) : ");
                publishDate = Console.ReadLine();
                if (errorCheck.BookPublishDate(publishDate) == false) //정규식 고칠것
                {
                    break;
                }

                FormErrorMsg("출판일자");
            }

            while (true)
            {
                Console.Write("\n\n\t출판사 입력(8자이내) : ");
                publisher = Console.ReadLine();
                if (errorCheck.BookName(publisher) == false)
                {
                    break;
                }

                FormErrorMsg("출판사명");
            }

            while (true)
            {
                Console.Write("\n\n\t수량 입력(숫자만 입력) : ");
                count = Console.ReadLine();
                if (errorCheck.BookCount(count) == false)
                {
                    break;
                }

                FormErrorMsg("수량");
            }


            Console.Write("\n\n\tISBN을 입력해주세요(양식: 1234567890 1234567890123) : ");
            isbn = Console.ReadLine();

            FormErrorMsg("ISBN");

            Console.Write("\n\n\t줄거리를 입력해주세요 : ");
            description = Console.ReadLine();

            FormErrorMsg("줄거리");

            BookVO newBook = new BookVO(0, name, author, price, publisher, publishDate, int.Parse(count), isbn, description);

            return(newBook);
        }