protected void btnEmitir_Click(object sender, EventArgs e) { try { // Valido los datos if (ValidarEmision()) { // Cargo los datos a guardar IFactura factura = FacturaFactory.GetFactura(); factura.GuiaID = GuiaID; factura.ClienteID = ClienteFacturacion1.ClienteCorporativoID ?? 0; factura.ClienteEventualID = ClienteFacturacion1.ClienteEventualID ?? 0; factura.AgenciaID = AgenciaConectadaID; factura.UnidadNegocioID = UnidadNegocioID; factura.CondicionIVAAgentePago = ClienteFacturacion1.CondicionIVA ?? 0; factura.NroCUITAgentePago = ClienteFacturacion1.NroCUIT; if (rbtContado.Checked) { factura.CondicionPagoID = (Int32)NegociosSisPackInterface.SisPack.CondicionPago.Contado; } else if (rbtCtaCte.Checked) { factura.CondicionPagoID = (Int32)NegociosSisPackInterface.SisPack.CondicionPago.CuentaCorriente; } else if (rbtPagoEnDestino.Checked) { factura.CondicionPagoID = (Int32)NegociosSisPackInterface.SisPack.CondicionPago.PagoEnDestino; } else { factura.CondicionPagoID = (Int32)NegociosSisPackInterface.SisPack.CondicionPago.TarjCredDeb; } factura.UsuarioIDAlta = usuario.UsuarioID; factura.ClienteEventual = ClienteFacturacion1.ClienteEventual; if (rbtTarjetaDeCredito.Checked) { Int32 _auxTarjeta; if (Int32.TryParse(txtNroLote.Text, out _auxTarjeta)) { factura.NroLoteTarjeta = _auxTarjeta; } if (Int32.TryParse(txtNroCupon.Text, out _auxTarjeta)) { factura.NroCuponTarjeta = _auxTarjeta; } } if (txtObservaciones.Text.Length > 500) { txtObservaciones.Text = txtObservaciones.Text.Substring(0, 500); } factura.Observaciones = txtObservaciones.Text; factura.NroRemitoCliente = txtNroRemitoCliente.Text.Trim(); factura.NroFacturaCliente = txtNroFacturaCliente.Text.Trim(); factura.NroHojaRutaCliente = txtNroHojaRutaCliente.Text.Trim(); IFacturaDetalle detalle = FacturaDetalleFactory.GetFacturaDetalle(); detalle.ConceptoFacturacionID = Convert.ToInt32(ddlConceptoFacturacion.SelectedValue); if (txtTope.Text != "") { detalle.Tope = Convert.ToDouble(txtTope.Text);//.Replace(".",",")); } if (txtCodigoBarras.Text != "") { detalle.CodigoBarras = txtCodigoBarras.Text.Trim();//.Replace(".",",")); } factura.DetalleFactura.Add(detalle); factura.ValidarCredito(); factura.ValidarCodigosDeBarra(); string _tipoGuia = factura.DeterminarTipoFacturaConceptoFacturacion(); factura.TipoGuia = _tipoGuia; // Reviso si tengo que determinar la empresa de facturación if (_tipoGuia == "A" || _tipoGuia == "B") { try { int _empresaFacturacionID = factura.DeterminarEmpresaFacturacionConceptoFacturacion(); factura.EmpresaFacturacionID = _empresaFacturacionID; factura.CargarInfoComprobante(); factura.CalcularImporteConceptoFacturacion(); /*****************************************************************/ //ws = Session["WSFactElect"] as SisPack.WSFEL.FEService; //if (ws == null) //{ // // create the proxy // //MyService = new localhost.MyDemo(); // ws = new SisPack.WSFEL.FEService(); // // create a container for the SessionID cookie // ws.CookieContainer = new CookieContainer(); // // store it in Session for next usage // Session["WSFactElect"] = ws; // ws.Inicializar(long.Parse(CUITExpress), NombreCertificadoExpress, Ambiente); // // ws.Inicializar(long.Parse(CUITCargas), NombreCertificadoCargas, Ambiente); //} IAFIP afip = AFIPFactory.GetAFIP(); string referencia = string.Empty; //string sError = string.Empty; //DateTime sVencimientoCae = new DateTime(); // Detalles detalleFE = new Detalles(); int puntoVta = int.Parse(factura.NroSucursalGuia); int tipoCbe = 6; int tipoDocumento = 96; long numeroDocumento = 30414121; int tipoConcepto = 2; double total = factura.ImporteTotal; double totalConcepto = 0; double neto = factura.ImporteNeto; double exento = 0; double totalTributos = 0; double totalIva = factura.ImporteIVA; int tipoIva = 5; long nroFactura = 0; if (factura.TipoGuia == "A") { tipoCbe = 1; //Factura A numeroDocumento = long.Parse(factura.ClienteEventual.NroCuit); if ((int)factura.ClienteEventual.TipoDocumentoCuit == 5) { tipoDocumento = 80; //CUIT } else if ((int)factura.ClienteEventual.TipoDocumentoCuit == 6) { tipoDocumento = 86; //CUIL } else { tipoDocumento = 91; //91 } } else { tipoCbe = 6; //Factura B numeroDocumento = long.Parse(factura.ClienteEventual.NroDocumento.ToString()); if ((int)factura.ClienteEventual.TipoDocumento == 1) { tipoDocumento = 96; //DNI } else if ((int)factura.ClienteEventual.TipoDocumento == 2) { tipoDocumento = 90; //LC } else if ((int)factura.ClienteEventual.TipoDocumento == 3) { tipoDocumento = 89; //LE } else if ((int)factura.ClienteEventual.TipoDocumento == 4) { tipoDocumento = 94; //Pasaporte } else if ((int)factura.ClienteEventual.TipoDocumento == 6) { tipoDocumento = 86; //CUIL } else { tipoDocumento = 91; //91 } } string fechaFE = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00"); if (totalIva == 0) { tipoIva = 3; //Iva 0 } //detalleFE.Ivas.AddIvasRow(tipoIva, neto, totalIva); if (factura.EmpresaFacturacionID == 1) { //nroFactura = ws.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITExpress)) + 1; //factura.NumeroCAE = ws.ObtenerCAE(1, 1, puntoVta, tipoCbe, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, nroFactura, fechaFE, // total, totalConcepto, neto, exento, totalTributos, totalIva, fechaFE, fechaFE, fechaFE, "PES", 1, detalleFE, ref sError, ref sVencimientoCae, long.Parse(CUITExpress)); if (afip.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITExpress), NombreCertificadoExpress, Ambiente)) { nroFactura = afip.NumeroFactura; if (afip.ObtenerCAE(puntoVta, tipoCbe, long.Parse(CUITExpress), NombreCertificadoExpress, Ambiente, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, fechaFE, total, totalConcepto, neto, exento, totalTributos, totalIva, tipoIva)) { factura.NumeroCAE = afip.NumeroCAE; } } } else { //nroFactura = ws.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITCargas)) + 1; //factura.NumeroCAE = ws.ObtenerCAE(1, 1, puntoVta, tipoCbe, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, nroFactura, fechaFE, // total, totalConcepto, neto, exento, totalTributos, totalIva, fechaFE, fechaFE, fechaFE, "PES", 1, detalleFE, ref sError, ref sVencimientoCae, long.Parse(CUITCargas)); } //if (sError.Contains("10016-El número o fecha del comprobante no se corresponde con el próximo a autorizar.")) if (afip.errorCAE.Contains("10016-El número o fecha del comprobante no se corresponde con el próximo a autorizar.")) { //verifico nuevamente por si alguien estaba usando ese numero if (factura.EmpresaFacturacionID == 1) { //nroFactura = ws.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITExpress)) + 1; //factura.NumeroCAE = ws.ObtenerCAE(1, 1, puntoVta, tipoCbe, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, nroFactura, fechaFE, // total, totalConcepto, neto, exento, totalTributos, totalIva, fechaFE, fechaFE, fechaFE, "PES", 1, detalleFE, ref sError, ref sVencimientoCae, long.Parse(CUITExpress)); if (afip.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITExpress), NombreCertificadoExpress, Ambiente)) { nroFactura = afip.NumeroFactura; if (afip.ObtenerCAE(puntoVta, tipoCbe, long.Parse(CUITExpress), NombreCertificadoExpress, Ambiente, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, fechaFE, total, totalConcepto, neto, exento, totalTributos, totalIva, tipoIva)) { factura.NumeroCAE = afip.NumeroCAE; } } } else { //nroFactura = ws.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITCargas)) + 1; //factura.NumeroCAE = ws.ObtenerCAE(1, 1, puntoVta, tipoCbe, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, nroFactura, fechaFE, // total, totalConcepto, neto, exento, totalTributos, totalIva, fechaFE, fechaFE, fechaFE, "PES", 1, detalleFE, ref sError, ref sVencimientoCae, long.Parse(CUITCargas)); } if (afip.errorCAE != string.Empty) { using (System.IO.StreamWriter archivo = System.IO.File.AppendText(@"C:\log\LogEmisionConcepto.log")) { archivo.WriteLine("EmisionConceptoFacturacion.aspx.cs linea 815-------------------------------------------------------------------------------------"); archivo.WriteLine("--------------------------------------------------------------------------------------"); } factura.EmitirFacturaConceptoFacturacion(null); } else { //factura.FechaCae = sVencimientoCae; factura.FechaCae = afip.fechaCAE; factura.NroGuia = int.Parse(nroFactura.ToString()); factura.EmitirFacturaConceptoFacturacionFE(null); } } else if (afip.errorCAE != string.Empty || (afip.errorCAE == string.Empty && factura.NumeroCAE == string.Empty)) { using (System.IO.StreamWriter archivo = System.IO.File.AppendText(@"C:\log\LogEmisionConcepto.log")) { archivo.WriteLine("EmisionConceptoFacturacion.aspx.cs linea 832-------------------------------------------------------------------------------------"); archivo.WriteLine("--------------------------------------------------------------------------------------"); } //Paso a la modalidad autoimpresor factura.EmitirFacturaConceptoFacturacion(null); } else { //factura.FechaCae = sVencimientoCae; factura.FechaCae = afip.fechaCAE; factura.NroGuia = int.Parse(nroFactura.ToString()); factura.EmitirFacturaConceptoFacturacionFE(null); } } catch (Exception ex) { using (System.IO.StreamWriter archivo = System.IO.File.AppendText(@"C:\log\LogEmisionConcepto.log")) { archivo.WriteLine("EmisionConceptoFacturacion.aspx.cs linea 850-------------------------------------------------------------------------------------"); archivo.WriteLine("--------------------------------------------------------------------------------------"); } factura.EmitirFacturaConceptoFacturacion(null); } /*****************************************************************/ } else { factura.EmitirFacturaConceptoFacturacion(null); } // Cargo los datos para imprimir IAgencia agencia = AgenciaFactory.GetAgencia(); txtPaginaImpresion.Value = agencia.GetPaginaImpresion(factura.TipoImpresionGuiaID, Implementacion); txtFacturaID.Value = factura.FacturaID.ToString(); //if (factura.ImportePercepcion != 0) //{ // int facturaid = factura.FacturaID; // //guardar en una tabla nueva la guiaid, percepcionid, percpecion importe. // //parte de inserrtar el origen // IPercepcionDominio _perDominio = IoC.GetObjectDominio<IPercepcionDominio>(); // List<Dominio.Entidades.GetOnePercepcionDatos> lstPerOrigen = _perDominio.PercepcionGetAllBYAgOri(this.AgenciaConectadaID); // if (lstPerOrigen.Count > 0) // { // _perDominio.InsertPercepcionFactura(lstPerOrigen[0].PercepcionID, facturaid, Convert.ToDouble(lstPerOrigen[0].PorcentajeImporte), "Origen", factura.ImportePercepcion); // } //} //guardar el mail if (txtFacturaID.Value != "0") { this.GuardarMail(Convert.ToInt32(txtFacturaID.Value)); } Session["DatosGuia"] = ToDsGuiaFacturaImpresion(factura.GetFacturaConceptoImpresionByFacturaID()); } } catch (Exception ex) { if (ex.Message.Contains("Datos inválidos:")) { throw ex; } else { throw new Exception("Error al guardar factura"); } } }
private bool Anular() { try { IAgencia oAgencia = AgenciaFactory.GetAgencia(); oAgencia.AgenciaID = this.AgenciaConectadaID; IParametroUNegocio param = ParametroUNegocioFactory.GetParametroUNegocio(); param.Parametro = NegociosSisPackInterface.SisPack.Parametro.AgenciaDeAdministracion; param.UnidadNegocioID = this.UnidadNegocioID; param.Consultar(); int agAdm = Utiles.Validaciones.obtieneEntero(param.ValorString); /* Verónica: La anulación la debe realizar la agencia de origen */ /*SFE: 12/04/2011. Anulacion de Facturas a Terminal desde Administracion. Se agrega la condicion de controlar si la agencia Conectada es Administracion*/ if (this.AgenciaConectadaID == Convert.ToInt32(this.txtAgenciaID.Text) || this.AgenciaConectadaID == agAdm) { bool bOk = false; IFactura factura = FacturaFactory.GetFactura(); factura.FacturaID = Convert.ToInt32(this.txtFacturaID.Text.Trim()); factura.TipoGuia = this.txtTipoGuia.Text.Trim(); factura.TipoImpresionGuiaID = Convert.ToInt32(this.txtTipoImpresionGuiaID.Text.Trim()); factura.AgenciaID = Convert.ToInt32(this.txtAgenciaID.Text.Trim()); factura.ClasificacionFacturaID = Convert.ToInt32(this.txtClasificacionFacturaID.Text.Trim()); factura.GuiaID = Utiles.Validaciones.obtieneEntero(this.txtGuiaID.Text.Trim()); factura.FechaEmision = Convert.ToDateTime(Utiles.Validaciones.obtieneFecha(txtFecha.Text)); factura.ObservacionIDGuia = Convert.ToInt32(Observacion1.ObservacionID); factura.UnidadNegocioID = UnidadNegocioID; factura.EliminarEstadosConformacion = true; bOk = factura.Anular(this.txtObservaciones.Text, this.usuario, this.AgenciaConectadaID); //esto es porque si se anula la factura y esta factura esta asociada a una guia que es subia a una HRR //se conforma y se agrega una observacion en la HRR if (factura.CambiarHRRFactAnulada(Convert.ToInt32(Utiles.Validaciones.obtieneEntero(this.txtGuiaID.Text.Trim()))) == 1) { factura.CambiaEstadoHRRFactAnulada(Convert.ToInt32(Utiles.Validaciones.obtieneEntero(this.txtGuiaID.Text.Trim()))); } //////////**********************************************************************************************************************////////// DsFactura ds; if (this.radioTipo.Checked) { ds = BuscarPorTipo(); } else { ds = BuscarPorCodigo(); } IClienteEventual ev = ClienteEventualFactory.GetClienteEventual(); if (ds.Tables[0].Rows[0]["ClienteEventualID"] != null) { ev.ClienteEventualID = int.Parse(ds.Tables[0].Rows[0]["ClienteEventualID"].ToString()); ev.Consultar(); } if (ds.Tables[0].Rows[0]["TipoGuia"].ToString() == "A" || ds.Tables[0].Rows[0]["TipoGuia"].ToString() == "B") { try { // La validación del número de guía debe realizarse sólo si el modo de impresión no es "Autoimpresor" IAgencia agencia = AgenciaFactory.GetAgencia(); agencia.AgenciaID = this.AgenciaConectadaID; agencia.Consultar(); //ws = Session["WSFactElect"] as SisPack.WSFEL.FEService; //if (ws == null) //{ // // create the proxy // //MyService = new localhost.MyDemo(); // ws = new SisPack.WSFEL.FEService(); // // create a container for the SessionID cookie // ws.CookieContainer = new CookieContainer(); // ws.Inicializar(long.Parse(CUITExpress), NombreCertificadoExpress, Ambiente); // //ws.Inicializar(long.Parse(CUITCargas), NombreCertificadoCargas, Ambiente); // // store it in Session for next usage // Session["WSFactElect"] = ws; //} string referencia = string.Empty; try { //string sError = string.Empty; //DateTime sVencimientoCae = new DateTime(); //Detalles detalle = new Detalles(); int puntoVta = int.Parse(ds.Tables[0].Rows[0]["NroSucursalGuia"].ToString()); int tipoCbe = 6; int tipoDocumento = 96; long numeroDocumento = 30414121; int tipoConcepto = 2; double totalConcepto = 0; double neto = double.Parse(ds.Tables[0].Rows[0]["ImporteNeto"].ToString()); double exento = 0; double totalTributos = 0; double totalIva = double.Parse(ds.Tables[0].Rows[0]["ImporteIVA"].ToString()); double total = neto + totalIva; int tipoIva = 5; long nroFactura = 0; if (ds.Tables[0].Rows[0]["TipoGuia"].ToString() == "A") { tipoCbe = 3; //Nota de Crédito A numeroDocumento = long.Parse(ev.NroCuit); if ((int)ev.TipoDocumentoCuit == 5) { tipoDocumento = 80; //CUIT } else if ((int)ev.TipoDocumentoCuit == 6) { tipoDocumento = 86; //CUIL } else { tipoDocumento = 91; //91 } } else { tipoCbe = 8; //Nota de Crédito B numeroDocumento = long.Parse(ev.NroDocumento.ToString()); if ((int)ev.TipoDocumento == 1) { tipoDocumento = 96; //DNI } else if ((int)ev.TipoDocumento == 2) { tipoDocumento = 90; //LC } else if ((int)ev.TipoDocumento == 3) { tipoDocumento = 89; //LE } else if ((int)ev.TipoDocumento == 4) { tipoDocumento = 94; //Pasaporte } else if ((int)ev.TipoDocumento == 6) { tipoDocumento = 86; //CUIL } else { tipoDocumento = 91; //91 } } if (totalIva == 0) { tipoIva = 3; //Iva 0 } IAFIP afip = AFIPFactory.GetAFIP(); string fechaFE = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00"); //detalle.Ivas.AddIvasRow(tipoIva, neto, totalIva); string NumeroCAE = string.Empty; if (ds.Tables[0].Rows[0]["EmpresaFacturacionID"].ToString() == "1") { //nroFactura = ws.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITExpress)) + 1; //NumeroCAE = ws.ObtenerCAE(1, 1, puntoVta, tipoCbe, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, nroFactura, fechaFE, // total, totalConcepto, neto, exento, totalTributos, totalIva, fechaFE, fechaFE, fechaFE, "PES", 1, detalle, ref sError, ref sVencimientoCae, long.Parse(CUITExpress)); if (afip.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITExpress), NombreCertificadoExpress, Ambiente)) { nroFactura = afip.NumeroFactura; if (afip.ObtenerCAE(puntoVta, tipoCbe, long.Parse(CUITExpress), NombreCertificadoExpress, Ambiente, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, fechaFE, total, totalConcepto, neto, exento, totalTributos, totalIva, tipoIva)) { NumeroCAE = afip.NumeroCAE; } } } else { //nroFactura = ws.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITCargas)) + 1; //NumeroCAE = ws.ObtenerCAE(1, 1, puntoVta, tipoCbe, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, nroFactura, fechaFE, // total, totalConcepto, neto, exento, totalTributos, totalIva, fechaFE, fechaFE, fechaFE, "PES", 1, detalle, ref sError, ref sVencimientoCae, long.Parse(CUITCargas)); } //if (sError.Contains("10016-El número o fecha del comprobante no se corresponde con el próximo a autorizar.")) if (afip.errorCAE.Contains("10016-El número o fecha del comprobante no se corresponde con el próximo a autorizar.")) { //verifico nuevamente por si alguien estaba usando ese numero if (ds.Tables[0].Rows[0]["EmpresaFacturacionID"].ToString() == "1") { //nroFactura = ws.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITExpress)) + 1; //NumeroCAE = ws.ObtenerCAE(1, 1, puntoVta, tipoCbe, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, nroFactura, fechaFE, // total, totalConcepto, neto, exento, totalTributos, totalIva, fechaFE, fechaFE, fechaFE, "PES", 1, detalle, ref sError, ref sVencimientoCae, long.Parse(CUITExpress)); if (afip.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITExpress), NombreCertificadoExpress, Ambiente)) { nroFactura = afip.NumeroFactura; if (afip.ObtenerCAE(puntoVta, tipoCbe, long.Parse(CUITExpress), NombreCertificadoExpress, Ambiente, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, fechaFE, total, totalConcepto, neto, exento, totalTributos, totalIva, tipoIva)) { NumeroCAE = afip.NumeroCAE; } } } else { //nroFactura = ws.ObtieneUltimoNroCbte(puntoVta, tipoCbe, long.Parse(CUITCargas)) + 1; //NumeroCAE = ws.ObtenerCAE(1, 1, puntoVta, tipoCbe, tipoConcepto, tipoDocumento, numeroDocumento, nroFactura, nroFactura, fechaFE, // total, totalConcepto, neto, exento, totalTributos, totalIva, fechaFE, fechaFE, fechaFE, "PES", 1, detalle, ref sError, ref sVencimientoCae, long.Parse(CUITCargas)); } } else if (afip.errorCAE != string.Empty) { using (System.IO.StreamWriter archivo = System.IO.File.AppendText(@"C:\log\LogFactura.log")) { archivo.WriteLine("AnularFactura.aspx.cs linea 753-------------------------------------------------------------------------------------"); archivo.WriteLine("--------------------------------------------------------------------------------------"); } } if (NumeroCAE != null && NumeroCAE != string.Empty) { ComprobanteElectronico ce = new ComprobanteElectronico(); ce.PuntoVenta = puntoVta.ToString(); ce.TipoComprobanteFEID = tipoCbe; ce.TipoConceptoFEID = tipoConcepto; ce.TipoDocumentoFEID = tipoDocumento; ce.NumeroDocumento = numeroDocumento.ToString(); ce.NumeroFactura = nroFactura.ToString(); ce.FechaFE = DateTime.Now; ce.Total = total; ce.TotalConcepto = totalConcepto; ce.Neto = neto; ce.Exento = exento; ce.TotalTributos = totalTributos; ce.TotalIVA = totalIva; ce.FechaVencimientoCae = afip.fechaCAE; ce.NumeroCae = NumeroCAE; ce.EmpresaFacturacionID = int.Parse(ds.Tables[0].Rows[0]["EmpresaFacturacionID"].ToString()); IoC.GetObjectDominio <IComprobanteElectronicoDominio>().Guardar(ce); } //datet.FechaCae = sVencimientoCae; //admGuiaO.FechaVencimientoCAI = sVencimientoCae; //admGuiaO.NroGuia = int.Parse(nroFactura.ToString()); } catch (Exception ex) { using (System.IO.StreamWriter archivo = System.IO.File.AppendText(@"C:\log\LogFactura.log")) { archivo.WriteLine("AnularFactura.aspx.cs linea 786-------------------------------------------------------------------------------------"); archivo.WriteLine(ex.Message); archivo.WriteLine("--------------------------------------------------------------------------------------"); } ex = new Exception("Error al crear la nota de credito para asociar a la factura. " + ex.Message); throw ex; } //Session["AdmGuia"] = admGuiaO; //this.txtNroGuia.Text = admGuiaO.NroGuia.ToString(); // GuardarFactura(agencia.TipoImpresionGuiaId, (int)NegociosSisPackInterface.SisPack.TipoValidacionEmision.CAE); } catch (Exception ex) { oAgencia = null; ex = new Exception("Error al crear la nota de credito para asociar a la factura. No se puede conectar con el WS de la AFIP" + ex.Message); throw ex; } } /////////************************************************************************************************************************////// factura = null; oAgencia = null; return(bOk); } else { oAgencia = null; Exception ex = new Exception("Solo la agencia emisora puede anular la factura."); throw ex; } } catch (Exception ex) { throw ex; } }