예제 #1
0
        // checks for duplicate ISBN when attempting to update
        public Boolean checkForDuplicateRecordUpdate(string enteredISBN)
        {
            string  nextRecord;
            Boolean isEndOfFile = true;
            Boolean success;
            int     countProcessedRecords = 0;

            nextRecord = currentBookFile.getNextRecord(ref isEndOfFile);
            while (!isEndOfFile)
            {
                countProcessedRecords++;
                success = book.createBookObject(nextRecord);
                if (success != true)
                {
                    MessageBox.Show
                        ("Unable to create Book Object. Book not created.",
                        "Book creation failed", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return(false);
                } // end if statement
                if (book.bookMatch(enteredISBN) == false)
                {
                    writeOneRecord(nextRecord);
                }
                else
                {
                    return(true);
                }
                nextRecord = currentBookFile.getNextRecord(ref isEndOfFile);
            }
            return(false);
        }
예제 #2
0
        } // end rewindFiles

        // checks for duplicate ISBN when attempting to add
        public Boolean checkForDuplicateRecordAdd(string enteredISBN)
        {
            string  nextRecord;
            Boolean isEndOfFile = true;
            Boolean success;
            int     countProcessedRecords = 0;

            nextRecord = currentBookFile.getNextRecord(ref isEndOfFile);
            while (!isEndOfFile)
            {
                countProcessedRecords++;
                BookClass book = new BookClass();
                success = book.createBookObject(nextRecord);
                if (success != true)
                {
                    MessageBox.Show
                        ("Unable to create Book Object. Book not created.",
                        "Book creation failed", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                } // end if statement
                if (book.bookMatch(enteredISBN) == false)
                {
                    writeOneRecord(nextRecord);
                }
                else
                {
                    MessageBox.Show
                        ("Book with ISBN: " + enteredISBN + " already exists in our library.", "ISBN error",
                        MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return(true);
                }

                nextRecord = currentBookFile.getNextRecord(ref isEndOfFile);
            }
            return(false);
        }