private void tslAgregar_Click(object sender, EventArgs e) { frmLaboratoriosAE frm = new frmLaboratoriosAE(this); frm.Text = "Nuevo Laboratorio"; DialogResult dr = frm.ShowDialog(this); if (dr == DialogResult.OK) { try { Laboratorio laboratorio = frm.GetLaboratorio(); if (!_servicio.Existe(laboratorio)) { _servicio.Guardar(laboratorio); DataGridViewRow r = ConstruirFila(); SetearFila(r, laboratorio); AñadirFila(r); MessageBox.Show("Registro Agregado"); } else { MessageBox.Show("Laboratorio repetido"); } } catch (Exception exception) { MessageBox.Show(exception.Message); } } }
private bool ValidarObjeto() { var valido = true; errorProvider1.Clear(); if (_servicio.Existe(laboratorio)) { valido = false; errorProvider1.SetError(txtLaboratorio, "Laboratorio repetida"); } return(valido); }