private void butDelete_Click(object sender, EventArgs e) { if (gridVoiceMails.SelectedCell.Y == -1 || gridVoiceMails.ListGridRows.Count <= gridVoiceMails.SelectedCell.Y) { MsgBox.Show(this, "No voice mail selected"); return; } VoiceMail voiceMailCur = (VoiceMail)gridVoiceMails.ListGridRows[gridVoiceMails.SelectedCell.Y].Tag; if (voiceMailCur.StatusVM == VoiceMailStatus.Deleted) { MsgBox.Show(this, "Voice mail is already deleted."); return; } //Check if the voice mail has been altered by another user before we delete it. VoiceMail voiceMailDb = VoiceMails.GetOne(voiceMailCur.VoiceMailNum); if (voiceMailCur.UserNum != voiceMailDb.UserNum || voiceMailCur.PatNum != voiceMailDb.PatNum || voiceMailCur.StatusVM != voiceMailDb.StatusVM || voiceMailCur.FileName != voiceMailDb.FileName) { MsgBox.Show(this, "Another user has modified this voice mail."); FillGrid(); return; } try { VoiceMails.Archive(voiceMailCur); } catch (Exception ex) { MessageBox.Show(Lan.g(this, "Unable to archive deleted voice mail:") + "\r\n" + ex.Message); return; } axWindowsMediaPlayer.close(); //No need to keep playing a deleted message. FillGrid(); }