Пример #1
0
        public void ChangeQuantity(int id, int quantity)
        {
            var conn = dbAccessor.OpenConnection();

            dbAccessor.ExecuteQuery(String.Format("UPDATE[BooksForAppoo].[dbo].[Books] SET quantity = {1} WHERE id = {0}", id, quantity), conn);
            dbAccessor.CloseConnection(conn);
        }
Пример #2
0
        public void BuyBook(int id)
        {
            var conn = dbAccessor.OpenConnection();

            dbAccessor.ExecuteQuery(String.Format("UPDATE[BooksForAppoo].[dbo].[Books] SET quantity = quantity - 1 WHERE id = {0}", id), conn);
            dbAccessor.CloseConnection(conn);
        }
Пример #3
0
        public void ShowCatalog()
        {
            var conn = dbAccessor.OpenConnection();
            var cmd  = dbAccessor.ExecuteQuery("Select * From Books", conn);

            catalogPrinter.PrintBooksForManager(cmd);
            dbAccessor.CloseConnection(conn);
        }
Пример #4
0
        public void AddNewBook(Book book)
        {
            DbAccessor dbAccessor = new DbAccessor();
            var        conn       = dbAccessor.OpenConnection();

            SqlCommand cmd = new SqlCommand(String.Format("INSERT INTO [BooksForAppoo].[dbo].[Books] VALUES({0}, \'{1}\', {2}, {3});", book.getId(), book.getName(), book.getPrice(), book.getQuantity()), conn);

            cmd.ExecuteNonQuery();

            dbAccessor.CloseConnection(conn);
        }
Пример #5
0
        public void ChangeQuantity(int id, int quantity)
        {
            DbAccessor dbAccessor = new DbAccessor();
            var        conn       = dbAccessor.OpenConnection();

            SqlCommand cmd = new SqlCommand(String.Format("UPDATE[BooksForAppoo].[dbo].[Books] SET quantity = {1} WHERE id = {0}", id, quantity), conn);

            cmd.ExecuteNonQuery();

            dbAccessor.CloseConnection(conn);
        }
Пример #6
0
        public void ShowBookById(int id)
        {
            DbAccessor dbAccessor = new DbAccessor();
            var        conn       = dbAccessor.OpenConnection();

            SqlCommand cmd = new SqlCommand(String.Format("Select * From Books WHERE id = {0} ", id), conn);

            // dbAccessor.PrintBooks(cmd);

            dbAccessor.CloseConnection(conn);
        }
Пример #7
0
        public void ShowCatalog()
        {
            DbAccessor dbAccessor = new DbAccessor();
            var        conn       = dbAccessor.OpenConnection();

            SqlCommand cmd = new SqlCommand("Select * From Books", conn);

            // dbAccessor.PrintBooks(cmd);

            dbAccessor.CloseConnection(conn);
        }
Пример #8
0
        public void DeleteBookById(int id)
        {
            DbAccessor dbAccessor = new DbAccessor();
            var        conn       = dbAccessor.OpenConnection();

            SqlCommand cmd = new SqlCommand(String.Format("Delete from [BooksForAppoo].[dbo].[Books] WHERE id = {0}", id), conn);

            cmd.ExecuteNonQuery();

            dbAccessor.CloseConnection(conn);
        }
Пример #9
0
        public List <Book> ReturnAllBooks()
        {
            DbAccessor dbAccessor = new DbAccessor();
            var        conn       = dbAccessor.OpenConnection();

            SqlCommand cmd   = new SqlCommand("Select * From Books", conn);
            var        books = dbAccessor.ReturnBooks(cmd);

            dbAccessor.CloseConnection(conn);

            return(books);
        }