public List<BookBorrow> ShowBorrowedBooks(int memberNo)
        {
            List<BookBorrow> aBookList = new List<BookBorrow>();
            string query = "SELECT * FROM tbl_borrow WHERE MemberNo='" + memberNo + "'";
            SqlConnection aConnection = new SqlConnection(connectionString);
            SqlCommand aCommand = new SqlCommand(query, aConnection);

            aConnection.Open();
            SqlDataReader aReader = aCommand.ExecuteReader();

            while (aReader.Read())
            {

                // Setup DataReader
                // Set DR values to Text fields
                BookBorrow aBook = new BookBorrow();
                aBook.Title = aReader["selectabook"].ToString();

                aBookList.Add(aBook);

            }

            aReader.Close();
            aConnection.Close();
            return aBookList;
        }
 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
 {
     //List<BookBorrow> aBook=new List<BookBorrow>();
     BookBorrow aBook = new BookBorrow();
     string bookName = Convert.ToString(bookDropDownList.SelectedItem);
     //
     aBook = aManager.ShowInTextBox(bookName);
     authorTextBox.Text = aBook.Author;
     publisherTextBox.Text = aBook.Publisher;
     aBook.MemberNo = Convert.ToInt32(memberNoTextBox.Text);
 }
 public string ReturnBorrowedBook(BookBorrow aEntry)
 {
     string massege = " ";
     string query = "DELETE FROM tbl_borrow WHERE Title='" + aEntry.Title + "'";
     SqlConnection aConnection = new SqlConnection(connectionString);
     SqlCommand aCommand = new SqlCommand(query, aConnection);
     aConnection.Open();
     int rowAffected = aCommand.ExecuteNonQuery();
     aConnection.Close();
     return massege = "A Book Has Been Returned By " + aEntry.MemberNo;
 }
        public string BorrowBookEntry(BookBorrow aEntry)
        {
            string massege = " ";
            string query = "INSERT INTO tbl_borrow VALUES ('" + aEntry.Title + "','" + aEntry.Author + "', '" + aEntry.Publisher + "','"+aEntry.MemberNo+"');";
            SqlConnection aConnection = new SqlConnection(connectionString);
            SqlCommand aCommand = new SqlCommand(query, aConnection);

            aConnection.Open();
            int rowAffected = aCommand.ExecuteNonQuery();
            aConnection.Close();

            return massege = "A Book Has Been Borrowed By " +aEntry.MemberNo ;
        }
        protected void borrowButton_Click(object sender, EventArgs e)
        {
            BookBorrow aBook = new BookBorrow();
            aBook.Author = authorTextBox.Text;
            aBook.Publisher = publisherTextBox.Text;
            aBook.MemberNo = Convert.ToInt32(memberNoTextBox.Text);
            aBook.Title = Convert.ToString(bookDropDownList.SelectedItem);

            if (memberNoTextBox.Text==string.Empty)
            {
                msgLabel.Text = "Please Enter a Member ID";
            }
            else
            {
                msgLabel.Text = aManager.BorrowBookEntry(aBook);
            }
        }
        public BookBorrow ShowInTextBox(string bookName)
        {
            List<BookBorrow> aBookList = new List<BookBorrow>();
            string query = "SELECT * FROM tbl_book WHERE Title='"+bookName+"'";
            SqlConnection aConnection = new SqlConnection(connectionString);
            SqlCommand aCommand = new SqlCommand(query, aConnection);

            aConnection.Open();
            SqlDataReader aReader = aCommand.ExecuteReader();
            BookBorrow aBook = new BookBorrow();
            if (aReader.HasRows)
            {
                aReader.Read();
                // Setup DataReader
                // Set DR values to Text fields
                aBook.Author = aReader["author"].ToString();
                aBook.Publisher = aReader["publisher"].ToString();

            }

            aReader.Close();
            aConnection.Close();
            return aBook;
        }