Beispiel #1
0
        public void RentBook(string searchBy)
        {
            ConsoleKeyInfo input;
            List <BookVO>  foundList = SearchBook("rentBook", searchBy, "user");

            if (foundList == null)
            {
                userMenu.BookRentSearchMenu();
                return;
            }

            string indexInput;

            while (true)
            {
                print.PrintBooks(foundList);
                print.Check("대여");
                indexInput = Console.ReadLine();

                //입력 양식 및 q를 눌렀을때 혹은 찾은 bookList에 입력한 해당 고유번호가 존재할때만
                if (errorCheck.BookIndex(indexInput) == false || indexInput.ToUpper().Equals("Q"))
                {
                    if (indexInput.ToUpper().Equals("Q"))
                    {
                        adminMenu.BookManagementMenu();
                        return;
                    }

                    if (foundList.Find(book => book.Index.Equals(int.Parse(indexInput))) != null)
                    {
                        break;
                    }
                }

                //if (foundList.Find(book => book.Index.Equals(int.Parse(indexInput))) != null && errorCheck.BookIndex(indexInput) == false)
                //  break;

                print.FormErrorMsg("고유번호");
            }

            BookVO foundBook = foundList.Find(book => book.Index.Equals(int.Parse(indexInput)));

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

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

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

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

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

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

            //대여함
            dao.Update(foundBook, logonID);
            logOnMember.RentBook = foundBook.Name;
            logOnMember.DueDate  = DateTime.Today.ToString().Remove(11);

            foundBook.Count = foundBook.Count - 1;

            dao.Update(foundBook);

            print.CompleteMsg("해당 도서 대여");
            dao.Insert(logOnMember.Name, "도서대여", foundBook.Name, DateTime.Now);
            userMenu.BookRentMenu();
            return;
        }
Beispiel #2
0
 public void Update(BookVO foundBook, string logOnID)
 {
     dataReader.Close();
     sqlQuery = "update member set rentbook ='" + foundBook.Name + "', duedate ='" + DateTime.Today.ToString().Remove(11) + "' where id='" + logOnID + "';";
     SendQuery(sqlQuery);
 }
Beispiel #3
0
 public void Update(BookVO foundBook)
 {
     dataReader.Close();
     sqlQuery = "update book set count ='" + foundBook.Count + "' where name='" + foundBook.Name + "';";
     SendQuery(sqlQuery);
 }
Beispiel #4
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);
        }