protected void btnEmitir_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(hdnFechaDesde.Value) || string.IsNullOrEmpty(hdnFechaHasta.Value)) { throw new Exception("Debe realizar busqueda primero"); } List <DTO_EMISION_FACTURA> lista = new List <DTO_EMISION_FACTURA>(); foreach (GridViewRow row in grdFacturas.Rows) { if (row.RowType == DataControlRowType.DataRow) { var hdnId = row.FindControl("hdnId") as HiddenField; var txtDescuento = row.FindControl("txtDescuento") as TextBox; //se guardan las modificaciones cuando existen DTO_EMISION_FACTURA dto = new DTO_EMISION_FACTURA(); dto.ID_CLIENTE = int.Parse(hdnId.Value); dto.DESCUENTO = int.Parse(txtDescuento.Text); lista.Add(dto); } } if (!lista.Any()) { throw new Exception("No hay prestaciones por facturar"); } DateTime FechaDesde = DateTime.Parse(hdnFechaDesde.Value); DateTime FechaHasta = DateTime.Parse(hdnFechaHasta.Value); TrxFACTURACION _TrxFACTURACION = new TrxFACTURACION(); _TrxFACTURACION.EmitirFacturas(lista, FechaDesde, FechaHasta); Response.Redirect("MensajeExito.aspx?t=Emisión de Facturas&m=Se han emitidos los documentos correspondientes", false); } catch (Exception ex) { ISException.RegisterExcepcion(ex); panelMensaje.CssClass = "MostrarMensaje"; lblMensaje.Text = ex.Message; return; } }
protected void btnEmitir_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(hdnFechaDesde.Value) || string.IsNullOrEmpty(hdnFechaHasta.Value)) throw new Exception("Debe realizar busqueda primero"); List<DTO_EMISION_FACTURA> lista = new List<DTO_EMISION_FACTURA>(); foreach (GridViewRow row in grdFacturas.Rows) { if (row.RowType == DataControlRowType.DataRow) { var hdnId = row.FindControl("hdnId") as HiddenField; var txtDescuento = row.FindControl("txtDescuento") as TextBox; //se guardan las modificaciones cuando existen DTO_EMISION_FACTURA dto = new DTO_EMISION_FACTURA(); dto.ID_CLIENTE = int.Parse(hdnId.Value); dto.DESCUENTO = int.Parse(txtDescuento.Text); lista.Add(dto); } } if (!lista.Any()) throw new Exception("No hay prestaciones por facturar"); DateTime FechaDesde = DateTime.Parse(hdnFechaDesde.Value); DateTime FechaHasta = DateTime.Parse(hdnFechaHasta.Value); TrxFACTURACION _TrxFACTURACION = new TrxFACTURACION(); _TrxFACTURACION.EmitirFacturas(lista, FechaDesde, FechaHasta); Response.Redirect("MensajeExito.aspx?t=Emisión de Facturas&m=Se han emitidos los documentos correspondientes", false); } catch (Exception ex) { ISException.RegisterExcepcion(ex); panelMensaje.CssClass = "MostrarMensaje"; lblMensaje.Text = ex.Message; return; } }