/// <summary> /// Handles the Click event of the tsbMessageDelete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void tsbMessageDelete_Click(object sender, EventArgs e) { try { // Delete the message if (this.Message.GetType() == typeof(IncomingMessage)) { // Delete the message IncomingMessage msg = this.Message as IncomingMessage; if (StringEnum.GetStringValue(MessageStatus.Archived).Equals(msg.Status)) { DialogResult result = FormHelper.Confirm(Resources.MsgConfirmDeleteMessage); if (result == DialogResult.Yes) { // Physically delete the message msg.Delete(); RefreshMessageView(ViewAction.RefreshArchivedInbox); FormHelper.ShowInfo(Resources.MsgMessageDeleted); } } else { // Set the message status to "Archived" msg.Status = StringEnum.GetStringValue(MessageStatus.Archived); msg.Update(); RefreshMessageView(ViewAction.RefreshArchivedInbox); RefreshMessageView(ViewAction.RefreshInbox); FormHelper.ShowInfo(Resources.MsgMessageArchived); } } else if (this.Message.GetType() == typeof(OutgoingMessage)) { // Delete the message OutgoingMessage msg = this.Message as OutgoingMessage; if (StringEnum.GetStringValue(MessageStatus.Archived).Equals(msg.Status)) { DialogResult result = FormHelper.Confirm(Resources.MsgConfirmDeleteMessage); if (result == DialogResult.Yes) { // Physically delete the message msg.Delete(); RefreshMessageView(ViewAction.RefreshArchivedOutbox); FormHelper.ShowInfo(Resources.MsgMessageDeleted); } } else { // Set the message status to "Archived" msg.Status = StringEnum.GetStringValue(MessageStatus.Archived); msg.Update(); RefreshMessageView(ViewAction.RefreshArchivedOutbox); RefreshMessageView(ViewAction.RefreshOutbox); FormHelper.ShowInfo(Resources.MsgMessageArchived); } } } catch (Exception ex) { FormHelper.ShowError(ex.Message); } }