예제 #1
0
        //获取符合条件的书籍的OracleReader
        private OracleDataReader FetchBook(Book book)
        {
            if (!book.HasAnyData())
            {
                return(null);
            }
            string sql    = "select * from Book where ";
            string format = "";

            if (book.IsbnHasData())
            {
                sql += "b_isbn = '" + book.isbn + "'"; format = " and ";
            }
            if (book.TitleHasData())
            {
                sql += format + "b_title = '" + book.title + "'"; format = " and ";
            }
            if (book.AuthorHasData())
            {
                sql += format + "b_author = '" + book.author + "'"; format = " and ";
            }
            if (book.LanguageHasData())
            {
                sql += format + "b_language = '" + book.language + "'"; format = " and ";
            }
            if (book.AmountHasData())
            {
                sql += format + "b_amount = " + book.amount; format = " and ";
            }
            if (book.PublisherHasData())
            {
                sql += format + "b_publisher = '" + book.publisher + "'"; format = " and ";
            }
            if (book.Cost_priceHasData())
            {
                sql += format + "b_cost_price = " + book.cost_price; format = " and ";
            }
            if (book.Sell_priceHasData())
            {
                sql += format + "b_sell_price = " + book.sell_price; format = " and ";
            }
            if (book.Shelf_idHasData())
            {
                sql += format + "shel_id = '" + book.shelf_id + "'"; format = " and ";
            }
            if (book.Type_idHasData())
            {
                sql += format + "tp_id = '" + book.type_id + "'"; format = " and ";
            }
            OracleDataReader reader = ctrl.ExecuteReader(sql);

            return(reader);
        }