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_BreakBook : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        N38_GetDataSet myDS = new N38_GetDataSet();
        anpborrow.RecordCount = myDS.GetBreakCount();
        int pageindex = anpborrow.CurrentPageIndex - 1;
        int pagesize = 5;
        GridView1.DataSource = myDS.GetBreakData(pageindex, pagesize);
        GridView1.DataKeyNames = new string[] { "n38_break_id" };
        GridView1.DataBind();
    }
    protected void ibtnbreak_Click(object sender, ImageClickEventArgs e)
    {
        N38_BookOperate myBookOP = new N38_BookOperate();
        bool result=myBookOP.BookBreak(tbname.Text.Trim());
        if (result)
        {
            Response.Write("<script>alert('图书报废成功')</script>");
            tbname.Text = "";
            BindData();
        }
        else
        {
            Response.Write("<script>alert('书名输入错误，没有这本书')</script>");
        }
    }
    protected void anpcatalog_PageChanged(object sender, EventArgs e)
    {
        BindData();
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#d0e5f5'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
            e.Row.Attributes.Add("style", "height:22px;background-color:#ffffff");
        }
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Attributes.Add("style", "background-image:url('n38_image/ht_10.gif');height:22px");
        }
    }
}
