private void toolStripButton2_Click(object sender, EventArgs e) { if (TurnsGrid.Rows.Count > 0) { int id = int.Parse(TurnsGrid.Rows[int.Parse(TurnsGrid.CurrentCell.RowIndex.ToString())].Cells[0].Value.ToString()); var result = MessageBox.Show("آیا از حذف نوبت شماره " + TurnsGrid.Rows[int.Parse(TurnsGrid.CurrentCell.RowIndex.ToString())].Cells[0].Value.ToString() + " مطمئن هستید ؟", "هشدار", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { TurnRepository.RemoveTurn(id); initTurnGrid(); } else { MessageBox.Show("عملیات لغو شد", "لغو عملیات", MessageBoxButtons.OK); } } else { MessageBox.Show("لطفا ابتدا یک نوبت را انتخاب نمایید", "خطا", MessageBoxButtons.OK); } }