Exemplo n.º 1
0
        public string DeleteBook(string BookId)
        {
            try
            {
                Dictionary <string, object> par = new Dictionary <string, object>(11);
                par.Add("BookId", BookId);


                int lcRecCount = ClsDBConnection.Execute("DELETE FROM tbl_book WHERE BookId=@BookId", par);
                if (lcRecCount == 1)
                {
                    return("One product Deleted");
                }
                else
                {
                    return("Error Unexpected product delete count: " + lcRecCount);
                }
            }
            catch (Exception ex)
            {
                return("Error: " + ex.GetBaseException().Message);
            }
        }
Exemplo n.º 2
0
        public string PostBook(clsBook prBook)
        {
            Console.WriteLine("fgfgfgf {0}", prBook.Package);
            try
            {
                Dictionary <string, object> par = new Dictionary <string, object>(11);
                par.Add("BookName", prBook.BookName);
                par.Add("AuthorName", prBook.AuthorName);
                par.Add("ISBN", prBook.ISBN);
                par.Add("BookDesc", prBook.BookDesc);
                par.Add("Price", prBook.Price.ToString());
                par.Add("BooksLeft", prBook.BooksLeft.ToString());
                par.Add("LastUpdatedDate", prBook.LastUpdatedDate.ToString());
                par.Add("BookCondition", prBook.Condition);
                par.Add("GenreId", prBook.GenreId.ToString());
                par.Add("Antique", prBook.Antique.ToString());
                par.Add("Package", prBook.Package);
                par.Add("Weight", prBook.Weight.ToString());
                Console.WriteLine("fgfgfgf tertre {0}", prBook.Package);

                int lcRecCount = ClsDBConnection.Execute("INSERT INTO tbl_book " +
                                                         "(BookName, AuthorName, ISBN, BookDesc, Price, BooksLeft, LastUpdtDate, BookCondition, ct_id, Antique, Package, Weight) " +
                                                         "VALUES (@BookName, @AuthorName, @ISBN, @BookDesc, @Price, @BooksLeft, @LastUpdatedDate, @BookCondition, @GenreId, @Antique, @Package, @Weight)", par);
                if (lcRecCount == 1)
                {
                    return("One Book inserted");
                }
                else
                {
                    return("Error Unexpected Book insert count: " + lcRecCount);
                }
            }
            catch (Exception ex)
            {
                return("Error: " + ex.GetBaseException().Message);
            }
        }
Exemplo n.º 3
0
        public string UpdateBook(clsBook prBook)
        {
            try
            {
                Dictionary <string, object> par = new Dictionary <string, object>(11);
                par.Add("BookId", prBook.BookId.ToString());
                par.Add("BookName", prBook.BookName);
                par.Add("AuthorName", prBook.AuthorName);
                par.Add("ISBN", prBook.ISBN);
                par.Add("BookDesc", prBook.BookDesc);
                par.Add("Price", prBook.Price.ToString());
                par.Add("BooksLeft", prBook.BooksLeft.ToString());
                par.Add("LastUpdatedDate", prBook.LastUpdatedDate.ToString());
                par.Add("BookCondition", prBook.Condition);
                par.Add("GenreId", prBook.GenreId.ToString());
                par.Add("Antique", prBook.Antique.ToString());
                par.Add("Package", prBook.Package);
                par.Add("Weight", prBook.Weight.ToString());

                int lcRecCount = ClsDBConnection.Execute(
                    "UPDATE tbl_book SET BookName = @BookName, AuthorName = @AuthorName, ISBN = @ISBN, BookDesc = @BookDesc, Price = @Price, BooksLeft = @BooksLeft, LastUpdtDate = @LastUpdtDate, " +
                    "BookCondition = @BookCondition, ct_id = @GenreId, Antique = @Antique, Package = @Package, Weight = @Weight WHERE BookId = @BookId", par);
                if (lcRecCount == 1)
                {
                    return("One product updated");
                }
                else
                {
                    return("Error Unexpected product update count: " + lcRecCount);
                }
            }
            catch (Exception ex)
            {
                return("Error: " + ex.GetBaseException().Message);
            }
        }