Ejemplo n.º 1
0
        //向书籍表中插入一条书籍元组
        private int InsertBook(Book book)
        {
            if (!book.HasAnyNull())
            {
                int    result = 0;
                string sql1   = "insert into Book(b_isbn, b_title, b_author, b_language, b_amount, b_publisher,b_cost_price, b_sell_price, shel_id, tp_id) values ('" +
                                book.isbn + "','" + book.title + "','" + book.author + "','" + book.language + "'," + book.amount + ",'" + book.publisher + "'," + book.cost_price +
                                "," + book.sell_price + ",'" + book.shelf_id + "','" + book.type_id + "')";
                result = ctrl.ExecNonQuery(sql1);

                string sql2 = "update Shelf set shel_capacity = shel_capacity - " + book.amount + "where shel_id = '" + book.shelf_id + "'";
                ctrl.ExecNonQuery(sql2);
                return(result);
            }
            else
            {
                Console.WriteLine("书籍信息录入不全");
                Console.Read();
                return(0);
            }
        }