コード例 #1
0
        private void buttonBuy_Click(object sender, EventArgs e)
        {
            BookWithAuthorsAndCategories currentBook = guiManager.getSelectedBook();

            if (currentBook == null)
            {
                MessageBox.Show("Select book");
                return;
            }
            string msg = "";

            if (currentBook != null)
            {
                int quantity = 0;
                try {
                    quantity = Convert.ToInt32(textBoxQuantity.Text);
                    msg      = searchFunctions.buyBook(currentBook, quantity);
                }
                catch (Exception)
                {
                }


                if (msg == searchFunctions.operationSuccesful())
                {
                    currentBook.Quantity -= quantity;
                }
                else
                {
                    MessageBox.Show(msg);
                }
            }
        }
コード例 #2
0
        private void buttonSaveInToBuy_Click(object sender, EventArgs e)
        {
            BookWithAuthorsAndCategories currentBook = guiManager.getSelectedBook();

            if (currentBook != null)
            {
                searchFunctions.saveBookInToBuy(currentBook);
            }
        }
コード例 #3
0
        private void buttonViewBook_Click(object sender, EventArgs e)
        {
            BookWithAuthorsAndCategories currentBook = guiManager.getSelectedBook();

            if (currentBook != null)
            {
                searchFunctions.viewBook(currentBook);
                FormViewBook f = new FormViewBook(currentBook);
                f.Show();
            }
        }
コード例 #4
0
        private int calculateScoreForBook(BookWithAuthorsAndCategories bookWithAuthors, CurrentUser user)
        {
            int score = 0;

            foreach (ScoreGeneratingModule s in scoreModules)
            {
                string          descriptor = s.getDescriptor();
                ScoreModuleInfo mInfo      = recommendationsFunctions.fetchMultiplicatorsData(descriptor);
                s.ModuleInfo = mInfo;
                score       += s.calculateScore(recommendationsFunctions, bookWithAuthors, user);
            }
            return(score);
        }
コード例 #5
0
 public BookWithAuthorsAndCategories getSelectedBook()
 {
     if (cellSelectedAndContainsValue())
     {
         try
         {
             BookWithAuthorsAndCategories toReturn = (dgv.CurrentCell.Value as BookInfoContainer).book;
             return(toReturn);
         }
         catch (Exception e)
         {
             return(null);
         }
     }
     return(null);
 }
コード例 #6
0
        public BookContainerAuthors(BookWithAuthorsAndCategories b) : base(b)
        {
            LinkedList <Author> authors = b.Authors;
            string authorsConcated      = "";
            int    i = 0;

            foreach (Author a in authors)
            {
                string singleAuthor = a.FirstName + " " + a.LastName;
                authorsConcated += singleAuthor;
                if (i < authors.Count - 1)
                {
                    authorsConcated += ", ";
                }
                i++;
            }
            this.authors = authorsConcated;
        }
コード例 #7
0
 public FormViewBook(BookWithAuthorsAndCategories book)
 {
     InitializeComponent();
     labelTitle.Text     = book.title;
     labelPrice.Text     = book.price.ToString();
     labelDiscount.Text  = book.priceMinusDiscountInProcent.ToString();
     labelQuantity.Text  = book.Quantity.ToString();
     labelStartSell.Text = book.StartSellingDate.Date.ToString();
     labelAvailable.Text = "yes";
     if (book.Deleted)
     {
         labelAvailable.Text = "no";
     }
     foreach (Author a in book.Authors)
     {
         listBoxAuthors.Items.Add(a);
     }
     foreach (string c in book.Categories)
     {
         listBoxCategories.Items.Add(c);
     }
 }
コード例 #8
0
 public BookContainerScore(int bookScore, BookWithAuthorsAndCategories b) : base(b)
 {
     score = bookScore;
 }
コード例 #9
0
 public BookContainerId(BookWithAuthorsAndCategories b) : base(b)
 {
 }
コード例 #10
0
 public BookInfoContainer(BookWithAuthorsAndCategories b)
 {
     book = b;
 }