/// <summary> /// 选项卡选中之后的显示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tcInfoManager_SelectedIndexChanged(object sender, EventArgs e) { BLL.BookInfoBLL bll = new BLL.BookInfoBLL(); TabControl control = sender as TabControl; string name = control.TabPages[control.SelectedIndex].Text; if (name == "学生管理") { tpStudent.Controls.Clear(); AdminForm ad = new AdminForm(); ad.TopLevel = false; tpStudent.Controls.Add(ad); ad.Show(); } else if (name == "图书管理") { this.txtBookSearch.Focus(); dgvBook.DataSource = bll.getAllBookInfoList(1); LoadDgvFont(dgvBook); BookPage.DataCount = bll.getBookCount(); } else if (name == "管理员") { } }
/// <summary> /// 删除内容(快捷菜单) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BookDelete_Click(object sender, EventArgs e) { if (dgvBook.SelectedRows.Count == 0) { return; } if (MessageBox.Show("确定要删除图书吗?", "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { BookInfoModel book = dgvBook.SelectedRows[0].DataBoundItem as BookInfoModel; BLL.BookInfoBLL bll = new BLL.BookInfoBLL(); int result = bll.deleteBookInfo(book.BookID); if (result == 1) { MessageBox.Show("删除成功"); } else if (result > 1) { MessageBox.Show("删除了多条记录"); } else if (result == 0) { MessageBox.Show("未执行删除操作"); } else { MessageBox.Show("删除失败"); } //更新数据源 this.dgvBook.DataSource = bll.getAllBookInfoList(BookPage.PageIndex); } }