---恢复内容开始---

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Web;
 5 using System.Web.UI;
 6 using System.Web.UI.WebControls;
 7 using System.Data;
 8 using System.Data.SqlClient;
 9 using Model;
10 using BLL;
11 
12 public partial class _Default : System.Web.UI.Page
13 {
14     
15     /// <summary>
16     /// 加载事件
17     /// </summary>
18     /// <param name="sender"></param>
19     /// <param name="e"></param>
20     BookBLL book = new BookBLL();
21     
22     BookTypeBLL booktype = new BookTypeBLL();
23     protected void Page_Load(object sender, EventArgs e)
24     {
25         if (!IsPostBack)
26         {
27             bindddl();
28             BookBinder();
29         }
30 
31     }
32    public  void bindddl()
33     {
34         List<BookType> list = booktype.GetSet();
35         ddlType.DataSource = list;
36         ddlType.DataTextField = "BookTypeName";
37         ddlType.DataValueField = "BookTypeID";
38         ddlType.DataBind();
39     }
40     public void BookBinder()
41     {
42         List<Book> list = book.GetSet();
43 
44         GridView1.DataSource = list;
45         GridView1.DataKeyNames = new string[] { "BookTitle" };
46         GridView1.DataBind();
47     }
48     
49     protected void btn_Click(object sender, EventArgs e)
50     {
51         Book book = new Book();
52         book.BookTitle = txtTitle.Text;
53         book.Amount = Convert.ToInt32(txtAmount.Text);
54         book.Update = Convert.ToDateTime(txtTime.Text);
55         book.PerName = txtPreName.Text;
56         book.BookTypeID = Convert.ToInt32(ddlType.SelectedValue);
57 
58         if (book.Add(book))
59         {
60             this.DataBind();
61        }
62         
63     }
64     protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
65     {
66         string title = Convert.ToString(e.Keys[0]);
67         Book book = new Book();
68         book.BookTitle = title;
69         if (book.Remove(book))
70         {
71             this.BookBinder();
72         }
73     }
74     public string GetBookNameById(object id)
75     {
76         BookType bookType = booktype.GetBookTypeById((int)id);
77         return bookType.BookTypeName;
78     }
79     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
80     {
81         if (e.Row.RowType == DataControlRowType.DataRow)
82         {
83             e.Row.Attributes.Add("onmouseover", "tr_mouseover(this);");
84             e.Row.Attributes.Add("onmouseout", "tr_mouseout(this);");
85         }
86     }
87     
88 }

这之间的58,和69行报错,说每天加using 引用,但我确实添加了引用的,哎,不知道咋回事?求解救?

---恢复内容结束---

posted on 2014-12-28 10:06  谢梦兮  阅读(145)  评论(2编辑  收藏  举报