public FrmMantAlumno(AlumnoRoot alumnoRoot) { InitializeComponent(); _alumnoRoot = alumnoRoot; alumnoRootBindingSource.DataSource = _alumnoRoot; alumnoRootBindingSource.ResetBindings(false); }
private void btnEliminar_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; var seleccionado = alumnoInfoListBindingSource.Current as AlumnoInfo; if (seleccionado == null) { return; } if (MessageBox.Show("¿Está seguro que desea eliminar el registro?", "Confirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { AlumnoRoot.DeleteEditableRoot(seleccionado.Id); btnCargar.PerformClick(); } } catch (Exception ex) { MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { Cursor.Current = Cursors.Default; } }
private void btnNuevo_Click(object sender, EventArgs e) { using (var frm = new FrmMantAlumno(AlumnoRoot.NewEditableRoot())) { if (frm.ShowDialog() == DialogResult.OK) { btnCargar.PerformClick(); } } }
private void btnGrabar_Click(object sender, EventArgs e) { try { alumnoRootBindingSource.EndEdit(); _alumnoRoot = _alumnoRoot.Save(); DialogResult = DialogResult.OK; } catch (ValidationException) { MessageBox.Show(_alumnoRoot.GetBrokenRules().ToString()); } catch (DataPortalException ex) { MessageBox.Show(ex.BusinessException.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnEditar_Click(object sender, EventArgs e) { try { var seleccionado = alumnoInfoListBindingSource.Current as AlumnoInfo; if (seleccionado == null) { return; } using (var frm = new FrmMantAlumno(AlumnoRoot.GetEditableRoot(seleccionado.Id))) { if (frm.ShowDialog() == DialogResult.OK) { btnCargar.PerformClick(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }