コード例 #1
0
        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();
            }
        }
コード例 #2
0
 public override bool Equals(System.Object otherBook)
 {
     if (!(otherBook is Book))
     {
         return(false);
     }
     else
     {
         Book newBook = (Book)otherBook;
         return(this.GetId().Equals(newBook.GetId()));
     }
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
ファイル: Book.cs プロジェクト: Zebrozkii/Libaray-Join-table
 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);
     }
 }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
ファイル: Books.cs プロジェクト: grepcats/library-catalog
 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);
     }
 }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
ファイル: Book.cs プロジェクト: tessasullivan/Library
 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);
     }
 }
コード例 #9
0
 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);
     }
 }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
        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();
            }
        }
コード例 #12
0
        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();
            }
        }
コード例 #13
0
        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();
            }
        }
コード例 #14
0
 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);
     }
 }
コード例 #15
0
ファイル: Author.cs プロジェクト: brianhenry617/wk4-wednesday
        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();
            }
        }
コード例 #16
0
        //
        //     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();
            }
        }