public editItemWindow(editTypes edType, AbstractItem item = null)
 {
     InitializeComponent();
     
     List<Type> tlist = typeof(Book).Assembly.GetTypes().ToList<Type>();
     List<string> Types = new List<string>()
         {
             "Book", "Journal"
         };
     Subtypes = new ObservableCollection<string>();
     typeCombo.ItemsSource = Types;
     typeCombo.DataContext = this;
     subTypeCombo.DataContext = this;
     if (edType == editTypes.Add)
     {
         saveButton.Visibility = System.Windows.Visibility.Hidden;
         addButton.Visibility = System.Windows.Visibility.Visible;
     }
     else if (edType == editTypes.Edit)
     {
         addButton.Visibility = System.Windows.Visibility.Hidden;
         saveButton.Visibility = System.Windows.Visibility.Visible;
         SearchObject sobj = getSearchObject(item);
         this.DataContext = sobj;
     }
 }
Beispiel #2
0
 public editItemWindow(editTypes edType, AbstractItem item = null)
 {
     InitializeComponent();
     List<Type> tlist = typeof(Book).Assembly.GetTypes().ToList<Type>();
     List<string> Types = new List<string>()
         {
             "Book", "Journal"
         };
     CategoriesList = new ObservableCollection<string>();
     typeCombo.ItemsSource = Types;
     typeCombo.DataContext = this;
     subTypeCombo.DataContext = this;
     categoryCombo.DataContext = this;
     bestsellerInp.DataContext = this;
     itemSubjectInp.DataContext = this;
     etype = edType;
     if (edType == editTypes.Add)
     {
         saveButton.Visibility = System.Windows.Visibility.Hidden;
         addButton.Visibility = System.Windows.Visibility.Visible;
         serialNumInp.IsEnabled = false;
     }
     else if (edType == editTypes.Edit)
     {
         editedItem = item;
         editItem(item);
     }
 }
 public void Add(AbstractItem item)
 {
     AbstractItem foundItem = items.Find(x => x.Name == item.Name);
     if (foundItem != null)
     {
         foundItem.DepositItem();
     }
     else
     {
         items.Add(item);
     }
 }
Beispiel #4
0
 // Add item to the collection. Both new item and an existing item.
 public void AddItem(AbstractItem item)
 {
     if (!coll.Contains(item) || coll[item.ISBN][0].GetHashCode() != item.GetHashCode())
     {
         while (!validateISBN(item.ISBN))
         {
             item.ISBN = new ISBN();
         }
         ItemCollection.RegisteredISBNList.Add(item.ISBN);
         coll.Add(item);
         coll.Add(item);
     }
     else
     {
         coll.Add(item);
     }
     Search(item);
 }
        private SearchObject getSearchObject(AbstractItem item)
        {
            SearchObject sobj = null;

            if (item is ChildrenBook)
            {
                ChildrenBook book = item as ChildrenBook;
                Dictionary<string, string> parameters = getParamsByBook(book);
                parameters["Category"] = book.Category.ToString();
                sobj = new SearchObject(parameters, book.PrintDate);
            }
            else if (item is RegularBook)
            {
                RegularBook book = item as RegularBook;
                Dictionary<string, string> parameters = getParamsByBook(book);
                parameters["Category"] = book.Category.ToString();
                this.DataContext = book;
            }
            else if (item is StudyBook)
            {
                StudyBook book = item as StudyBook;
                Dictionary<string, string> parameters = getParamsByBook(book);
                parameters["Category"] = book.Category.ToString();
                this.DataContext = book;
            }
            else if (item is RegularJournal)
            {
                RegularJournal journal = item as RegularJournal;
                Dictionary<string, string> parameters = getParamsByJournal(journal);
                parameters["Category"] = journal.Category.ToString();
                this.DataContext = journal;
            }
            else if (item is ScienceJournal)
            {
                ScienceJournal journal = item as ScienceJournal;
                Dictionary<string, string> parameters = getParamsByJournal(journal);
                parameters["Category"] = journal.Category.ToString();
                this.DataContext = journal;
            }
            return sobj;
        }
Beispiel #6
0
 public void Search(AbstractItem item)
 {
     /* 3. Search a specific, known item.
      * Does exactly what it should.
      */
     HashSet<AbstractItem> results = new HashSet<AbstractItem>(coll[item.ISBN]);
     if (onSearchComplete != null)
     {
         onSearchComplete(results.ToList());
     }
 }
Beispiel #7
0
 public void RemoveItem(AbstractItem item)
 {
     while (coll[item.ISBN].Count > 0)
     {
         coll.Remove(item);
     }
 }
 public void Remove(AbstractItem item)
 {
     items.Remove(item);
 }
 private static Dictionary<string, string> getParams(AbstractItem item)
 {
     Dictionary<string, string> parameters = new Dictionary<string, string>();
     parameters["Name"] = item.Name;
     parameters["Author"] = item.Author;
     parameters["Subtype"] = item.GetType().Name;
     parameters["Author"] = item.Author;
     return parameters;
 }
 private void generateRowFromItem(AbstractItem item, DataRow row)
 {
     row["ISBN"] = item.ISBN.Number;
     row["Name"] = item.Name;
     row["Author"] = item.Author;
     row["Subtype"] = ((NameAttr)item.GetType().GetCustomAttributes(typeof(NameAttr), false)[0]).Desc;
     row["Publish Date"] = item.PrintDate;
     row["Location"] = item.Location;
     row["Edition"] = item.Edition;
     List<AbstractItem> itemCopies = SearchHelper.searchByISBN(item.ISBN.Number);
     row["Copies"] = itemCopies.Count - 1;
 }
Beispiel #11
0
 private void editItem(AbstractItem item)
 {
     addButton.Visibility = System.Windows.Visibility.Hidden;
     saveButton.Visibility = System.Windows.Visibility.Visible;
     SelectedType = item.GetType().IsSubclassOf(typeof(Book)) ? "Book" : "Journal";
     SelectedSubtype = ((NameAttr)item.GetType().GetCustomAttributes(typeof(NameAttr), false)[0]).Desc;
     if (item.GetType().IsSubclassOf(typeof(Book)))
     {
         if (item is RegularBook)
         {
             RegularBook book = item as RegularBook;
             object[] refCat = typeof(RegularBook.Categories).GetField(book.Category.ToString()).GetCustomAttributes(typeof(NameAttr), false);
             SelectedCategory = refCat.Length > 0 ? ((NameAttr)refCat[0]).Desc : book.Category.ToString();
             this.DataContext = book;
         }
         else if (item is ChildrenBook)
         {
             ChildrenBook book = item as ChildrenBook;
             object[] refCat = typeof(ChildrenBook.Categories).GetField(book.Category.ToString()).GetCustomAttributes(typeof(NameAttr), false);
             SelectedCategory = refCat.Length > 0 ? ((NameAttr)refCat[0]).Desc : book.Category.ToString();
             this.DataContext = book;
         }
         else if (item is StudyBook)
         {
             StudyBook book = item as StudyBook;
             object[] refCat = typeof(StudyBook.Categories).GetField(book.Category.ToString()).GetCustomAttributes(typeof(NameAttr), false);
             SelectedCategory = refCat.Length > 0 ? ((NameAttr)refCat[0]).Desc : book.Category.ToString();
             this.DataContext = book;
         }
         IsBestseller = ((Book)item).IsBestseller;
     }
     else if (item.GetType().IsSubclassOf(typeof(Journal)))
     {
         if (item is RegularJournal)
         {
             RegularJournal journal = item as RegularJournal;
             object[] refCat = typeof(RegularJournal.Categories).GetField(journal.Category.ToString()).GetCustomAttributes(typeof(NameAttr), false);
             SelectedCategory = refCat.Length > 0 ? ((NameAttr)refCat[0]).Desc : journal.Category.ToString();
             this.DataContext = journal;
         }
         else if (item is ScienceJournal)
         {
             ScienceJournal journal = item as ScienceJournal;
             object[] refCat = typeof(ScienceJournal.Categories).GetField(journal.Category.ToString()).GetCustomAttributes(typeof(NameAttr), false);
             SelectedCategory = refCat.Length > 0 ? ((NameAttr)refCat[0]).Desc : journal.Category.ToString();
             this.DataContext = journal;
         }
         Subject = ((Journal)item).Subject;
     }
 }
Beispiel #12
0
 private static Dictionary<string, string> getParams(AbstractItem item)
 {
     Dictionary<string, string> parameters = new Dictionary<string, string>();
     parameters["Name"] = item.Name;
     parameters["Author"] = item.Author;
     parameters["Subtype"] = ((NameAttr)item.GetType().GetCustomAttributes(typeof(NameAttr), false)[0]).Desc;
     parameters["Author"] = item.Author;
     parameters["ISBN"] = item.ISBN.Number;
     parameters["Edition"] = item.Edition.ToString();
     parameters["Location"] = item.Location;
     return parameters;
 }