Example #1
0
        public clsBook GetBookDetailsById(string BookId)
        {
            Console.WriteLine("ssss");
            Dictionary <string, object> par = new Dictionary <string, object>(1);


            par.Add("BookId", BookId);

            DataTable dtBooks = ClsDBConnection.GetDataTable("SELECT * FROM tbl_book where BookId=@BookId", par);

            //List<clsBook> lcBookList = new List<clsBook>();

            //lcBookList.Add(new clsBook
            //{
            clsBook _Book = new clsBook();

            _Book.BookId          = (int)dtBooks.Rows[0][0];
            _Book.BookName        = (string)dtBooks.Rows[0][1];
            _Book.AuthorName      = (string)dtBooks.Rows[0][2];
            _Book.ISBN            = (int)dtBooks.Rows[0][3];
            _Book.BookDesc        = (string)dtBooks.Rows[0][4];
            _Book.Price           = (decimal)dtBooks.Rows[0][5];
            _Book.BooksLeft       = (int)dtBooks.Rows[0][6];
            _Book.LastUpdatedDate = (dtBooks.Rows[0][7]).ToString();
            _Book.Condition       = (string)dtBooks.Rows[0][8];
            _Book.GenreId         = (int)dtBooks.Rows[0][9];
            _Book.Antique         = Convert.ToBoolean(dtBooks.Rows[0][10]);
            _Book.Package         = (string)dtBooks.Rows[0][11];
            _Book.Weight          = (decimal)dtBooks.Rows[0][12];

            //});
            return(_Book);


            //    return new clsBook()
            //    {
            //        BookId = (int)dtBooks.Rows[0][0];
            //}
        }
Example #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);
            }
        }
Example #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);
            }
        }