public void AddBook(Book newBook) { MySqlConnection conn = DB.Connection(); conn.Open(); var cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"INSERT INTO authors_books (author_id, book_id) VALUES (@AuthorId, @BookId);"; MySqlParameter author_id = new MySqlParameter(); author_id.ParameterName = "@AuthorId"; author_id.Value = _id; cmd.Parameters.Add(author_id); MySqlParameter book_id = new MySqlParameter(); book_id.ParameterName = "@BookId"; book_id.Value = newBook.GetId(); cmd.Parameters.Add(book_id); cmd.ExecuteNonQuery(); conn.Close(); if (conn != null) { conn.Dispose(); } }
public override bool Equals(System.Object otherBook) { if (!(otherBook is Book)) { return(false); } else { Book newBook = (Book)otherBook; return(this.GetId().Equals(newBook.GetId())); } }
public override bool Equals(System.Object otherBookName) { if (!(otherBookName is Book)) { return(false); } else { Book newBook = (Book)otherBookName; bool idEquality = (this.GetId() == newBook.GetId()); bool nameEquality = (this.GetName() == newBook.GetName()); return(idEquality && nameEquality); } }
public override bool Equals(System.Object otherBook) { if (!(otherBook is Book)) { return(false); } else { Book newBook = (Book)otherBook; bool idEquality = (this.GetId() == newBook.GetId()); bool descriptionEquality = (this.GetBookTitle() == newBook.GetBookTitle()); return(idEquality && descriptionEquality); } }
public override bool Equals(Object otherBook) { if (!(otherBook is Book)) { return(false); } else { Book newBook = (Book)otherBook; bool idEquality = newBook.GetId() == this._id; bool titleEquality = newBook.GetTitle() == this._title; return(idEquality && titleEquality); } }
public override bool Equals(System.Object otherBook) { if (!(otherBook is Book)) { return(false); } else { Book newBook = (Book)otherBook; bool bookIdEquality = (this.GetId() == newBook.GetId()); bool bookTitleEquality = (this.GetTitle() == newBook.GetTitle()); return(bookIdEquality && bookTitleEquality); } }
public override bool Equals(System.Object otherBook) { if (!(otherBook is Book)) { return(false); } else { Book newBook = (Book)otherBook; bool idEquality = this.GetId() == newBook.GetId(); bool titleEquality = this.GetTitle() == newBook.GetTitle(); bool copiesEquality = this.GetCopies() == newBook.GetCopies(); return(idEquality && titleEquality && copiesEquality); } }
public override bool Equals(System.Object otherItem) { if (!(otherItem is Book)) { return(false); } else { Book newBook = (Book)otherItem; bool idEquality = (this.GetId() == newBook.GetId()); bool titleEq = (this.GetTitle() == newBook.GetTitle()); bool yearEq = (this.GetYear() == newBook.GetYear()); return(idEquality && titleEq && yearEq); } }
public override bool Equals(System.Object otherBook) { if (!(otherBook is Book)) { return(false); } else { Book newBook = (Book)otherBook; bool areIdsEqual = (this.GetId() == newBook.GetId()); bool areNameEqual = (this.GetName() == newBook.GetName()); bool areauthor_idEqual = (this.GetAuthorId() == newBook.GetAuthorId()); bool areYearEqual = (this.GetYear() == newBook.GetYear()); return(areIdsEqual && areNameEqual && areauthor_idEqual && areYearEqual); } }
public override bool Equals(System.Object otherBook) { if (!(otherBook is Book)) { return(false); } else { Book newBook = (Book)otherBook; bool idEquality = (this.GetId() == newBook.GetId()); bool titleEquality = (this.GetTitle() == newBook.GetTitle()); bool genreEquality = (this.GetGenre() == newBook.GetGenre()); bool inventoryEquality = (this.GetInventory() == newBook.GetInventory()); return(idEquality && titleEquality && genreEquality); } }
public void Chekout(Book newBook) { MySqlConnection conn = DB.Connection(); conn.Open(); var cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"INSERT INTO patrons_books (patron_id, book_id) VALUE (@patronId, @bookId);"; cmd.Parameters.AddWithValue("@patronId", this._id); cmd.Parameters.AddWithValue("@bookId", newBook.GetId()); cmd.ExecuteNonQuery(); conn.Close(); if (conn != null) { conn.Dispose(); } }
public void Return(Book newBook) { MySqlConnection conn = DB.Connection(); conn.Open(); var cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"DELETE FROM patrons_books WHERE book_id = @bookId AND patron_id = @patronId;"; cmd.Parameters.AddWithValue("@patronId", this._id); cmd.Parameters.AddWithValue("@bookId", newBook.GetId()); cmd.ExecuteNonQuery(); conn.Close(); if (conn != null) { conn.Dispose(); } }
public void AddBook(Book author) { MySqlConnection conn = DB.Connection(); conn.Open(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = @"INSERT INTO authors_books (author_id, book_id) VALUES (@AuthorId, @BookId)"; cmd.Parameters.Add(new MySqlParameter("@AuthorId", author.GetId())); cmd.Parameters.Add(new MySqlParameter("@BookId", _id)); cmd.ExecuteNonQuery(); conn.Close(); if (conn != null) { conn.Dispose(); } }
public override bool Equals(System.Object otherBook) { if (!(otherBook is Book)) { return(false); } else { Book newBook = (Book)otherBook; bool idEquality = (this.GetId() == newBook.GetId()); bool titleEquality = (this.GetTitle() == newBook.GetTitle()); bool callNumberEquality = (this.GetCallNumber() == newBook.GetCallNumber()); bool tagNumberEquality = (this.GetTagNumber() == newBook.GetTagNumber()); bool checkoutDateEquality = (this.GetCheckoutDate() == newBook.GetCheckoutDate()); bool dueDateEquality = (this.GetDueDate() == newBook.GetDueDate()); bool statusEquality = (this.GetStatus() == newBook.GetStatus()); // return _id == newBook._id && _title == newBook._title && _callNumber == newBook._callNumber && _tagNumber == newBook._tagNumber && _checkoutDate == newBook._checkoutDate && _dueDate == newBook._dueDate && _status == newBook._status; return(idEquality && titleEquality && callNumberEquality && tagNumberEquality && checkoutDateEquality && dueDateEquality && statusEquality); } }
public void AddBook(Book newBook) { MySqlConnection conn = DB.Connection(); conn.Open(); var cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"INSERT INTO books_authors (book_id, author_id) VALUES (@bookId, @authorId);"; cmd.Parameters.Add(new MySqlParameter("@authorId", _id)); cmd.Parameters.Add(new MySqlParameter("@bookId", newBook.GetId())); cmd.ExecuteNonQuery(); _id = (int)cmd.LastInsertedId; conn.Close(); if (conn != null) { conn.Dispose(); } }
// // public void SetCopies(int copies) // { // _copies = copies; // } // // public int GetCopies() // { // return _copies; // } public void AddAuthorToBook(Book theBook) { MySqlConnection conn = DB.Connection(); conn.Open(); MySqlCommand cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"INSERT INTO `books_authors` (`book_id`, `author_id`) VALUES ('" + theBook.GetId() + "', " + _id + ");"; cmd.ExecuteNonQuery(); conn.Close(); if (conn != null) { conn.Dispose(); } }