/// <summary> /// 删除机器 /// </summary> private void toolStripButtonDelete_Click(object sender, EventArgs e) { if (this.dgvMatMain.SelectedRows.Count <= 0) { return; } string strReceiptId = this.dgvMatMain.SelectedRows[0].Cells["拆件单据编号"].Value.ToString().Trim(); if (strReceiptId == "") { MessageBox.Show("请选择一条记录!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("确定要删除吗?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) { try { MatSplitMainDAO.DeleteByReceiptId(strReceiptId); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } InitDataGridViewMain(); } }
private void InitDataGridViewMain() { DataTable dt = MatSplitMainDAO.GetDatas(); InitFuncs initFuncs = new InitFuncs(); initFuncs.InitDataGridView(this.dgvMatMain, dt); this.dgvMatMain.ClearSelection(); this.dgvMatMain.Rows[this.CurRowIndex].Selected = true; }