// Alta private void Button1_Click(object sender, EventArgs e) { // formato DD/MM/AAAA var regex = new Regex(@"\d{1,2}/\d{1,2}/\d{4}"); if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox2.Text) && regex.IsMatch(txtFechaNac.Text) ) { BE.Persona persona = new BE.Persona { Nombre = textBox1.Text, Apellido = textBox2.Text, FechaNac = DateTime.Parse(txtFechaNac.Text) }; if (BLLpersona.Alta(persona)) { MessageBox.Show("Todo ok"); Enlazar(); } } else { MessageBox.Show("Verifique los datos ingresados."); } }
private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Rows.Count > 0) { PERSONA_SELECCIONADA = (BE.Persona)dataGridView1.Rows[e.RowIndex].DataBoundItem; } }
private void btnModificar_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count != 1) { MessageBox.Show("Seleccione solo una persona."); return; } if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox2.Text)) { var cells = dataGridView1.SelectedRows[0].Cells; BE.Persona persona = new BE.Persona { ID = (int)cells[0].Value, Nombre = textBox1.Text, Apellido = textBox2.Text, FechaNac = dateTimePicker1.Value, }; if (BLLpersona.Modificar(persona)) { MessageBox.Show("Todo ok"); Enlazar(); } } else { MessageBox.Show("Debe ingresar datos a modificar."); } }