예제 #1
0
        private void addBookButton_Click(object sender, RoutedEventArgs e)
        {
            Book book = new Book();

            book.bookDetails(title.Text, author.Text, price.Text, ISBN.Text, genre.Text);
            Library.Instance.libraryList.Add(book);
            book.saveToFile();
            MessageBox.Show(book.bookTitle + " has been added to the library");
            this.Close();
            Homepage homepage = new Homepage(user);

            homepage.Show();
        }
예제 #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     login = new Login();
     if (login.verifyCredentials(userInput.Text, passInput.Password, userlist))
     {
         user     = new User(userInput.Text, passInput.Password, login.isAdmin);
         homepage = new Homepage(user);
         homepage.Show();
         this.Close();
     }
     else
     {
         System.Windows.MessageBox.Show("Please enter a valid username and password", "Invalid login credentials");
     }
 }
예제 #3
0
        public static void findBook(string filepath, string Searchtext, Homepage page)          //takes in file path, seachtext  and form
        {
            int           foundcounter = 0;                                                     //incremental find counter
            List <string> FileLines    = File.ReadLines(filepath).ToList <string>();            // reading the lines of the file into a list

            foreach (string item in FileLines)                                                  //goes through each line in file
            {
                if (item.IndexOf(Searchtext, StringComparison.InvariantCultureIgnoreCase) >= 0) //this returns an index of the match without case sens. if nothings found it skips to next line.
                {
                    foundcounter += 1;
                    Book book = new Book(item);                  //creating new book object using file information.
                    switch (foundcounter)                        //if item found then item is placed in lable and image boxe is populated in order it
                    {
                    case 1:                                      //1st item found
                        page.button1.Content = book.bookTitle;   //setting found lable to book title....
                        page.image.Source    = book.BookCover(); //setting image to book cover....
                        bookOne = book;
                        break;

                    case 2:    //2nd item found.....
                        page.button2.Content = book.bookTitle;
                        page.image1.Source   = book.BookCover();
                        bookTwo = book;
                        break;

                    case 3:
                        page.button3.Content = book.bookTitle;
                        page.image2.Source   = book.BookCover();
                        bookThree            = book;
                        break;

                    case 4:
                        page.button4.Content = book.bookTitle;
                        page.image3.Source   = book.BookCover();
                        bookFour             = book;
                        break;
                    }
                }
            }
        }
예제 #4
0
 private void returnButton_Click(object sender, RoutedEventArgs e)
 {
     homepage = new Homepage(user);
     homepage.Show();
     this.Close();
 }