Ejemplo n.º 1
0
        static void UpdateBookById()
        {
            try
            {
                Book book = new Book();
                Console.Write("Enter the book ID for update : ");
                book.BookID = int.Parse(Console.ReadLine());
                Console.Write("Enter the book name for update : ");
                book.BookName = Console.ReadLine();
                Console.Write("Enter the author name for update : ");
                book.AuthorName = Console.ReadLine();
                Console.Write("Enter the publisher name for update : ");
                book.Publisher = Console.ReadLine();
                Console.Write("Enter the number of this book for update : ");
                book.NoOfCopies = int.Parse(Console.ReadLine());
                Console.Write("Enter the book price for update : ");
                book.Price = int.Parse(Console.ReadLine());

                BusinessLayer bll = new BusinessLayer();
                bll.UpdateBook(book);
                Console.WriteLine("Updated record successfully");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
        static void DisplayAllBooks()
        {
            BusinessLayer bll      = new BusinessLayer();
            List <Book>   lstBooks = bll.GetAllBooks();

            foreach (Book book in lstBooks)
            {
                Console.WriteLine(book.BookID + "\t\t" + book.BookName + "\t\t" + book.AuthorName + "\t\t"
                                  + book.Publisher + "\t\t" + book.NoOfCopies + "\t\t" + book.Price);
            }
        }
Ejemplo n.º 3
0
 static void DeleteBookById()
 {
     try
     {
         BusinessLayer bll = new BusinessLayer();
         Console.Write("Enter the bookID to delete the book detail : ");
         int bookID = int.Parse(Console.ReadLine());
         bll.DeleteBook(bookID);
         Console.WriteLine("Record deleted successfully....");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Ejemplo n.º 4
0
 static void SearchBookById()
 {
     try
     {
         int  bookID;
         Book book = null;
         Console.Write("Enter bookID for search : ");
         bookID = int.Parse(Console.ReadLine());
         //search book using business layer
         BusinessLayer bll = new BusinessLayer();
         book = bll.SelectBookById(bookID);
         Console.WriteLine(book.BookID + "\t\t" + book.BookName + "\t\t" + book.AuthorName + "\t\t"
                           + book.Publisher + "\t\t" + book.NoOfCopies + "\t\t" + book.Price);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Ejemplo n.º 5
0
 static void SearchBookByBookName()
 {
     try
     {
         List <Book> lstBooks = new List <Book>();
         Console.Write("Enter the book name to search : ");
         string bookName = Console.ReadLine();
         //search book using business layer
         BusinessLayer bll = new BusinessLayer();
         lstBooks = bll.SelectBookByBookName(bookName);
         foreach (Book book in lstBooks)
         {
             Console.WriteLine(book.BookID + "\t\t" + book.BookName + "\t\t" + book.AuthorName + "\t\t"
                               + book.Publisher + "\t\t" + book.NoOfCopies + "\t\t" + book.Price);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Ejemplo n.º 6
0
        static void AddBook()
        {
            Book book = new Book();

            Console.Write("Enter the book ID : ");
            book.BookID = int.Parse(Console.ReadLine());
            Console.Write("Enter the book name : ");
            book.BookName = Console.ReadLine();
            Console.Write("Enter the author name : ");
            book.AuthorName = Console.ReadLine();
            Console.Write("Enter the publisher name : ");
            book.Publisher = Console.ReadLine();
            Console.Write("Enter the number of this book : ");
            book.NoOfCopies = int.Parse(Console.ReadLine());
            Console.Write("Enter the book price : ");
            book.Price = int.Parse(Console.ReadLine());

            //insert using Business Layer
            BusinessLayer bll = new BusinessLayer();

            bll.AddBook(book);
            Console.WriteLine("Record inserted successfully");
        }