Esempio n. 1
0
        /// <summary>
        /// Удалить выделенную операцию
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int currentNumber = OperationList.CurrentCellAddress.Y;
                if (currentNumber < 0)
                {
                    MessageBox.Show("Нет выделенных записей", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                OperationClass operationInfo = GetSelectedOperation();
                if (operationInfo.OpenedOperationViewForm != null && !operationInfo.OpenedOperationViewForm.IsDisposed)
                {
                    MessageBox.Show("Данная операция заблокирована для удаления,\r\nтак как она в данный момент редактируется.\r\nЗакройте окно просмотра информации по данной операции\r\nи попробуйте ещё раз.", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    operationInfo.OpenedOperationViewForm.Focus();
                    return;
                }

                if (DialogResult.Yes == MessageBox.Show("Вы уверены, что хотите удалить все данные об операции " + OperationList.Rows[currentNumber].Cells[1].Value + "?\r\nДанная операция необратима.", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    _patientInfo.DeleteOperation(Convert.ToInt32(OperationList.Rows[currentNumber].Cells[0].Value));
                }

                ShowOperations();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }