public static DataTable ObtenerPublicacionNF() { DBAxon db = new DBAxon(); DataTable dtPublicacionPendienteEnvio = new DataTable(); try { db.OpenFactoryConnection(); string query = "SELECT * FROM fehfe " + "WHERE fehfepnfe = 1 "; dtPublicacionPendienteEnvio = db.DataAdapter(CommandType.Text, query); return(dtPublicacionPendienteEnvio); } catch (Exception ex) { throw new Exception("Excepción: ObtenerDetalleFacturaElectronica(Int64 correlativo)" + ex.Message); } finally { db.CloseFactoryConnection(); db = null; } }
public static DataTable AnularDocumentoFiscal() { DBAxon db = new DBAxon(); string file = Log.Instancia.GeneraNombreLog(); DataTable dtAnularDocumentoFiscal = new DataTable(); int respuestaUpdate = 0; try { db.OpenFactoryConnection(); db.SetLockModeToWait(); string query = "SELECT * FROM fehfe " + "WHERE fehfestat=" + (int)ESTADOS_FACTURACION_ELECTRONICA.PENDIENTE_DE_ANULAR + " AND fehfemrcb=0"; dtAnularDocumentoFiscal = db.DataAdapter(CommandType.Text, query); if (dtAnularDocumentoFiscal.Rows.Count > 0) { foreach (DataRow dataRow in dtAnularDocumentoFiscal.Rows) { try { Int64 idDocFiscalERP = Int64.Parse(dataRow["fehfeiddf"].ToString()); file += idDocFiscalERP.ToString(); string queryUpdate = "UPDATE fehfe SET fehfestat=" + (int)ESTADOS_FACTURACION_ELECTRONICA.ENVIADO_AL_FEEL_PENDIENTE_DE_ANULAR + " WHERE fehfemrcb=0 AND fehfeiddf=" + idDocFiscalERP; respuestaUpdate = db.ExecuteNonQuery(CommandType.Text, queryUpdate); } catch (Exception ex) { Log.Instancia.LogWS_Mensaje_FSX(file, "Excepción en: AnularDocumentoFiscal() al hacer un UPDATE fehfe" + ex.Message); } } } else { return(new DataTable()); } return(dtAnularDocumentoFiscal); } catch (Exception ex) { throw new Exception("Excepción: AnularDocumentoFiscal() en el try catch mas grande." + ex.Message); } finally { db.CloseFactoryConnection(); db = null; } }
DataTable ObtenerListaDetalle(string idFactura) { DBAxon db = new DBAxon(); try { db.OpenFactoryConnection(); db.SetLockModeToWait(); string query = "SELECT * FROM fedfe WHERE fedfeiddf=" + idFactura; return(db.DataAdapter(CommandType.Text, query)); } catch (Exception ex) { throw new Exception("Excepción: ObtenerListaDetalle()|" + ex.Message); } finally { db.CloseFactoryConnection(); db = null; } }
public static DataTable ObtenerCabeceraFacturaElectronicaPendienteEnvio() { DBAxon db = new DBAxon(); DataTable dtFacturaPendienteEnvio = new DataTable(); int respuestaUpdate = 0; try { db.OpenFactoryConnection(); db.SetLockModeToWait(); string query = "SELECT * FROM fehfe " + "WHERE fehfemrcb=0 AND fehfelote=0 AND fehfestat=" + (int)ESTADOS_FACTURACION_ELECTRONICA.PENDIENTES_DE_ENVIO; dtFacturaPendienteEnvio = db.DataAdapter(CommandType.Text, query); if (dtFacturaPendienteEnvio.Rows.Count > 0) { string queryUpdate = "UPDATE fehfe SET fehfestat=" + (int)ESTADOS_FACTURACION_ELECTRONICA.ENVIADA_AL_FEEL + " WHERE fehfemrcb=0 AND fehfelote=0 AND fehfestat=" + (int)ESTADOS_FACTURACION_ELECTRONICA.PENDIENTES_DE_ENVIO; respuestaUpdate = db.ExecuteNonQuery(CommandType.Text, queryUpdate); } else { return(new DataTable()); } return(dtFacturaPendienteEnvio); } catch (Exception ex) { throw new Exception("Excepción: ObtenerCabezeraFacturaElectronica() en el try catch mas grande." + ex.Message); } finally { db.CloseFactoryConnection(); db = null; } }
public DataTable ObtenerUltimoIDE() { DataTable dtUltimaFactura = new DataTable(); try { Axon.DAL.Conexion oConexion = new Axon.DAL.Conexion(); DBAxon db = new DBAxon(); db.OpenFactoryConnection(); string query = "SELECT max(fehfeiddf) FROM fehfe"; dtUltimaFactura = db.DataAdapter(CommandType.Text, query); db.CloseFactoryConnection(); db = null; } catch (Exception ex) { throw new Exception(ex.Message); } return(dtUltimaFactura); }
DataTable ObtenerFacturasAConsultar() { DBAxon db = new DBAxon(); try { db.OpenFactoryConnection(); db.SetLockModeToWait(); string query = "SELECT "; query += string.Join(", ", BD.Instancia.CamposFacturaCabeceraConsolidado); query += ", fehfecsta FROM fehfe WHERE fehfeecdf = " + EstadoDocumentoFiscal.E500_PendienteDeConsulta; return(db.DataAdapter(CommandType.Text, query)); } catch (Exception ex) { throw new Exception("Excepción: ObtenerFacturasAConsultar()|" + ex.Message); } finally { db.CloseFactoryConnection(); db = null; } }
public static DataTable ObtenerDetalleFacturaElectronicaPendienteEnvio(Int64 idDocFiscalERP) { DBAxon db = new DBAxon(); DataTable dtDetalleFacturaPendienteEnvio = new DataTable(); try { db.OpenFactoryConnection(); string query = "SELECT * FROM fedfe WHERE fedfeiddf=" + idDocFiscalERP; dtDetalleFacturaPendienteEnvio = db.DataAdapter(CommandType.Text, query); return(dtDetalleFacturaPendienteEnvio); } catch (Exception ex) { throw new Exception("Excepción: ObtenerDetalleFacturaElectronica(Int64 correlativo)" + ex.Message); } finally { db.CloseFactoryConnection(); db = null; } }
public void GeneraFacturaestandar() { int index = cbxEstadoFactura.SelectedIndex; string estadoFactura = string.Empty; if (index != -1) { //MessageBox.Show("Debe seleccionar un estado"); switch (index) { case 0: estadoFactura = "100"; break; case 1: estadoFactura = "200"; break; default: break; } } int indexTipoFactura = cbxTipoFactura.SelectedIndex; string tipoFactura = string.Empty; if (indexTipoFactura != -1) { //MessageBox.Show("Debe seleccionar un estado"); switch (indexTipoFactura) { case 0: tipoFactura = "1"; break; case 1: tipoFactura = "2"; break; case 2: tipoFactura = "3"; break; default: break; } } Axon.DAL.Conexion oConexion = new Axon.DAL.Conexion(); oConexion.CargarDatosConfiguracion(tipoConexion, baseDatos, dataSource, userId, password, clientLocale, dbLocale); DBAxon db = new DBAxon(); try { DataTable ult = new DataTable(); ult = ObtenerUltimoIDE(); int NroFacturaInicio = int.Parse(ult.Rows[0][0].ToString()) + 1; int esLote; if (!checkBox1.Checked) { esLote = 0; // 0 no es lote 1 es lote } else { esLote = 1; } int Identificadorlote = 0; int Cantidadlote = Convert.ToInt32(textBox2.Text); //cantidad de facturas que se van a generar int contingencia = 0; // si las facturas son de contingencia int CantidadDetalles = Convert.ToInt32(textBox1.Text); string query = ""; string Cabecera; string Detalle; int iddf = 0; int nfac = 0; int item = 0; int limite = NroFacturaInicio + Cantidadlote; db.OpenFactoryConnection(); db.SetLockModeToWait(); db.BeginTransaction(); for (int i = NroFacturaInicio; i < limite; i++) { query = ""; iddf = i; nfac = i; Cabecera = "INSERT INTO fehfe" + "(" + "fehfenfac, fehfedire, fehfeciud, fehfezona, fehfenmed, fehfefemi, fehfegest, fehfemmes, fehfectdi, fehfeccuf, fehfendoc, " + "fehfecomp, fehfecsuc, fehfecpve, fehfenest, fehfersoc, fehfeteve, fehfeleve, fehfefeve, fehfeaeve, fehfensal, fehfedsal, " + "fehfecmon, fehfemser, fehfedoco, fehfedico, fehfenpre, fehfemtot, fehfemtaf, fehfemled, fehfeccli, fehfel317, fehfemtsi, " + "fehfemtmo, fehfetcam, fehfemtoj, fehfemtsl, fehfecdse, fehfenemi, fehfecmpa, fehfemdes, fehfeleye, fehfeusua, fehfentar, " + "fehfepfac, fehfecpai, fehfepveh, fehfetenv, fehfemice, fehfenpro, fehfenrle, fehfecpag, fehfepent, fehfechue, fehfechab, " + "fehfecmay, fehfecmen, fehfefiho, fehfenotu, fehfersot, fehfeckwh, fehfecmcu, fehfedley, fehfetase, fehfetalu, fehfeidca, " + "fehfemtpu, fehfeomon, fehfeinco, fehfepdes, fehfeldes, fehfepvbr, fehfegtfr, fehfesfro, fehfetffr, fehfemtfr, fehfemsin, " + "fehferemi, fehfecons, fehfelapu, fehfeidbd, fehfemrcb, fehfestat, fehfecres, fehfetres, fehfecufd, fehfecont, fehfelote, " + "fehfeidlo, fehfeufac, fehfectip" + ")" + "VALUES" + "(" + " " + nfac + "," + " 'Gualberto villarroel 123', NULL, NULL, NULL, " + "20190205162700" + ", NULL, NULL, 1, NULL, '5642111', NULL, 0, 0, NULL, 'Juan Perez', NULL," + " NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, 50.5, NULL, NULL, 55421, NULL, NULL, 50.5, 6.97, NULL, NULL," + tipoFactura + "," + //fehfecdse " 1028305029, " + //--fehfenemi " 1," + " null, " + //--fehfemdes " 'Ley N 453: Est', 'FTL', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL," + " NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL," + " 0, " + estadoFactura + ", NULL, NULL, NULL, " + "0, " + //fehfecont contingencia "0, " + //fehfelote es lote "0, " + //fehfeidlo id del lote "1, " + //fehfeufac ultima factura "1" + //fehfectip codigo tipo factura ");"; query += Cabecera; for (int j = 1; j <= CantidadDetalles; j++) { Detalle = " INSERT INTO fedfe" + "( fedfeiddf, fedfeitem, fedfeaeco, fedfecpsi, fedfecpro, fedfectha, fedfecnan, fedfedesc, fedfecdia, fedfecant, fedfemice, fedfepuni, fedfestot, fedfemdes, fedfeumed, fedfenser, fedfeespe, fedfeedet, fedfenqso, fedfeemed, fedfename, fedfenifm, fedfenofm, fedfefmed, fedfepdid, fedfenaci, fedfemrcb, fedfestat ) " + "VALUES ( " + iddf + ", " + j + ", " + " '123123', 123, 123, NULL, NULL, 'coca cola 1 litro', NULL, 5, NULL, 10.1, 10.1, " + "NULL" + ", 'botella', '1234567ADC', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );"; query += Detalle; } db.DataAdapter(CommandType.Text, query); } db.CommitTransaction(); db.CloseFactoryConnection(); db = null; } catch (Exception ex) { db.RollbackTransaction(); throw new Exception(ex.Message); } }
public void ServicioGFEvalidacion() { if (ValidarDatosConexion()) { DBAxon db = new DBAxon(); Axon.DAL.Conexion oConexion = new Axon.DAL.Conexion(); string baseDatos = ConfigurationManager.AppSettings["BaseDatos"].ToString(); string dataSource = ConfigurationManager.AppSettings["DataSource"].ToString(); string userId = ConfigurationManager.AppSettings["UserId"].ToString(); string password = ConfigurationManager.AppSettings["Password"].ToString(); string dbLocale = ConfigurationManager.AppSettings["dbLocale"].ToString(); string clientLocale = ConfigurationManager.AppSettings["clientLocale"].ToString(); Axon.DAL.TipoConexion tipoConexion = (Axon.DAL.TipoConexion)Convert.ToInt32(ConfigurationManager.AppSettings["TipoConn"].ToString()); oConexion.CargarDatosConfiguracion(tipoConexion, baseDatos, dataSource, userId, password, clientLocale, dbLocale); DataTable facturas = null; try { db.OpenFactoryConnection(); db.SetLockModeToWait(); string query = "SELECT FIRST 500 fehfeifee, fehfenfac, fehfeccuf FROM fehfe WHERE fehfeifee IS NOT NULL AND fehfenfac IS NOT NULL AND fehfeccuf IS NOT NULL"; facturas = db.DataAdapter(CommandType.Text, query); } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { db.CloseFactoryConnection(); db = null; } string request = @"{""tipoValidacion""= 12,""idDocFiscalFEEL"" = ""11"",""respuestaSIN"" = true,""codigoRecepcion"" = """",""estado"" = 903,""numeroFactura"" = 1,""cuf"" = ""BCA""}"; Debug.WriteLine("Iniciando - " + DateTime.Now.ToString("HH:mm:ss")); Debug.WriteLine(facturas.Rows.Count + " facturas..."); foreach (DataRow f in facturas.Rows) { request = @"{""tipoValidacion"": 12,""idDocFiscalFEEL"" : ""[@idDoc]"",""respuestaSIN"" : true,""codigoRecepcion"": -1,""estado"": 903,""numeroFactura"": [@numFactu],""cuf"": ""[@cuf]""}"; request = request.Replace("[@idDoc]", f["fehfeifee"].ToString()); request = request.Replace("[@numFactu]", f["fehfenfac"].ToString()); request = request.Replace("[@cuf]", f["fehfeccuf"].ToString()); Stopwatch sw = new Stopwatch(); sw.Start(); //var restClient = new RestClient("http://localhost:64918/axon-gfe"); var restClient = new RestClient("http://190.104.3.139:1580/GFE/axon-gfe"); var rr = new RestRequest("validacion", Method.POST); rr.AddParameter("application/json", request, ParameterType.RequestBody); var resp = restClient.Execute(rr); sw.Stop(); Debug.WriteLine(sw.ElapsedMilliseconds); JObject res = JObject.Parse(resp.Content); if (res.ContainsKey("codRespuesta")) { if (res["codRespuesta"].ToString() != "0") { throw new Exception("Retornó error: " + res["codRespuesta"].ToString() + " - " + res["txtRespuesta"]); } } else { throw new Exception("no hay codRespuesta" + Environment.NewLine + resp.Content); } } Debug.WriteLine("FIN - " + DateTime.Now.ToString("HH:mm:ss")); } }