示例#1
0
        public string GetGenreIdByName(string Genre)
        {
            Console.WriteLine("etthi");
            string GenreId = "";
            Dictionary <string, object> par = new Dictionary <string, object>(1);

            par.Add("Genre", Genre);

            DataTable lcResult =

                ClsDBConnection.GetDataTable("SELECT * FROM tbl_genre WHERE GenreName = @Genre", par);
            List <clsGenre1> lcGenre = new List <clsGenre1>();

            if (lcResult.Rows.Count > 0)
            {
                foreach (DataRow dr in lcResult.Rows)
                {
                    lcGenre.Add(new clsGenre1
                    {
                        Id   = (int)dr[0],
                        Name = (string)dr[1],
                        Desc = (string)dr[2]
                    });
                }
                Console.WriteLine(GenreId);
                GenreId = lcGenre[0].ToString();
                return(GenreId);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        public List <clsBook> GetBookListByGenreId(string Genre)
        {
            Console.WriteLine("Gen {0}", Genre);
            Dictionary <string, object> par = new Dictionary <string, object>(1);


            par.Add("GenreName", Genre);

            DataTable lcGenreId = ClsDBConnection.GetDataTable("SELECT GenreId FROM tbl_genre where GenreName=@GenreName", par);

            Console.WriteLine(lcGenreId.Rows[0]["GenreId"]);
            par.Add("Id", lcGenreId.Rows[0]["GenreId"]);
            DataTable      lcResult   = ClsDBConnection.GetDataTable("SELECT BookName,BooksLeft,BookDesc FROM tbl_book where ct_id=@Id", par);
            List <clsBook> lcBookList = new List <clsBook>();

            foreach (DataRow dr in lcResult.Rows)
            {
                lcBookList.Add(new clsBook
                {
                    BookName = (string)dr[0],

                    BooksLeft = (int)dr[1],
                    BookDesc  = (string)dr[2]
                });
            }
            return(lcBookList);
        }
示例#3
0
        public List <clsGenre> GetGenreList()
        {
            DataTable       lcResult = ClsDBConnection.GetDataTable("SELECT GenreId,GenreName,Description FROM tbl_genre", null);
            List <clsGenre> lcGenre  = new List <clsGenre>();

            foreach (DataRow dr in lcResult.Rows)
            {
                lcGenre.Add(new clsGenre
                {
                    Id   = (int)dr[0],
                    Name = (string)dr[1],
                    Desc = (string)dr[2]
                });
            }
            return(lcGenre);
        }
示例#4
0
        public string GetBookNameByName(string BookName)
        {
            string Result = "";
            Dictionary <string, object> par = new Dictionary <string, object>(1);

            par.Add("BookName", BookName);

            DataTable lcResult =

                ClsDBConnection.GetDataTable("SELECT * FROM tbl_book WHERE BookName = @BookName", par);

            if (lcResult.Rows.Count > 0)
            {
                Result = "1";
            }
            else
            {
                Result = "0";
            }
            return(Result);
        }
示例#5
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];
            //}
        }
示例#6
0
        public string GetGenreNameById(string GenreId)
        {
            string Genre = "";
            Dictionary <string, object> par = new Dictionary <string, object>(1);

            par.Add("GenreId", GenreId);

            DataTable lcResult =

                ClsDBConnection.GetDataTable("SELECT GenreName FROM tbl_genre WHERE GenreId = @GenreId", par);

            if (lcResult.Rows.Count > 0)
            {
                Genre = lcResult.Rows[0]["GenreName"].ToString();

                Console.WriteLine("Genre: {0}", Genre);
                return(Genre);
            }
            else
            {
                return(null);
            }
        }