示例#1
0
 // Adds an isbn to the list.
 public void addISBN(ISBN isbn)
 {
     ItemCollection.RegisteredISBNList.Add(isbn);
 }
示例#2
0
 // validates that the ISBN doesn't exist already.
 public bool validateISBN(ISBN isbn)
 {
     if (ItemCollection.RegisteredISBNList.Contains(isbn))
     {
         return false;
     }
     else
     {
         return true;
     }
 }
示例#3
0
 // Removes an ISBN from the list.
 public void removeISBN(ISBN isbn)
 {
     ItemCollection.RegisteredISBNList.Remove(isbn);
 }
示例#4
0
 public StudyBook(string name, string author, DateTime printDate, ISBN isbn, Categories cat, string location)
     :base(name, author, printDate, isbn, location)
 {
     this.Category = cat;
 }
示例#5
0
 public Book(string name, string author, DateTime printDate, ISBN isbn, string location) : base(name, author, printDate, isbn, location)
 {
     this.ISBN = isbn;
 }
示例#6
0
 private void editExistingItem()
 {
     if (validateMandatoryInputs())
     {
         int editionNumber;
         if (int.TryParse(itemEditionInp.Text, out editionNumber))
         {
             editedItem.Edition = editionNumber;
         }
         else
         {
             throw new InvalidCastException("Edition must be a number only!");
         }
         string refinedCategory = SelectedCategory.Replace("&", string.Empty);
         refinedCategory = refinedCategory.Replace(" ", string.Empty);
         editedItem.Name = nameField.Text;
         if (serialNumInp.Text != editedItem.ISBN.Number)
         {
             ISBN newisbn = new ISBN(serialNumInp.Text);
             if (data.validateISBN(newisbn))
             {
                 data.removeISBN(editedItem.ISBN);
                 editedItem.ISBN = newisbn;
                 data.addISBN(newisbn);
             }
             else
             {
                 throw new InvalidSerialNumberException("This ISBN is already registered to another item! Try something else!");
             }
         }
         editedItem.Location = locBox.Text;
         editedItem.PrintDate = (DateTime)dateFromPicker.SelectedDate;
         editedItem.Author = authorInp.Text;
         if (editedItem.GetType().IsSubclassOf(typeof(Book)))
         {
             if (editedItem is RegularBook)
             {
                 RegularBook book = editedItem as RegularBook;
                 book.Category = (RegularBook.Categories)Enum.Parse(typeof(RegularBook.Categories), refinedCategory);
             }
             else if (editedItem is ChildrenBook)
             {
                 ChildrenBook book = editedItem as ChildrenBook;
                 book.Category = (ChildrenBook.Categories)Enum.Parse(typeof(ChildrenBook.Categories), refinedCategory);
             }
             else if (editedItem is StudyBook)
             {
                 StudyBook book = editedItem as StudyBook;
                 book.Category = (StudyBook.Categories)Enum.Parse(typeof(StudyBook.Categories), refinedCategory);
             }
             ((Book)editedItem).IsBestseller = IsBestseller;
         }
         else if (editedItem.GetType().IsSubclassOf(typeof(Journal)))
         {
             if (editedItem is RegularJournal)
             {
                 RegularJournal journal = editedItem as RegularJournal;
                 journal.Category = (RegularJournal.Categories)Enum.Parse(typeof(RegularJournal.Categories), refinedCategory);
             }
             else if (editedItem is ScienceJournal)
             {
                 ScienceJournal journal = editedItem as ScienceJournal;
                 journal.Category = (ScienceJournal.Categories)Enum.Parse(typeof(ScienceJournal.Categories), refinedCategory);
             }
             ((Journal)editedItem).Subject = Subject;
         }
         editActionCompleted(this, null);
     }
 }