public int actualizar_repositorio(clsRepositorio repositorio) { int filas_afectadas = -1; try { con.conectarBD(); tra = con.conector.BeginTransaction(); cmd = new MySqlCommand("actualizar_repositorio", con.conector); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tra; cmd.Parameters.Add(new MySqlParameter("@_repositorioid", MySqlDbType.Int32)); cmd.Parameters.Add(new MySqlParameter("@_estadosunat", MySqlDbType.Int32)); cmd.Parameters.Add(new MySqlParameter("@_mensajesunat", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_pcorigenactualiza", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_usuariopcactualiza", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_docxml", MySqlDbType.LongBlob)); cmd.Parameters.Add(new MySqlParameter("@_docpdf", MySqlDbType.LongBlob)); cmd.Parameters.Add(new MySqlParameter("@_doczip", MySqlDbType.LongBlob)); cmd.Parameters[0].Value = repositorio.Repositorioid; cmd.Parameters[1].Value = repositorio.Estadosunat; cmd.Parameters[2].Value = repositorio.Mensajesunat; cmd.Parameters[3].Value = repositorio.Pcorigen; cmd.Parameters[4].Value = repositorio.Usuariopc; cmd.Parameters[5].Value = repositorio.Archivo.Xml; cmd.Parameters[6].Value = repositorio.Archivo.Pdf; cmd.Parameters[7].Value = repositorio.Archivo.Zip; dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { filas_afectadas = Convert.ToInt32(dr["_filas_afectadas"]); } dr.Close(); } tra.Commit(); return(filas_afectadas); } catch (MySqlException ex) { tra.Rollback(); return(filas_afectadas); throw ex; } finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); } }
public List <Entidades.clsRepositorio> buscar_repositorio(Entidades.clsRepositorio repo) { try { con.conectarBD(); consulta = "buscar_repositorio"; cmd = new MySqlCommand(consulta, con.conector); cmd.CommandType = CommandType.StoredProcedure; MySqlParameter oParam; oParam = cmd.Parameters.AddWithValue("_tipdoc", repo.Tipodoc); oParam = cmd.Parameters.AddWithValue("_serie", repo.Serie); oParam = cmd.Parameters.AddWithValue("_correlativo", repo.Correlativo); oParam = cmd.Parameters.AddWithValue("_fechaemision", repo.Fechaemision.ToString("yyyy/MM/dd")); oParam = cmd.Parameters.AddWithValue("_monto", repo.Monto); dr = cmd.ExecuteReader(); if (dr.HasRows) { lista = new List <clsRepositorio>(); while (dr.Read()) { clsrepo = new clsRepositorio(); clsrepo.Repoid = (int)dr["repositorioid"]; clsrepo.Tipodoc = (int)dr["tipdoc"]; clsrepo.Fechaemision = DateTime.Parse(dr["fechaemision"].ToString()).Date; clsrepo.Serie = (string)dr["serie"]; clsrepo.Correlativo = (string)dr["correlativo"]; clsrepo.Monto = (decimal)dr["monto"]; clsrepo.Estadosunat = (string)dr["estadosunat"]; clsrepo.Mensajesunat = (string)dr["mensajesunat"]; clsrepo.Pdf = (byte[])dr["docpdf"]; clsrepo.Xml = (byte[])dr["docxml"]; clsrepo.Nombredoc = (string)dr["nombredoc"]; clsrepo.Usuario = (int)dr["usuario"]; clsrepo.Fechaemision = DateTime.Parse(dr["fecharegistro"].ToString()); lista.Add(clsrepo); } } return(lista); } catch (MySqlException ex) { return(lista); } finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); } }
public clsRepositorio listar_repositorio_xtscfm(clsRepositorio repositorio) { clsRepositorio repo = null; try { con.conectarBD(); cmd = new MySqlCommand("listar_repositorio_xtscfm", con.conector); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("@_tipocomprobante", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_serie", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_correlativo", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_fechaemision", MySqlDbType.Date)); cmd.Parameters.Add(new MySqlParameter("@_monto", MySqlDbType.Decimal)); cmd.Parameters[0].Value = repositorio.Tipodocumento; cmd.Parameters[1].Value = repositorio.Serie; cmd.Parameters[2].Value = repositorio.Correlativo; cmd.Parameters[3].Value = repositorio.Fechaemision; cmd.Parameters[4].Value = repositorio.Monto; dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { repo = repositorio; repo.Repositorioid = (int)dr["repositorioid"]; } } else { repo = repositorio; repo.Repositorioid = 0; } return(repo); } catch (MySqlException ex) { return(repo); throw ex; } finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); } }
public void descargar_xml(int index, int opcion) { //opcion 1 apertura, 0 solo descarga try { repositorio = new clsRepositorio() { Repositorioid = Convert.ToInt32(dg_repositorio.Rows[index].Cells[0].Value.ToString()) }; repositorio = admrepo.listar_archivo_xrepositorio(repositorio); if (repositorio != null) { if (repositorio.Archivo != null) { if (File.Exists(dg_repositorio.Rows[index].Cells[rutaxml.Index].Value.ToString())) { File.WriteAllBytes(dg_repositorio.Rows[index].Cells[rutaxml.Index].Value.ToString(), repositorio.Archivo.Xml); } else { File.WriteAllBytes(herramienta.GetResourcesPath5() + "\\" + dg_repositorio.Rows[index].Cells[nombredocxml.Index].Value.ToString(), repositorio.Archivo.Xml); } if (opcion == 1) { if (File.Exists(dg_repositorio.Rows[index].Cells[rutaxml.Index].Value.ToString())) { Process.Start(dg_repositorio.Rows[index].Cells[rutaxml.Index].Value.ToString()); } else { Process.Start(herramienta.GetResourcesPath5() + "\\" + dg_repositorio.Rows[index].Cells[nombredocxml.Index].Value.ToString()); } } } } } catch (Exception) { } }
public bool actualiza_repositorio(clsRepositorio repo) { try { con.conectarBD(); mysqltransaccion = con.conector.BeginTransaction(); consulta = "actualiza_estadosunat_repositorio"; cmd = new MySqlCommand(consulta, con.conector); cmd.CommandType = CommandType.StoredProcedure; MySqlParameter oParam; oParam = cmd.Parameters.AddWithValue("_repositorioid", repo.Repoid); oParam = cmd.Parameters.AddWithValue("_estadosunat", repo.Estadosunat); oParam = cmd.Parameters.AddWithValue("_mensajesunat", repo.Mensajesunat); oParam = cmd.Parameters.AddWithValue("_cdrzip", repo.CDR); oParam = cmd.Parameters.AddWithValue("_resultado", 0); oParam.Direction = ParameterDirection.Output; int x = cmd.ExecuteNonQuery(); x = Convert.ToInt32(cmd.Parameters["_resultado"].Value); mysqltransaccion.Commit(); if (x != 0) { return(true); } else { return(false); } } catch (MySqlException ex) { if (mysqltransaccion != null) { mysqltransaccion.Rollback(); } throw ex; } finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); } }
public clsRepositorio listar_archivo_xrepositorio(clsRepositorio repositorio) { clsRepositorio repo = null; try { con.conectarBD(); cmd = new MySqlCommand("listar_archivo_xrepositorio", con.conector); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("@_repositorioid", MySqlDbType.Int32)); cmd.Parameters[0].Value = repositorio.Repositorioid; dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { repo = new clsRepositorio() { Archivo = new clsArchivo() { Xml = (byte[])dr["docxml"], Pdf = (byte[])dr["docpdf"] }, }; } } return(repo); } catch (MySqlException ex) { return(repo); throw ex; } finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); } }
public void descargar_pdf(int index, int opcion) { //opcion 1 apertura, 0 solo descarga try { if (!archivo_existe(dg_repositorio.Rows[index].Cells[rutapdf.Index].Value.ToString())) { repositorio = new clsRepositorio() { Repositorioid = Convert.ToInt32(dg_repositorio.Rows[index].Cells[repositorioid.Index].Value.ToString()) }; repositorio = admrepo.listar_archivo_xrepositorio(repositorio); if (repositorio != null) { if (repositorio.Archivo != null) { if (File.Exists(dg_repositorio.Rows[index].Cells[rutapdf.Index].Value.ToString())) { File.WriteAllBytes(dg_repositorio.Rows[index].Cells[rutapdf.Index].Value.ToString(), repositorio.Archivo.Pdf); } else { switch (dg_repositorio.Rows[index].Cells[tipocomprobante.Index].Value.ToString()) { case "03": File.WriteAllBytes(herramienta.GetResourcesPath6() + "\\" + dg_repositorio.Rows[index].Cells[nombredocpdf.Index].Value.ToString(), repositorio.Archivo.Pdf); break; case "01": File.WriteAllBytes(herramienta.GetResourcesPath3() + "\\" + dg_repositorio.Rows[index].Cells[nombredocpdf.Index].Value.ToString(), repositorio.Archivo.Pdf); break; case "07": File.WriteAllBytes(herramienta.GetResourcesPath7() + "\\" + dg_repositorio.Rows[index].Cells[nombredocpdf.Index].Value.ToString(), repositorio.Archivo.Pdf); break; case "08": File.WriteAllBytes(herramienta.GetResourcesPath8() + "\\" + dg_repositorio.Rows[index].Cells[nombredocpdf.Index].Value.ToString(), repositorio.Archivo.Pdf); break; } } //File.WriteAllBytes(dg_repositorio.Rows[index].Cells[rutapdf.Index].Value.ToString(), repositorio.Archivo.Pdf); if (opcion == 1) { if (File.Exists(dg_repositorio.Rows[index].Cells[rutapdf.Index].Value.ToString())) { Process.Start(dg_repositorio.Rows[index].Cells[rutapdf.Index].Value.ToString()); } else { switch (dg_repositorio.Rows[index].Cells[tipocomprobante.Index].Value.ToString()) { case "03": Process.Start(herramienta.GetResourcesPath6() + "\\" + dg_repositorio.Rows[index].Cells[nombredocpdf.Index].Value.ToString()); break; case "01": Process.Start(herramienta.GetResourcesPath3() + "\\" + dg_repositorio.Rows[index].Cells[nombredocpdf.Index].Value.ToString()); break; case "07": Process.Start(herramienta.GetResourcesPath7() + "\\" + dg_repositorio.Rows[index].Cells[nombredocpdf.Index].Value.ToString()); break; case "08": Process.Start(herramienta.GetResourcesPath8() + "\\" + dg_repositorio.Rows[index].Cells[nombredocpdf.Index].Value.ToString()); break; } //Process.Start(herramienta.GetResourcesPath5() + "\\" + dg_repositorio.Rows[index].Cells[nombredocpdf.Index].Value.ToString()); } //Process.Start(dg_repositorio.Rows[index].Cells[rutapdf.Index].Value.ToString()); } } } } else { if (opcion == 1) { Process.Start(dg_repositorio.Rows[index].Cells[rutapdf.Index].Value.ToString()); } } } catch (Exception) { } }
public async void enviar_documentos() { try { byte[] archivo_xml = null; byte[] archivo_cdr = null; int enviados = 0; byte[] archivo_pdf = null; foreach (DataGridViewRow row in dg_repositorio.Rows) { //if (!archivo_existe(row.Cells[rutaxml.Index].Value.ToString())) //{ descargar_xml(row.Index, 0); descargar_pdf(row.Index, 0); //} var tramaXmlSinFirma = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutaxml.Index].Value.ToString())) ? Convert.ToBase64String(File.ReadAllBytes(row.Cells[rutaxml.Index].Value.ToString())) : Convert.ToBase64String(File.ReadAllBytes(herramienta.GetResourcesPath5() + "\\" + dg_repositorio.Rows[row.Index].Cells[nombredocxml.Index].Value.ToString())); var firmadoRequest = new FirmadoRequest { TramaXmlSinFirma = tramaXmlSinFirma, CertificadoDigital = Convert.ToBase64String(File.ReadAllBytes(herramienta.GetResourcesPath() + "\\" + empresa.Rutacertificado)), PasswordCertificado = empresa.Clavecertificado, UnSoloNodoExtension = false }; ICertificador certificador = new Certificador(); var respuestaFirmado = await new Firmar(certificador).Post(firmadoRequest); if (!respuestaFirmado.Exito) { MessageBox.Show(respuestaFirmado.MensajeError); } var enviarDocumentoRequest = new EnviarDocumentoRequest { Ruc = empresa.Ruc, UsuarioSol = empresa.Usuariosol, ClaveSol = empresa.Clavesol, EndPointUrl = empresa.Urlenvio, //https://www.sunat.gob.pe/ol-ti-itcpgem-sqa/billService //RETENCION IdDocumento = row.Cells[comprobante.Index].Value.ToString(), TipoDocumento = row.Cells[tipocomprobante.Index].Value.ToString(), TramaXmlFirmado = respuestaFirmado.TramaXmlFirmado }; /*===================================*/ ISerializador serializador = new Serializador(); IServicioSunatDocumentos servicioSunatDocumentos = new ServicioSunatDocumentos(); RespuestaComunConArchivo respuestaEnvio; respuestaEnvio = await new EnviarDocumento(serializador, servicioSunatDocumentos).Post(enviarDocumentoRequest); var rpta = (EnviarDocumentoResponse)respuestaEnvio; if (!respuestaEnvio.Exito) { MessageBox.Show(respuestaEnvio.MensajeError); } /*==============================*/ if (rpta != null) { repositorio = new clsRepositorio(); repositorio.Repositorioid = Convert.ToInt32(row.Cells[repositorioid.Index].Value.ToString()); archivo_xml = Convert.FromBase64String(respuestaFirmado.TramaXmlFirmado); File.WriteAllBytes($"{Program.CarpetaXml}\\{rpta.NombreArchivo}.xml", archivo_xml); if (rpta.Exito) { if (rpta.MensajeRespuesta != null) { if (rpta.MensajeRespuesta.IndexOf("1033") > 0) { repositorio.Estadosunat = 0; repositorio.Mensajesunat = rpta.MensajeRespuesta; } else { if (rpta.MensajeRespuesta.IndexOf("ha sido aceptada") > 0) { repositorio.Estadosunat = 0; repositorio.Mensajesunat = rpta.MensajeRespuesta; } else { repositorio.Estadosunat = -1; repositorio.Mensajesunat = rpta.MensajeRespuesta; } } } else { repositorio.Estadosunat = -1; repositorio.Mensajesunat = "No Enviado"; } if (!string.IsNullOrEmpty(rpta.TramaZipCdr)) { archivo_cdr = Convert.FromBase64String(rpta.TramaZipCdr); File.WriteAllBytes($"{Program.CarpetaCdr}\\R-{rpta.NombreArchivo}.zip", archivo_cdr); } if (File.Exists($"{Program.CarpetaXml}\\{rpta.NombreArchivo}.xml") && File.Exists($"{Program.CarpetaCdr}\\R-{rpta.NombreArchivo}.zip")) { switch (row.Cells[tipocomprobante.Index].Value.ToString()) { case "03": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath6() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; case "01": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath3() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; case "07": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath7() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; case "08": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath8() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; } if (!string.IsNullOrEmpty(rpta.TramaZipCdr)) { archivo = new clsArchivo() { Xml = File.ReadAllBytes($"{Program.CarpetaXml}\\{rpta.NombreArchivo}.xml"), Zip = File.ReadAllBytes($"{Program.CarpetaCdr}\\R-{rpta.NombreArchivo}.zip"), Pdf = archivo_pdf }; repositorio.Archivo = archivo; repositorio.Pcorigen = SystemInformation.UserDomainName; repositorio.Usuariopc = SystemInformation.UserName; if (admrepo.actualizar_repositorio(repositorio) < 0) { MessageBox.Show("Problemas para actualizar información el proceso de detuvo...", "Información"); break; } } else { archivo = new clsArchivo() { Xml = File.ReadAllBytes($"{Program.CarpetaXml}\\{rpta.NombreArchivo}.xml"), Pdf = archivo_pdf }; repositorio.Archivo = archivo; repositorio.Pcorigen = SystemInformation.UserDomainName; repositorio.Usuariopc = SystemInformation.UserName; if (admrepo.actualizar_repositorio(repositorio) < 0) { MessageBox.Show("Problemas para actualizar información el proceso de detuvo...", "Información"); break; } } } else { switch (row.Cells[tipocomprobante.Index].Value.ToString()) { case "03": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath6() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; case "01": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath3() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; case "07": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath7() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; case "08": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath8() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; } archivo = new clsArchivo() { Xml = File.ReadAllBytes($"{Program.CarpetaXml}\\{rpta.NombreArchivo}.xml"), Pdf = archivo_pdf }; repositorio.Archivo = archivo; repositorio.Pcorigen = SystemInformation.UserDomainName; repositorio.Usuariopc = SystemInformation.UserName; if (admrepo.actualizar_repositorio(repositorio) < 0) { MessageBox.Show("Problemas para actualizar información el proceso de detuvo...", "Información"); break; } } } else { switch (row.Cells[tipocomprobante.Index].Value.ToString()) { case "03": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath6() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; case "01": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath3() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; case "07": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath7() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; case "08": archivo_pdf = (File.Exists(dg_repositorio.Rows[row.Index].Cells[rutapdf.Index].Value.ToString())) ? File.ReadAllBytes(row.Cells[rutapdf.Index].Value.ToString()) : File.ReadAllBytes(herramienta.GetResourcesPath8() + "\\" + row.Cells[nombredocpdf.Index].Value.ToString()); break; } archivo = new clsArchivo() { Xml = File.ReadAllBytes($"{Program.CarpetaXml}\\{rpta.NombreArchivo}.xml"), Pdf = archivo_pdf }; if (rpta.MensajeRespuesta != null) { if (rpta.MensajeRespuesta.IndexOf("1033") > 0) { repositorio.Estadosunat = 0; repositorio.Mensajesunat = rpta.MensajeRespuesta; } else { enviados++; repositorio.Estadosunat = -1; repositorio.Mensajesunat = rpta.MensajeRespuesta; } } else { repositorio.Estadosunat = -1; repositorio.Mensajesunat = "No Enviado"; enviados++; } repositorio.Archivo = archivo; repositorio.Pcorigen = SystemInformation.UserDomainName; repositorio.Usuariopc = SystemInformation.UserName; if (admrepo.actualizar_repositorio(repositorio) < 0) { MessageBox.Show("Problemas para actualizar información el proceso de detuvo...", "Información"); break; } } } else { enviados++; } } if (enviados > 0) { MessageBox.Show("No todos los documentos se enviaron...", "Información"); btn_buscar.PerformClick(); } else { MessageBox.Show("Todos los documentos se enviaron...", "Información"); btn_buscar.PerformClick(); } } catch (Exception a) { MessageBox.Show(a.Message); } }
public int registrar_repositorio(clsRepositorio repositorio) { int id = -1; try { con.conectarBD(); tra = con.conector.BeginTransaction(); cmd = new MySqlCommand("registrar_repositorio", con.conector); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tra; cmd.Parameters.Add(new MySqlParameter("@_tipocomprobante", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_serie", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_correlativo", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_comprobante", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_fechaemision", MySqlDbType.Date)); cmd.Parameters.Add(new MySqlParameter("@_monto", MySqlDbType.Decimal)); cmd.Parameters.Add(new MySqlParameter("@_estadosunat", MySqlDbType.Int32)); cmd.Parameters.Add(new MySqlParameter("@_mensajesunat", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_nombredocxml", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_rutaxml", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_nombredocpdf", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_rutapdf", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_pcorigen", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_usuariopc", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_docxml", MySqlDbType.LongBlob)); cmd.Parameters.Add(new MySqlParameter("@_docpdf", MySqlDbType.LongBlob)); cmd.Parameters.Add(new MySqlParameter("@_doczip", MySqlDbType.LongBlob)); cmd.Parameters.Add(new MySqlParameter("@_cliente", MySqlDbType.VarChar)); cmd.Parameters.Add(new MySqlParameter("@_documento_cliente", MySqlDbType.VarChar)); cmd.Parameters[0].Value = repositorio.Tipodocumento; cmd.Parameters[1].Value = repositorio.Serie; cmd.Parameters[2].Value = repositorio.Correlativo; cmd.Parameters[3].Value = repositorio.Comprobante; cmd.Parameters[4].Value = repositorio.Fechaemision; cmd.Parameters[5].Value = repositorio.Monto; cmd.Parameters[6].Value = repositorio.Estadosunat; cmd.Parameters[7].Value = repositorio.Mensajesunat; cmd.Parameters[8].Value = repositorio.Nombredocxml; cmd.Parameters[9].Value = repositorio.Rutaxml; cmd.Parameters[10].Value = repositorio.Nombredocpdf; cmd.Parameters[11].Value = repositorio.Rutapdf; cmd.Parameters[12].Value = repositorio.Pcorigen; cmd.Parameters[13].Value = repositorio.Usuariopc; cmd.Parameters[14].Value = repositorio.Archivo.Xml; cmd.Parameters[15].Value = repositorio.Archivo.Pdf; cmd.Parameters[16].Value = repositorio.Archivo.Zip; cmd.Parameters[17].Value = repositorio.Cliente.Nombreyapellido; cmd.Parameters[18].Value = repositorio.Cliente.Documento; dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { id = Convert.ToInt32(dr["_id"]); } dr.Close(); } tra.Commit(); return(id); } catch (MySqlException ex) { tra.Rollback(); return(id); throw ex; } finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); } }