/**
     *
     * CREATE TRIGGER no_price ON book_table
     *  FOR INSERT
     *          AS
     *      IF(
     *              (
     *                  SELECT COUNT(*) FROM inserted
     *                  WHERE inserted.price<0
     *
     *                  )>0
     *
     *          )
     *
     *                                  raiserror('价格不能小于0',16,11)
     *      rollback TRANSACTION;
     **/

    protected void insert_book_Click(object sender, EventArgs e)//添加书籍信息
    {
        book_tableTableAdapter adprbook = new book_tableTableAdapter();

        int    id        = Int32.Parse(TextBox_bookid.Text);
        string name      = TextBox_bookname.Text;
        string writer    = TextBox_writer.Text;
        string publisher = TextBox_publisher.Text;
        int    left      = Int32.Parse(TextBox_left.Text);
        float  price     = float.Parse(TextBox_price.Text);
        int    floor     = Int32.Parse(TextBox_floor.Text);
        int    shelve    = Int32.Parse(TextBox_shelve.Text);

        try
        {
            locationTableAdapter locationadpr = new locationTableAdapter();
            adprbook.InsertQuery(id, name, writer, publisher, left, price);

            locationadpr.InsertQuery(id, floor, shelve);
            bookGridView.DataBind();
        }
        catch (Exception exp)
        {
            bookinsertMsg.Text = exp.Message;
            //bookinsertMsg.Text = "输入数据错误";
            bookinsertMsg.Visible = true;
            //return;
        }
    }
    protected void delete_book(object sender, EventArgs e)//删除单个书籍记录
    {
        Button btn = (Button)sender;

        string id = btn.CommandArgument;


        int bookid = Int32.Parse(id);
        book_tableTableAdapter bookadpr     = new book_tableTableAdapter();
        locationTableAdapter   locationadpr = new locationTableAdapter();

        try
        {
            locationadpr.DeleteQuery(bookid);
            bookadpr.DeleteQuery(bookid);
            bookGridView.DataBind();
        }
        catch
        {
            Label_delete_book.Text    = "不能删除有借阅记录的书";
            Label_delete_book.Visible = true;
        }
    }