Example #1
0
        //메뉴 입력에서 예외처리 한번에 처리하기 위한 메소드
        public void MenuInput(string menuType, string errorCheckType)
        {
            print.Menu(menuType);
            menuSelect = Console.ReadKey();
            error      = errorCheck.IsValidMenuInput(menuSelect, errorCheckType);
            if (menuSelect.Key == ConsoleKey.Escape)
            {
                MainMenu();
            }

            if (error == true)
            {
                print.MenuErrorMsg(errorCheckType); //오류 메시지

                switch (errorCheckType)
                {
                case "메인메뉴":
                    MainMenu();
                    return;

                case "회원관리메뉴":
                    MemberManagementMenu();
                    return;

                case "도서관리메뉴":
                    BookManagementMenu();
                    return;

                case "도서수정검색메뉴":
                    BookEditMenu();
                    return;

                case "도서삭제검색메뉴":
                    BookRemoveMenu();
                    return;

                case "도서검색검색메뉴":
                    BookSearchMenu();
                    return;

                case "도서대여메뉴":
                    BookRentMenu();
                    return;

                case "도서대여검색메뉴":
                    BookRentSearchMenu();
                    return;
                }
            }
        }
Example #2
0
        public void RentBook(string searchBy)
        {
            ConsoleKeyInfo input;
            BookVO         foundBook = SearchBook("rentBook", searchBy);

            if (dataReader == null)
            {
                menu.BookRentSearchMenu();
                return;
            }

            if (foundBook.Count == 0) //빌릴 책의 수량이 없는 경우
            {
                print.NotInStockMsg();
                menu.BookRentSearchMenu();
                return;
            }

            if (Login.logOnMember.RentBook != "없음") //빌려간 책이 있는 경우
            {
                while (true)
                {
                    print.RentErrorMsg(Login.logOnMember.Name, Login.logOnMember.RentBook);
                    input = Console.ReadKey();
                    if (errorCheck.IsValidMenuInput(input, "선택") == false)
                    {
                        break;
                    }
                }

                if (input.KeyChar.ToString().Equals("1"))
                {
                    ReturnBook();
                    return;
                }
                menu.BookRentSearchMenu();
                return;
            }

            print.CheckRentBook(foundBook);
            while (true) //제대로 입력할때까지 반복
            {
                input = Console.ReadKey();
                if (errorCheck.Confirm(input.KeyChar.ToString()) == false)
                {
                    break;
                }

                print.MenuErrorMsg("Y/N오류");
            }

            if (input.KeyChar.ToString().Equals("N") || input.KeyChar.ToString().Equals("n")) //대여 안함
            {
                menu.BookRentSearchMenu();
                return;
            }

            //대여함
            sqlQuery = "update member set rentbook ='" + foundBook.Name + "', duedate ='" + "2018-05-11" + "' where id='" + Login.logOnMember.Id + "';";
            SendQuery();
            Login.logOnMember.RentBook = foundBook.Name;
            Login.logOnMember.DueDate  = "2018-05-11";

            if (errorCheck.IsValidChange(dataReader) == false)
            {
                CloseDB();
                print.ErrorMsg("대여");
                menu.BookRentSearchMenu();
                return;
            }
            CloseDB();

            foundBook.Count = foundBook.Count - 1;

            sqlQuery = "update book set count ='" + foundBook.Count + "' where name='" + foundBook.Name + "';";
            SendQuery();

            if (errorCheck.IsValidChange(dataReader) == false)
            {
                CloseDB();
                print.ErrorMsg("도서 수량 정보 갱신");
                menu.BookRentSearchMenu();
                return;
            }

            CloseDB();
            print.CompleteMsg("해당 도서 대여");
            menu.BookRentMenu();
            return;
        }