private void tslAgregar_Click(object sender, EventArgs e) { frmTiposDeDocumentosAE frm = new frmTiposDeDocumentosAE(this); frm.Text = "Nuevo tipo de documento"; DialogResult dr = frm.ShowDialog(this); if (dr == DialogResult.OK) { try { TipoDeDocumento tipoDeDocumento = frm.GetTipoDeDocumento(); if (!_servicio.Existe(tipoDeDocumento)) { _servicio.Guardar(tipoDeDocumento); DataGridViewRow r = ConstruirFila(); SetearFila(r, tipoDeDocumento); AñadirFila(r); MessageBox.Show("Registro Agregado"); } else { MessageBox.Show("Tipo de documento repetido"); } } catch (Exception exception) { MessageBox.Show(exception.Message); } } }
private void btnAceptar_Click(object sender, System.EventArgs e) { if (ValidarDatos()) { if (tipoDeDocumento == null) { tipoDeDocumento = new TipoDeDocumento(); } tipoDeDocumento.Descripcion = txtTipoDeDocumento.Text; if (ValidarObjeto()) { if (!_esEdicion) { try { _servicio.Guardar(tipoDeDocumento); if (frm != null) { frm.AgregarFila(tipoDeDocumento); } 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; } } } }