private void btnFacturar_Click(object sender, EventArgs e) { Factura factura = new Factura(); string error = string.Empty; TarjetaDeCredito tarjeta = null; if (Convert.ToInt32(cmbMedioDePago.SelectedValue) == 0) { error += "Seleccione un medio de pago"; } factura.TipoPagoId = Convert.ToInt32(cmbMedioDePago.SelectedValue); factura.ClienteId = this.ClienteId; if (factura.TipoPagoId == 2) { error += ValidateTarjeta(); if (string.IsNullOrEmpty(error)) { tarjeta = CreateTarjetaDeCredito(); } } if (string.IsNullOrEmpty(error)) { try { factura.EstadiaId = Convert.ToInt32(txtNroEstadia.Text); factura.Fecha = Session.Fecha; factura.Items = new List <FacturaItem>(); EstadiaService estadiaService = new EstadiaService(); Estadia estadia = estadiaService.GetById(Convert.ToInt32(txtNroEstadia.Text)); ReservaService reservaService = new ReservaService(); Reserva reserva = reservaService.GetReservaByCodigo(estadia.CodigoReserva); RegimenService regimenService = new RegimenService(); Regimen regimen = regimenService.GetByCodigo(reserva.RegimenCodigo); CreateNightsItems(factura, estadia, reserva, regimen.Precio); CreateConsumibleItems(factura, estadia, regimen.ConsumiblesGratis); foreach (FacturaItem fi in factura.Items) { factura.Total += fi.Precio; } FacturaService service = new FacturaService(); factura.Numero = service.Insert(factura, tarjeta); MostrarFactura(factura); } catch (Exception) { MessageBox.Show("Ocurrió un error al crear la factura"); } } else { MessageBox.Show(error); } }