protected void Button1_Click(object sender, EventArgs e) { Model.BookTable Mbook = new Model.BookTable(); Mbook.BookId = Convert.ToInt32(TextBox1.Text); Mbook.BookName = TextBox2.Text; Mbook.BookPrice = TextBox3.Text; Mbook.BookCategory = DropDownList2.SelectedValue.ToString(); Mbook.BookPress = DropDownList1.SelectedValue.ToString(); Mbook.BookLendDate = DateTime.Now; Mbook.BookynLend = "否"; Mbook.BookynMake = "否"; Bll.BookTable book = new Bll.BookTable(); bool tianjia; tianjia = book.insert(Mbook); if (tianjia) { Response.Write("<script>alert('添加成功');</script>"); Response.Redirect("BookAdminWeb.aspx"); } else { Response.Write("<script>alert('添加失败');</script>"); } }
public void bang() { Bll.BookTable books = new Bll.BookTable(); GridView1.DataSource = books.select(""); GridView1.DataKeyNames = new string[] { "BookId" }; GridView1.DataBind(); }
protected void Button2_Click(object sender, EventArgs e) { if (TextBox3.Text != "") { if (DropDownList1.Text == "图书编号") { Bll.BookTable bBor = new Bll.BookTable(); this.GridView1.DataSource = bBor.select("BookId like '%" + TextBox3.Text + "%'"); this.GridView1.DataKeyNames = new string[] { "BookId" }; this.GridView1.DataBind(); } if (DropDownList1.Text == "图书名称") { Bll.BookTable bBor = new Bll.BookTable(); this.GridView1.DataSource = bBor.select("BookName like '%" + TextBox3.Text + "%'"); this.GridView1.DataKeyNames = new string[] { "BookId" }; this.GridView1.DataBind(); } if (DropDownList1.Text == "出版社名称") { Bll.BookTable bBor = new Bll.BookTable(); this.GridView1.DataSource = bBor.select("BookPress like '%" + TextBox3.Text + "%'"); this.GridView1.DataKeyNames = new string[] { "BookId" }; this.GridView1.DataBind(); } this.Label4.Text = ""; } else { this.Label4.Text = "不能为空"; } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string jiechu = GridView1.Rows[e.RowIndex].Cells[6].Text.Trim(); string yuyue = GridView1.Rows[e.RowIndex].Cells[7].Text.Trim(); if (jiechu == "否") { if (yuyue == "否") { bool shanchu = false; Bll.BookTable books = new Bll.BookTable(); shanchu = books.delete(GridView1.DataKeys[e.RowIndex].Value.ToString()); if (shanchu) { Response.Write("<script>alert('删除成功');</script>"); } else { Response.Write("<script>alert('删除失败');</script>"); } bang(); } else { Response.Write("<script>alert('此书已被预约,不允许删除');</script>"); } } else { Response.Write("<script>alert('此书已借出,不允许删除');</script>"); } }
public void bind() { Bll.BookTable book = new Bll.BookTable(); DataTable da = book.select("BookId='" + Request.QueryString["name"] + "'"); txt_bookid.Text = Request.QueryString["name"]; txt_bookname.Text = da.Rows[0]["BookName"].ToString().Trim(); }
public void bang() { Bll.BookTable book = new Bll.BookTable(); DataTable da = book.select("BookynMake='" + "否" + "'"); GridView1.DataSource = da; GridView1.DataKeyNames = new string[] { "BookId" }; GridView1.DataBind(); }
protected void Button2_Click(object sender, EventArgs e) { if (TextBox3.Text != "") { Bll.BookTable bBor = new Bll.BookTable(); this.GridView1.DataSource = bBor.select("BookynMake like '%" + TextBox3.Text + "%'"); this.GridView1.DataKeyNames = new string[] { "BookynMake" }; this.GridView1.DataBind(); this.Label4.Text = ""; } else { this.Label4.Text = "不能为空"; } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Bll.BookTable books = new Bll.BookTable(); Model.BookTable Mbook = new Model.BookTable(); Mbook.BookName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim(); Mbook.BookPrice = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim(); Mbook.BookPress = ((DropDownList)(GridView1.Rows[e.RowIndex].Cells[4].Controls[1])).Text.ToString().Trim(); Mbook.BookCategory = ((DropDownList)(GridView1.Rows[e.RowIndex].Cells[3].Controls[1])).Text.ToString().Trim(); Mbook.BookLendDate = Convert.ToDateTime(((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim()); Mbook.BookynLend = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString().Trim(); Mbook.BookynMake = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[7].Controls[0])).Text.ToString().Trim(); books.update(Mbook, int.Parse(((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text.ToString().Trim())); GridView1.EditIndex = -1; bang(); //books.update(); }
public void bang() { DropDownList grid; Bll.BookTable books = new Bll.BookTable(); DataTable da = books.select(""); GridView1.DataSource = da; GridView1.DataKeyNames = new string[] { "BookId" }; GridView1.DataBind(); for (int i = 0; i < GridView1.Rows.Count; i++) { DataRowView mydiv = da.DefaultView[i]; grid = (DropDownList)GridView1.Rows[i].FindControl("DropDownList2"); grid.Text = da.Rows[i]["BookPress"].ToString(); grid.Enabled = false; grid = (DropDownList)GridView1.Rows[i].FindControl("DropDownList1"); grid.Text = da.Rows[i]["BookCategory"].ToString(); grid.Enabled = false; //grid.SelectedIndex = grid.Items.IndexOf(grid.Items.FindByText(da.Rows[i]["BookPress"].ToString())); } }