private void btnDelete_Click(object sender, EventArgs e) { int Tmplate_Id = Convert.ToInt32(dgvTemplate["TMPLATE_ID", dgvTemplate.CurrentCell.RowIndex].Value); if (MessageBox.Show("是否要删除选择的模板?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } try { ServiceItemController itemController = new ServiceItemController( ); itemController.DeleteTemplateItem(Tmplate_Id); dgvTemplate.Rows.RemoveAt(dgvTemplate.CurrentCell.RowIndex); dgvDetail.Rows.Clear( ); } catch (Exception err) { MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }