public void RemoverElemento(int index) { try { if (index >= this.vista.Endosos.Count || index < 0) { throw new Exception("No se encontró el deducible seleccionado"); } List <EndosoBO> endosos = this.vista.Endosos; EndosoBO endoso = endosos[index]; if (endoso.EndosoID.HasValue) { endoso.EndosoID = endoso.EndosoID.Value * -1; List <EndosoBO> borrados = this.vista.EndososBorrados; borrados.Add(endoso); this.vista.EndososBorrados = borrados; } endosos.RemoveAt(index); this.vista.Endosos = endosos; this.CalcularTotales();//RI0015 this.vista.ActualizarLista(); } catch (Exception ex) { throw new Exception(this.nombreClase + ".RemoverElemento: " + ex.Message); } }
protected void grdEndosos_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": EndosoBO deducible = this.Endosos[index]; this.presentador.RemoverElemento(index); this.MostrarSumas(); break; } } catch (Exception ex) { MostrarMensaje("Inconsistencias al presentar la información", ETipoMensajeIU.ERROR, nombreClase + ".grdEndosos_RowCommand: " + ex.Message); } }
public void AgregarItem() { string s; if ((s = this.ValidarCampos()) != null) { this.vista.MostrarMensaje(s, ETipoMensajeIU.ADVERTENCIA, null); return; } try { List <EndosoBO> endosos = this.vista.Endosos; EndosoBO endoso = new EndosoBO { Importe = this.vista.Importe.Value, Motivo = this.vista.Motivo }; endosos.Add(endoso); this.vista.Endosos = endosos; this.CalcularTotales();//RI0015 this.vista.ActualizarLista(); this.vista.LimpiarCampos(); } catch (Exception ex) { throw new Exception(this.nombreClase + ".AgregarItem: " + ex.Message); } }