public void GenerarArchivosXml() { //splashScreenManager1.ShowWaitForm(); try { foreach (var item in listado_cbtes_info) { string sIdCbteFact = ""; //item.CbteFactura.infoTributaria = new infoTributaria(); // si es factura if (item.TipoCbte == eTipoComprobante.Factura) { try { sIdCbteFact = item.CbteFactura.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.FAC + "-" + item.CbteFactura.infoTributaria.estab + "-" + item.CbteFactura.infoTributaria.ptoEmi + "-" + item.CbteFactura.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(factura)); myWriter = new StreamWriter(Efirm.Properties.Settings.Default.PatchXml + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.CbteFactura, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { } } // si es retencion else if (item.TipoCbte == eTipoComprobante.Retencion) { try { sIdCbteFact = item.cbteRet.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.RET + "-" + item.cbteRet.infoTributaria.estab + "-" + item.cbteRet.infoTributaria.ptoEmi + "-" + item.cbteRet.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(comprobanteRetencion)); myWriter = new StreamWriter(Efirm.Properties.Settings.Default.PatchXml + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.cbteRet, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { } } // si es nota de credito else if (item.TipoCbte == eTipoComprobante.NotaCred) { try { sIdCbteFact = item.cbteNC.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.NTC + "-" + item.cbteNC.infoTributaria.estab + "-" + item.cbteNC.infoTributaria.ptoEmi + "-" + item.cbteNC.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(notaCredito)); myWriter = new StreamWriter(Efirm.Properties.Settings.Default.PatchXml + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.cbteNC, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { } } // si es guia de remision else if (item.TipoCbte == eTipoComprobante.Guia) { try { sIdCbteFact = sIdCbteFact = item.cbtGR.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.GUI + "-" + item.cbtGR.infoTributaria.estab + "-" + item.cbtGR.infoTributaria.ptoEmi + "-" + item.cbtGR.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(guiaRemision)); myWriter = new StreamWriter(Efirm.Properties.Settings.Default.PatchXml + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.cbtGR, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { } } // si es nota debito else if (item.TipoCbte == eTipoComprobante.NotaDeb) { try { sIdCbteFact = sIdCbteFact = item.cbteDeb.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.NTD + "-" + item.cbteDeb.infoTributaria.estab + "-" + item.cbteDeb.infoTributaria.ptoEmi + "-" + item.cbteDeb.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(notaDebito)); myWriter = new StreamWriter(Efirm.Properties.Settings.Default.PatchXml + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.cbteDeb, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { } } } } catch (Exception ex) { } finally { } }
public void GenerarArchivosXml() { gridControlCbtes.RefreshDataSource(); //splashScreenManager1.ShowWaitForm(); try { foreach (var item in listado_cbtes_info) { string sIdCbteFact = ""; //item.CbteFactura.infoTributaria = new infoTributaria(); if (item.Checked == true) { // si es factura if (item.TipoCbte == eTipoComprobante.Factura) { try { sIdCbteFact = item.CbteFactura.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.FAC + "-" + item.CbteFactura.infoTributaria.estab + "-" + item.CbteFactura.infoTributaria.ptoEmi + "-" + item.CbteFactura.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(factura)); myWriter = new StreamWriter(txtRuta.Text + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.CbteFactura, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { MessageBox.Show(ex.Message); } } // si es retencion else if (item.TipoCbte == eTipoComprobante.Retencion) { try { sIdCbteFact = item.cbteRet.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.RET + "-" + item.cbteRet.infoTributaria.estab + "-" + item.cbteRet.infoTributaria.ptoEmi + "-" + item.cbteRet.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(comprobanteRetencion)); myWriter = new StreamWriter(txtRuta.Text + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.cbteRet, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { MessageBox.Show(ex.Message); } } // si es nota de credito else if (item.TipoCbte == eTipoComprobante.NotaCred) { try { sIdCbteFact = item.cbteNC.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.NTC + "-" + item.cbteNC.infoTributaria.estab + "-" + item.cbteNC.infoTributaria.ptoEmi + "-" + item.cbteNC.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(notaCredito)); myWriter = new StreamWriter(txtRuta.Text + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.cbteNC, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { MessageBox.Show(ex.Message); } } // si es guia de remision else if (item.TipoCbte == eTipoComprobante.Guia) { try { sIdCbteFact = sIdCbteFact = item.cbtGR.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.GUI + "-" + item.cbtGR.infoTributaria.estab + "-" + item.cbtGR.infoTributaria.ptoEmi + "-" + item.cbtGR.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(guiaRemision)); myWriter = new StreamWriter(txtRuta.Text + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.cbtGR, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { MessageBox.Show(ex.Message); } } // si es nota debito else if (item.TipoCbte == eTipoComprobante.NotaDeb) { try { sIdCbteFact = sIdCbteFact = item.cbteDeb.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.NTD + "-" + item.cbteDeb.infoTributaria.estab + "-" + item.cbteDeb.infoTributaria.ptoEmi + "-" + item.cbteDeb.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(notaDebito)); myWriter = new StreamWriter(txtRuta.Text + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.cbteDeb, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (item.TipoCbte == eTipoComprobante.LiqComp) { try { sIdCbteFact = sIdCbteFact = item.cbte_liq.infoTributaria.razonSocial.Substring(0, 3) + "-" + eTipoCodComprobante.LIQC + "-" + item.cbte_liq.infoTributaria.estab + "-" + item.cbte_liq.infoTributaria.ptoEmi + "-" + item.cbte_liq.infoTributaria.secuencial; XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces(); NamespaceObject.Add("", ""); XmlSerializer mySerializer = new XmlSerializer(typeof(liquidacionCompra)); myWriter = new StreamWriter(txtRuta.Text + sIdCbteFact + ".xml"); mySerializer.Serialize(myWriter, item.cbte_liq, NamespaceObject); myWriter.Close(); // GRABAR COMP ObuscComp = new fx_Comprobantes_generados_Bus(); fx_Comprobante_generados_Info comprobante = new fx_Comprobante_generados_Info(); comprobante.IdRegistro = sIdCbteFact; comprobante.Estado = "A"; ObuscComp.GuardarComprobantes_generados_FX(comprobante); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } listado_cbtes_info = new BindingList <fx_GeneradorXML_Comprobante_Info>(); gridControlCbtes.DataSource = listado_cbtes_info; gridControlCbtes.RefreshDataSource(); } catch (Exception ex) { } finally { } }