private void RecipientForm_Load(object sender, EventArgs e) { recipients = new List <ReportRecipientsDto>(); info = new FileInfo(FileName); ReportNameTextBox.Text = ReportName; FilenameTextBox.Text = info.Name; ConfigureBindingList(); ConfigureRecipientList(); RecipientNameTextBox.Focus(); }
private void AddRecipientButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(RecipientNameTextBox.Text)) { MessageBox.Show("El nombre del destinatario no puede quedar vacio.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); RecipientNameTextBox.Focus(); return; } if (string.IsNullOrEmpty(RecipientEmailTextBox.Text)) { MessageBox.Show("El email del destinatario no puede quedar vacio.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); RecipientEmailTextBox.Focus(); return; } const string expresion = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; if (!Regex.IsMatch(RecipientEmailTextBox.Text, expresion)) { MessageBox.Show("El email ingresado no es válido.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); RecipientEmailTextBox.Focus(); return; } var dto = new ReportRecipientsDto { Name = RecipientNameTextBox.Text, Subject = ReportName, Email = RecipientEmailTextBox.Text, Filename = info.FullName, Message = ReportName }; recipients.Add(dto); ConfigureBindingList(); ConfigureRecipientList(); RecipientNameTextBox.Text = string.Empty; RecipientEmailTextBox.Text = string.Empty; }