public void RemoverElemento(int index) { try { if (index >= this.vista.Deducibles.Count || index < 0) { throw new Exception("No se encontró el deducible seleccionado"); } List <DeducibleBO> deducibles = this.vista.Deducibles; DeducibleBO deducible = deducibles[index]; if (deducible.DeducibleID.HasValue) { deducible.DeducibleID = deducible.DeducibleID * -1; List <DeducibleBO> borrados = this.vista.DeduciblesBorrados; borrados.Add(deducible); this.vista.DeduciblesBorrados = borrados; } deducibles.RemoveAt(index); this.vista.Deducibles = deducibles; this.vista.ActualizarLista(); } catch (Exception ex) { throw new Exception(this.nombreClase + ".RemoverElemento: " + ex.Message); } }
public void AgregarElemento() { string s; if ((s = this.ValidarCampos()) != null) { this.vista.MostrarMensaje(s, ETipoMensajeIU.ADVERTENCIA, null); return; } if ((s = this.ValidarFormato()) != null) { this.vista.MostrarMensaje(s, ETipoMensajeIU.ADVERTENCIA, null); return; } try { List <DeducibleBO> deducibles = this.vista.Deducibles; DeducibleBO deducible = new DeducibleBO { Concepto = this.vista.Concepto, Porcentaje = this.vista.Porcentaje }; deducibles.Add(deducible); this.vista.Deducibles = deducibles; this.vista.ActualizarLista(); this.vista.LimpiarCampos(); } catch (Exception ex) { throw new Exception(this.nombreClase + ".AgregarItem: " + ex.Message); } }
protected void grdDeducibles_RowCommand(object sender, GridViewCommandEventArgs e) { try { string eCommandNameUpper = e.CommandName.ToUpper(); if (eCommandNameUpper == "PAGE" || eCommandNameUpper == "SORT") { return; } int index = Convert.ToInt32(e.CommandArgument); switch (e.CommandName.ToString()) { case "Eliminar": DeducibleBO deducible = this.Deducibles[index]; presentador.RemoverElemento(index); break; } } catch (Exception ex) { MostrarMensaje("Inconsistencias al presentar la información", ETipoMensajeIU.ERROR, nombreClase + ".grdDeducibles_RowCommand: " + ex.Message); } }