Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
0
        //书籍入库
        public bool InputStock(Book book, string manage_id)
        {
            string sql1 = "select count(*) from Book natural join Shelf where b_isbn = '" + book.isbn + "' and shel_capacity >= " + book.amount;

            if (Convert.ToInt32(ctrl.ExecuteScalar(sql1)) != 0)
            {
                string sql2 = "update Book set b_amount = b_amount + " + book.amount + "where b_isbn = '" + book.isbn + "'";
                string sql3 = "update Shelf set shel_capacity = shel_capacity - " + book.amount +
                              " where shel_id = (select shel_id from book where b_isbn = '" + book.isbn + "')";
                ctrl.ExecNonQuery(sql2);
                ctrl.ExecNonQuery(sql3);
                CreateUpdateInfo(book.isbn, manage_id, book.amount);
                return(true);
            }

            string sql4 = "select * from Book where b_isbn = '" + book.isbn + "'";

            if (ctrl.ExecuteScalar(sql4) != null)
            {
                return(false);
            }
            else
            {
                if (!book.Shelf_idHasData())
                {
                    return(false);
                }
                else
                {
                    InsertBook(book);
                    CreateUpdateInfo(book.isbn, manage_id, book.amount);
                    return(true);
                }
            }
            return(false);
        }