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 void btnAceptar_Click(object sender, System.EventArgs e) { if (ValidarDatos()) { if (laboratorio == null) { laboratorio = new Laboratorio(); } laboratorio.NombreLaboratorio = txtLaboratorio.Text; if (ValidarObjeto()) { if (!_esEdicion) { try { _servicio.Guardar(laboratorio); if (frm != null) { frm.AgregarFila(laboratorio); } MessageBox.Show("Registro Guardado", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult dr = MessageBox.Show("¿Desea dar de alta otro registro?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.No) { DialogResult = DialogResult.Cancel; } else { InicializarControles(); } } catch (Exception exception) { MessageBox.Show(exception.Message); } } else { DialogResult = DialogResult.OK; } } } }