Example #1
0
        //按批更新图书信息
        public int ModifyBookInfo(Book original, Book lastest)
        {
            OracleDataReader reader = FetchBook(original);
            int sccess_count        = 0;

            while (reader.Read())
            {
                string sql    = "update Book set ";
                string format = "";
                if (lastest.IsbnHasData())
                {
                    sql += "b_isbn = '" + lastest.isbn + "'"; format = " , ";
                }
                if (lastest.TitleHasData())
                {
                    sql += format + "b_title = '" + lastest.title + "'"; format = " , ";
                }
                if (lastest.AmountHasData())
                {
                    sql += format + "b_author = '" + lastest.author + "'"; format = " , ";
                }
                if (lastest.LanguageHasData())
                {
                    sql += format + "b_language = '" + lastest.language + "'"; format = " , ";
                }
                if (lastest.AmountHasData())
                {
                    sql += format + "b_amount = " + lastest.amount; format = " , ";
                }
                if (lastest.PublisherHasData())
                {
                    sql += format + "b_publisher = '" + lastest.publisher + "'"; format = " , ";
                }
                if (lastest.Cost_priceHasData())
                {
                    sql += format + "b_cost_price = " + lastest.cost_price; format = " , ";
                }
                if (lastest.Sell_priceHasData())
                {
                    sql += format + "b_sell_price = " + lastest.sell_price; format = " , ";
                }
                if (lastest.Shelf_idHasData())
                {
                    sql += format + "shel_id = '" + lastest.shelf_id + "'"; format = " , ";
                }
                if (lastest.Type_idHasData())
                {
                    sql += format + "tp_id = '" + lastest.type_id + "'"; format = " , ";
                }
                sql += " where b_isbn = " + reader[reader.GetOrdinal("b_isbn")];
                ctrl.ExecNonQuery(sql);
                sccess_count += 1;
            }
            return(sccess_count);
        }
Example #2
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);
        }