Beispiel #1
0
        public Book BookEdit(Book inputBook, BookManagement bookManagement)
        {
            string count;

            Console.Clear();
            Console.WriteLine("\n\n\t---------------------------------수정할 도서 기존 정보--------------------------------");
            Console.WriteLine("\t도서 제목 : {0}", inputBook.BookName);
            Console.WriteLine("\t출판사 : {0}", inputBook.Publisher);
            Console.WriteLine("\t저자 : {0}", inputBook.Author);
            Console.WriteLine("\t도서 가격 : {0}", inputBook.Price);
            Console.WriteLine("\t수량 : {0}", inputBook.Count + "\n");
            Console.WriteLine("\t--------------------------------------------------------------------------------------");

            Console.WriteLine("\n\n\t---------------------------------수정할 도서 수량 입력--------------------------------");
            while (true)
            {
                Console.Write("\n\t수량을 입력해주세요 : ");
                count = CancelKey.ReadLineWithCancel();
                if (count == null)
                {
                    bookManagement.Edit(bookManagement);
                }
                if (errorCheck.BookCount(count) == false)
                {
                    break;
                }
                RegisterErrorMsg("수량");
            }
            inputBook.Count = int.Parse(count);
            return(inputBook);
        }
Beispiel #2
0
 public BookManagement(Menu menu, List <Book> bookList)
 {
     this.menu       = menu;
     this.bookList   = bookList;
     this.print      = Print.GetInstance();
     this.errorCheck = ErrorCheck.GetInstance();
     bookManagement  = this;
 }
Beispiel #3
0
 public Menu()
 {
     this.memberList       = new List <Member>();
     this.bookList         = new List <Book>();
     this.memberManagement = new MemberManagement(this, memberList);
     this.bookManagement   = new BookManagement(this, bookList);
     this.bookRent         = new BookRent(this, memberList, bookList);
     this.print            = Print.GetInstance(); //Print객체가 있으면 생성하지 않고 없으면 생성하는 메소드
     this.errorCheck       = ErrorCheck.GetInstance();
     new DataAdd(this.memberList, this.bookList); //최초 데이터 추가
 }
Beispiel #4
0
        public void Edit(BookManagement bookManagement)
        {
            while (true)
            {
                print.Menu("도서수정");
                menuSelect = CancelKey.ReadLineWithCancel();
                if (menuSelect == null)
                {
                    ViewMenu();
                }
                if (errorCheck.Number(menuSelect, "5지선다") == false)
                {
                    break;
                }
                print.MenuErrorMsg("5지선다오류");
            }
            switch (int.Parse(menuSelect))
            {
            case SEARCH_BY_NAME:
                listIndex = SearchByName();
                break;

            case SEARCH_BY_PUBLISHER:
                listIndex = SearchByPublisher();
                break;

            case SEARCH_BY_AUTHOR:
                listIndex = SearchByAuthor();
                break;

            case PREV:
                menu.ViewMenu();
                break;

            case SHUT_DOWN:
                Environment.Exit(0);
                break;
            }

            if (listIndex == NO_BOOK)
            {
                while (true)
                {
                    print.ErrorMsg("존재하지않는도서");
                    menuSelect = CancelKey.ReadLineWithCancel();
                    if (menuSelect == null)
                    {
                        Edit(this);
                    }
                    if (errorCheck.Number(menuSelect, "선택") == false)
                    {
                        break;
                    }
                }

                switch (int.Parse(menuSelect))
                {
                case REINPUT:
                    Edit(this);
                    break;

                case GOPREV:
                    Edit(this);
                    break;
                }
            }
            else //리스트에 존재
            {
                bookList[listIndex] = print.BookEdit(bookList[listIndex], this);
                print.CompleteMsg("수량 수정 완료");
                ViewMenu();
            }
        }
Beispiel #5
0
        public Book BookRegister(BookManagement bookManagement)
        {
            string bookName, publisher, author, price, count;

            Console.Clear();
            while (true)
            {
                Console.Write("\n\n\t도서 제목 입력(16자이내) : ");
                bookName = CancelKey.ReadLineWithCancel();
                if (bookName == null)
                {
                    bookManagement.ViewMenu();
                }
                if (errorCheck.BookName(bookName) == false)
                {
                    break;
                }
                RegisterErrorMsg("도서제목");
            }
            while (true)
            {
                Console.Write("\n\n\t출판사 입력(8자이내) : ");
                publisher = CancelKey.ReadLineWithCancel();
                if (publisher == null)
                {
                    BookRegister(bookManagement);
                }
                if (errorCheck.BookName(publisher) == false)
                {
                    break;
                }
                RegisterErrorMsg("출판사명");
            }
            while (true)
            {
                Console.Write("\n\n\t저자 입력(10자이내) : ");
                author = CancelKey.ReadLineWithCancel();
                if (author == null)
                {
                    BookRegister(bookManagement);
                }
                if (errorCheck.BookAuthor(author) == false)
                {
                    break;
                }
                RegisterErrorMsg("저자");
            }
            while (true)
            {
                Console.Write("\n\n\t가격 입력(예:50000원) : ");
                price = CancelKey.ReadLineWithCancel();
                if (price == null)
                {
                    BookRegister(bookManagement);
                }
                if (errorCheck.BookPrice(price) == false)
                {
                    break;
                }
                RegisterErrorMsg("가격");
            }
            while (true)
            {
                Console.Write("\n\n\t수량 입력(숫자만 입력) : ");
                count = CancelKey.ReadLineWithCancel();
                if (count == null)
                {
                    BookRegister(bookManagement);
                }
                if (errorCheck.BookCount(count) == false)
                {
                    break;
                }
                RegisterErrorMsg("수량");
            }
            Book newBook = new Book(bookName, publisher, author, price, int.Parse(count));

            return(newBook);
        }