private void btnAgregar_Click(object sender, EventArgs e) { try { CLS.difunto difunto = new CLS.difunto(); difunto.Iddifunto = int.Parse(txbID.Text); difunto.Idcontrato = idcontrato; difunto.Nombres = txb_nombres.Text; difunto.Apellidos = txb_apellidos.Text; difunto.CausaMuerte = txb_Causa.Text; difunto.DireccionDeEntrega = txbdireccionEntrega.Text; difunto.DireccionDeToma = txbdireccionToma.Text; difunto.Fechanacimiento = dp_fechanacimiento.Value; difunto.FechanMuerte = dtp_muerte.Value; if (difunto.Editar()) { MessageBox.Show("Registro actualizado"); this.Close(); } else { MessageBox.Show("No se puede actualizar ese registro"); } } catch { MessageBox.Show("Error al actualizar registro, intente rellenar los campos"); } }
private void btnEliminar_Click(object sender, EventArgs e) { if (SesionManager.CLS.Sesion.Instancia.Rol != "Vendedor") { if (dt_difuntos.SelectedRows.Count > 0) { DialogResult dr = MessageBox.Show("¿Desea Eliminar la Entrega ID: " + dt_difuntos.SelectedRows[0].Cells[0].Value + " ?", "Confirmacion", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { int i = (int)dt_difuntos.SelectedRows[0].Cells[0].Value; CLS.difunto d = new CLS.difunto(); if (d.Eliminar(i)) { MessageBox.Show("Registro eliminado"); this.EntregasDetalles_Load(sender, e); } else { MessageBox.Show("Este registro no pudo eliminarse"); } } } else { MessageBox.Show("Seleccione una entrega"); } } else { MessageBox.Show("Acceso Denegado"); } }