using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class N38_AddNewBook : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            N38_Catalog myCL = new N38_Catalog();
            myCL.rDropDownList(ddlcatalog);
        }
    }
    protected void ibtnok_Click(object sender, ImageClickEventArgs e)
    {
        if (Page.IsValid)
        {
            N38_Book myBook = new N38_Book();
            float price = float.Parse(tbprice.Text.Trim());
            int amount=int.Parse(tbamount.Text.Trim());
            if (ddlcatalog.SelectedIndex == 0)
            {
                Response.Write("<script>alert('请选择分类')</script>");
            }
            else
            {
                bool result = myBook.AddNewBook(tbname.Text.Trim(), ddlcatalog.SelectedValue, price, amount, tbisbn.Text.Trim(), "在馆");
                if (result)
                {
                    Response.Write("<script>alert('图书添加成功')</script>");
                    tbamount.Text = tbisbn.Text = tbname.Text = tbprice.Text = "";
                }
                else
                {
                    Response.Write("<script>alert('图书添加失败')</script>");
                }
            }
        }
    }
}
