private void btnDelete_Click(object sender, EventArgs e) { int transportId; //DialogResult strDelete = MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.YesNo); //if (strDelete.ToString().Equals("No")) //{ // return; //} if (dgvTranspor.SelectedRows.Count > 0) { if (MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { try { if (dgvTranspor.SelectedRows.Count > 0) { transportId = Convert.ToInt32(dgvTranspor.SelectedCells[0].Value.ToString()); if (transportLogic.FrmTransportDelete(transportId)) { //MessageBox.Show("删除记录成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); SetDataGridView(); } //else //{ // MessageBox.Show("删除记录失败,请从新操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); //} } } catch (Exception) { MessageBox.Show("记录正在使用,无法删除!"); } } } else { MessageBox.Show("选择要删除的行!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } }