コード例 #1
0
        /*
         * Given a book ISBN(entered by the user) and a book record(read from
         * the currentBookFile) checks to see if the user ISBN matches the record
         * ISBN(the first  field of the record_. If there is a match, this method splits
         * the record into its 6 component parts and saves them
         */
        public Boolean findAndSaveBook(String ISBN)
        {
            string  nextRecord;
            Boolean isEndOfFile = true;
            Boolean success;

            nextRecord = currentBookFile.getNextRecord(ref isEndOfFile);
            while (!isEndOfFile)
            {
                Book tempBook = new Book();
                success = tempBook.populateBookObject(nextRecord);

                if (success != true)
                {
                    MessageBox.Show
                        ("Unable to create a Book Object",
                        "Book object creation Failed", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return(false);
                }
                if (tempBook.bookMatch(ISBN, tempBook))
                {
                    book = tempBook;
                    return(true);
                }
                nextRecord = BookStore.currentBookFile.getNextRecord(ref isEndOfFile);
            } //end While
            return(false);
        }
コード例 #2
0
        /*
         * Checks for a duplicate record when user attempts to add new book
         */
        public Boolean checkForDuplicateRecord(String ISBN, String Author, DateTime date, String Title, Decimal Price, int onHand)
        {
            String line = ISBN + " * " + Title + " * " + Author + " * " +
                          Price + " * " + onHand + " * " + date.ToString();
            Book   addBook  = new Book();
            String tempISBN = ISBN = ISBN.Replace("-", "");

            if (!findAndSaveBook(ISBN))
            {
                addBook.populateBookObject(line);
                addBook.displayBookRecord();
                writeOneRecord(addBook);
                return(false);
            }
            return(true);
        }