void ToolBarButtonClick(object sender, ToolBarButtonClickEventArgs e) { switch (e.Button.Text) { case "添加": AddForm addForm = new AddForm(); addForm.StartPosition = FormStartPosition.CenterParent; if (addForm.ShowDialog() == DialogResult.OK) { RebindToDataGrid(); } break; case "删除": if (DeleteSelectedRows() == true) { RebindToDataGrid(); } break; case "修改": UpdateForm updateForm = new UpdateForm(); updateForm.StartPosition = FormStartPosition.CenterParent; if (updateForm.ShowDialog() == DialogResult.OK) { RebindToDataGrid(); } break; case "查询": SearchForm searchForm = new SearchForm(); searchForm.StartPosition = FormStartPosition.CenterParent; if (searchForm.ShowDialog() == DialogResult.OK) { RebindToDataGrid(); } break; case "导入": //if(MessageBox.Show("导入前请先保存并关闭所有打开的Excel文档!","警告",MessageBoxButtons.OKCancel,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1) == DialogResult.OK) //{ if (ImportExcelData() == true) { RebindToDataGrid(); } //} break; case "导出": ExportDataToExcel(); break; case "隐藏": this.currentDataSet = null; this.dataGrid1.DataSource = null; break; case "全选": for (int i = 0; i < this.currentDataSet.Tables[0].Rows.Count; i++) { this.dataGrid1.Select(i); } break; case "统计": StatSubscribeForm statSubscribeForm = new StatSubscribeForm(); statSubscribeForm.StartPosition = FormStartPosition.CenterParent; if (statSubscribeForm.ShowDialog() == DialogResult.OK) { ShowStatResultForm form = new ShowStatResultForm(this.statResultTable, this.currentInputDate); form.StartPosition = FormStartPosition.CenterParent; form.ShowDialog(); } break; } }