Ejemplo n.º 1
0
        private async void Button_Delete_Click(object sender, EventArgs e)
        {
            if (selectedItemId >= 0)
            {
                if (messageBoxHelper.showYesNo(this, "Are you sure you want to delete this template?", "Warning") == DialogResult.Yes)
                {
                    await templateServices.deleteMailTemplate(
                        emailTemplates[selectedItemId].id
                        );

                    ListBox_EmailTemplates.Items.RemoveAt(selectedItemId);
                    emailTemplates.RemoveAt(selectedItemId);
                    mainWindow.mailTemplates.RemoveAt(selectedItemId);
                    selectedItemId = -1;
                    ListBox_EmailTemplates.SelectedIndex = -1;
                    ComboBox_TemplateStrings.Enabled     = false;
                    TextBox_TemplateName.Enabled         = false;
                    TextBox_Subject.Enabled       = false;
                    TextBox_Body.Enabled          = false;
                    ComboBox_TemplateStrings.Text = "";
                    TextBox_TemplateName.Text     = "";
                    TextBox_Subject.Text          = "";
                    TextBox_Body.Text             = "";
                }
            }
            else
            {
                messageBoxHelper.showWarning(this, "No template has been choosen", "Warning");
            }
        }
Ejemplo n.º 2
0
        private async void Button_Delete_Click(object sender, EventArgs e)
        {
            DialogResult result = messageBoxHelper.showYesNo(this,
                                                             "Are you sure you want to delete this participant", "Question");

            if (result == DialogResult.Yes)
            {
                bool deleted = await participantServices.deleteParticipant(participant.participantId);

                if (deleted)
                {
                    tableLayoutHelper.RemoveArbitraryRow(mainWindow.Table_ParticipantsData1, rowNumber);
                    mainWindow.participantsToolTipHelpers.RemoveAt(rowNumber);
                    int allParticipantsid = mainWindow.allParticipants.FindIndex(p => p.participantId.Equals(participant.participantId));
                    mainWindow.allParticipants.RemoveAt(allParticipantsid);
                    if (mainWindow.filteredParticipants.Count > 0)
                    {
                        int filteredParticipantsid = mainWindow.filteredParticipants.FindIndex(p => p.participantId.Equals(participant.participantId));
                        mainWindow.filteredParticipants.Remove(participant);
                    }
                    if (mainWindow.selectedEventParticipants.Count > 0)
                    {
                        int id = mainWindow.selectedEventParticipants.FindIndex(p => p.participantId.Equals(participant.participantId));
                        mainWindow.selectedEventParticipants.RemoveAt(id);
                    }

                    mainWindow.Label_FilteredAmount.Text   = mainWindow.filteredParticipants.Count.ToString();
                    mainWindow.Label_RegisteredAmount.Text = mainWindow.selectedEventParticipants.Count.ToString();
                    mainWindow.Enabled = true;
                    this.Dispose();
                }
                else
                {
                    messageBoxHelper.showWarning(this, "Delete unsuccesful. Check your internet " +
                                                 "connection or contact programmer (might be database issues)", "Warning");
                }
            }
            else if (result == DialogResult.No)
            {
            }
        }